Package org.dozer.vo.inheritance

Examples of org.dozer.vo.inheritance.AnotherSubClass


    return result;
  }

  public AnotherSubClass getAnotherSubClass() {
    AnotherSubClass asub = newInstance(AnotherSubClass.class);
    asub.setBaseAttribute("base");
    asub.setSubAttribute("sub");
    List<BaseSubClass> list = newInstance(ArrayList.class);
    SClass s = newInstance(SClass.class);
    s.setBaseSubAttribute("sBase");
    s.setSubAttribute("s");
    S2Class s2 = newInstance(S2Class.class);
    s2.setBaseSubAttribute("s2Base");
    s2.setSub2Attribute("s2");
    list.add(s2);
    list.add(s);
    asub.setSubList(list);

    List<BaseSubClass> list2 = newInstance(ArrayList.class);
    SClass sclass = newInstance(SClass.class);
    sclass.setBaseSubAttribute("sBase");
    sclass.setSubAttribute("s");
    S2Class s2class = newInstance(S2Class.class);
    s2class.setBaseSubAttribute("s2Base");
    s2class.setSub2Attribute("s2");
    SClass sclass2 = newInstance(SClass.class);
    sclass2.setBaseSubAttribute("sclass2");
    sclass2.setSubAttribute("sclass2");
    list2.add(s2class);
    list2.add(sclass);
    list2.add(sclass2);
    asub.setListToArray(list2);

    SClass sclassA = newInstance(SClass.class);
    SClass sclassB = newInstance(SClass.class);
    sclassA.setBaseSubAttribute("sBase");
    sclassA.setSubAttribute("s");
    sclassB.setBaseSubAttribute("sBase");
    sclassB.setSubAttribute("s");
    asub.setSClass(sclassA);
    asub.setSClass2(sclassB);

    return asub;
  }
View Full Code Here


  }

  @Test(timeout = 12000)
  public void testMapping4() throws Exception {
    // AnotherSubClass --> AnotherSubClassPrime (Inheritance)
    AnotherSubClass src = testDataFactory.getAnotherSubClass();
    runGeneric("testMapping4", src, AnotherSubClassPrime.class);
  }
View Full Code Here

    t4.join();
  }

  private void mapSomething() {
    TestObject src = testDataFactory.getInputGeneralMappingTestObject();
    AnotherSubClass src2 = testDataFactory.getAnotherSubClass();

    mapper.map(src, TestObjectPrime.class);
    mapper.map(src2, AnotherSubClassPrime.class);
  }
View Full Code Here

  @Test
  public void testGeneralInheritance2() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    // test base to base and sub to sub mapping with an intermediate on the destination
    AnotherSubClass asub = newInstance(AnotherSubClass.class);
    asub.setBaseAttribute("base");
    asub.setSubAttribute("sub");
    List<BaseSubClass> list = newInstance(ArrayList.class);
    SClass s = newInstance(SClass.class);
    s.setBaseSubAttribute("sBase");
    s.setSubAttribute("s");
    S2Class s2 = newInstance(S2Class.class);
    s2.setBaseSubAttribute("s2Base");
    s2.setSub2Attribute("s2");
    list.add(s2);
    list.add(s);
    asub.setSubList(list);

    List<BaseSubClass> list2 = newInstance(ArrayList.class);
    SClass sclass = newInstance(SClass.class);
    sclass.setBaseSubAttribute("sBase");
    sclass.setSubAttribute("s");
    S2Class s2class = newInstance(S2Class.class);
    s2class.setBaseSubAttribute("s2Base");
    s2class.setSub2Attribute("s2");
    SClass sclass2 = newInstance(SClass.class);
    sclass2.setBaseSubAttribute("sclass2");
    sclass2.setSubAttribute("sclass2");
    list2.add(s2class);
    list2.add(sclass);
    list2.add(sclass2);
    asub.setListToArray(list2);

    SClass sclassA = newInstance(SClass.class);
    SClass sclassB = newInstance(SClass.class);
    sclassA.setBaseSubAttribute("sBase");
    sclassA.setSubAttribute("s");
    sclassB.setBaseSubAttribute("sBase");
    sclassB.setSubAttribute("s");
    asub.setSClass(sclassA);
    asub.setSClass2(sclassB);

    AnotherSubClassPrime subPrime = mapper.map(asub, AnotherSubClassPrime.class);

    assertEquals(asub.getSubAttribute(), subPrime.getSubAttribute2());
    assertEquals(asub.getBaseAttribute(), subPrime.getBaseAttribute2());
    assertTrue(subPrime.getTheListOfSubClassPrime().get(0) instanceof S2ClassPrime);
    assertTrue(subPrime.getTheListOfSubClassPrime().get(1) instanceof SClassPrime);
    assertEquals(s2.getSub2Attribute(), ((S2ClassPrime) subPrime.getTheListOfSubClassPrime().get(0)).getSub2Attribute2());
    assertEquals(s2.getBaseSubAttribute(), ((S2ClassPrime) subPrime.getTheListOfSubClassPrime().get(0)).getBaseSubAttribute2());
    assertEquals(s.getSubAttribute(), ((SClassPrime) subPrime.getTheListOfSubClassPrime().get(1)).getSubAttribute2());
    assertEquals(s.getBaseSubAttribute(), ((SClassPrime) subPrime.getTheListOfSubClassPrime().get(1)).getBaseSubAttribute2());
    assertTrue(subPrime.getArrayToList()[0] instanceof S2ClassPrime);
    assertTrue(subPrime.getArrayToList()[1] instanceof SClassPrime);
    assertTrue(subPrime.getArrayToList()[2] instanceof SClassPrime);
    assertEquals(s2class.getSub2Attribute(), ((S2ClassPrime) subPrime.getArrayToList()[0]).getSub2Attribute2());
    assertEquals(s2class.getBaseSubAttribute(), ((S2ClassPrime) subPrime.getArrayToList()[0]).getBaseSubAttribute2());
    assertEquals(sclass.getSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[1]).getSubAttribute2());
    assertEquals(sclass.getBaseSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[1]).getBaseSubAttribute2());
    assertEquals(sclass2.getSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[2]).getSubAttribute2());
    assertEquals(sclass2.getBaseSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[2]).getBaseSubAttribute2());
    assertEquals(asub.getSClass().getSubAttribute(), subPrime.getSClass().getSubAttribute2());
    assertEquals(asub.getSClass().getBaseSubAttribute(), subPrime.getSClass().getBaseSubAttribute2());
    assertEquals(asub.getSClass2().getSubAttribute(), subPrime.getSClass2().getSubAttribute2());
    assertEquals(asub.getSClass2().getBaseSubAttribute(), subPrime.getSClass2().getBaseSubAttribute2());

    // map it back
    AnotherSubClass sub = mapper.map(subPrime, AnotherSubClass.class);
    assertTrue(sub.getSubList().get(0) instanceof S2Class);
    assertTrue(sub.getSubList().get(1) instanceof SClass);
    assertEquals(s2.getSub2Attribute(), ((S2Class) sub.getSubList().get(0)).getSub2Attribute());
    assertEquals(s2.getBaseSubAttribute(), ((S2Class) sub.getSubList().get(0)).getBaseSubAttribute());
    assertEquals(s.getSubAttribute(), ((SClass) sub.getSubList().get(1)).getSubAttribute());
    assertEquals(s.getBaseSubAttribute(), ((SClass) sub.getSubList().get(1)).getBaseSubAttribute());
  }
View Full Code Here

  @Test
  public void testGeneralInheritance2() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    // test base to base and sub to sub mapping with an intermediate on the destination
    AnotherSubClass asub = newInstance(AnotherSubClass.class);
    asub.setBaseAttribute("base");
    asub.setSubAttribute("sub");
    List<BaseSubClass> list = newInstance(ArrayList.class);
    SClass s = newInstance(SClass.class);
    s.setBaseSubAttribute("sBase");
    s.setSubAttribute("s");
    S2Class s2 = newInstance(S2Class.class);
    s2.setBaseSubAttribute("s2Base");
    s2.setSub2Attribute("s2");
    list.add(s2);
    list.add(s);
    asub.setSubList(list);

    List<BaseSubClass> list2 = newInstance(ArrayList.class);
    SClass sclass = newInstance(SClass.class);
    sclass.setBaseSubAttribute("sBase");
    sclass.setSubAttribute("s");
    S2Class s2class = newInstance(S2Class.class);
    s2class.setBaseSubAttribute("s2Base");
    s2class.setSub2Attribute("s2");
    SClass sclass2 = newInstance(SClass.class);
    sclass2.setBaseSubAttribute("sclass2");
    sclass2.setSubAttribute("sclass2");
    list2.add(s2class);
    list2.add(sclass);
    list2.add(sclass2);
    asub.setListToArray(list2);

    SClass sclassA = newInstance(SClass.class);
    SClass sclassB = newInstance(SClass.class);
    sclassA.setBaseSubAttribute("sBase");
    sclassA.setSubAttribute("s");
    sclassB.setBaseSubAttribute("sBase");
    sclassB.setSubAttribute("s");
    asub.setSClass(sclassA);
    asub.setSClass2(sclassB);

    AnotherSubClassPrime subPrime = mapper.map(asub, AnotherSubClassPrime.class);

    assertEquals(asub.getSubAttribute(), subPrime.getSubAttribute2());
    assertEquals(asub.getBaseAttribute(), subPrime.getBaseAttribute2());
    assertTrue(subPrime.getTheListOfSubClassPrime().get(0) instanceof S2ClassPrime);
    assertTrue(subPrime.getTheListOfSubClassPrime().get(1) instanceof SClassPrime);
    assertEquals(s2.getSub2Attribute(), ((S2ClassPrime) subPrime.getTheListOfSubClassPrime().get(0)).getSub2Attribute2());
    assertEquals(s2.getBaseSubAttribute(), ((S2ClassPrime) subPrime.getTheListOfSubClassPrime().get(0)).getBaseSubAttribute2());
    assertEquals(s.getSubAttribute(), ((SClassPrime) subPrime.getTheListOfSubClassPrime().get(1)).getSubAttribute2());
    assertEquals(s.getBaseSubAttribute(), ((SClassPrime) subPrime.getTheListOfSubClassPrime().get(1)).getBaseSubAttribute2());
    assertTrue(subPrime.getArrayToList()[0] instanceof S2ClassPrime);
    assertTrue(subPrime.getArrayToList()[1] instanceof SClassPrime);
    assertTrue(subPrime.getArrayToList()[2] instanceof SClassPrime);
    assertEquals(s2class.getSub2Attribute(), ((S2ClassPrime) subPrime.getArrayToList()[0]).getSub2Attribute2());
    assertEquals(s2class.getBaseSubAttribute(), ((S2ClassPrime) subPrime.getArrayToList()[0]).getBaseSubAttribute2());
    assertEquals(sclass.getSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[1]).getSubAttribute2());
    assertEquals(sclass.getBaseSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[1]).getBaseSubAttribute2());
    assertEquals(sclass2.getSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[2]).getSubAttribute2());
    assertEquals(sclass2.getBaseSubAttribute(), ((SClassPrime) subPrime.getArrayToList()[2]).getBaseSubAttribute2());
    assertEquals(asub.getSClass().getSubAttribute(), subPrime.getSClass().getSubAttribute2());
    assertEquals(asub.getSClass().getBaseSubAttribute(), subPrime.getSClass().getBaseSubAttribute2());
    assertEquals(asub.getSClass2().getSubAttribute(), subPrime.getSClass2().getSubAttribute2());
    assertEquals(asub.getSClass2().getBaseSubAttribute(), subPrime.getSClass2().getBaseSubAttribute2());

    // map it back
    AnotherSubClass sub = mapper.map(subPrime, AnotherSubClass.class);
    assertTrue(sub.getSubList().get(0) instanceof S2Class);
    assertTrue(sub.getSubList().get(1) instanceof SClass);
    assertEquals(s2.getSub2Attribute(), ((S2Class) sub.getSubList().get(0)).getSub2Attribute());
    assertEquals(s2.getBaseSubAttribute(), ((S2Class) sub.getSubList().get(0)).getBaseSubAttribute());
    assertEquals(s.getSubAttribute(), ((SClass) sub.getSubList().get(1)).getSubAttribute());
    assertEquals(s.getBaseSubAttribute(), ((SClass) sub.getSubList().get(1)).getBaseSubAttribute());
  }
View Full Code Here

  }

  @Test(timeout = 12000)
  public void testMapping4() throws Exception {
    // AnotherSubClass --> AnotherSubClassPrime (Inheritance)
    AnotherSubClass src = testDataFactory.getAnotherSubClass();
    runGeneric("testMapping4", src, AnotherSubClassPrime.class);
  }
View Full Code Here

    t4.join();
  }

  private void mapSomething() {
    TestObject src = testDataFactory.getInputGeneralMappingTestObject();
    AnotherSubClass src2 = testDataFactory.getAnotherSubClass();

    mapper.map(src, TestObjectPrime.class);
    mapper.map(src2, AnotherSubClassPrime.class);
  }
View Full Code Here

    return result;
  }

  public AnotherSubClass getAnotherSubClass() {
    AnotherSubClass asub = newInstance(AnotherSubClass.class);
    asub.setBaseAttribute("base");
    asub.setSubAttribute("sub");
    List<BaseSubClass> list = newInstance(ArrayList.class);
    SClass s = newInstance(SClass.class);
    s.setBaseSubAttribute("sBase");
    s.setSubAttribute("s");
    S2Class s2 = newInstance(S2Class.class);
    s2.setBaseSubAttribute("s2Base");
    s2.setSub2Attribute("s2");
    list.add(s2);
    list.add(s);
    asub.setSubList(list);

    List<BaseSubClass> list2 = newInstance(ArrayList.class);
    SClass sclass = newInstance(SClass.class);
    sclass.setBaseSubAttribute("sBase");
    sclass.setSubAttribute("s");
    S2Class s2class = newInstance(S2Class.class);
    s2class.setBaseSubAttribute("s2Base");
    s2class.setSub2Attribute("s2");
    SClass sclass2 = newInstance(SClass.class);
    sclass2.setBaseSubAttribute("sclass2");
    sclass2.setSubAttribute("sclass2");
    list2.add(s2class);
    list2.add(sclass);
    list2.add(sclass2);
    asub.setListToArray(list2);

    SClass sclassA = newInstance(SClass.class);
    SClass sclassB = newInstance(SClass.class);
    sclassA.setBaseSubAttribute("sBase");
    sclassA.setSubAttribute("s");
    sclassB.setBaseSubAttribute("sBase");
    sclassB.setSubAttribute("s");
    asub.setSClass(sclassA);
    asub.setSClass2(sclassB);

    return asub;
  }
View Full Code Here

TOP

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

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.