Package org.dozer.vo

Examples of org.dozer.vo.TestObject


  }

  @Test
  public void testMapToMap() throws Exception {
    Mapper mapper = getMapper(new String[] { "mapInterfaceMapping.xml", "dozerBeanMapping.xml" });
    TestObject to = newInstance(TestObject.class);
    to.setOne("one");
    TestObject to2 = newInstance(TestObject.class);
    to2.setTwo(new Integer(2));
    Map<String, TestObject> map = newInstance(HashMap.class);
    map.put("to", to);
    map.put("to2", to2);

    Map<String, TestObject> map2 = newInstance(HashMap.class);
View Full Code Here


  }

  @Test
  public void testMapToMapExistingDestination() throws Exception {
    Mapper mapper = getMapper(new String[] { "mapInterfaceMapping.xml", "dozerBeanMapping.xml" });
    TestObject to = newInstance(TestObject.class);
    to.setOne("one");
    TestObject to2 = newInstance(TestObject.class);
    to2.setTwo(new Integer(2));
    Map<String, TestObject> map = newInstance(HashMap.class);
    map.put("to", to);
    map.put("to2", to2);
    MapToMap mtm = newInstance(MapToMap.class);
    mtm.setStandardMap(map);
View Full Code Here

    assertEquals("field 5 not trimmed", Integer.valueOf("127"), dest.getField5());
  }

  @Test
  public void testTrimStrings_ClassMapLevel() {
    TestObject src = newInstance(TestObject.class);
    String value = "    shouldNotBeNeedingTrimmed     ";
    src.setOne(value);

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

    assertEquals(value, dest.getOnePrime());
  }
View Full Code Here

    custom.setSetDataType(set);
    return custom;
  }

  public TestObject getInputTestListFieldEmptyListTestObject() {
    TestObject custom = newInstance(TestObject.class);
    custom.setEqualNamedList(newInstance(ArrayList.class));
    return custom;
  }
View Full Code Here

    custom.setEqualNamedList(newInstance(ArrayList.class));
    return custom;
  }

  public TestObject getInputTestListFieldArrayListTestObject() {
    TestObject custom = newInstance(TestObject.class);
    Integer[] array = { new Integer(1) };
    custom.setArrayForLists(array);
    return custom;
  }
View Full Code Here

    custom.setArrayForLists(array);
    return custom;
  }

  public TestObject getInputTestListUsingDestHintTestObject() {
    TestObject custom = newInstance(TestObject.class);
    List<TheFirstSubClass> list = newInstance(ArrayList.class);
    list.add(newInstance(TheFirstSubClass.class));
    custom.setHintList(list);
    return custom;
  }
View Full Code Here

    custom.setHintList(list);
    return custom;
  }

  public TestObject getInputGeneralMappingTestObject() {
    TestObject custom = newInstance(TestObject.class);
    custom.setOne("one");
    custom.setTwo(new Integer(2));

    int[] pa = { 0, 1, 2, 3, 4 };
    custom.setPrimArray(pa);

    InsideTestObject ito = newInstance(InsideTestObject.class);
    ito.setLabel("label");
    ito.setWrapper(new Integer(1));
    ito.setToWrapper(1);

    custom.setThree(ito);

    // testing if it will map two custom objects that are different types but same names //
    InsideTestObject ito2 = newInstance(InsideTestObject.class);
    ito2.setLabel("label");
    custom.setInsideTestObject(ito2);

    List<String> list1 = newInstance(ArrayList.class);
    list1.add("1value");
    list1.add("2value");
    List<String> list2 = newInstance(ArrayList.class);
    list2.add("1value");
    list2.add("2value");
    custom.setEqualNamedList(list1);
    custom.setUnequalNamedList(list2);

    custom.setThePrimitive(3);
    custom.setTheMappedPrimitive(4);

    int[] intArray = { 1, 1 };
    Integer[] integerArray = { new Integer(1), new Integer(1) };
    custom.setAnArray(intArray);
    custom.setArrayForLists(integerArray);
    custom.setBigDecimalToInt(new BigDecimal(1));
    custom.setIntToBigDecimal(1);
    Date date = new Date();
    custom.setDate(date);
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    custom.setCalendar(calendar);
    Van van = newInstance(Van.class);
    van.setName("van");
    van.setTestValue("testValue");
    custom.setVan(van);
    custom.setExcludeMe("takemeout");

    // testing interfaces
    MetalThingyIF car = newInstance(Car.class);
    car.setName("metalthingy");
    custom.setCarMetalThingy(car);

    List<TheFirstSubClass> hintList = newInstance(ArrayList.class);
    TheFirstSubClass fsc = newInstance(TheFirstSubClass.class);
    TheFirstSubClass fsc2 = newInstance(TheFirstSubClass.class);
    fsc.setS("s");
    fsc2.setS("s");
    hintList.add(fsc);
    hintList.add(fsc2);

    custom.setHintList(hintList);

    custom.setBlankDate("");
    custom.setBlankStringToLong("");
    NoExtendBaseObject nebo = newInstance(NoExtendBaseObject.class);
    custom.setCopyByReference(nebo);
    NoExtendBaseObject nebo2 = newInstance(NoExtendBaseObject.class);
    custom.setCopyByReferenceDeep(nebo2);
    NoExtendBaseObjectGlobalCopyByReference globalNebo = newInstance(NoExtendBaseObjectGlobalCopyByReference.class);
    custom.setGlobalCopyByReference(globalNebo);

    String[] stringArray = new String[] { null, "one", "two" };
    custom.setStringArrayWithNullValue(stringArray);
    return custom;
  }
View Full Code Here

  }

  @Test(expected=MappingException.class)
  public void testNullDestObj() throws Exception {
    Object destObj = null;
    mapper.map(new TestObject(), destObj);
    fail("should have thrown mapping exception");
  }
View Full Code Here

    fail("should have thrown mapping exception");
  }

  @Test(expected=MappingException.class)
  public void testMapIdDoesNotExist() {
    mapper.map(new TestObject(), TestObjectPrime.class, "thisMapIdDoesNotExist");
    fail("should have thrown exception");
  }
View Full Code Here

    // -----------------------------------------------------------

    Mapper mapper = getNewMapper(new String[]{"customfactorymapping.xml"});

    TestObjectPrime prime = mapper.map(testDataFactory.getInputGeneralMappingTestObject(), TestObjectPrime.class);
    TestObject source = mapper.map(prime, TestObject.class);

    // The following asserts will verify that the ClassMap beanFactory attr gets applied to both classes
    assertNotNull("created by factory name should not be null", prime.getCreatedByFactoryName());
    assertNotNull("created by factory name should not be null", source.getCreatedByFactoryName());
    assertEquals(SampleCustomBeanFactory.class.getName(), prime.getCreatedByFactoryName());
    assertEquals(SampleCustomBeanFactory.class.getName(), source.getCreatedByFactoryName());

    // The following asserts will verify that default configuration is being applied
    assertNotNull("created by factory name should not be null", source.getThree().getCreatedByFactoryName());
    assertEquals(SampleDefaultBeanFactory.class.getName(), source.getThree().getCreatedByFactoryName());

    // The following asserts will verify that dest or src class level attr's override classMap and default config attr's
    assertNotNull("created by factory name should not be null", prime.getThreePrime().getCreatedByFactoryName());
    assertEquals(SampleCustomBeanFactory2.class.getName(), prime.getThreePrime().getCreatedByFactoryName());
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.