@Test
public void testMapManufacuringFacilityToDTSMerge() {
Map<String, Object> betriebsstaetteMap =
getManufacturingFacility(4L,"Manufacturing Facility Description.");
ManufacturingFacility manufacturingFacility = (ManufacturingFacility)betriebsstaetteMap.get(BaseManufacturingFacilityTest.MANUFACTURINGFACILITY_KEY);
ManufacturingFacilityDTS manufacturingFacilityDTS = (ManufacturingFacilityDTS)betriebsstaetteMap.get(BaseManufacturingFacilityTest.MANUFACTURINGFACILITYDTS_KEY);
addAddressToManufacturingFacility(betriebsstaetteMap, 10L, "StreetA", 815L, "This is a comment. 10", 'D');
addAddressToManufacturingFacility(betriebsstaetteMap, 11L, "StreetB", 816L, "This is a comment. 11", 'E');
addAddressToManufacturingFacility(betriebsstaetteMap, 12L, "StreetC", 817L, "This is a comment. 12", 'F');
// Edit some values on "orginal" bean.
// This is because we want to see if values are kept which are not mapped.
// With the AddressMergingMapper this variable does not contain any addresses after merge.
// The entity mapped from contains 3 addresses.
// Without the AddressMergingMapper there are contained 3 adresses.
// But then the check for the land value fails.
ManufacturingFacilityDTS manufacturingFacilityDTSServer = mapper.map(manufacturingFacility, ManufacturingFacilityDTS.class);
manufacturingFacilityDTSServer.setIdNumber(4L);
Character vLand = 'D';
for(AddressDTO currAnschrift: manufacturingFacilityDTSServer.getAddressL()){
currAnschrift.setLand(vLand);
}
ManufacturingFacility manufacturingFacilityToEdit = mapper.map(manufacturingFacilityDTSServer,ManufacturingFacility.class);
manufacturingFacilityToEdit.putPrototype(manufacturingFacilityDTSServer);
// Now the bean will be edited to see if the mapped values are correctly merged.
List<Address> anschriftenGUI = manufacturingFacilityToEdit.getAddresses();
anschriftenGUI.remove(1);
manufacturingFacilityToEdit.setDescription("Description after merge.");
Address firstAdr = anschriftenGUI.get(0);
firstAdr.setStreet("Street new");
// merge
ManufacturingFacilityDTS prototype = manufacturingFacilityToEdit.returnPrototype();
mapper.map(manufacturingFacilityToEdit, prototype);
// Do some checks.
assertTrue("IdNumber was not kept after merge.",
4L == prototype.getIdNumber());