From 6bab705944217661c11aeac24386935905def018 Mon Sep 17 00:00:00 2001 From: Michael Sievers Date: Tue, 17 Sep 2019 08:09:08 +0200 Subject: [PATCH] [BAEL-3077] Update comments in unit tests to align with article snippets --- .../mapper/DeliveryAddressMapperUnitTest.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java b/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java index e2c12fcba3..7d1e432546 100644 --- a/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java +++ b/mapstruct/src/test/java/com/baeldung/mapper/DeliveryAddressMapperUnitTest.java @@ -17,48 +17,51 @@ public class DeliveryAddressMapperUnitTest { @Test public void testGivenCustomerAndAddress_mapsToDeliveryAddress() { - // given + // given a customer Customer customer = new Customer().setFirstName("Max") .setLastName("Powers"); + // and some address Address homeAddress = new Address().setStreet("123 Some Street") .setCounty("Nevada") .setPostalcode("89123"); - // when + // when calling DeliveryAddressMapper::from DeliveryAddress deliveryAddress = deliveryAddressMapper.from(customer, homeAddress); - // then + // then a new DeliveryAddress is created, based on the given customer and his home address assertEquals(deliveryAddress.getForename(), customer.getFirstName()); assertEquals(deliveryAddress.getSurname(), customer.getLastName()); assertEquals(deliveryAddress.getStreet(), homeAddress.getStreet()); assertEquals(deliveryAddress.getCounty(), homeAddress.getCounty()); assertEquals(deliveryAddress.getPostalcode(), homeAddress.getPostalcode()); + } @Test public void testGivenDeliveryAddressAndSomeOtherAddress_updatesDeliveryAddress() { - // given - Customer customer = new Customer().setFirstName("Max") - .setLastName("Powers"); - - DeliveryAddress deliveryAddress = new DeliveryAddress().setStreet("123 Some Street") + // given a delivery address + DeliveryAddress deliveryAddress = new DeliveryAddress().setForename("Max") + .setSurname("Powers") + .setStreet("123 Some Street") .setCounty("Nevada") .setPostalcode("89123"); - Address otherAddress = new Address().setStreet("456 Some other street") + // and some new address + Address newAddress = new Address().setStreet("456 Some other street") .setCounty("Arizona") .setPostalcode("12345"); - // when - DeliveryAddress updatedDeliveryAddress = deliveryAddressMapper.updateAddress(deliveryAddress, otherAddress); + // when calling DeliveryAddressMapper::updateAddress + DeliveryAddress updatedDeliveryAddress = deliveryAddressMapper.updateAddress(deliveryAddress, newAddress); - // then + // then the *existing* delivery address is updated assertSame(deliveryAddress, updatedDeliveryAddress); - assertEquals(deliveryAddress.getStreet(), otherAddress.getStreet()); - assertEquals(deliveryAddress.getCounty(), otherAddress.getCounty()); - assertEquals(deliveryAddress.getPostalcode(), otherAddress.getPostalcode()); + assertEquals(deliveryAddress.getStreet(), newAddress.getStreet()); + assertEquals(deliveryAddress.getCounty(), newAddress.getCounty()); + assertEquals(deliveryAddress.getPostalcode(), newAddress.getPostalcode()); + } }