Address implements InternalModelTransformer, Serializable { @Override public InternalModelObject transformToInternalModel() { final com.worldpay.internal.model.Address intAddress = new com.worldpay.internal.model.Address(); intAddress.setFirstName(firstName); intAddress.setLastName(lastName); intAddress.setPostalCode(postalCode); intAddress.setCity(city); intAddress.setState(state); intAddress.setCountryCode(countryCode); List<Object> addressDetails = intAddress.getStreetOrHouseNameOrHouseNumberOrHouseNumberExtensionOrAddress1OrAddress2OrAddress3(); if (street != null) { final Street intStreet = new Street(); intStreet.setvalue(street); addressDetails.add(intStreet); } if (houseName != null) { final HouseName intHouseName = new HouseName(); intHouseName.setvalue(houseName); addressDetails.add(intHouseName); } if (houseNumber != null) { final HouseNumber intHouseNumber = new HouseNumber(); intHouseNumber.setvalue(houseNumber); addressDetails.add(intHouseNumber); } if (houseNumberExtension != null) { final HouseNumberExtension intHouseNumberExt = new HouseNumberExtension(); intHouseNumberExt.setvalue(houseNumberExtension); addressDetails.add(intHouseNumberExt); } if (address1 != null) { final Address1 intAddress1 = new Address1(); intAddress1.setvalue(address1); addressDetails.add(intAddress1); } if (address2 != null) { final Address2 intAddress2 = new Address2(); intAddress2.setvalue(address2); addressDetails.add(intAddress2); } if (address3 != null) { final Address3 intAddress3 = new Address3(); intAddress3.setvalue(address3); addressDetails.add(intAddress3); } if (StringUtils.isNotBlank(telephoneNumber)) { intAddress.setTelephoneNumber(telephoneNumber); } return intAddress; } Address();  Address(final String firstName, final String lastName, final String address1, final String address2, final String address3, final String postalCode, final String city, final String countryCode); @Override InternalModelObject transformToInternalModel(); String getFirstName(); void setFirstName(final String firstName); String getLastName(); void setLastName(final String lastName); String getStreet(); void setStreet(final String street); String getHouseName(); void setHouseName(final String houseName); String getHouseNumberExtension(); void setHouseNumberExtension(final String houseNumberExtension); String getAddress1(); void setAddress1(final String address1); String getAddress2(); void setAddress2(final String address2); String getAddress3(); void setAddress3(final String address3); String getPostalCode(); void setPostalCode(final String postalCode); String getCity(); void setCity(final String city); String getState(); void setState(final String state); String getCountryCode(); void setCountryCode(final String countryCode); String getTelephoneNumber(); void setTelephoneNumber(final String telephoneNumber); String getHouseNumber(); void setHouseNumber(final String houseNumber); @Override String toString();  }
@Test public void testTransformToInternalModel() throws Exception { testObj.setState(STATE); testObj.setFirstName(FIRST_NAME); testObj.setLastName(LAST_NAME); testObj.setStreet(STREET); testObj.setHouseName(HOUSE_NAME); testObj.setHouseNumberExtension(HOUSE_NUMBER_EXTENSION); testObj.setAddress1(ADDRESS_1); testObj.setAddress2(ADDRESS_2); testObj.setAddress3(ADDRESS_3); testObj.setPostalCode(POSTAL_CODE); testObj.setCity(CITY); testObj.setCountryCode(COUNTRY_CODE); testObj.setTelephoneNumber(TELEPHONE_NUMBER); testObj.setHouseNumber(HOUSE_NUMBER); final com.worldpay.internal.model.Address result = (com.worldpay.internal.model.Address) testObj.transformToInternalModel(); assertEquals(STATE, result.getState()); assertEquals(FIRST_NAME, result.getFirstName()); assertEquals(LAST_NAME, result.getLastName()); final List<Object> addressDetails = result.getStreetOrHouseNameOrHouseNumberOrHouseNumberExtensionOrAddress1OrAddress2OrAddress3(); assertThat(addressDetails, hasItems(instanceOf(Street.class), instanceOf(HouseName.class), CoreMatchers.instanceOf(HouseNumber.class), instanceOf(HouseNumberExtension.class), instanceOf(Address1.class), instanceOf(Address2.class), instanceOf(Address3.class))); assertThat(addressDetails, hasItems(hasProperty(VALUE, is(STREET)), hasProperty(VALUE, is(HOUSE_NAME)), hasProperty(VALUE,is(HOUSE_NUMBER)), hasProperty(VALUE, is(HOUSE_NUMBER_EXTENSION)), hasProperty(VALUE, is(ADDRESS_1)), hasProperty(VALUE, is(ADDRESS_2)), hasProperty(VALUE, is(ADDRESS_3)))); assertEquals(POSTAL_CODE, result.getPostalCode()); assertEquals(CITY, result.getCity()); assertEquals(COUNTRY_CODE, result.getCountryCode()); assertEquals(TELEPHONE_NUMBER, result.getTelephoneNumber()); }