Examples of TestObject


Examples of org.dozer.vo.TestObject

  }

  public void testAllowedExceptionsDoNotThrowException() throws Exception {
    Mapper mapper = getMapper(new String[] { "allowedExceptionsMapping.xml" });
    TestObject to2 = newInstance(TestObject.class);
    to2.setThrowNonAllowedExceptionOnMap("do not throw me");
    try {
      mapper.map(to2, TestObjectPrime.class);
    } catch (RuntimeException e) {
      fail("This should not have been thrown");
    }
View Full Code Here

Examples of org.dozer.vo.TestObject

  @Test
  public void testStringToDateMapping() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss:SS");
    String dateStr = "01/29/1975 10:45:13:25";
    TestObject sourceObj = newInstance(TestObject.class);
    sourceObj.setDateStr(dateStr);
    TestObjectPrime result = mapper.map(sourceObj, TestObjectPrime.class);
    assertEquals(df.parse(dateStr), result.getDateFromStr());
    assertEquals(dateStr, df.format(result.getDateFromStr()));

    TestObject result2 = mapper.map(result, TestObject.class);
    assertEquals(df.format(result.getDateFromStr()), result2.getDateStr());
    assertEquals(result.getDateFromStr(), df.parse(result2.getDateStr()));
  }
View Full Code Here

Examples of org.dozer.vo.TestObject

  public void testNullField2() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    // Test that String --> String with an empty String input value results
    // in the destination field being an empty String and not null.
    String input = "";
    TestObject src = newInstance(TestObject.class);
    src.setOne(input);

    TestObjectPrime dest = mapper.map(src, TestObjectPrime.class);
    assertNotNull("dest field should not be null", dest.getOnePrime());
    assertEquals("invalid dest field value", input, dest.getOnePrime());
  }
View Full Code Here

Examples of org.dozer.vo.TestObject

  @Test
  public void testNullToPrimitive() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    AnotherTestObject src = newInstance(AnotherTestObject.class);
    AnotherTestObjectPrime prime = newInstance(AnotherTestObjectPrime.class);
    TestObject to = newInstance(TestObject.class);
    to.setThePrimitive(AnotherTestObjectPrime.DEFAULT_FIELD1);
    prime.setTo(to);
    mapper.map(src, prime);
    // check primitive on deep field
    // primitive should still be default
    assertEquals("invalid field value", AnotherTestObjectPrime.DEFAULT_FIELD1, prime.getField1());
View Full Code Here

Examples of org.dozer.vo.TestObject

  }

  @Test
  public void testGlobalRelationshipType() throws Exception {
    mapper = getMapper(new String[] { "relationship-type-global-configuration.xml" });
    TestObject src = new TestObject();
    src.setHintList(new ArrayList<String>(Arrays.asList(new String[] { "a" })));

    TestObjectPrime dest = new TestObjectPrime();
    dest.setHintList(new ArrayList<String>(Arrays.asList(new String[] { "a", "b" })));

    mapper.map(src, dest);
View Full Code Here

Examples of org.dozer.vo.TestObject

  }

  @Test
  public void testClassMapRelationshipType() throws Exception {
    mapper = getMapper(new String[] { "relationshipTypeMapping.xml" });
    TestObject src = new TestObject();
    src.setHintList(new ArrayList<String>(Arrays.asList(new String[] { "a" })));

    TestObjectPrime dest = new TestObjectPrime();
    dest.setHintList(new ArrayList<String>(Arrays.asList(new String[] { "a", "b" })));

    mapper.map(src, dest);
View Full Code Here

Examples of org.dozer.vo.TestObject

    assertNotNull(type);
  }

  @Test
  public void testSimple() {
    TestObject source = new TestObject();
    source.setOne("ABC");
    EmployeeWithInnerClass result = mapper.map(source, EmployeeWithInnerClass.class);
    assertNotNull(result);
    assertEquals("ABC", result.getFirstName());
  }
View Full Code Here

Examples of org.dozer.vo.TestObject

    assertEquals("ABC", result.getFirstName());
  }
 
  @Test
  public void testNestedInnerClass() {
    TestObject source = new TestObject();
    source.setOne("Name");
    EmployeeWithInnerClass.Address.State result = mapper.map(source, EmployeeWithInnerClass.Address.State.class);
    assertNotNull(result);
    assertEquals("Name", result.getName());
  }
View Full Code Here

Examples of org.dozer.vo.TestObject

    assertEquals("Name", result.getName());
  }
 
  @Test
  public void testDateToXMLGregorianCalendar() {
      TestObject source = new TestObject();
      Date now = new Date();
      source.setDate(now);
      EmployeeWithInnerClass result = mapper.map(source, EmployeeWithInnerClass.class);
      assertNotNull(result);
      assertEquals(now.getTime(), result.getBirthDate().toGregorianCalendar().getTimeInMillis());
  }
View Full Code Here

Examples of org.dozer.vo.TestObject

  @Test
  public void testXMLGregorianCalendarToDate() throws DatatypeConfigurationException {
      Calendar cal = GregorianCalendar.getInstance();
      EmployeeWithInnerClass source = new EmployeeWithInnerClass();
      source.setBirthDate(DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar) cal));
      TestObject result = mapper.map(source, TestObject.class);
      assertNotNull(result);
      assertEquals(cal.getTimeInMillis(), result.getDate().getTime());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.