AbstractWorldpayOrderService { public AddressModel cloneAndSetBillingAddressFromCart(final CartModel cartModel, final PaymentInfoModel paymentInfoModel) { final AddressModel paymentAddress = cartModel.getPaymentAddress(); validateParameterNotNull(paymentAddress, "Payment Address cannot be null."); final AddressModel clonedAddress = addressService.cloneAddressForOwner(paymentAddress, paymentInfoModel); clonedAddress.setBillingAddress(true); clonedAddress.setShippingAddress(false); clonedAddress.setOwner(paymentInfoModel); paymentInfoModel.setBillingAddress(clonedAddress); return clonedAddress; } protected  AbstractWorldpayOrderService(final CommerceCheckoutService commerceCheckoutService,
                                           final WorldpayPaymentInfoService worldpayPaymentInfoService,
                                           final WorldpayPaymentTransactionService worldpayPaymentTransactionService,
                                           final WorldpayOrderService worldpayOrderService,
                                           final WorldpayServiceGateway worldpayServiceGateway,
                                           final AddressService addressService); CommerceCheckoutParameter createCommerceCheckoutParameter(final AbstractOrderModel abstractOrderModel, final PaymentInfoModel paymentInfoModel, final BigDecimal authorisationAmount); AddressModel cloneAndSetBillingAddressFromCart(final CartModel cartModel, final PaymentInfoModel paymentInfoModel); CommerceCheckoutService getCommerceCheckoutService(); WorldpayPaymentInfoService getWorldpayPaymentInfoService(); WorldpayPaymentTransactionService getWorldpayPaymentTransactionService(); WorldpayOrderService getWorldpayOrderService(); WorldpayServiceGateway getWorldpayServiceGateway();  }
@Test public void cloneAndSetBillingAddressFromCart_ShouldCloneAndSetBillingAddressFromCart_WhenItIsCalled() { when(cartModelMock.getPaymentAddress()).thenReturn(paymentAddressModelMock); when(addressServiceMock.cloneAddressForOwner(paymentAddressModelMock, paymentInfoModelMock)).thenReturn(clonedAddressModelMock); final AddressModel result = testObj.cloneAndSetBillingAddressFromCart(cartModelMock, paymentInfoModelMock); assertEquals(result, clonedAddressModelMock); verify(clonedAddressModelMock).setBillingAddress(true); verify(clonedAddressModelMock).setShippingAddress(false); verify(paymentInfoModelMock).setBillingAddress(clonedAddressModelMock); }