AbstractWorldpayPaymentMethodCheckoutStepController extends AbstractCheckoutStepController { protected CSEAdditionalAuthInfo createCSEAdditionalAuthInfo(final CSEPaymentForm csePaymentForm) { final WorldpayMerchantConfigData currentSiteMerchantConfigData = worldpayMerchantConfigDataFacade.getCurrentSiteMerchantConfigData(); final CSEAdditionalAuthInfo cseAdditionalAuthInfo = new CSEAdditionalAuthInfo(); populateAdditionalAuthInfo(csePaymentForm.isSaveInAccount(), null, cseAdditionalAuthInfo); cseAdditionalAuthInfo.setEncryptedData(csePaymentForm.getCseToken()); cseAdditionalAuthInfo.setCardHolderName(csePaymentForm.getNameOnCard()); cseAdditionalAuthInfo.setExpiryYear(csePaymentForm.getExpiryYear()); cseAdditionalAuthInfo.setExpiryMonth(csePaymentForm.getExpiryMonth()); final Additional3DS2Info additional3DS2Info = new Additional3DS2Info(); additional3DS2Info.setDfReferenceId(csePaymentForm.getReferenceId()); additional3DS2Info.setChallengeWindowSize(csePaymentForm.getWindowSizePreference()); additional3DS2Info.setChallengePreference(currentSiteMerchantConfigData.getThreeDSFlexChallengePreference()); cseAdditionalAuthInfo.setAdditional3DS2(additional3DS2Info); return cseAdditionalAuthInfo; }  @ModelAttribute("billingCountries") Collection<CountryData> getBillingCountries(); @ModelAttribute("cardTypes") Collection<CardTypeData> getCardTypes(); @ModelAttribute("months") List<SelectOption> getMonths(); @ModelAttribute("expiryYears") List<SelectOption> getExpiryYears(); WorldpayPaymentCheckoutFacade getWorldpayPaymentCheckoutFacade(); WorldpayHostedOrderFacade getWorldpayHostedOrderFacade(); WorldpayAdditionalInfoFacade getWorldpayAdditionalInfoFacade(); WorldpayMerchantConfigDataFacade getWorldpayMerchantConfigDataFacade();  }
@Test public void shouldPopulateCCFieldsToCseAdditionalAuthInfo() { when(worldpayMerchantConfigDataFacadeMock.getCurrentSiteMerchantConfigData()).thenReturn(worldpayMerchantConfigDataMock); when(worldpayMerchantConfigDataMock.getThreeDSFlexChallengePreference()).thenReturn(CHALLENGE_PREFERENCE); when(csePaymentFormMock.getNameOnCard()).thenReturn(CARD_HOLDER_NAME); when(csePaymentFormMock.getExpiryMonth()).thenReturn(EXPIRY_MONTH); when(csePaymentFormMock.getExpiryYear()).thenReturn(EXPIRY_YEAR); when(csePaymentFormMock.getReferenceId()).thenReturn(REFERENCE_ID); when(csePaymentFormMock.getWindowSizePreference()).thenReturn(WINDOW_SIZE); final CSEAdditionalAuthInfo result = testObj.createCSEAdditionalAuthInfo(csePaymentFormMock); assertEquals(CARD_HOLDER_NAME, result.getCardHolderName()); assertEquals(EXPIRY_MONTH, result.getExpiryMonth()); assertEquals(EXPIRY_YEAR, result.getExpiryYear()); assertEquals(REFERENCE_ID, result.getAdditional3DS2().getDfReferenceId()); assertEquals(WINDOW_SIZE, result.getAdditional3DS2().getChallengeWindowSize()); assertEquals(CHALLENGE_PREFERENCE, result.getAdditional3DS2().getChallengePreference()); }