RESOLVED - BATCH-779: RFC: make FieldSetMapper and LineAggregator extend ItemProcessor

reverted to original method names
This commit is contained in:
robokaso
2008-10-09 11:16:11 +00:00
parent 81513dbdc6
commit 3acd3228d3
43 changed files with 174 additions and 158 deletions

View File

@@ -189,7 +189,7 @@ public class FlatFileItemWriter<T> extends ExecutionContextUserSupport implement
StringBuilder lines = new StringBuilder();
int lineCount = 0;
for (T item : items) {
lines.append(lineAggregator.process(item) + lineSeparator);
lines.append(lineAggregator.aggregate(item) + lineSeparator);
lineCount++;
}
try {

View File

@@ -102,7 +102,7 @@ public class BeanWrapperFieldSetMapper<T> extends DefaultPropertyEditorRegistrar
/**
* The bean name (id) for an object that can be populated from the field set
* that will be passed into {@link #process(FieldSet)}. Typically a
* that will be passed into {@link #map(FieldSet)}. Typically a
* prototype scoped bean so that a new instance is returned for each field
* set mapped.
*
@@ -118,7 +118,7 @@ public class BeanWrapperFieldSetMapper<T> extends DefaultPropertyEditorRegistrar
/**
* Public setter for the type of bean to create instead of using a prototype
* bean. An object of this type will be created from its default constructor
* for every call to {@link #process(FieldSet)}.<br/>
* for every call to {@link #map(FieldSet)}.<br/>
*
* Either this property or the prototype bean name must be specified, but
* not both.
@@ -153,10 +153,10 @@ public class BeanWrapperFieldSetMapper<T> extends DefaultPropertyEditorRegistrar
* the {@link DataBinder} from {@link #createBinder(Object)} has errors
* after binding).
*
* @see org.springframework.batch.item.file.mapping.FieldSetMapper#process(FieldSet)
* @see org.springframework.batch.item.file.mapping.FieldSetMapper#map(FieldSet)
*/
@SuppressWarnings("unchecked")
public T process(FieldSet fs) {
public T map(FieldSet fs) {
T copy = getBean();
DataBinder binder = createBinder(copy);
binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties())));

View File

@@ -17,7 +17,7 @@ public class DefaultLineMapper<T> implements LineMapper<T> {
private FieldSetMapper<T> fieldSetMapper;
public T mapLine(String line, int lineNumber) throws Exception {
return fieldSetMapper.process(tokenizer.process(line));
return fieldSetMapper.map(tokenizer.tokenize(line));
}
public void setLineTokenizer(LineTokenizer tokenizer) {

View File

@@ -17,6 +17,7 @@
package org.springframework.batch.item.file.mapping;
/**
* Interface that is used to map data obtained from a {@link FieldSet} into an
* object.
@@ -27,5 +28,10 @@ package org.springframework.batch.item.file.mapping;
*/
public interface FieldSetMapper<T> {
T process(FieldSet fieldSet);
/**
* Method used to map data obtained from a {@link FieldSet} into an object.
*
* @param fieldSet the {@link FieldSet} to map
*/
T map(FieldSet fieldSet);
}

View File

@@ -31,7 +31,7 @@ public class PassThroughFieldSetMapper implements FieldSetMapper<FieldSet> {
* org.springframework.batch.io.file.FieldSetMapper#mapLine(org.springframework
* .batch.io.file.FieldSet)
*/
public FieldSet process(FieldSet fs) {
public FieldSet map(FieldSet fs) {
return fs;
}

View File

@@ -64,7 +64,7 @@ public abstract class AbstractLineTokenizer implements LineTokenizer {
*
* @return the resulting tokens
*/
public FieldSet process(String line) {
public FieldSet tokenize(String line) {
if(line == null){
line = "";

View File

@@ -36,7 +36,7 @@ public class DelimitedLineAggregator<T> implements LineAggregator<T[]> {
/* (non-Javadoc)
* @see org.springframework.batch.item.file.transform.LineAggregator#aggregate(java.lang.Object)
*/
public String process(T[] item) {
public String aggregate(T[] item) {
return StringUtils.arrayToDelimitedString(item, delimiter);
}

View File

@@ -94,7 +94,7 @@ public class FormatterLineAggregator<T> implements LineAggregator<T> {
* @param item data to be aggregated
* @return aggregated string
*/
public String process(T item) {
public String aggregate(T item) {
Assert.notNull(item);
Assert.notNull(format);

View File

@@ -16,9 +16,6 @@
package org.springframework.batch.item.file.transform;
/**
* Interface used to create string representing object.
*
@@ -26,5 +23,11 @@ package org.springframework.batch.item.file.transform;
*/
public interface LineAggregator<T> {
String process(T item);
/**
* Create a string from the value provided.
*
* @param item values to be converted
* @return string
*/
String aggregate(T item);
}

View File

@@ -18,7 +18,6 @@ package org.springframework.batch.item.file.transform;
import org.springframework.batch.item.file.mapping.FieldSet;
/**
* Interface that is used by framework to split string obtained typically from a
* file into tokens.
@@ -28,5 +27,13 @@ import org.springframework.batch.item.file.mapping.FieldSet;
*/
public interface LineTokenizer {
FieldSet process(String line);
/**
* Yields the tokens resulting from the splitting of the supplied
* <code>line</code>.
*
* @param line the line to be tokenized (can be <code>null</code>)
*
* @return the resulting tokens
*/
FieldSet tokenize(String line);
}

View File

@@ -6,9 +6,9 @@ public class PassThroughLineAggregator<T> implements LineAggregator<T> {
/**
* Simply convert to a String with toString().
*
* @see org.springframework.batch.item.file.transform.LineAggregator#process(java.lang.Object)
* @see org.springframework.batch.item.file.transform.LineAggregator#aggregate(java.lang.Object)
*/
public String process(T item) {
public String aggregate(T item) {
return item.toString();
}

View File

@@ -31,7 +31,7 @@ public class PrefixMatchingCompositeLineTokenizer implements LineTokenizer {
this.tokenizers = new LinkedHashMap<String, LineTokenizer>(tokenizers);
}
public FieldSet process(String line) {
public FieldSet tokenize(String line) {
if (line == null) {
return new DefaultFieldSet(new String[0]);
@@ -61,7 +61,7 @@ public class PrefixMatchingCompositeLineTokenizer implements LineTokenizer {
throw new IllegalStateException("Could not match record to tokenizer for line=[" + line + "]");
}
return tokenizer.process(line);
return tokenizer.tokenize(line);
}
}

View File

@@ -31,10 +31,10 @@ public class RecursiveCollectionLineAggregator<T> implements LineAggregator<Coll
* (non-Javadoc)
* @see org.springframework.batch.item.file.transform.LineAggregator#aggregate(java.lang.Object)
*/
public String process(Collection<T> items) {
public String aggregate(Collection<T> items) {
StringBuilder builder = new StringBuilder();
for (T value : items) {
builder.append(delegate.process(value) + LINE_SEPARATOR);
builder.append(delegate.aggregate(value) + LINE_SEPARATOR);
}
return builder.delete(builder.length()-LINE_SEPARATOR.length(),builder.length()).toString();
}

View File

@@ -148,7 +148,7 @@ public class FlatFileItemWriterTests {
@Test
public void testWriteWithConverter() throws Exception {
writer.setLineAggregator(new LineAggregator<String>() {
public String process(String item) {
public String aggregate(String item) {
return "FOO:" + item;
}
});
@@ -168,7 +168,7 @@ public class FlatFileItemWriterTests {
@Test
public void testWriteWithConverterAndString() throws Exception {
writer.setLineAggregator(new LineAggregator<String>() {
public String process(String item) {
public String aggregate(String item) {
return "FOO:" + item;
}
});
@@ -417,7 +417,7 @@ public class FlatFileItemWriterTests {
writer.setLineAggregator(new LineAggregator<String>() {
public String process(String item) {
public String aggregate(String item) {
if (item.equals("2")) {
throw new RuntimeException("aggregation failed on " + item);
}

View File

@@ -63,7 +63,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "true", "C" },
new String[] { "varString", "varBoolean", "varChar" });
TestObject result = mapper.process(fieldSet);
TestObject result = mapper.map(fieldSet);
assertEquals("This is some dummy string", result.getVarString());
assertEquals(true, result.isVarBoolean());
assertEquals('C', result.getVarChar());
@@ -78,7 +78,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "true", "C" },
new String[] { "varString", "varBoolean", "varChar" });
TestObject result = mapper.process(fieldSet);
TestObject result = mapper.map(fieldSet);
assertEquals("This is some dummy string", result.getVarString());
assertEquals(true, result.isVarBoolean());
assertEquals('C', result.getVarChar());
@@ -93,7 +93,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "true", "C" },
new String[] { "VarString", "VAR_BOOLEAN", "VAR_CHAR" });
TestObject result = mapper.process(fieldSet);
TestObject result = mapper.map(fieldSet);
assertEquals("This is some dummy string", result.getVarString());
assertEquals(true, result.isVarBoolean());
assertEquals('C', result.getVarChar());
@@ -107,7 +107,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "true", "C" },
new String[] { "varString", "varBoolean", "varChar" });
TestObject result = mapper.process(fieldSet);
TestObject result = mapper.map(fieldSet);
assertEquals("This is some dummy string", result.getVarString());
assertEquals(true, result.isVarBoolean());
assertEquals('C', result.getVarChar());
@@ -130,7 +130,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
new String[] { "This is some dummy string", "1", "Another dummy", "2" }, new String[] { "valueA",
"valueB", "testObjectB.valueA", "testObjectB.testObjectC.value" });
TestNestedA result = mapper.process(fieldSet);
TestNestedA result = mapper.map(fieldSet);
assertEquals("This is some dummy string", result.getValueA());
assertEquals(1, result.getValueB());
@@ -150,7 +150,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "1" }, new String[] {
"VALUE_A", "VALUE_B" });
TestNestedA result = (TestNestedA) mapper.process(fieldSet);
TestNestedA result = (TestNestedA) mapper.map(fieldSet);
assertEquals("This is some dummy string", result.getValueA());
assertEquals(1, result.getValueB());
@@ -167,7 +167,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "1" }, new String[] { "foo" });
TestNestedC result = mapper.process(fieldSet);
TestNestedC result = mapper.map(fieldSet);
// "foo" is similar enough to "value" that it matches - but only because
// nothing else does...
@@ -189,7 +189,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "Another dummy", "2" }, new String[] {
"TestObjectB.ValueA", "TestObjectB.TestObjectC.Value" });
TestNestedA result = mapper.process(fieldSet);
TestNestedA result = mapper.map(fieldSet);
assertEquals("Another dummy", result.getTestObjectB().getValueA());
assertEquals(2, result.getTestObjectB().getTestObjectC().getValue());
@@ -209,7 +209,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "Another dummy" }, new String[] { "TestObjectB.foo" });
try {
mapper.process(fieldSet);
mapper.map(fieldSet);
fail("Expected NotWritablePropertyException");
}
catch (NotWritablePropertyException e) {
@@ -231,7 +231,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "2" }, new String[] { "TestObjectA.garbage" });
try {
mapper.process(fieldSet);
mapper.map(fieldSet);
fail("Expected NotWritablePropertyException");
}
catch (NotWritablePropertyException e) {
@@ -271,7 +271,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "1", "2", "3" }, new String[] { "NestedC[0].Value",
"NestedC[1].Value", "NestedC[2].Value" });
mapper.process(fieldSet);
mapper.map(fieldSet);
assertEquals(1, ((TestNestedC) nestedList.getNestedC().get(0)).getValue());
assertEquals(2, ((TestNestedC) nestedList.getNestedC().get(1)).getValue());
@@ -285,7 +285,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
mapper.setTargetType(TestObject.class);
FieldSet fieldSet = new DefaultFieldSet(new String[] { "00009" }, new String[] { "varLong" });
TestObject bean = (TestObject) mapper.process(fieldSet);
TestObject bean = (TestObject) mapper.map(fieldSet);
// since Spring 2.5.5 this is OK (before that BATCH-261)
assertEquals(9, bean.getVarLong());
}
@@ -299,7 +299,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
mapper.setCustomEditors(Collections.singletonMap(Long.TYPE, new CustomNumberEditor(Long.class, NumberFormat
.getNumberInstance(), true)));
TestObject bean = (TestObject) mapper.process(fieldSet);
TestObject bean = (TestObject) mapper.map(fieldSet);
assertEquals(9, bean.getVarLong());
}
@@ -313,7 +313,7 @@ public class BeanWrapperFieldSetMapperTests extends TestCase {
mapper.setCustomEditors(Collections.singletonMap(Long.TYPE, new CustomNumberEditor(Long.class, NumberFormat
.getNumberInstance(), true)));
TestObject bean = (TestObject) mapper.process(fieldSet);
TestObject bean = (TestObject) mapper.map(fieldSet);
assertEquals(9, bean.getVarLong());
assertEquals(78, bean.getVarInt());

View File

@@ -20,12 +20,12 @@ public class DefaultLineMapperTests {
final String item = "ITEM";
LineTokenizer tokenizer = createStrictMock(LineTokenizer.class);
expect(tokenizer.process(line)).andReturn(fs);
expect(tokenizer.tokenize(line)).andReturn(fs);
replay(tokenizer);
@SuppressWarnings("unchecked")
FieldSetMapper<String> fsMapper = createStrictMock(FieldSetMapper.class);
expect(fsMapper.process(fs)).andReturn(item);
expect(fsMapper.map(fs)).andReturn(item);
replay(fsMapper);
tested.setLineTokenizer(tokenizer);

View File

@@ -27,11 +27,11 @@ public class PassThroughFieldSetMapperTests extends TestCase {
/**
* Test method for
* {@link org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper#process(org.springframework.batch.item.file.mapping.FieldSet)}.
* {@link org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper#map(org.springframework.batch.item.file.mapping.FieldSet)}.
*/
public void testMapLine() {
FieldSet fieldSet = new DefaultFieldSet(new String[] { "foo", "bar" });
assertEquals(fieldSet, mapper.process(fieldSet));
assertEquals(fieldSet, mapper.map(fieldSet));
}

View File

@@ -30,12 +30,12 @@ public class DelimitedLineAggregatorTests {
@Test
public void testSetDelimiter() {
aggregator.setDelimiter(";");
assertEquals("foo;bar", aggregator.process(new String[] { "foo", "bar" }));
assertEquals("foo;bar", aggregator.aggregate(new String[] { "foo", "bar" }));
}
@Test
public void testAggregate() {
assertEquals("foo,bar", aggregator.process(new String[] { "foo", "bar" }));
assertEquals("foo,bar", aggregator.aggregate(new String[] { "foo", "bar" }));
}
}

View File

@@ -27,7 +27,7 @@ public class DelimitedLineTokenizerTests extends TestCase {
private DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
public void testTokenizeRegularUse() {
FieldSet tokens = tokenizer.process("sfd,\"Well,I have no idea what to do in the afternoon\",sFj, asdf,,as\n");
FieldSet tokens = tokenizer.tokenize("sfd,\"Well,I have no idea what to do in the afternoon\",sFj, asdf,,as\n");
assertEquals(6, tokens.getFieldCount());
assertTrue(TOKEN_MATCHES, tokens.readString(0).equals("sfd"));
assertTrue(TOKEN_MATCHES, tokens.readString(1).equals("Well,I have no idea what to do in the afternoon"));
@@ -36,7 +36,7 @@ public class DelimitedLineTokenizerTests extends TestCase {
assertTrue(TOKEN_MATCHES, tokens.readString(4).equals(""));
assertTrue(TOKEN_MATCHES, tokens.readString(5).equals("as"));
tokens = tokenizer.process("First string,");
tokens = tokenizer.tokenize("First string,");
assertEquals(2, tokens.getFieldCount());
assertTrue(TOKEN_MATCHES, tokens.readString(0).equals("First string"));
assertTrue(TOKEN_MATCHES, tokens.readString(1).equals(""));
@@ -53,13 +53,13 @@ public class DelimitedLineTokenizerTests extends TestCase {
}
public void testDelimitedLineTokenizer() {
FieldSet line = tokenizer.process("a,b,c");
FieldSet line = tokenizer.tokenize("a,b,c");
assertEquals(3, line.getFieldCount());
}
public void testNames() {
tokenizer.setNames(new String[] {"A", "B", "C"});
FieldSet line = tokenizer.process("a,b,c");
FieldSet line = tokenizer.tokenize("a,b,c");
assertEquals(3, line.getFieldCount());
assertEquals("a", line.readString("A"));
}
@@ -67,7 +67,7 @@ public class DelimitedLineTokenizerTests extends TestCase {
public void testTooFewNames() {
tokenizer.setNames(new String[] {"A", "B"});
try {
tokenizer.process("a,b,c");
tokenizer.tokenize("a,b,c");
fail("Expected IncorrectTokenCountException");
}
catch (IncorrectTokenCountException e) {
@@ -79,7 +79,7 @@ public class DelimitedLineTokenizerTests extends TestCase {
public void testTooManyNames() {
tokenizer.setNames(new String[] {"A", "B", "C", "D"});
try{
tokenizer.process("a,b,c");
tokenizer.tokenize("a,b,c");
}
catch(IncorrectTokenCountException e){
assertEquals(4, e.getExpectedCount());
@@ -90,25 +90,25 @@ public class DelimitedLineTokenizerTests extends TestCase {
public void testDelimitedLineTokenizerChar() {
AbstractLineTokenizer tokenizer = new DelimitedLineTokenizer(' ');
FieldSet line = tokenizer.process("a b c");
FieldSet line = tokenizer.tokenize("a b c");
assertEquals(3, line.getFieldCount());
}
public void testTokenizeWithQuotes() {
FieldSet line = tokenizer.process("a,b,\"c\"");
FieldSet line = tokenizer.tokenize("a,b,\"c\"");
assertEquals(3, line.getFieldCount());
assertEquals("c", line.readString(2));
}
public void testTokenizeWithNotDefaultQuotes() {
tokenizer.setQuoteCharacter('\'');
FieldSet line = tokenizer.process("a,b,'c'");
FieldSet line = tokenizer.tokenize("a,b,'c'");
assertEquals(3, line.getFieldCount());
assertEquals("c", line.readString(2));
}
public void testTokenizeWithEscapedQuotes() {
FieldSet line = tokenizer.process("a,\"\"b,\"\"\"c\"");
FieldSet line = tokenizer.tokenize("a,\"\"b,\"\"\"c\"");
assertEquals(3, line.getFieldCount());
assertEquals("\"\"b", line.readString(1));
assertEquals("\"c", line.readString(2));
@@ -116,39 +116,39 @@ public class DelimitedLineTokenizerTests extends TestCase {
public void testTokenizeWithUnclosedQuotes() {
tokenizer.setQuoteCharacter('\'');
FieldSet line = tokenizer.process("a,\"b,c");
FieldSet line = tokenizer.tokenize("a,\"b,c");
assertEquals(3, line.getFieldCount());
assertEquals("\"b", line.readString(1));
assertEquals("c", line.readString(2));
}
public void testTokenizeWithSpaceAtEnd() {
FieldSet line = tokenizer.process("a,b,c ");
FieldSet line = tokenizer.tokenize("a,b,c ");
assertEquals(3, line.getFieldCount());
assertEquals("c", line.readString(2));
}
public void testTokenizeWithQuoteAndSpaceAtEnd() {
FieldSet line = tokenizer.process("a,b,\"c\" ");
FieldSet line = tokenizer.tokenize("a,b,\"c\" ");
assertEquals(3, line.getFieldCount());
assertEquals("c", line.readString(2));
}
public void testTokenizeWithQuoteAndSpaceBeforeDelimiter() {
FieldSet line = tokenizer.process("a,\"b\" ,c");
FieldSet line = tokenizer.tokenize("a,\"b\" ,c");
assertEquals(3, line.getFieldCount());
assertEquals("b", line.readString(1));
}
public void testTokenizeWithDelimiterAtEnd() {
FieldSet line = tokenizer.process("a,b,c,");
FieldSet line = tokenizer.tokenize("a,b,c,");
assertEquals(4, line.getFieldCount());
assertEquals("c", line.readString(2));
assertEquals("", line.readString(3));
}
public void testEmptyLine() throws Exception {
FieldSet line = tokenizer.process("");
FieldSet line = tokenizer.tokenize("");
assertEquals(0, line.getFieldCount());
}
@@ -156,7 +156,7 @@ public class DelimitedLineTokenizerTests extends TestCase {
tokenizer.setNames(new String[]{"A", "B"});
try{
tokenizer.process("");
tokenizer.tokenize("");
}
catch(IncorrectTokenCountException ex){
assertEquals(2, ex.getExpectedCount());
@@ -165,33 +165,33 @@ public class DelimitedLineTokenizerTests extends TestCase {
}
public void testWhitespaceLine() throws Exception {
FieldSet line = tokenizer.process(" ");
FieldSet line = tokenizer.tokenize(" ");
// whitespace counts as text
assertEquals(1, line.getFieldCount());
}
public void testNullLine() throws Exception {
FieldSet line = tokenizer.process(null);
FieldSet line = tokenizer.tokenize(null);
// null doesn't...
assertEquals(0, line.getFieldCount());
}
public void testMultiLineField() throws Exception {
FieldSet line = tokenizer.process("a,b,c\nrap");
FieldSet line = tokenizer.tokenize("a,b,c\nrap");
assertEquals(3, line.getFieldCount());
assertEquals("c\nrap", line.readString(2));
}
public void testMultiLineFieldWithQuotes() throws Exception {
FieldSet line = tokenizer.process("a,b,\"c\nrap\"");
FieldSet line = tokenizer.tokenize("a,b,\"c\nrap\"");
assertEquals(3, line.getFieldCount());
assertEquals("c\nrap", line.readString(2));
}
public void testTokenizeWithQuotesEmptyValue() {
FieldSet line = tokenizer.process("\"a\",\"b\",\"\",\"d\"");
FieldSet line = tokenizer.tokenize("\"a\",\"b\",\"\",\"d\"");
assertEquals(4, line.getFieldCount());
assertEquals("", line.readString(2));
}

View File

@@ -36,7 +36,7 @@ public class FixedLengthTokenizerTests {
public void testTokenizeEmptyString() {
tokenizer.setColumns(new Range[] { new Range(1, 5), new Range(6, 10), new Range(11, 15) });
try {
tokenizer.process("");
tokenizer.tokenize("");
fail("Expected IncorrectLineLengthException");
}
catch (IncorrectLineLengthException ex) {
@@ -48,14 +48,14 @@ public class FixedLengthTokenizerTests {
@Test
public void testEmptyStringWithNoRanges() {
tokenizer.setColumns(new Range[] {});
tokenizer.process("");
tokenizer.tokenize("");
}
@Test
public void testTokenizeSmallerStringThanRanges() {
tokenizer.setColumns(new Range[] { new Range(1, 5), new Range(6, 10), new Range(11, 15) });
try {
tokenizer.process("12345");
tokenizer.tokenize("12345");
fail("Expected IncorrectLineLengthException");
}
catch (IncorrectLineLengthException ex) {
@@ -68,7 +68,7 @@ public class FixedLengthTokenizerTests {
@Test
public void testTokenizeSmallerStringThanRangesWithWhitespace() {
tokenizer.setColumns(new Range[] { new Range(1, 5), new Range(6, 10) });
FieldSet tokens = tokenizer.process("12345 ");
FieldSet tokens = tokenizer.tokenize("12345 ");
assertEquals("12345", tokens.readString(0));
assertEquals("", tokens.readString(1));
}
@@ -77,7 +77,7 @@ public class FixedLengthTokenizerTests {
public void testTokenizeSmallerStringThanRangesNotStrict() {
tokenizer.setColumns(new Range[] { new Range(1, 5), new Range(6, 10) });
tokenizer.setStrict(false);
FieldSet tokens = tokenizer.process("12345");
FieldSet tokens = tokenizer.tokenize("12345");
assertEquals("12345", tokens.readString(0));
assertEquals("", tokens.readString(1));
}
@@ -85,7 +85,7 @@ public class FixedLengthTokenizerTests {
@Test
public void testTokenizeSmallerStringThanRangesWithWhitespaceOpenEnded() {
tokenizer.setColumns(new Range[] { new Range(1, 5), new Range(6) });
FieldSet tokens = tokenizer.process("12345 ");
FieldSet tokens = tokenizer.tokenize("12345 ");
assertEquals("12345", tokens.readString(0));
assertEquals("", tokens.readString(1));
}
@@ -94,7 +94,7 @@ public class FixedLengthTokenizerTests {
public void testTokenizeNullString() {
tokenizer.setColumns(new Range[] { new Range(1, 5), new Range(6, 10), new Range(11, 15) });
try {
tokenizer.process(null);
tokenizer.tokenize(null);
fail("Expected IncorrectLineLengthException");
}
catch (IncorrectLineLengthException ex) {
@@ -106,7 +106,7 @@ public class FixedLengthTokenizerTests {
tokenizer.setColumns(new Range[] { new Range(1, 2), new Range(3, 7), new Range(8, 12) });
// test shorter line as defined by record descriptor
line = "H11234512345";
FieldSet tokens = tokenizer.process(line);
FieldSet tokens = tokenizer.tokenize(line);
assertEquals(3, tokens.getFieldCount());
assertEquals("H1", tokens.readString(0));
assertEquals("12345", tokens.readString(1));
@@ -118,7 +118,7 @@ public class FixedLengthTokenizerTests {
tokenizer.setColumns(new Range[] { new Range(1, 10), new Range(11, 25), new Range(26, 30) });
// test shorter line as defined by record descriptor
line = "H1 12345678 12345";
FieldSet tokens = tokenizer.process(line);
FieldSet tokens = tokenizer.tokenize(line);
assertEquals(3, tokens.getFieldCount());
assertEquals(line.substring(0, 10).trim(), tokens.readString(0));
assertEquals(line.substring(10, 25).trim(), tokens.readString(1));
@@ -130,7 +130,7 @@ public class FixedLengthTokenizerTests {
tokenizer.setColumns(new Range[] { new Range(1, 10), new Range(11, 25), new Range(26, 30) });
line = "H1 12345678 1234567890";
try {
tokenizer.process(line);
tokenizer.tokenize(line);
fail("Expected IncorrectLineLengthException");
}
catch (IncorrectLineLengthException ex) {
@@ -143,7 +143,7 @@ public class FixedLengthTokenizerTests {
public void testLongerLinesOpenRange() throws Exception {
tokenizer.setColumns(new Range[] { new Range(1, 10), new Range(11, 25), new Range(26) });
line = "H1 12345678 1234567890";
FieldSet tokens = tokenizer.process(line);
FieldSet tokens = tokenizer.tokenize(line);
assertEquals(line.substring(0, 10).trim(), tokens.readString(0));
assertEquals(line.substring(10, 25).trim(), tokens.readString(1));
assertEquals(line.substring(25).trim(), tokens.readString(2));
@@ -154,7 +154,7 @@ public class FixedLengthTokenizerTests {
tokenizer.setColumns(new Range[] { new Range(1, 10), new Range(11, 25), new Range(26,30) });
line = "H1 12345678 1234567890";
tokenizer.setStrict(false);
FieldSet tokens = tokenizer.process(line);
FieldSet tokens = tokenizer.tokenize(line);
assertEquals(line.substring(0, 10).trim(), tokens.readString(0));
assertEquals(line.substring(10, 25).trim(), tokens.readString(1));
assertEquals(line.substring(25, 30).trim(), tokens.readString(2));
@@ -165,7 +165,7 @@ public class FixedLengthTokenizerTests {
tokenizer.setColumns(new Range[] { new Range(14, 28), new Range(34, 38), new Range(1, 10) });
// test normal length
line = "H1 +++12345678 +++++12345";
FieldSet tokens = tokenizer.process(line);
FieldSet tokens = tokenizer.tokenize(line);
assertEquals(3, tokens.getFieldCount());
assertEquals(line.substring(0, 10).trim(), tokens.readString(2));
assertEquals(line.substring(13, 28).trim(), tokens.readString(0));
@@ -177,7 +177,7 @@ public class FixedLengthTokenizerTests {
tokenizer.setColumns(new Range[] { new Range(1, 5), new Range(6, 15), new Range(16, 25), new Range(26, 27) });
// test another type of record
line = "H2 123456 12345 12";
FieldSet tokens = tokenizer.process(line);
FieldSet tokens = tokenizer.tokenize(line);
assertEquals(4, tokens.getFieldCount());
assertEquals(line.substring(0, 5).trim(), tokens.readString(0));
assertEquals(line.substring(5, 15).trim(), tokens.readString(1));
@@ -191,7 +191,7 @@ public class FixedLengthTokenizerTests {
new Range(34) });
// test another type of record
line = "H2 123456 12345 12-123456";
FieldSet tokens = tokenizer.process(line);
FieldSet tokens = tokenizer.tokenize(line);
assertEquals(5, tokens.getFieldCount());
assertEquals(line.substring(0, 5).trim(), tokens.readString(0));
assertEquals(line.substring(5, 15).trim(), tokens.readString(1));
@@ -205,7 +205,7 @@ public class FixedLengthTokenizerTests {
tokenizer.setColumns(new Range[] { new Range(1, 5) });
try {
tokenizer.process("12345");
tokenizer.tokenize("12345");
fail("Exception was expected: too few names provided");
}
catch (IncorrectTokenCountException e) {

View File

@@ -39,7 +39,7 @@ public class FormatterLineAggregatorTests {
String[] args = { "does not matter what is here" };
try {
aggregator.process(args);
aggregator.aggregate(args);
fail("should not work with no format specified");
}
catch (IllegalArgumentException expected) {
@@ -56,7 +56,7 @@ public class FormatterLineAggregatorTests {
aggregator.setMaximumLength(3);
aggregator.setFormat("%3s");
try {
aggregator.process(args);
aggregator.aggregate(args);
fail("Invalid text length, exception should have been thrown");
}
catch (IllegalStateException expected) {
@@ -71,7 +71,7 @@ public class FormatterLineAggregatorTests {
public void testAggregate() {
String[] args = { "Matchsize", "Smallsize" };
aggregator.setFormat("%9s%9s");
String result = aggregator.process(args);
String result = aggregator.aggregate(args);
assertEquals("MatchsizeSmallsize", result);
}
@@ -82,7 +82,7 @@ public class FormatterLineAggregatorTests {
public void testAggregateWithLastRangeUnbound() {
String[] args = { "Matchsize", "Smallsize" };
aggregator.setFormat("%-12s%s");
String result = aggregator.process(args);
String result = aggregator.aggregate(args);
assertEquals("Matchsize Smallsize", result);
}
@@ -93,7 +93,7 @@ public class FormatterLineAggregatorTests {
public void testAggregateFormattedRight() {
String[] args = { "Matchsize", "Smallsize" };
aggregator.setFormat("%13s%10s");
String result = aggregator.process(args);
String result = aggregator.aggregate(args);
assertEquals(23, result.length());
assertEquals(" Matchsize Smallsize", result);
}
@@ -127,7 +127,7 @@ public class FormatterLineAggregatorTests {
}
});
String result = aggregator.process(args);
String result = aggregator.aggregate(args);
assertEquals(" Matchsize Smallsize ", result);
}
@@ -160,7 +160,7 @@ public class FormatterLineAggregatorTests {
}
});
String result = aggregator.process(args);
String result = aggregator.aggregate(args);
assertEquals("Matchsize....Smallsize..", result);
}
@@ -171,7 +171,7 @@ public class FormatterLineAggregatorTests {
public void testAggregateFormattedLeft() {
String[] args = { "Matchsize", "Smallsize" };
aggregator.setFormat("%-13s%-11s");
String result = aggregator.process(args);
String result = aggregator.aggregate(args);
assertEquals("Matchsize Smallsize ", result);
}
@@ -183,6 +183,6 @@ public class FormatterLineAggregatorTests {
public void testAggregateNullArgument() {
String[] args = { null };
aggregator.setFormat("%3s");
assertEquals(" ", aggregator.process(args));
assertEquals(" ", aggregator.aggregate(args));
}
}

View File

@@ -11,11 +11,11 @@ public class PassThroughLineAggregatorTests extends TestCase {
public void testUnmapItemAsFieldSet() throws Exception {
Object item = new Object();
assertEquals(item.toString(), mapper.process(item));
assertEquals(item.toString(), mapper.aggregate(item));
}
public void testUnmapItemAsString() throws Exception {
assertEquals("foo", mapper.process("foo"));
assertEquals("foo", mapper.aggregate("foo"));
}
}

View File

@@ -32,7 +32,7 @@ public class PrefixMatchingCompositeLineTokenizerTests extends TestCase {
public void testNoTokenizers() throws Exception {
try {
tokenizer.process("a line");
tokenizer.tokenize("a line");
fail("Expected IllegalStateException");
} catch (IllegalStateException e) {
// expected
@@ -41,7 +41,7 @@ public class PrefixMatchingCompositeLineTokenizerTests extends TestCase {
public void testNullLine() throws Exception {
tokenizer.setTokenizers(Collections.singletonMap("foo", (LineTokenizer) new DelimitedLineTokenizer()));
FieldSet fields = tokenizer.process(null);
FieldSet fields = tokenizer.tokenize(null);
assertEquals(0, fields.getFieldCount());
}
@@ -49,12 +49,12 @@ public class PrefixMatchingCompositeLineTokenizerTests extends TestCase {
Map<String, LineTokenizer> map = new HashMap<String, LineTokenizer>();
map.put("", new DelimitedLineTokenizer());
map.put("foo", new LineTokenizer() {
public FieldSet process(String line) {
public FieldSet tokenize(String line) {
return null;
}
});
tokenizer.setTokenizers(map);
FieldSet fields = tokenizer.process("abc");
FieldSet fields = tokenizer.tokenize("abc");
assertEquals(1, fields.getFieldCount());
}
@@ -62,20 +62,20 @@ public class PrefixMatchingCompositeLineTokenizerTests extends TestCase {
Map<String, LineTokenizer> map = new LinkedHashMap<String, LineTokenizer>();
map.put("", new LineTokenizer() {
public FieldSet process(String line) {
public FieldSet tokenize(String line) {
return null;
}
});
map.put("foo", new DelimitedLineTokenizer());
tokenizer.setTokenizers(map);
FieldSet fields = tokenizer.process("foo,bar");
FieldSet fields = tokenizer.tokenize("foo,bar");
assertEquals("bar", fields.readString(1));
}
public void testNoMatch() throws Exception {
tokenizer.setTokenizers(Collections.singletonMap("foo", (LineTokenizer) new DelimitedLineTokenizer()));
try {
tokenizer.process("nomatch");
tokenizer.tokenize("nomatch");
fail("Expected IllegalStateException");
} catch (IllegalStateException e) {
// expected
@@ -84,11 +84,11 @@ public class PrefixMatchingCompositeLineTokenizerTests extends TestCase {
public void testMatchWithPrefix() throws Exception {
tokenizer.setTokenizers(Collections.singletonMap("foo", (LineTokenizer) new LineTokenizer() {
public FieldSet process(String line) {
public FieldSet tokenize(String line) {
return new DefaultFieldSet(new String[] {line});
}
}));
FieldSet fields = tokenizer.process("foo bar");
FieldSet fields = tokenizer.tokenize("foo bar");
assertEquals(1, fields.getFieldCount());
assertEquals("foo bar", fields.readString(0));
}

View File

@@ -34,15 +34,15 @@ public class RecursiveCollectionItemTransformerTests extends TestCase {
public void testSetDelegateAndPassInString() throws Exception {
aggregator.setDelegate(new LineAggregator<String>() {
public String process(String item) {
public String aggregate(String item) {
return "bar";
}
});
assertEquals("bar", aggregator.process(Collections.singleton("foo")));
assertEquals("bar", aggregator.aggregate(Collections.singleton("foo")));
}
public void testTransformList() throws Exception {
String result = aggregator.process(Arrays.asList(StringUtils.commaDelimitedListToStringArray("foo,bar")));
String result = aggregator.aggregate(Arrays.asList(StringUtils.commaDelimitedListToStringArray("foo,bar")));
String[] array = StringUtils.delimitedListToStringArray(result, LINE_SEPARATOR);
assertEquals("foo", array[0]);
assertEquals("bar", array[1]);

View File

@@ -67,7 +67,7 @@ public abstract class AbstractTradeBatchTests extends TestCase {
}
protected static class TradeMapper implements FieldSetMapper<Trade> {
public Trade process(FieldSet fs) {
public Trade map(FieldSet fs) {
return new Trade(fs);
}
}

View File

@@ -6,7 +6,7 @@ import org.springframework.batch.sample.domain.football.Game;
public class GameFieldSetMapper implements FieldSetMapper<Game> {
public Game process(FieldSet fs) {
public Game map(FieldSet fs) {
if(fs == null){
return null;

View File

@@ -6,7 +6,7 @@ import org.springframework.batch.sample.domain.football.Player;
public class PlayerFieldSetMapper implements FieldSetMapper<Player> {
public Player process(FieldSet fs) {
public Player map(FieldSet fs) {
if(fs == null){
return null;

View File

@@ -83,7 +83,7 @@ public class AggregateItemFieldSetMapper<T> implements FieldSetMapper<AggregateI
* @return an {@link AggregateItem} that wraps the return value from the
* delegate
*/
public AggregateItem<T> process(FieldSet fieldSet) {
public AggregateItem<T> map(FieldSet fieldSet) {
if (fieldSet.readString(0).equals(begin)) {
return AggregateItem.getHeader();
@@ -92,7 +92,7 @@ public class AggregateItemFieldSetMapper<T> implements FieldSetMapper<AggregateI
return AggregateItem.getFooter();
}
return new AggregateItem<T>(delegate.process(fieldSet));
return new AggregateItem<T>(delegate.map(fieldSet));
}

View File

@@ -33,7 +33,7 @@ public class AddressFieldSetMapper implements FieldSetMapper<Address> {
public static final String COUNTRY_COLUMN = "COUNTRY";
public Address process(FieldSet fieldSet) {
public Address map(FieldSet fieldSet) {
Address address = new Address();
address.setAddressee(fieldSet.readString(ADDRESSEE_COLUMN));

View File

@@ -27,7 +27,7 @@ public class BillingFieldSetMapper implements FieldSetMapper<BillingInfo> {
public static final String PAYMENT_TYPE_ID_COLUMN = "PAYMENT_TYPE_ID";
public static final String PAYMENT_DESC_COLUMN = "PAYMENT_DESC";
public BillingInfo process(FieldSet fieldSet) {
public BillingInfo map(FieldSet fieldSet) {
BillingInfo info = new BillingInfo();
info.setPaymentId(fieldSet.readString(PAYMENT_TYPE_ID_COLUMN));

View File

@@ -34,7 +34,7 @@ public class CustomerFieldSetMapper implements FieldSetMapper<Customer> {
public static final String REG_ID_COLUMN = "REG_ID";
public static final String VIP_COLUMN = "VIP";
public Customer process(FieldSet fieldSet) {
public Customer map(FieldSet fieldSet) {
Customer customer = new Customer();
if (Customer.LINE_ID_BUSINESS_CUST.equals(fieldSet.readString(LINE_ID_COLUMN))) {

View File

@@ -27,7 +27,7 @@ public class HeaderFieldSetMapper implements FieldSetMapper<Order> {
public static final String ORDER_ID_COLUMN = "ORDER_ID";
public static final String ORDER_DATE_COLUMN = "ORDER_DATE";
public Order process(FieldSet fieldSet) {
public Order map(FieldSet fieldSet) {
Order order = new Order();
order.setOrderId(fieldSet.readLong(ORDER_ID_COLUMN));
order.setOrderDate(fieldSet.readDate(ORDER_DATE_COLUMN));

View File

@@ -33,7 +33,7 @@ public class OrderItemFieldSetMapper implements FieldSetMapper<LineItem> {
public static final String ITEM_ID_COLUMN = "ITEM_ID";
public LineItem process(FieldSet fieldSet) {
public LineItem map(FieldSet fieldSet) {
LineItem item = new LineItem();
item.setItemId(fieldSet.readLong(ITEM_ID_COLUMN));

View File

@@ -89,7 +89,7 @@ public class OrderItemReader implements ItemReader<Order> {
// start a new Order
if (Order.LINE_ID_HEADER.equals(lineId)) {
log.debug("STARTING NEW RECORD");
order = headerMapper.process(fieldSet);
order = headerMapper.map(fieldSet);
return;
}
@@ -114,7 +114,7 @@ public class OrderItemReader implements ItemReader<Order> {
log.debug("MAPPING CUSTOMER");
if (order.getCustomer() == null) {
order.setCustomer(customerMapper.process(fieldSet));
order.setCustomer(customerMapper.map(fieldSet));
order.getCustomer().setBusinessCustomer(true);
}
@@ -125,7 +125,7 @@ public class OrderItemReader implements ItemReader<Order> {
log.debug("MAPPING CUSTOMER");
if (order.getCustomer() == null) {
order.setCustomer(customerMapper.process(fieldSet));
order.setCustomer(customerMapper.map(fieldSet));
order.getCustomer().setBusinessCustomer(false);
}
@@ -134,25 +134,25 @@ public class OrderItemReader implements ItemReader<Order> {
if (Address.LINE_ID_BILLING_ADDR.equals(lineId)) {
log.debug("MAPPING BILLING ADDRESS");
order.setBillingAddress(addressMapper.process(fieldSet));
order.setBillingAddress(addressMapper.map(fieldSet));
return;
}
if (Address.LINE_ID_SHIPPING_ADDR.equals(lineId)) {
log.debug("MAPPING SHIPPING ADDRESS");
order.setShippingAddress(addressMapper.process(fieldSet));
order.setShippingAddress(addressMapper.map(fieldSet));
return;
}
if (BillingInfo.LINE_ID_BILLING_INFO.equals(lineId)) {
log.debug("MAPPING BILLING INFO");
order.setBilling(billingMapper.process(fieldSet));
order.setBilling(billingMapper.map(fieldSet));
return;
}
if (ShippingInfo.LINE_ID_SHIPPING_INFO.equals(lineId)) {
log.debug("MAPPING SHIPPING INFO");
order.setShipping(shippingMapper.process(fieldSet));
order.setShipping(shippingMapper.map(fieldSet));
return;
}
@@ -162,7 +162,7 @@ public class OrderItemReader implements ItemReader<Order> {
if (order.getLineItems() == null) {
order.setLineItems(new ArrayList<LineItem>());
}
order.getLineItems().add(itemMapper.process(fieldSet));
order.getLineItems().add(itemMapper.map(fieldSet));
return;
}

View File

@@ -50,18 +50,18 @@ public class OrderProcessor implements ItemProcessor<Order, List<String>> {
List<String> result = new ArrayList<String>();
result.add(getAggregator("header").process(OrderFormatterUtils.headerArgs(order)));
result.add(getAggregator("customer").process(OrderFormatterUtils.customerArgs(order)));
result.add(getAggregator("address").process(OrderFormatterUtils.billingAddressArgs(order)));
result.add(getAggregator("billing").process(OrderFormatterUtils.billingInfoArgs(order)));
result.add(getAggregator("header").aggregate(OrderFormatterUtils.headerArgs(order)));
result.add(getAggregator("customer").aggregate(OrderFormatterUtils.customerArgs(order)));
result.add(getAggregator("address").aggregate(OrderFormatterUtils.billingAddressArgs(order)));
result.add(getAggregator("billing").aggregate(OrderFormatterUtils.billingInfoArgs(order)));
List<LineItem> items = order.getLineItems();
for (LineItem lineItem : items) {
result.add(getAggregator("item").process(OrderFormatterUtils.lineItemArgs(lineItem)));
result.add(getAggregator("item").aggregate(OrderFormatterUtils.lineItemArgs(lineItem)));
}
result.add(getAggregator("footer").process(OrderFormatterUtils.footerArgs(order)));
result.add(getAggregator("footer").aggregate(OrderFormatterUtils.footerArgs(order)));
return result;
}

View File

@@ -28,7 +28,7 @@ public class ShippingFieldSetMapper implements FieldSetMapper<ShippingInfo> {
public static final String SHIPPING_TYPE_ID_COLUMN = "SHIPPING_TYPE_ID";
public static final String SHIPPER_ID_COLUMN = "SHIPPER_ID";
public ShippingInfo process(FieldSet fieldSet) {
public ShippingInfo map(FieldSet fieldSet) {
ShippingInfo info = new ShippingInfo();
info.setShipperId(fieldSet.readString(SHIPPER_ID_COLUMN));

View File

@@ -26,11 +26,11 @@ public class CompositeCustomerUpdateLineTokenizer extends StepExecutionListenerS
/* (non-Javadoc)
* @see org.springframework.batch.item.file.transform.LineTokenizer#tokenize(java.lang.String)
*/
public FieldSet process(String line) {
public FieldSet tokenize(String line) {
if(line.charAt(0) == 'F'){
//line starts with F, so the footer tokenizer should tokenize it.
FieldSet fs = footerTokenizer.process(line);
FieldSet fs = footerTokenizer.tokenize(line);
long customerUpdateTotal = stepExecution.getReadCount();
long fileUpdateTotal = fs.readLong(1);
if(customerUpdateTotal != fileUpdateTotal){
@@ -45,7 +45,7 @@ public class CompositeCustomerUpdateLineTokenizer extends StepExecutionListenerS
}
else if(line.charAt(0) == 'A' || line.charAt(0) == 'U' || line.charAt(0) == 'D'){
//line starts with A,U, or D, so it must be a customer operation.
return customerTokenizer.process(line);
return customerTokenizer.tokenize(line);
}
else{
//If the line doesn't start with any of the characters above, it must obviously be invalid.

View File

@@ -16,7 +16,7 @@ import org.springframework.batch.item.file.mapping.FieldSetMapper;
*/
public class CustomerUpdateFieldSetMapper implements FieldSetMapper<CustomerUpdate> {
public CustomerUpdate process(FieldSet fs) {
public CustomerUpdate map(FieldSet fs) {
CustomerOperation operation = CustomerOperation.fromCode(fs.readChar(0));
String name = fs.readString(1);

View File

@@ -29,7 +29,7 @@ public class TradeFieldSetMapper implements FieldSetMapper<Trade> {
public static final int PRICE_COLUMN = 2;
public static final int CUSTOMER_COLUMN = 3;
public Trade process(FieldSet fieldSet) {
public Trade map(FieldSet fieldSet) {
Trade trade = new Trade();
trade.setIsin(fieldSet.readString(ISIN_COLUMN));

View File

@@ -17,26 +17,26 @@ public class AggregateItemFieldSetMapperTests {
@Test
public void testDefaultBeginRecord() throws Exception {
assertTrue(mapper.process(new DefaultFieldSet(new String[] { "BEGIN" })).isHeader());
assertFalse(mapper.process(new DefaultFieldSet(new String[] { "BEGIN" })).isFooter());
assertTrue(mapper.map(new DefaultFieldSet(new String[] { "BEGIN" })).isHeader());
assertFalse(mapper.map(new DefaultFieldSet(new String[] { "BEGIN" })).isFooter());
}
@Test
public void testSetBeginRecord() throws Exception {
mapper.setBegin("FOO");
assertTrue(mapper.process(new DefaultFieldSet(new String[] { "FOO" })).isHeader());
assertTrue(mapper.map(new DefaultFieldSet(new String[] { "FOO" })).isHeader());
}
@Test
public void testDefaultEndRecord() throws Exception {
assertFalse(mapper.process(new DefaultFieldSet(new String[] { "END" })).isHeader());
assertTrue(mapper.process(new DefaultFieldSet(new String[] { "END" })).isFooter());
assertFalse(mapper.map(new DefaultFieldSet(new String[] { "END" })).isHeader());
assertTrue(mapper.map(new DefaultFieldSet(new String[] { "END" })).isFooter());
}
@Test
public void testSetEndRecord() throws Exception {
mapper.setEnd("FOO");
assertTrue(mapper.process(new DefaultFieldSet(new String[] { "FOO" })).isFooter());
assertTrue(mapper.map(new DefaultFieldSet(new String[] { "FOO" })).isFooter());
}
@Test
@@ -53,11 +53,11 @@ public class AggregateItemFieldSetMapperTests {
@Test
public void testDelegate() throws Exception {
mapper.setDelegate(new FieldSetMapper<String>() {
public String process(FieldSet fs) {
public String map(FieldSet fs) {
return "foo";
}
});
assertEquals("foo", mapper.process(new DefaultFieldSet(new String[] { "FOO" })).getItem());
assertEquals("foo", mapper.map(new DefaultFieldSet(new String[] { "FOO" })).getItem());
}

View File

@@ -84,13 +84,13 @@ public class OrderItemReaderTests {
// create mock mapper
FieldSetMapper mapper = createMock(FieldSetMapper.class);
// set how mapper should respond - set return values for mapper
expect(mapper.process(headerFS)).andReturn(order);
expect(mapper.process(customerFS)).andReturn(customer);
expect(mapper.process(billingFS)).andReturn(billing);
expect(mapper.process(shippingFS)).andReturn(shipping);
expect(mapper.process(billingInfoFS)).andReturn(billingInfo);
expect(mapper.process(shippingInfoFS)).andReturn(shippingInfo);
expect(mapper.process(itemFS)).andReturn(item).times(3);
expect(mapper.map(headerFS)).andReturn(order);
expect(mapper.map(customerFS)).andReturn(customer);
expect(mapper.map(billingFS)).andReturn(billing);
expect(mapper.map(shippingFS)).andReturn(shipping);
expect(mapper.map(billingInfoFS)).andReturn(billingInfo);
expect(mapper.map(shippingInfoFS)).andReturn(shippingInfo);
expect(mapper.map(itemFS)).andReturn(item).times(3);
replay(mapper);
// set-up provider: set mappers

View File

@@ -36,7 +36,7 @@ public class CompositeCustomerUpdateLineTokenizerTests {
public void testCustomerAdd() throws Exception{
String customerAddLine = "AFDASFDASFDFSA";
FieldSet fs = compositeTokenizer.process(customerAddLine);
FieldSet fs = compositeTokenizer.tokenize(customerAddLine);
assertEquals(customerFieldSet, fs);
assertEquals(customerAddLine, customerTokenizer.getTokenizedLine());
}
@@ -45,7 +45,7 @@ public class CompositeCustomerUpdateLineTokenizerTests {
public void testCustomerDelete() throws Exception{
String customerAddLine = "DFDASFDASFDFSA";
FieldSet fs = compositeTokenizer.process(customerAddLine);
FieldSet fs = compositeTokenizer.tokenize(customerAddLine);
assertEquals(customerFieldSet, fs);
assertEquals(customerAddLine, customerTokenizer.getTokenizedLine());
}
@@ -54,7 +54,7 @@ public class CompositeCustomerUpdateLineTokenizerTests {
public void testCustomerUpdate() throws Exception{
String customerAddLine = "UFDASFDASFDFSA";
FieldSet fs = compositeTokenizer.process(customerAddLine);
FieldSet fs = compositeTokenizer.tokenize(customerAddLine);
assertEquals(customerFieldSet, fs);
assertEquals(customerAddLine, customerTokenizer.getTokenizedLine());
}
@@ -63,7 +63,7 @@ public class CompositeCustomerUpdateLineTokenizerTests {
public void testInvalidLine() throws Exception{
String invalidLine = "INVALID";
compositeTokenizer.process(invalidLine);
compositeTokenizer.tokenize(invalidLine);
}
@@ -76,7 +76,7 @@ public class CompositeCustomerUpdateLineTokenizerTests {
this.fieldSetToReturn = fieldSetToReturn;
}
public FieldSet process(String line) {
public FieldSet tokenize(String line) {
this.tokenizedLine = line;
return fieldSetToReturn;
}

View File

@@ -38,7 +38,7 @@ public abstract class AbstractFieldSetMapperTests {
*/
@Test
public void testRegularUse() throws Exception {
assertEquals(expectedDomainObject(), fieldSetMapper().process(fieldSet()));
assertEquals(expectedDomainObject(), fieldSetMapper().map(fieldSet()));
}
}