private static DAG<IRVertex, IREdge> compileDAG(final String[] args) throws Exception { final String userMainClassName; final String[] userMainMethodArgs; try { final Configuration configuration = JobLauncher.getJobConf(args); final Injector injector = Tang.Factory.getTang().newInjector(configuration); userMainClassName = injector.getNamedInstance(JobConf.UserMainClass.class); userMainMethodArgs = injector.getNamedInstance(JobConf.UserMainArguments.class).split(" "); } catch (final Exception e) { throw new RuntimeException("An exception occurred while processing configuration for invoking user main. " + "Note: Using compileDAG for multiple times will fail, as compileDAG method enables static method mocking " + "on JobLauncher and because of this Tang may misbehave afterwards.", e); } final Class userMainClass = Class.forName(userMainClassName); final Method userMainMethod = userMainClass.getMethod("main", String[].class); final ArgumentCaptor<DAG> captor = ArgumentCaptor.forClass(DAG.class); final ArgumentCaptor<String> stringArg = ArgumentCaptor.forClass(String.class); PowerMockito.mockStatic(JobLauncher.class); PowerMockito.doNothing().when(JobLauncher.class, "launchDAG", captor.capture(), stringArg.capture()); userMainMethod.invoke(null, (Object) userMainMethodArgs); return captor.getValue(); }
builtJobConf = getJobConf(args);