DefaultAPMConfigurationLookupService implements APMConfigurationLookupService { @Override public Set<String> getAllApmPaymentTypeCodes() { final Set<String> apmPaymentTypesCodes = new HashSet<>(); for (final WorldpayAPMConfigurationModel worldpayAPMConfiguration : worldpayAPMConfigurationDao.find()) { final PaymentType paymentType = PaymentType.getPaymentType(worldpayAPMConfiguration.getCode()); if (paymentType != null) { apmPaymentTypesCodes.add(paymentType.getMethodCode()); } } return apmPaymentTypesCodes; }  @Override WorldpayAPMConfigurationModel getAPMConfigurationForCode(final String paymentTypeCode); @Override Set<String> getAllApmPaymentTypeCodes(); @Required void setWorldpayAPMConfigurationDao(final WorldpayAPMConfigurationDao worldpayAPMConfigurationDao);  }
@Test public void getAllApmPaymentTypeCodesReturnsSetOfPaymentTypeCodes() { when(worldpayAPMConfigurationDaoMock.find()).thenReturn(Collections.singletonList(worldpayAPMConfigurationModelMock)); final String alipayMethodCode = ALIPAY.getMethodCode(); when(worldpayAPMConfigurationModelMock.getCode()).thenReturn(alipayMethodCode); final Set<String> result = testObj.getAllApmPaymentTypeCodes(); assertNotNull(result); assertTrue(result.contains(alipayMethodCode)); }
@Test public void getAllApmPaymentTypeCodesReturns() { when(worldpayAPMConfigurationDaoMock.find()).thenReturn(Collections.singletonList(worldpayAPMConfigurationModelMock)); when(worldpayAPMConfigurationModelMock.getCode()).thenReturn(NON_EXISTING_METHOD_CODE); final Set<String> result = testObj.getAllApmPaymentTypeCodes(); assertNotNull(result); assertTrue(result.isEmpty()); }