ExportManagerImpl implements ExportManager { @Override public Future<?> exportProfiles(final List<String> profileIds, final String destination, final Filter filter, final ExportOptions options, final String outputEncoding, final boolean bom) { final ExportTask exportTask = new ExportTask(destination, profileIds, filter, options, outputEncoding, bom, itemWriter, profileContextLocator); final FutureTask<?> task = new FutureTask<Object>(exportTask, null) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { if (mayInterruptIfRunning) { exportTask.cancel(); } return super.cancel(false); } }; executor.execute(task); return task; } ExportManagerImpl();  ExportManagerImpl(ProfileContextLocator profileContextLocator,
                             ItemWriter<ProfileResourceNode> itemWriter); @Override Future<?> exportProfiles(final List<String> profileIds, final String destination, 
        final Filter filter, final ExportOptions options, final String outputEncoding, final boolean bom); void setProfileContextLocator(
            final ProfileContextLocator profileContextLocator); void setItemWriter(final ItemWriter<ProfileResourceNode> itemWriter); void destroy();  }
@Test public void testExportNodesToCsv() throws Exception { ProfileInstanceManager profileInstanceManager = mock(ProfileInstanceManager.class); ProfileInstance profile1 = mock(ProfileInstance.class); when(profileContextLocator.getProfileInstance("profile1")).thenReturn(profile1); when(profileContextLocator.hasProfileContext(anyString())).thenReturn(true); when(profileInstanceManager.getNodeItemReader()).thenReturn(reader); when(profileContextLocator.openProfileInstanceManager(profile1)).thenReturn(profileInstanceManager); ProfileResourceNode node1 = new ProfileResourceNode(new URI("node1")); ProfileResourceNode node2 = new ProfileResourceNode(new URI("node2")); ProfileResourceNode node3 = new ProfileResourceNode(new URI("node3")); final List<ProfileResourceNode> fis = new ArrayList<ProfileResourceNode>(); fis.add(node1); fis.add(node2); fis.add(node3); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { ItemReaderCallback<ProfileResourceNode> callback = (ItemReaderCallback<ProfileResourceNode>) invocation.getArguments()[0]; try { callback.onItem(fis); } catch (JobCancellationException e) { fail(e.getMessage()); } return null; } }).when(reader).readAll(any(ItemReaderCallback.class), nullable(Filter.class)); List<String> profileIdList = new ArrayList<String>(); profileIdList.add("profile1"); exportManager.exportProfiles(profileIdList, "destination", null, ExportOptions.ONE_ROW_PER_FILE, null, false).get(); verify(writer).open(any(Writer.class)); verify(writer).write(fis); verify(writer).close(); }