DefaultWorldpayOrderService implements WorldpayOrderService { @Override public Additional3DSData createAdditional3DSData(final WorldpayAdditionalInfoData worldpayAdditionalInfoData) { return Optional.ofNullable(worldpayAdditionalInfoData.getAdditional3DS2()).map(additional3DS2Info -> { Additional3DSData additional3DSData = new Additional3DSData(); additional3DSData.setDfReferenceId(additional3DS2Info.getDfReferenceId()); final ChallengeWindowSizeEnum challengeWindowSizeEnum = ChallengeWindowSizeEnum.getEnum(additional3DS2Info.getChallengeWindowSize()); additional3DSData.setChallengeWindowSize(challengeWindowSizeEnum); if (additional3DS2Info.getChallengePreference() != null) { final ChallengePreferenceEnum challengePreferenceEnum = ChallengePreferenceEnum.getEnum(additional3DS2Info.getChallengePreference()); additional3DSData.setChallengePreference(challengePreferenceEnum); } return additional3DSData; }).orElse(null); } DefaultWorldpayOrderService(final CommonI18NService commonI18NService, final WorldpayUrlService worldpayUrlService, final SiteConfigService siteConfigService); @Override Amount createAmount(final Currency currency, final int amount); @Override Amount createAmount(final CurrencyModel currencyModel, final double amount); @Override Amount createAmount(final Currency currency, final double amount); @Override BigDecimal convertAmount(final Amount amount); @Override Session createSession(final WorldpayAdditionalInfoData worldpayAdditionalInfo); @Override Browser createBrowser(final WorldpayAdditionalInfoData worldpayAdditionalInfo); @Override BasicOrderInfo createBasicOrderInfo(final String worldpayOrderCode, final String description, final Amount amount); @Override Shopper createShopper(final String customerEmail, final Session session, final Browser browser); @Override Shopper createAuthenticatedShopper(final String customerEmail, final String authenticatedShopperID, final Session session, final Browser browser); @Override TokenRequest createTokenRequest(final String tokenEventReference, final String tokenReason); @Override TokenRequest createTokenRequestForDeletion(final String tokenEventReference, final String tokenReason, final String authenticatedShopperId); @Override CreateTokenServiceRequest createTokenServiceRequest(final MerchantInfo merchantInfo, final String authenticatedShopperId,
                                                               final Payment csePayment, final TokenRequest tokenRequest); @Override Payment createBankPayment(final String paymentMethod, final String shopperBankCode); @Override Payment createKlarnaPayment(final String countryCode, final String languageCode, final String extraMerchantData); @Override Token createToken(final String subscriptionId, final String securityCode); @Override UpdateTokenServiceRequest createUpdateTokenServiceRequest(final MerchantInfo merchantInfo, final WorldpayAdditionalInfoData worldpayAdditionalInfoData,
                                                                     final TokenRequest tokenRequest, final String paymentTokenID,
                                                                     final CardDetails cardDetails); @Override Payment createApplePayPayment(final ApplePayAdditionalAuthInfo worldpayAdditionalInfoApplePayData); @Override Additional3DSData createAdditional3DSData(final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override Cse createCsePayment(final CSEAdditionalAuthInfo cseAdditionalAuthInfo, final Address billingAddress); @Override PayWithGoogleSSL createGooglePayPayment(final String protocolVersion, final String signature, final String signedMessage); @Override StoredCredentials createStoredCredentials(final Usage usage, final MerchantInitiatedReason merchantInitiatedReason, final String transactionIdentifier);  }
@Test public void shouldCreateAdditional3DSData() { when(worldpayAdditionalInfoDataMock.getAdditional3DS2()).thenReturn(additional3DS2InfoMock); when(additional3DS2InfoMock.getDfReferenceId()).thenReturn(REFERENCE_ID); when(additional3DS2InfoMock.getChallengeWindowSize()).thenReturn(WINDOW_SIZE); when(additional3DS2InfoMock.getChallengePreference()).thenReturn(NO_PREFERENCE); final Additional3DSData result = testObj.createAdditional3DSData(worldpayAdditionalInfoDataMock); assertThat(result.getDfReferenceId()).isEqualTo(REFERENCE_ID); assertThat(result.getChallengeWindowSize()).isEqualTo(ChallengeWindowSizeEnum.getEnum(WINDOW_SIZE)); assertThat(result.getChallengePreference()).isEqualTo(ChallengePreferenceEnum.getEnum(NO_PREFERENCE)); }
@Test public void shouldCreateAdditional3DSDataEvenIfWithChallengePreferenceAsEmptyBeingNoPreferenceAsDefault() { when(worldpayAdditionalInfoDataMock.getAdditional3DS2()).thenReturn(additional3DS2InfoMock); when(additional3DS2InfoMock.getDfReferenceId()).thenReturn(REFERENCE_ID); when(additional3DS2InfoMock.getChallengeWindowSize()).thenReturn(null); when(additional3DS2InfoMock.getChallengePreference()).thenReturn(null); final Additional3DSData result = testObj.createAdditional3DSData(worldpayAdditionalInfoDataMock); assertThat(result.getDfReferenceId()).isEqualTo(REFERENCE_ID); assertThat(result.getChallengeWindowSize()).isEqualTo(ChallengeWindowSizeEnum.getEnum(WINDOW_SIZE)); assertThat(result.getChallengePreference()).isNull(); }