/*
   * (non-Javadoc)
   *
   * @see in.com.v2kart.ccavenuepaymentintegration.services.CreateCCAvenuePaymentRequestStrategy#createPaymentRequest (java.lang.String,
   * java.lang.String, java.lang.String, de.hybris.platform.core.model.user.CustomerModel, java.lang.String, java.lang.String,
   * de.hybris.platform.commercefacades.user.data.AddressData, java.lang.String, java.lang.String, java.lang.String)
   */
  @Override
  public CCAvenuePaymentRequest createPaymentRequest(
      final String requestUrl,
      final String successUrl,
      final String cancelUrl,
      final CustomerModel customer,
      final String merchantKey,
      final String enforcedPaymentMethod,
      final AddressData addressData,
      final String currency,
      final String language,
      final String phoneNumber) {
    final CartModel cartModel = getCartService().getSessionCart();
    if (cartModel == null) {
      return null;
    }

    final CCAvenuePaymentRequest request = new CCAvenuePaymentRequest();
    request.setRequestUrl(requestUrl);
    request.setCancelUrl(cancelUrl);
    request.setRedirectUrl(successUrl);
    request.setAmount(String.valueOf(cartModel.getTotalPrice()));
    request.setCurrency(currency);
    request.setLanguage(language);
    request.setMerchantId(merchantKey);
    request.setOrderId(cartModel.getCode() + "_" + System.currentTimeMillis());
    request.setPaymentOption(paymentOptionMappings.get(enforcedPaymentMethod));

    if (addressData != null) {
      request.setCustomerBillToData(getCustomerBillToData(addressData));
    } else {
      final AddressModel address = cartModel.getDeliveryAddress();
      request.setCustomerBillToData(getCustomerBillToDataConverter().convert(address));
    }
    request
        .getCustomerBillToData()
        .setBillToEmail(getCustomerEmailResolutionService().getEmailForCustomer(customer));
    request.getCustomerBillToData().setBillToPhoneNumber(phoneNumber);
    final CountryModel countryModel =
        getCommonI18NService().getCountry(PaymentProperties.INDIA_COUNTRY_ISO);
    request.getCustomerBillToData().setBillToCountry(countryModel.getName());
    return request;
  }
  @Test
  public void shouldCalculateTaxes() {
    final AddressModel address = mock(AddressModel.class);

    final DeliveryModeModel deliveryMode = mock(DeliveryModeModel.class);

    final CartModel cart = mock(CartModel.class);
    final BaseStoreModel baseStore = mock(BaseStoreModel.class);
    given(baseStore.getExternalTaxEnabled()).willReturn(Boolean.TRUE);
    given(cart.getStore()).willReturn(baseStore);
    given(cart.getNet()).willReturn(Boolean.TRUE);
    given(cart.getDeliveryAddress()).willReturn(address);
    given(cart.getDeliveryMode()).willReturn(deliveryMode);
    given(defaultOndemandDeliveryAddressStrategy.getDeliveryAddressForOrder(cart))
        .willReturn(address);

    final boolean calculateTaxes =
        defaultOmsDetermineExternalTaxStrategy.shouldCalculateExternalTaxes(cart);
    Assert.assertEquals(calculateTaxes, true);
  }