Package org.springframework.batch.item.file.transform

Examples of org.springframework.batch.item.file.transform.DefaultFieldSet


            .getNumberInstance(Locale.GERMAN), true));
      }
    };
    mapper.setTargetType(TestTwoDoubles.class);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "9.876,1", "7890.1" }, new String[] { "value", "other" });
    TestTwoDoubles bean = mapper.mapFieldSet(fieldSet);

    assertEquals(9876.1, bean.getValue(), 0.01);
    assertEquals(7890.1, bean.getOther(), 0.01);
  }
View Full Code Here


            .getNumberInstance(Locale.GERMAN), true));
      }
    };
    mapper.setTargetType(TestTwoDoubles.class);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "9.876,1", "7890.1" }, new String[] { "value", "other" });
    TestTwoDoubles bean = mapper.mapFieldSet(fieldSet);

    assertEquals(9876.1, bean.getValue(), 0.01);
    assertEquals(7890.1, bean.getOther(), 0.01);
  }
View Full Code Here

    BeanWrapperFieldSetMapper<TestObject> mapper = new BeanWrapperFieldSetMapper<TestObject>();
    mapper.setStrict(true);
    mapper.setTargetType(TestObject.class);
    mapper.afterPropertiesSet();

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "This won't be mapped",
        "true", "C" }, new String[] { "varString", "illegalPropertyName", "varBoolean", "varChar" });
    try {
      mapper.mapFieldSet(fieldSet);
      fail("expected error");
    }
View Full Code Here

    BeanWrapperFieldSetMapper<TestObject> mapper = new BeanWrapperFieldSetMapper<TestObject>();
    mapper.setStrict(false);
    mapper.setTargetType(TestObject.class);
    mapper.afterPropertiesSet();

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "This is some dummy string", "This won't be mapped",
        "true", "C" }, new String[] { "varString", "illegalPropertyName", "varBoolean", "varChar" });
    TestObject result = mapper.mapFieldSet(fieldSet);
    assertEquals("This is some dummy string", result.getVarString());
    assertEquals(true, result.isVarBoolean());
    assertEquals('C', result.getVarChar());
View Full Code Here

  }
 
  @Test
  public void testMapping() throws Exception {
    final String line = "TEST";
    final FieldSet fs = new DefaultFieldSet(new String[]{"token1", "token2"});
    final String item = "ITEM";
   
    LineTokenizer tokenizer = mock(LineTokenizer.class);
    when(tokenizer.tokenize(line)).thenReturn(fs);
   
View Full Code Here

  public void testKeyFound() throws Exception {
    Map<String, LineTokenizer> tokenizers = new HashMap<String, LineTokenizer>();
    tokenizers.put("foo*", new LineTokenizer() {
            @Override
      public FieldSet tokenize(String line) {
        return new DefaultFieldSet(new String[] { "a", "b" });
      }
    });
    tokenizers.put("bar*", new LineTokenizer() {
            @Override
      public FieldSet tokenize(String line) {
        return new DefaultFieldSet(new String[] { "c", "d" });
      }
    });
    mapper.setTokenizers(tokenizers);

    Map<String, FieldSetMapper<Name>> fieldSetMappers = new HashMap<String, FieldSetMapper<Name>>();
View Full Code Here

  public void testMapperKeyNotFound() throws Exception {
    Map<String, LineTokenizer> tokenizers = new HashMap<String, LineTokenizer>();
    tokenizers.put("foo*", new LineTokenizer() {
            @Override
      public FieldSet tokenize(String line) {
        return new DefaultFieldSet(new String[] { "a", "b" });
      }
    });
    tokenizers.put("bar*", new LineTokenizer() {
            @Override
      public FieldSet tokenize(String line) {
        return new DefaultFieldSet(new String[] { "c", "d" });
      }
    });
    mapper.setTokenizers(tokenizers);

    Map<String, FieldSetMapper<Name>> fieldSetMappers = new HashMap<String, FieldSetMapper<Name>>();
View Full Code Here

  /**
   * Test method for
   * {@link org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper#mapFieldSet(org.springframework.batch.item.file.transform.FieldSet)}.
   */
  public void testMapLine() {
    FieldSet fieldSet = new DefaultFieldSet(new String[] { "foo", "bar" });
    assertEquals(fieldSet, mapper.mapFieldSet(fieldSet));
  }
View Full Code Here

public class AggregateItemFieldSetMapperTests {
  private AggregateItemFieldSetMapper<String> mapper = new AggregateItemFieldSetMapper<String>();

  @Test
  public void testDefaultBeginRecord() throws Exception {
    assertTrue(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "BEGIN" })).isHeader());
    assertFalse(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "BEGIN" })).isFooter());
  }
View Full Code Here

  }

  @Test
  public void testSetBeginRecord() throws Exception {
    mapper.setBegin("FOO");
    assertTrue(mapper.mapFieldSet(new DefaultFieldSet(new String[] { "FOO" })).isHeader());
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.file.transform.DefaultFieldSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.