RESOLVED - BATCH-779: RFC: make FieldSetMapper and LineAggregator extend ItemProcessor
reverted to original method names
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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" }));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user