@Override
  public void populate(final AddressModel source, final CustomerBillToData target)
      throws ConversionException {
    // We may not have any existing billing address.
    if (source == null) {
      return;
    }
    validateParameterNotNull(target, "Parameter [CustomerBillToData] target cannot be null");

    target.setBillToCustomerIdRef(source.getEmail()); // UID is the email address
    target.setBillToEmail(source.getEmail());

    target.setBillToCity(source.getTown());
    target.setBillToCompany(source.getCompany());
    target.setBillToCountry(source.getCountry().getIsocode());
    target.setBillToEmail(source.getEmail());
    target.setBillToFirstName(source.getFirstname());
    target.setBillToLastName(source.getLastname());
    target.setBillToPhoneNumber(source.getPhone1());
    target.setBillToPostalCode(source.getPostalcode());
    target.setBillToState(source.getDistrict());
    target.setBillToStreet1(source.getLine1());
    target.setBillToStreet2(source.getLine2());
  }
  protected OrderModel placeTestOrder(final boolean valid)
      throws InvalidCartException, CalculationException {
    final CartModel cart = cartService.getSessionCart();
    final UserModel user = userService.getCurrentUser();
    cartService.addNewEntry(cart, productService.getProductForCode("testProduct1"), 1, null);
    cartService.addNewEntry(cart, productService.getProductForCode("testProduct2"), 2, null);
    cartService.addNewEntry(cart, productService.getProductForCode("testProduct3"), 3, null);

    final AddressModel deliveryAddress = new AddressModel();
    deliveryAddress.setOwner(user);
    deliveryAddress.setFirstname("Der");
    deliveryAddress.setLastname("Buck");
    deliveryAddress.setTown("Muenchen");
    deliveryAddress.setCountry(commonI18NService.getCountry("DE"));
    modelService.save(deliveryAddress);

    final DebitPaymentInfoModel paymentInfo = new DebitPaymentInfoModel();
    paymentInfo.setOwner(cart);
    paymentInfo.setBank("MeineBank");
    paymentInfo.setUser(user);
    paymentInfo.setAccountNumber("34434");
    paymentInfo.setBankIDNumber("1111112");
    paymentInfo.setBaOwner("Ich");
    paymentInfo.setCode("testPaymentInfo1");
    modelService.save(paymentInfo);

    cart.setDeliveryMode(deliveryService.getDeliveryModeForCode("free"));
    cart.setDeliveryAddress(deliveryAddress);
    cart.setPaymentInfo(paymentInfo);

    final CardInfo card = new CardInfo();
    card.setCardType(CreditCardType.VISA);
    card.setCardNumber("4111111111111111");
    card.setExpirationMonth(Integer.valueOf(12));
    if (valid) {
      card.setExpirationYear(Integer.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 2));
    } else {
      card.setExpirationYear(Integer.valueOf(Calendar.getInstance().get(Calendar.YEAR) - 2));
    }

    final PaymentTransactionModel paymentTransaction =
        paymentService
            .authorize(
                "code4" + codeNo++,
                BigDecimal.ONE,
                Currency.getInstance("EUR"),
                deliveryAddress,
                deliveryAddress,
                card)
            .getPaymentTransaction();

    cart.setPaymentTransactions(Collections.singletonList(paymentTransaction));
    modelService.save(cart);
    calculationService.calculate(cart);

    final CommerceCheckoutParameter parameter = new CommerceCheckoutParameter();
    parameter.setEnableHooks(true);
    parameter.setCart(cart);
    parameter.setSalesApplication(SalesApplication.WEB);

    return commerceCheckoutService.placeOrder(parameter).getOrder();
  }