DefaultWorldpayBankConfigurationFacade implements WorldpayBankConfigurationFacade { @Override public boolean isBankTransferApm(final String paymentMethod) { return Optional.ofNullable(apmConfigurationLookupService.getAPMConfigurationForCode(paymentMethod)) .map(WorldpayAPMConfigurationModel::getBank) .orElse(false); } DefaultWorldpayBankConfigurationFacade(final APMConfigurationLookupService apmConfigurationLookupService,
                                                  final WorldpayBankConfigurationLookupService worldpayBankConfigurationLookupService,
                                                  final Converter<WorldpayBankConfigurationModel, BankConfigurationData> bankConfigurationModelBankConfigurationDataConverter); @Override List<BankConfigurationData> getBankConfigurationForAPMCode(final String apmCode); @Override boolean isBankTransferApm(final String paymentMethod);  }
@Test public void isBankTransferApmShouldReturnTrueIfPaymentMethodIsApmThatSupportsBankTransfer() { when(apmConfigurationLookupServiceMock.getAPMConfigurationForCode(BANK_TRANSFER_APM)).thenReturn(apmConfigurationModelMock); when(apmConfigurationModelMock.getBank()).thenReturn(true); final boolean result = testObj.isBankTransferApm(BANK_TRANSFER_APM); assertTrue(result); }
@Test public void isBankTransferApmShouldReturnFalseIfPaymentMethodIsNotApmThatSupportsBankTransfer() { when(apmConfigurationLookupServiceMock.getAPMConfigurationForCode(APM_CODE)).thenReturn(apmConfigurationModelMock); when(apmConfigurationModelMock.getBank()).thenReturn(false); final boolean result = testObj.isBankTransferApm(APM_CODE); assertFalse(result); }
@Test public void isBankTransferApmShouldReturnFalseIfPaymentMethodIsNotApm() { when(apmConfigurationLookupServiceMock.getAPMConfigurationForCode(PAYMENT_METHOD)).thenReturn(null); final boolean result = testObj.isBankTransferApm(PAYMENT_METHOD); assertFalse(result); }