### Question:
PluginZipFileProcessor { public Future<Void> processBackground( ExecutorService executorService, final Supplier<ZipInputStream> zipInputStreamProvider, final ZipOutputStream zipOutputStream, final ExceptionSettable<Throwable> exceptionSettable ) { return executorService.submit( () -> { long elapsedTime = System.currentTimeMillis(); logger.debug( "Start processing zip plugin '{}'", name ); try { if ( isPluginProcessedBefore ) { logger.debug( "Found bundle {} installed. Processing manifest instead", name ); processManifest( zipOutputStream ); } else { process( zipInputStreamProvider, zipOutputStream ); } } catch ( IOException e ) { exceptionSettable.setException( e ); } logger.debug( "Finished processing zip plugin '{}'", name ); logger.debug( "Elapsed time in millis: {} ", ( System.currentTimeMillis() - elapsedTime ) ); return null; } ); } PluginZipFileProcessor( List<PluginFileHandler> pluginFileHandlers, boolean isPluginProcessedBefore,
                                 String name, String symbolicName,
                                 String version ); Future<Void> processBackground( ExecutorService executorService,
                                         final Supplier<ZipInputStream> zipInputStreamProvider,
                                         final ZipOutputStream zipOutputStream,
                                         final ExceptionSettable<Throwable> exceptionSettable ); void process( Supplier<ZipInputStream> zipInputStreamProvider, ZipOutputStream zipOutputStream ); void processManifest( ZipOutputStream zipOutputStream ); static final String BLUEPRINT; static final String PLUGIN_SPRING_XML_FILENAME; }### Answer:
@Test @SuppressWarnings( "unchecked" ) public void testProcessBackgroundWithException() throws IOException { List<PluginFileHandler> pluginFileHandlers = new ArrayList<PluginFileHandler>(); PluginZipFileProcessor pluginZipFileProcessor = new PluginZipFileProcessor( pluginFileHandlers, false, "test", "test-symbolic", "version" ); ZipOutputStream zipOutputStream = mock( ZipOutputStream.class ); ZipInputStream zipInputStream = mock( ZipInputStream.class ); ExceptionSettable<Throwable> exceptionSettable = mock( ExceptionSettable.class ); IOException myException = new IOException( "TEST_EXCEPTION" ); when( zipInputStream.getNextEntry() ).thenThrow( myException ); pluginZipFileProcessor.processBackground( executorService, () -> zipInputStream, zipOutputStream, exceptionSettable ); verify( exceptionSettable ).setException( myException ); }
@Test @SuppressWarnings( "unchecked" ) public void testProcessBackgroundWithNoException() throws IOException { List<PluginFileHandler> pluginFileHandlers = new ArrayList<PluginFileHandler>(); PluginZipFileProcessor pluginZipFileProcessor = new PluginZipFileProcessor( pluginFileHandlers, false, "test", "test-symbolic", "version" ); ZipOutputStream zipOutputStream = mock( ZipOutputStream.class ); ZipInputStream zipInputStream = mock( ZipInputStream.class ); ExceptionSettable<Throwable> exceptionSettable = mock( ExceptionSettable.class ); pluginZipFileProcessor.processBackground( executorService, () -> zipInputStream, zipOutputStream, exceptionSettable ); verifyNoMoreInteractions( exceptionSettable ); }