/** * Main method for testing. * * @param provider a provider for the transform runner. */ static void main(TransformRunnerProvider provider) { try { provider.provide().runTransform(); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Starts the transform. Here the transform is instantiated through reflection. If the config file * is specified, a constructor with a single parameter accepting a {@link File} is used, otherwise * an empty constructor. * * @throws Exception for any exception happened during the transform process. */ void runTransform() throws Exception { Transform transform = configFile != null ? transformClass.getConstructor(File.class).newInstance(configFile) : transformClass.newInstance(); TransformOutputProvider transformOutputProvider = new JarsTransformOutputProvider(outputJarsDir, inputJarsDir); runTransform(transform, transformOutputProvider); }
@Test public void whenStarting_shouldRunTransform() throws Exception { final TransformRunner runner = mock(TransformRunner.class); CliTransform.main( new CliTransform.TransformRunnerProvider() { @Override public TransformRunner provide() { return runner; } }); verify(runner).runTransform(); } }