ProcessorChainFactory { @SuppressWarnings("unchecked") public ProcessorChain createProcessorChain( ProcessorReferenceChain chainReference, DataSource source, DataRepository dataRepository) { Assert.assertNotNull(chainReference, source, dataRepository); SourceAdapter adapter; Filter<ObjectNode, ?> firstFilter = null; Filter<?, ObjectNode> lastFilter = null; Iterator<ProcessorReference> iterator = chainReference.getProcessors().iterator(); adapter = (SourceAdapter) createProcessorFromAnnotation(adapterFactory, SourceAdapterFactory.class, iterator.next(), source, dataRepository); while (iterator.hasNext()) { Filter filter = (Filter) createProcessorFromAnnotation(filterFactory, FilterFactory.class, iterator.next(), source, dataRepository); if (firstFilter == null) { firstFilter = (Filter<ObjectNode, ObjectNode>) filter; lastFilter = (Filter<ObjectNode, ObjectNode>) filter; } else { lastFilter = (Filter<ObjectNode, ObjectNode>) lastFilter.setNextFilter(filter); } } return new ProcessorChain(adapter, firstFilter); } @Inject  ProcessorChainFactory(
			SourceAdapterFactory adapterFactory,
			FilterFactory filterFactory); @SuppressWarnings("unchecked") ProcessorChain createProcessorChain(
			ProcessorReferenceChain chainReference,
			DataSource source,
			DataRepository dataRepository);  }
@Test public void testCreation( @Mocked final FilterFactory filterFactory, @Mocked final SourceAdapterFactory adapterFactory, @Mocked final DataRepository dataRepository) throws Exception { final ProcessorChainFactory chainFactory = new ProcessorChainFactory(adapterFactory, filterFactory); chainFactory.createProcessorChain(chainReference, new DataSource(null, null, null, null), dataRepository); new Verifications() {{ adapterFactory.createJsonSourceAdapter((DataSource) any, anyString); times = 1; filterFactory.createDbInsertionFilter((DataSource) any, (DataRepository) any, anyBoolean); times = 1; filterFactory.createNotificationFilter((DataSource) any); times = 1; filterFactory.createTransformationFilter((DataSource) any, simpleExtension); times = 1; }}; }