Package org.dozer

Examples of org.dozer.Mapper.map()


    mapper.map(source, TestObjectPrime.class);

    int numIters = 4000;
    for (int i = 0; i < numIters; i++) {
      SimpleObj src = testDataFactory.getSimpleObj();
      mapper.map(src, SimpleObjPrime2.class);
    }

    mappingFiles = new ArrayList<String>();
    mappingFiles.add("arrayToStringCustomConverter.xml");
    mapper = new DozerBeanMapper(mappingFiles);
View Full Code Here


      simple.setField1(String.valueOf(System.currentTimeMillis()));

      ArrayCustConverterObj src = new ArrayCustConverterObj();
      src.setField1(new SimpleObj[] { simple });

      mapper.map(src, ArrayCustConverterObjPrime.class);
    }
  }
}
View Full Code Here

    userGroup.setName("usergroup name");
    userGroup.setUsers(users);
    userGroup.setStatus(Status.SUCCESS);

    // do mapping
    UserGroupPrime userGroupPrime = mapper.map(userGroup, UserGroupPrime.class);

    // prove access to generic type information
    Method setter = UserGroupPrime.class.getMethod("setUsers", List.class);
    Type[] parameterTypes = setter.getGenericParameterTypes();
    assertEquals(1, parameterTypes.length);
View Full Code Here

    assertTrue("Expecting instance of UserPrime.", usersPrime.get(0) instanceof UserPrime);
    assertTrue("Expecting instance of UserPrime.", usersPrime.get(1) instanceof UserPrime);
    assertEquals("SUCCESS", userGroupPrime.getStatusPrime().name());

    // Map the other way
    UserGroup userGroupMapBack = mapper.map(userGroupPrime, UserGroup.class);
    Set<?> usersGroupPrime = userGroupMapBack.getUsers();
    assertNotNull(usersGroupPrime);
    assertEquals(2, usersGroupPrime.size());
    assertTrue("Expecting instance of UserPrime.", usersGroupPrime.iterator().next() instanceof User);
  }
View Full Code Here

    testObject2.setEqualNamedList(Arrays.asList(new AnotherTestObject[] { anotherTestObject }));

    SrcDeepObj src = newInstance(SrcDeepObj.class);
    src.setSomeList(Arrays.asList(new TestObject[] { testObject1, testObject2 }));

    DestDeepObj dest = mapper.map(src, DestDeepObj.class);
    assertEquals("another test object field 3 value", dest.getDest5());
    assertEquals(Integer.valueOf("6453"), (dest.getHintList().get(0)).getTwoPrime());
  }

  @Test
View Full Code Here

  public void testDeepMappingWithIndexOnDestField() {
    Mapper mapper = getMapper(new String[] { "genericCollectionMapping.xml" });
    DestDeepObj src = newInstance(DestDeepObj.class);
    src.setDest5("some string value for field");

    SrcDeepObj dest = mapper.map(src, SrcDeepObj.class);
    assertEquals("some string value for field", dest.getSomeList().get(1).getEqualNamedList().get(0).getField3());
  }

  @Test
  public void testDeepMapIndexed() throws Exception {
View Full Code Here

    myPets[1] = secondPet;

    // Save the pet details into the source object
    source.setPets(myPets);

    HeadOfHouseHold dest = mapper.map(source, HeadOfHouseHold.class);
    assertEquals((source.getFamilyMembers().get(0)).getFirstName(), dest.getFirstName());
    assertEquals((source.getFamilyMembers().get(0)).getLastName(), dest.getLastName());
    assertEquals((source.getFamilyMembers().get(0)).getSalary(), dest.getSalary());
    assertEquals(source.getPets()[1].getPetName(), dest.getPetName());
    assertEquals(String.valueOf(source.getPets()[1].getPetAge()), dest.getPetAge());
View Full Code Here

    source.setSalary(new Integer(15000));
    source.setPetAge("2");
    source.setOffSpringName("Ronny2");

    Family dest = newInstance(Family.class);
    mapper.map(source, dest);

    assertEquals((dest.getFamilyMembers().get(0)).getFirstName(), source.getFirstName());
    assertEquals((dest.getFamilyMembers().get(0)).getLastName(), source.getLastName());
    assertEquals((dest.getFamilyMembers().get(0)).getSalary(), source.getSalary());
    assertEquals(dest.getPets()[1].getPetName(), source.getPetName());
View Full Code Here

    House house = newInstance(House.class);
    MetalThingyIF thingy = newInstance(Car.class);
    thingy.setName("name");
    house.setThingy(thingy);
    ito.setHouse(house);
    InsideTestObjectPrime itop = mapper.map(ito, InsideTestObjectPrime.class);
    assertEquals("name", itop.getDeepInterfaceString());

    mapper.map(itop, InsideTestObject.class);
    assertEquals("name", ito.getHouse().getThingy().getName());
  }
View Full Code Here

    house.setThingy(thingy);
    ito.setHouse(house);
    InsideTestObjectPrime itop = mapper.map(ito, InsideTestObjectPrime.class);
    assertEquals("name", itop.getDeepInterfaceString());

    mapper.map(itop, InsideTestObject.class);
    assertEquals("name", ito.getHouse().getThingy().getName());
  }

  /*
   * Related to feature request #1456486. Deep mapping with custom getter/setter does not work
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.