RESOLVED - issue BATCH-640: FieldSetMapper.mapLine() should contain the line number

Added rownum parameter to field set mapper (with default value -1 defined as constant in FieldSetMapper)
This commit is contained in:
dsyer
2008-06-05 15:03:10 +00:00
parent b89bbbadb6
commit 85e168e2db
24 changed files with 76 additions and 63 deletions

View File

@@ -90,19 +90,19 @@ public class OrderItemReaderTests extends TestCase {
mapperControl = MockControl.createControl(FieldSetMapper.class);
mapper = (FieldSetMapper)mapperControl.getMock();
//set how mapper should respond - set return values for mapper
mapper.mapLine(headerFS);
mapper.mapLine(headerFS, FieldSetMapper.ROW_NUMBER_UNKNOWN);
mapperControl.setReturnValue(order);
mapper.mapLine(customerFS);
mapper.mapLine(customerFS, FieldSetMapper.ROW_NUMBER_UNKNOWN);
mapperControl.setReturnValue(customer);
mapper.mapLine(billingFS);
mapper.mapLine(billingFS, FieldSetMapper.ROW_NUMBER_UNKNOWN);
mapperControl.setReturnValue(billing);
mapper.mapLine(shippingFS);
mapper.mapLine(shippingFS, FieldSetMapper.ROW_NUMBER_UNKNOWN);
mapperControl.setReturnValue(shipping);
mapper.mapLine(billingInfoFS);
mapper.mapLine(billingInfoFS, FieldSetMapper.ROW_NUMBER_UNKNOWN);
mapperControl.setReturnValue(billingInfo);
mapper.mapLine(shippingInfoFS);
mapper.mapLine(shippingInfoFS, FieldSetMapper.ROW_NUMBER_UNKNOWN);
mapperControl.setReturnValue(shippingInfo);
mapper.mapLine(itemFS);
mapper.mapLine(itemFS, FieldSetMapper.ROW_NUMBER_UNKNOWN);
mapperControl.setReturnValue(item,3);
mapperControl.replay();

View File

@@ -1,10 +1,10 @@
package org.springframework.batch.sample.mapping;
import junit.framework.TestCase;
import org.springframework.batch.item.file.mapping.FieldSet;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import junit.framework.TestCase;
/**
* Encapsulates basic logic for testing custom {@link FieldSetMapper} implementations.
*
@@ -35,7 +35,7 @@ public abstract class AbstractFieldSetMapperTests extends TestCase {
* Assumes the domain object implements sensible <code>equals(Object other)</code>
*/
public void testRegularUse() {
assertEquals(expectedDomainObject(), fieldSetMapper().mapLine(fieldSet()));
assertEquals(expectedDomainObject(), fieldSetMapper().mapLine(fieldSet(), FieldSetMapper.ROW_NUMBER_UNKNOWN));
}
}

View File

@@ -40,11 +40,11 @@ public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests{
}
public void testBeginRecord() throws Exception {
assertEquals(AggregateItemReader.BEGIN_RECORD, fieldSetMapper().mapLine(new DefaultFieldSet(new String[] {"BEGIN"})));
assertEquals(AggregateItemReader.BEGIN_RECORD, fieldSetMapper().mapLine(new DefaultFieldSet(new String[] {"BEGIN"}), FieldSetMapper.ROW_NUMBER_UNKNOWN));
}
public void testEndRecord() throws Exception {
assertEquals(AggregateItemReader.END_RECORD, fieldSetMapper().mapLine(new DefaultFieldSet(new String[] {"END"})));
assertEquals(AggregateItemReader.END_RECORD, fieldSetMapper().mapLine(new DefaultFieldSet(new String[] {"END"}), FieldSetMapper.ROW_NUMBER_UNKNOWN));
}
}