DefaultWorldpayMerchantInfoService implements WorldpayMerchantInfoService { protected MerchantInfo createMerchantInfo(final WorldpayMerchantConfigData worldpayMerchantConfigData) { final MerchantInfo merchantInfo = new MerchantInfo(worldpayMerchantConfigData.getCode(), worldpayMerchantConfigData.getPassword()); if (worldpayMerchantConfigData.getMacValidation()) { merchantInfo.setUsingMacValidation(true); merchantInfo.setMacSecret(worldpayMerchantConfigData.getMacSecret()); } return merchantInfo; }  @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 shouldCreateMerchantInfoUsingMacValidation() { when(merchantConfigDataMock.getCode()).thenReturn(MERCHANT_CODE); when(merchantConfigDataMock.getPassword()).thenReturn(MERCHANT_PASSWORD); when(merchantConfigDataMock.getMacSecret()).thenReturn(MAC_SECRET); when(merchantConfigDataMock.getMacValidation()).thenReturn(true); final MerchantInfo result = testObj.createMerchantInfo(merchantConfigDataMock); assertEquals(MAC_SECRET, result.getMacSecret()); assertEquals(MERCHANT_CODE, result.getMerchantCode()); assertEquals(MERCHANT_PASSWORD, result.getMerchantPassword()); assertEquals(true, result.isUsingMacValidation()); }
@Test public void shouldCreateMerchantInfoNotUsingMacValidation() { when(merchantConfigDataMock.getCode()).thenReturn(MERCHANT_CODE); when(merchantConfigDataMock.getPassword()).thenReturn(MERCHANT_PASSWORD); when(merchantConfigDataMock.getMacSecret()).thenReturn(MAC_SECRET); when(merchantConfigDataMock.getMacValidation()).thenReturn(false); final MerchantInfo result = testObj.createMerchantInfo(merchantConfigDataMock); assertEquals(MERCHANT_CODE, result.getMerchantCode()); assertEquals(MERCHANT_PASSWORD, result.getMerchantPassword()); assertNull(result.getMacSecret()); assertEquals(false, result.isUsingMacValidation()); }