List of usage examples for org.springframework.batch.item ItemProcessor process
@Nullable
O process(I item) throws Exception;
From source file:uk.ac.ebi.eva.pipeline.jobs.steps.processor.AnnotationProcessorTest.java
@Test public void shouldConvertAllFieldsInVariant() throws Exception { DBObject dbo = JobTestUtils.constructDbo(VariantData.getVariantWithoutAnnotation()); ItemProcessor<DBObject, VariantWrapper> processor = new AnnotationProcessor(); VariantWrapper variant = processor.process(dbo); assertEquals("+", variant.getStrand()); assertEquals("20", variant.getChr()); assertEquals("G/A", variant.getRefAlt()); assertEquals(60343, variant.getEnd()); assertEquals(60343, variant.getStart()); }
From source file:org.trpr.platform.batch.impl.spring.processor.CompositeItemProcessor.java
/** * Interface method implementation. Passes the item through the list of delegates by invoking {@link #process(Object)} on each. * Filtered data i.e. return of null value by an ItemTransformer/ItemProcessor will result in stopping the chained execution. * @see org.springframework.batch.item.ItemProcessor#process(java.lang.Object) *//* w ww. ja v a2s . c o m*/ @SuppressWarnings("unchecked") public O process(I item) throws Exception { Object result = item; for (ItemProcessor<Object, Object> delegate : delegates) { if (result == null) { // an ItemTransformer has filtered out the data return null; } result = delegate.process(result); } return (O) result; }
From source file:com.acmemotors.batch.LoadJobConfigurationTests.java
@Test public void testProcessor() throws Exception { LoaderJobConfiguration config = new LoaderJobConfiguration(); ItemProcessor<Map<String, Object>, String> processor = config.processor(500); Map<String, Object> item = new HashMap<>(); item.put("foo", "bar"); Date startTime = new Date(); String stringItem = processor.process(item); assertTrue(new Date().getTime() - startTime.getTime() > 500); assertEquals("{\"foo\":\"bar\"}", stringItem); }