DefaultWorldpayMerchantInfoService implements WorldpayMerchantInfoService { @Override public MerchantInfo getMerchantInfoByCode(final String merchantCode) throws WorldpayConfigurationException { final WorldpayMerchantConfigData worldpayMerchantConfigData = configuredMerchants.stream() .filter(config -> config.getCode().equals(merchantCode)) .findAny() .orElseThrow(() -> new WorldpayConfigurationException(MessageFormat.format("No merchant configuration found for merchant code {0}", merchantCode))); return createMerchantInfo(worldpayMerchantConfigData); }  @Override MerchantInfo getCurrentSiteMerchant(); @Override MerchantInfo getReplenishmentMerchant(); @Override MerchantInfo getMerchantInfoByCode(final String merchantCode); @Override MerchantInfo getMerchantInfoFromTransaction(final PaymentTransactionModel paymentTransactionModel); @Required void setWorldpayMerchantStrategy(final WorldpayMerchantStrategy worldpayMerchantStrategy); void setConfiguredMerchants(final List<WorldpayMerchantConfigData> configuredMerchants); List<WorldpayMerchantConfigData> getConfiguredMerchants();  }
@Test public void getMerchantConfigShouldReturnAlreadyKnownMerchantCode() throws WorldpayConfigurationException { final MerchantInfo result = testObj.getMerchantInfoByCode(KNOWN_MERCHANT_CODE); assertEquals(KNOWN_MERCHANT_CODE, result.getMerchantCode()); }
@Test(expected = WorldpayConfigurationException.class) public void getKnownMerchantShouldReturnExceptionWhenMerchantIsNotFound() throws WorldpayConfigurationException { testObj.getMerchantInfoByCode("mumbo jumbo"); }