Package org.dozer.vo

Examples of org.dozer.vo.AnotherTestObject


    mapper = getMapper(new String[] { "trimStringsMapping.xml" });
  }

  @Test
  public void testTrimStrings_Global() {
    AnotherTestObject src = newInstance(AnotherTestObject.class);
    src.setField3("      valueNeedingTrimmed       ");
    src.setField4("      anotherValueNeedingTrimmed       ");
    src.setField5("  127 ");

    AnotherTestObjectPrime dest = mapper.map(src, AnotherTestObjectPrime.class);

    assertEquals("valueNeedingTrimmed", dest.getField3());
    assertEquals("anotherValueNeedingTrimmed", dest.getTo().getOne());
View Full Code Here


  // Defect #1728385
  @Test
  public void testSimpleCustomConverter_ImplicitMapping() throws Exception {
    mapper = getMapper("simpleCustomConverter.xml");

    AnotherTestObject src = newInstance(AnotherTestObject.class);
    src.setField3(String.valueOf(System.currentTimeMillis()));

    AnotherTestObjectPrime dest = mapper.map(src, AnotherTestObjectPrime.class);

    // Custom converter specified for the field mapping, so verify custom converter was actually used
    assertNotNull("dest field should not be null", dest.getField3());
    StringTokenizer st = new StringTokenizer(dest.getField3(), "-");
    assertEquals("dest field value should contain a hyphon", 2, st.countTokens());
    String token1 = st.nextToken();
    assertEquals("1st portion of dest field value should equal src field value", src.getField3(), token1);
    String token2 = st.nextToken();
    assertEquals("dest field value should have been appended to by the cust converter", StringAppendCustomConverter.APPENDED_VALUE,
        token2);
  }
View Full Code Here

  public void testFieldCustomConverter_WithCustomConverterId() throws Exception {
    mapper = getMapper(new String[] { "fieldCustomConverter.xml" });
    Map<String, CustomConverter> map = newInstance(HashMap.class);
    map.put("CustomConverterWithId", new StringAppendCustomConverter());
    ((DozerBeanMapper) mapper).setCustomConvertersWithId(map);
    AnotherTestObject src = newInstance(AnotherTestObject.class);
    src.setField3("field3");

    SimpleObj dest = mapper.map(src, SimpleObj.class);

    assertEquals("dest field1 value should have been appended to by the cust converter", src.getField3() + "-"
        + StringAppendCustomConverter.APPENDED_VALUE, dest.getField1());
  }
View Full Code Here

  @Test
  public void testSimpleCustomConverter() throws Exception {
    SimpleObj src = newInstance(SimpleObj.class);
    src.setField1(String.valueOf(System.currentTimeMillis()));

    AnotherTestObject dest = mapper.map(src, AnotherTestObject.class);

    // Custom converter specified for the field1 mapping, so verify custom converter was actually used
    assertNotNull("dest field1 should not be null", dest.getField3());
    StringTokenizer st = new StringTokenizer(dest.getField3(), "-");
    assertEquals("dest field1 value should contain a hyphon", 2, st.countTokens());
    String token1 = st.nextToken();
    assertEquals("1st portion of dest field1 value should equal src field value", src.getField1(), token1);
    String token2 = st.nextToken();
    assertEquals("custom converter param should have been appended to by the cust converter", "CustomConverterParamTest", token2);
View Full Code Here

    zipCode.setZipCode("one");
    TestObject to2 = mapper.map(res, TestObject.class);
    assertEquals(res.getGetWeatherByZipCode().getZipCode(), to2.getOne());

    Set set = new HashSet();
    AnotherTestObject ato = new AnotherTestObject();
    ato.setDay("day");
    set.add(ato);
    to.setSetToArray(set);

    AnotherTestObject ato2 = new AnotherTestObject();
    ato2.setDay("day");
    to.addAnotherTestObject(ato2);
    GetWeatherByZipCodeResponseDocument responseDoc = mapper.map(to, GetWeatherByZipCodeResponseDocument.class);
    WeatherData[] weatherDataArray = responseDoc.getGetWeatherByZipCodeResponse().getWeatherDataArray();
    WeatherData[] weatherData2Array = responseDoc.getGetWeatherByZipCodeResponse().getWeatherData2Array();
    assertEquals(ato.getDay(), weatherDataArray[0].getDay());
    assertEquals(ato2.getDay(), weatherData2Array[0].getDay());

    // now take the xmlbeans array and map the other direction
    TestObject toResult = mapper.map(responseDoc, TestObject.class);
    assertEquals(weatherDataArray[0].getDay(), ((AnotherTestObject) toResult.getSetToArray().iterator().next()).getDay());
    assertEquals(weatherData2Array[0].getDay(), ((AnotherTestObject) toResult.getSetToArrayWithIterate().iterator().next())
View Full Code Here

  @Test
  public void testMapNull_MappingLevel() throws Exception {
    Mapper mapper = getMapper(new String[] { "nullFieldMapping.xml" });
    // check that null does not override an existing value when map-null="false"
    AnotherTestObject src = newInstance(AnotherTestObject.class);
    src.setField3(null);
    src.setField4(null);
    AnotherTestObjectPrime dest = newInstance(AnotherTestObjectPrime.class);
    dest.setTo(newInstance(TestObject.class));
    dest.setField3("555");
    dest.getTo().setOne("4641");
View Full Code Here

    // Reverse mapping
    AnotherTestObjectPrime src = newInstance(AnotherTestObjectPrime.class);
    src.setTo(newInstance(TestObject.class));
    src.setField3(null);
    src.getTo().setOne(null);
    AnotherTestObject dest = newInstance(AnotherTestObject.class);
    dest.setField3("555");
    dest.setField4("4641");

    // dest field should remain unchanged
    mapper.map(src, dest);
    assertEquals("invalid dest field value", "555", dest.getField3());
    assertEquals("invalid dest field value2", "4641", dest.getField4());
  }
View Full Code Here

  @Test
  public void testMapEmptyString_MappingLevel() throws Exception {
    Mapper mapper = getMapper(new String[] { "nullFieldMapping.xml" });
    // check that "" does not override an existing value when
    // map-empty-string="false"
    AnotherTestObject src = newInstance(AnotherTestObject.class);
    src.setField3("");
    src.setField4("");
    AnotherTestObjectPrime dest = newInstance(AnotherTestObjectPrime.class);
    dest.setTo(newInstance(TestObject.class));
    dest.setField3("555");
    dest.getTo().setOne("4641");
View Full Code Here

    // reverse mapping
    AnotherTestObjectPrime src = newInstance(AnotherTestObjectPrime.class);
    src.setTo(newInstance(TestObject.class));
    src.setField3("");
    src.getTo().setOne("");
    AnotherTestObject dest = newInstance(AnotherTestObject.class);
    dest.setField3("555");
    dest.setField4("4641");

    // dest field should remain unchanged
    mapper.map(src, dest);
    assertEquals("invalid dest field value", "555", dest.getField3());
    assertEquals("invalid dest field value2", "4641", dest.getField4());
  }
View Full Code Here

  }

  @Test
  public void testNullField() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    AnotherTestObject src = newInstance(AnotherTestObject.class);
    src.setField2(null);
    AnotherTestObjectPrime dest = newInstance(AnotherTestObjectPrime.class);
    dest.setField2(Integer.valueOf("555"));
    // check that null overrides an existing value
    mapper.map(src, dest);
    assertNull("dest field should be null", dest.getField2());
View Full Code Here

TOP

Related Classes of org.dozer.vo.AnotherTestObject

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.