Package org.dozer.vo

Examples of org.dozer.vo.CustomDoubleObjectIF


  @Test
  public void testCustomConverterMapping() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    TestCustomConverterObject obj = newInstance(TestCustomConverterObject.class);
    CustomDoubleObjectIF doub = newInstance(CustomDoubleObject.class);
    doub.setTheDouble(15);
    CustomDoubleObjectIF doub2 = newInstance(CustomDoubleObject.class);
    doub2.setTheDouble(15);
    obj.setAttribute(doub);

    Collection<CustomDoubleObjectIF> list = newInstance(ArrayList.class);
    list.add(doub2);

    obj.setNames(list);

    TestCustomConverterObjectPrime dest = mapper.map(obj, TestCustomConverterObjectPrime.class);

    assertEquals("Custom Converter failed", dest.getDoubleAttribute().doubleValue() + "", "15.0");
    assertEquals("Custom Converter failed", ((Double) dest.getNames().iterator().next()).doubleValue() + "", "15.0");

    TestCustomConverterObjectPrime objp = newInstance(TestCustomConverterObjectPrime.class);

    objp.setDoubleAttribute(new Double(15));

    Collection<Double> list2 = newInstance(ArrayList.class);
    list2.add(new Double(10));
    objp.setNames(list2);

    TestCustomConverterObject destp = mapper.map(objp, TestCustomConverterObject.class);

    assertEquals("Custom Converter failed", destp.getAttribute().getTheDouble() + "", "15.0");
    assertEquals("Custom Converter failed", ((CustomDoubleObjectIF) destp.getNames().iterator().next()).getTheDouble() + "", "10.0");

    destp.getAttribute().setName("testName");

    // pass by reference
    mapper.map(objp, destp);

    assertEquals("Custom Converter failed", destp.getAttribute().getTheDouble() + "", "15.0");
    assertEquals("testName", destp.getAttribute().getName());

    // test primitive double
    TestCustomConverterObjectPrime prime = newInstance(TestCustomConverterObjectPrime.class);
    prime.setPrimitiveDoubleAttribute(25.00);
    TestCustomConverterObject obj2 = mapper.map(prime, TestCustomConverterObject.class);
    CustomDoubleObjectIF customDouble = obj2.getPrimitiveDoubleAttribute();
    assertNotNull(customDouble);
    assertTrue(prime.getPrimitiveDoubleAttribute() == obj2.getPrimitiveDoubleAttribute().getTheDouble());

    // test conversion in the other direction
    prime = mapper.map(obj2, TestCustomConverterObjectPrime.class);
View Full Code Here


    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    TestCustomConverterObjectPrime prime = newInstance(TestCustomConverterObjectPrime.class);
    prime.setPrimitiveDoubleAttribute(25.00);
    prime.setDoubleAttribute(new Double(30.00));
    TestCustomConverterObject obj2 = mapper.map(prime, TestCustomConverterObject.class);
    CustomDoubleObjectIF customDouble = obj2.getPrimitiveDoubleAttribute();
    assertNotNull(customDouble);
    assertTrue(prime.getPrimitiveDoubleAttribute() == obj2.getPrimitiveDoubleAttribute().getTheDouble());

    // test conversion in the other direction
    prime = mapper.map(obj2, TestCustomConverterObjectPrime.class);
View Full Code Here

    if (source == null) {
      return null;
    }

    CustomDoubleObjectIF dest = null;
    if (source instanceof Double) {
      // check to see if the object already exists
      if (destination == null) {
        dest = new CustomDoubleObject();
      } else {
        dest = (CustomDoubleObjectIF) destination;
      }
      dest.setTheDouble(((Double) source).doubleValue());
      return dest;
    } else if (source instanceof CustomDoubleObject) {
      double sourceObj = ((CustomDoubleObjectIF) source).getTheDouble();
      return new Double(sourceObj);
    } else {
View Full Code Here

    obj.setTestObject(getInputGeneralMappingTestObject());
    HydrateTestObject2 sourceObj = newInstance(HydrateTestObject2.class);

    TestCustomConverterObject cobj = newInstance(TestCustomConverterObject.class);
    CustomDoubleObjectIF doub = newInstance(CustomDoubleObject.class);
    doub.setTheDouble(15);
    cobj.setAttribute(doub);

    obj.setCustomConvert(cobj);
    obj.setHydrate(sourceObj);
    obj.setSuperFieldToExclude("superFieldToExclude");
View Full Code Here

    obj.setTestObject(getInputGeneralMappingTestObject());
    HydrateTestObject2 sourceObj = newInstance(HydrateTestObject2.class);

    TestCustomConverterObject cobj = newInstance(TestCustomConverterObject.class);
    CustomDoubleObjectIF doub = newInstance(CustomDoubleObject.class);
    doub.setTheDouble(15);
    cobj.setAttribute(doub);

    obj.setCustomConvert(cobj);
    obj.setHydrate(sourceObj);
    obj.setSuperFieldToExclude("superFieldToExclude");
View Full Code Here

    if (source == null) {
      return null;
    }

    CustomDoubleObjectIF dest = null;
    if (source instanceof Double) {
      // check to see if the object already exists
      if (destination == null) {
        dest = new CustomDoubleObject();
      } else {
        dest = (CustomDoubleObjectIF) destination;
      }
      dest.setTheDouble(((Double) source).doubleValue());
      return dest;
    } else if (source instanceof CustomDoubleObject) {
      double sourceObj = ((CustomDoubleObjectIF) source).getTheDouble();
      return new Double(sourceObj);
    } else {
View Full Code Here

  @Test
  public void testCustomConverterMapping() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    TestCustomConverterObject obj = newInstance(TestCustomConverterObject.class);
    CustomDoubleObjectIF doub = newInstance(CustomDoubleObject.class);
    doub.setTheDouble(15);
    CustomDoubleObjectIF doub2 = newInstance(CustomDoubleObject.class);
    doub2.setTheDouble(15);
    obj.setAttribute(doub);

    Collection<CustomDoubleObjectIF> list = newInstance(ArrayList.class);
    list.add(doub2);

    obj.setNames(list);

    TestCustomConverterObjectPrime dest = mapper.map(obj, TestCustomConverterObjectPrime.class);

    assertEquals("Custom Converter failed", dest.getDoubleAttribute().doubleValue() + "", "15.0");
    assertEquals("Custom Converter failed", ((Double) dest.getNames().iterator().next()).doubleValue() + "", "15.0");

    TestCustomConverterObjectPrime objp = newInstance(TestCustomConverterObjectPrime.class);

    objp.setDoubleAttribute(new Double(15));

    Collection<Double> list2 = newInstance(ArrayList.class);
    list2.add(new Double(10));
    objp.setNames(list2);

    TestCustomConverterObject destp = mapper.map(objp, TestCustomConverterObject.class);

    assertEquals("Custom Converter failed", destp.getAttribute().getTheDouble() + "", "15.0");
    assertEquals("Custom Converter failed", ((CustomDoubleObjectIF) destp.getNames().iterator().next()).getTheDouble() + "", "10.0");

    destp.getAttribute().setName("testName");

    // pass by reference
    mapper.map(objp, destp);

    assertEquals("Custom Converter failed", destp.getAttribute().getTheDouble() + "", "15.0");
    assertEquals("testName", destp.getAttribute().getName());

    // test primitive double
    TestCustomConverterObjectPrime prime = newInstance(TestCustomConverterObjectPrime.class);
    prime.setPrimitiveDoubleAttribute(25.00);
    TestCustomConverterObject obj2 = mapper.map(prime, TestCustomConverterObject.class);
    CustomDoubleObjectIF customDouble = obj2.getPrimitiveDoubleAttribute();
    assertNotNull(customDouble);
    assertTrue(prime.getPrimitiveDoubleAttribute() == obj2.getPrimitiveDoubleAttribute().getTheDouble());

    // test conversion in the other direction
    prime = mapper.map(obj2, TestCustomConverterObjectPrime.class);
View Full Code Here

    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    TestCustomConverterObjectPrime prime = newInstance(TestCustomConverterObjectPrime.class);
    prime.setPrimitiveDoubleAttribute(25.00);
    prime.setDoubleAttribute(new Double(30.00));
    TestCustomConverterObject obj2 = mapper.map(prime, TestCustomConverterObject.class);
    CustomDoubleObjectIF customDouble = obj2.getPrimitiveDoubleAttribute();
    assertNotNull(customDouble);
    assertTrue(prime.getPrimitiveDoubleAttribute() == obj2.getPrimitiveDoubleAttribute().getTheDouble());

    // test conversion in the other direction
    prime = mapper.map(obj2, TestCustomConverterObjectPrime.class);
View Full Code Here

TOP

Related Classes of org.dozer.vo.CustomDoubleObjectIF

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.