Package org.dozer.vo.inheritance

Examples of org.dozer.vo.inheritance.B


  public void testCustomMappingForSuperClasses() throws Exception {
    // Test that the explicit super custom mapping definition is used when mapping sub classes
    mapper = getMapper(new String[] { "inheritanceMapping.xml" });

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertNull("superField1 should have been excluded", dest.getSuperField1());
    assertEquals("superBField not mapped correctly", src.getSuperAField(), dest.getSuperBField());
    assertEquals("field1 not mapped correctly", src.getField1(), dest.getField1());
    assertEquals("fieldB not mapped correctly", src.getFieldA(), dest.getFieldB());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here


  public void testNoCustomMappingForSuperClasses() throws Exception {
    // Test that wildcard fields in super classes are mapped when there is no explicit super custom mapping definition
    mapper = new DozerBeanMapper();

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertEquals("superField1 not mapped correctly", src.getSuperField1(), dest.getSuperField1());
    assertEquals("field1 not mapped correctly", src.getField1(), dest.getField1());
    assertNull("superBField should not have been mapped", dest.getSuperBField());
    assertNull("fieldB should not have been mapped", dest.getFieldB());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here

    // Test that when there isnt an explicit super custom mapping definition the subclass mapping def attrs are
    // applied to the super class mapping. In this use case, wildcard="false" for the A --> B mapping definition
    mapper = getMapper(new String[] { "inheritanceMapping2.xml" });

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertNull("fieldB should not have been mapped", dest.getSuperField1());
    assertNull("superBField should have not been mapped", dest.getSuperBField());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here

    // for subclasses. Also tests that a default class map is properly created and used for the subclass
    // field mappings
    mapper = getMapper(new String[] { "inheritanceMapping3.xml" });

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertNull("superField1 should have been excluded", dest.getSuperField1());
    assertEquals("superBField not mapped correctly", src.getSuperAField(), dest.getSuperBField());
    assertEquals("field1 not mapped correctly", src.getField1(), dest.getField1());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here

  public void testCustomMappingForSuperClasses() throws Exception {
    // Test that the explicit super custom mapping definition is used when mapping sub classes
    mapper = getMapper(new String[] { "inheritanceMapping.xml" });

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertNull("superField1 should have been excluded", dest.getSuperField1());
    assertEquals("superBField not mapped correctly", src.getSuperAField(), dest.getSuperBField());
    assertEquals("field1 not mapped correctly", src.getField1(), dest.getField1());
    assertEquals("fieldB not mapped correctly", src.getFieldA(), dest.getFieldB());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here

  public void testNoCustomMappingForSuperClasses() throws Exception {
    // Test that wildcard fields in super classes are mapped when there is no explicit super custom mapping definition
    mapper = new DozerBeanMapper();

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertEquals("superField1 not mapped correctly", src.getSuperField1(), dest.getSuperField1());
    assertEquals("field1 not mapped correctly", src.getField1(), dest.getField1());
    assertNull("superBField should not have been mapped", dest.getSuperBField());
    assertNull("fieldB should not have been mapped", dest.getFieldB());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here

    // Test that when there isnt an explicit super custom mapping definition the subclass mapping def attrs are
    // applied to the super class mapping. In this use case, wildcard="false" for the A --> B mapping definition
    mapper = getMapper(new String[] { "inheritanceMapping2.xml" });

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertNull("fieldB should not have been mapped", dest.getSuperField1());
    assertNull("superBField should have not been mapped", dest.getSuperBField());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here

    // for subclasses. Also tests that a default class map is properly created and used for the subclass
    // field mappings
    mapper = getMapper(new String[] { "inheritanceMapping3.xml" });

    A src = getA();
    B dest = mapper.map(src, B.class);

    assertNull("superField1 should have been excluded", dest.getSuperField1());
    assertEquals("superBField not mapped correctly", src.getSuperAField(), dest.getSuperBField());
    assertEquals("field1 not mapped correctly", src.getField1(), dest.getField1());

    // Remap to each other to test bi-directional mapping
    A mappedSrc = mapper.map(dest, A.class);
    B mappedDest = mapper.map(mappedSrc, B.class);

    assertEquals("objects not mapped correctly bi-directional", dest, mappedDest);
  }
View Full Code Here

TOP

Related Classes of org.dozer.vo.inheritance.B

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.