@Test public void isAvailableReturnsTrueIfNoRangesConfigured() { when(apmConfigurationMock.getCurrencyRanges()).thenReturn(Collections.emptySet()); final boolean result = testObj.isAvailable(apmConfigurationMock, cartModelMock); assertTrue(result); }
@Override public boolean isAvailable(final WorldpayAPMConfigurationModel apmConfiguration, final CartModel cartModel) { if (CollectionUtils.isEmpty(apmConfiguration.getCurrencyRanges())) { return true; } final String cartCurrencyIso = cartModel.getCurrency().getIsocode(); for (final WorldpayCurrencyRangeModel currencyRangeModel : apmConfiguration.getCurrencyRanges()) { if (cartCurrencyIso.equals(currencyRangeModel.getCurrency().getIsocode())) { return isCartTotalWithinRange(cartModel.getTotalPrice(), currencyRangeModel.getMin(), currencyRangeModel.getMax()); } } return true; }
APMAvailabilityRangeStrategy implements APMAvailabilityStrategy { @Override public boolean isAvailable(final WorldpayAPMConfigurationModel apmConfiguration, final CartModel cartModel) { if (CollectionUtils.isEmpty(apmConfiguration.getCurrencyRanges())) { return true; } final String cartCurrencyIso = cartModel.getCurrency().getIsocode(); for (final WorldpayCurrencyRangeModel currencyRangeModel : apmConfiguration.getCurrencyRanges()) { if (cartCurrencyIso.equals(currencyRangeModel.getCurrency().getIsocode())) { return isCartTotalWithinRange(cartModel.getTotalPrice(), currencyRangeModel.getMin(), currencyRangeModel.getMax()); } } return true; } }
APMAvailabilityRangeStrategy implements APMAvailabilityStrategy { @Override public boolean isAvailable(final WorldpayAPMConfigurationModel apmConfiguration, final CartModel cartModel) { if (CollectionUtils.isEmpty(apmConfiguration.getCurrencyRanges())) { return true; } final String cartCurrencyIso = cartModel.getCurrency().getIsocode(); for (final WorldpayCurrencyRangeModel currencyRangeModel : apmConfiguration.getCurrencyRanges()) { if (cartCurrencyIso.equals(currencyRangeModel.getCurrency().getIsocode())) { return isCartTotalWithinRange(cartModel.getTotalPrice(), currencyRangeModel.getMin(), currencyRangeModel.getMax()); } } return true; }  }
APMAvailabilityRangeStrategy implements APMAvailabilityStrategy { @Override public boolean isAvailable(final WorldpayAPMConfigurationModel apmConfiguration, final CartModel cartModel) { if (CollectionUtils.isEmpty(apmConfiguration.getCurrencyRanges())) { return true; } final String cartCurrencyIso = cartModel.getCurrency().getIsocode(); for (final WorldpayCurrencyRangeModel currencyRangeModel : apmConfiguration.getCurrencyRanges()) { if (cartCurrencyIso.equals(currencyRangeModel.getCurrency().getIsocode())) { return isCartTotalWithinRange(cartModel.getTotalPrice(), currencyRangeModel.getMin(), currencyRangeModel.getMax()); } } return true; }  @Override boolean isAvailable(final WorldpayAPMConfigurationModel apmConfiguration, final CartModel cartModel); }
APMAvailabilityRangeStrategy implements APMAvailabilityStrategy { @Override public boolean isAvailable(final WorldpayAPMConfigurationModel apmConfiguration, final CartModel cartModel) { if (CollectionUtils.isEmpty(apmConfiguration.getCurrencyRanges())) { return true; } final String cartCurrencyIso = cartModel.getCurrency().getIsocode(); for (final WorldpayCurrencyRangeModel currencyRangeModel : apmConfiguration.getCurrencyRanges()) { if (cartCurrencyIso.equals(currencyRangeModel.getCurrency().getIsocode())) { return isCartTotalWithinRange(cartModel.getTotalPrice(), currencyRangeModel.getMin(), currencyRangeModel.getMax()); } } return true; }  @Override boolean isAvailable(final WorldpayAPMConfigurationModel apmConfiguration, final CartModel cartModel);  }