Package org.dozer.vo

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


    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

  @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

    for (int i = 0; i < THREAD_COUNT; i++) {
      new Thread(new Runnable() {
        public void run() {
          try {
            mapper.map(new TestObject(), TestObjectPrime.class);
          }
          finally {
            latch.countDown();
          }
        }
View Full Code Here

      mapper.map(new String(), null);
    } catch (Throwable t) {
    }

    TestDataFactory testDataFactory = new TestDataFactory(NoProxyDataObjectInstantiator.INSTANCE);
    TestObject to = testDataFactory.getInputGeneralMappingTestObject();
    TestObjectPrime prime = mapper.map(to, TestObjectPrime.class);
    TestObject source = mapper.map(prime, TestObject.class);
    mapper.map(source, TestObjectPrime.class);

    int numIters = 4000;
    for (int i = 0; i < numIters; i++) {
      SimpleObj src = testDataFactory.getSimpleObj();
View Full Code Here

  }

  @Test(expected = TestException.class)
  public void testAllowedExceptionsThrowException() throws Exception {
    Mapper mapper = getMapper("allowedExceptionsMapping.xml");
    TestObject to = newInstance(TestObject.class);
    to.setThrowAllowedExceptionOnMap("throw me");
    mapper.map(to, TestObjectPrime.class);
    fail("We should have thrown TestException");

  }
View Full Code Here

  }

  public void testAllowedExceptionsDoNotThrowException() throws Exception {
    Mapper mapper = getMapper("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

  @Test
  public void testStringToDateMapping() throws Exception {
    mapper = getMapper("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

  public void testNullField2() throws Exception {
    mapper = getMapper("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

  @Test
  public void testNullToPrimitive() throws Exception {
    mapper = getMapper("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

TOP

Related Classes of org.dozer.vo.TestObject

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.