INT-375: Redecorate CallbackUrlExtractor (add interface and implementation) (#54)

This commit is contained in:
Baikov Dmitrii 2022-11-22 00:10:45 -08:00 committed by GitHub
parent ed09f7e71f
commit 97d85e7ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 16 deletions

View File

@ -12,7 +12,7 @@
</parent>
<artifactId>adapter-flow-lib</artifactId>
<version>0.1.19</version>
<version>0.1.20</version>
<packaging>jar</packaging>
<name>adapter-flow-lib</name>

View File

@ -11,7 +11,7 @@ import dev.vality.adapter.flow.lib.service.CardDataService;
import dev.vality.adapter.flow.lib.service.IdGenerator;
import dev.vality.adapter.flow.lib.service.TemporaryContextService;
import dev.vality.adapter.flow.lib.utils.AdapterProperties;
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.service.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.utils.CardDataUtils;
import dev.vality.adapter.flow.lib.utils.TargetStatusResolver;
import dev.vality.cds.storage.Auth3DS;

View File

@ -0,0 +1,13 @@
package dev.vality.adapter.flow.lib.service;
import java.util.Map;
public interface CallbackUrlExtractor {
String TERMINATION_URI = "termination_uri";
String extractCallbackUrl(String redirectUrl);
String getSuccessRedirectUrl(Map<String, String> adapterConfigurations, String redirectUrl);
}

View File

@ -8,7 +8,6 @@ import dev.vality.adapter.flow.lib.model.ExitStateModel;
import dev.vality.adapter.flow.lib.model.PollingInfo;
import dev.vality.adapter.flow.lib.model.ThreeDsData;
import dev.vality.adapter.flow.lib.serde.ParametersSerializer;
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.utils.ThreeDsDataInitializer;
import dev.vality.adapter.flow.lib.utils.TimeoutUtils;
import dev.vality.adapter.flow.lib.utils.TimerProperties;

View File

@ -6,7 +6,6 @@ import dev.vality.adapter.flow.lib.model.EntryStateModel;
import dev.vality.adapter.flow.lib.model.ExitStateModel;
import dev.vality.adapter.flow.lib.model.PollingInfo;
import dev.vality.adapter.flow.lib.model.ThreeDsData;
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.utils.ThreeDsDataInitializer;
import dev.vality.adapter.flow.lib.utils.TimeoutUtils;
import dev.vality.adapter.flow.lib.utils.TimerProperties;

View File

@ -4,7 +4,6 @@ import dev.vality.adapter.common.exception.HellgateException;
import dev.vality.adapter.common.hellgate.HellgateClient;
import dev.vality.adapter.flow.lib.serde.ParametersDeserializer;
import dev.vality.adapter.flow.lib.serde.ParametersSerializer;
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

View File

@ -1,6 +1,8 @@
package dev.vality.adapter.flow.lib.utils;
package dev.vality.adapter.flow.lib.service.impl;
import dev.vality.adapter.flow.lib.constant.RedirectFields;
import dev.vality.adapter.flow.lib.service.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.utils.AdapterProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder;
@ -8,18 +10,18 @@ import org.springframework.web.util.UriComponentsBuilder;
import java.util.Map;
@RequiredArgsConstructor
public class CallbackUrlExtractor {
public static final String TERMINATION_URI = "termination_uri";
public class CallbackUrlExtractorImpl implements CallbackUrlExtractor {
private final AdapterProperties adapterProperties;
@Override
public String extractCallbackUrl(String redirectUrl) {
return UriComponentsBuilder.fromUriString(adapterProperties.getCallbackUrl())
.path(adapterProperties.getPathCallbackUrl())
.queryParam(TERMINATION_URI, redirectUrl).build().toUriString();
}
@Override
public String getSuccessRedirectUrl(Map<String, String> adapterConfigurations, String redirectUrl) {
if (StringUtils.hasText(redirectUrl)) {
return redirectUrl;

View File

@ -11,7 +11,7 @@ import dev.vality.adapter.flow.lib.flow.full.FullThreeDsAllVersionsStepResolverI
import dev.vality.adapter.flow.lib.flow.full.GenerateTokenFullThreeDsAllVersionsStepResolverImpl;
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
import dev.vality.adapter.flow.lib.service.TagManagementService;
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.service.impl.CallbackUrlExtractorImpl;
import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator;
import dev.vality.bender.BenderSrv;
import dev.vality.damsel.proxy_provider.*;
@ -25,11 +25,10 @@ import static dev.vality.adapter.common.damsel.DomainPackageCreators.createTarge
import static dev.vality.adapter.flow.lib.flow.full.three.ds.ForwardRecurrentPaymentNon3dsTest.RECURRENT_TOKEN;
import static org.junit.jupiter.api.Assertions.*;
@PropertySource("classpath:application.yaml")
@ContextConfiguration(classes = {HandlerConfig.class, AppConfig.class, ProcessorConfig.class, SerdeConfig.class,
ThreeDsCallbackController.class, TomcatEmbeddedConfiguration.class, TagManagementService.class,
CallbackUrlExtractor.class, FullThreeDsAllVersionsStepResolverImpl.class,
CallbackUrlExtractorImpl.class, FullThreeDsAllVersionsStepResolverImpl.class,
GenerateTokenFullThreeDsAllVersionsStepResolverImpl.class})
public class AbstractGenerateTokenTest {

View File

@ -11,7 +11,7 @@ import dev.vality.adapter.flow.lib.flow.full.FullThreeDsAllVersionsStepResolverI
import dev.vality.adapter.flow.lib.flow.full.GenerateTokenFullThreeDsAllVersionsStepResolverImpl;
import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
import dev.vality.adapter.flow.lib.service.TagManagementService;
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.service.impl.CallbackUrlExtractorImpl;
import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator;
import dev.vality.bender.BenderSrv;
import dev.vality.damsel.domain.InvoicePaymentCaptured;
@ -27,11 +27,10 @@ import org.springframework.test.context.ContextConfiguration;
import static dev.vality.adapter.common.damsel.DomainPackageCreators.createTargetProcessed;
import static org.junit.jupiter.api.Assertions.*;
@PropertySource("classpath:application.yaml")
@ContextConfiguration(classes = {HandlerConfig.class, AppConfig.class, ProcessorConfig.class, SerdeConfig.class,
ThreeDsCallbackController.class, TomcatEmbeddedConfiguration.class, TagManagementService.class,
CallbackUrlExtractor.class, FullThreeDsAllVersionsStepResolverImpl.class,
CallbackUrlExtractorImpl.class, FullThreeDsAllVersionsStepResolverImpl.class,
GenerateTokenFullThreeDsAllVersionsStepResolverImpl.class})
public class AbstractPaymentTest {

View File

@ -23,7 +23,7 @@ import dev.vality.adapter.flow.lib.serde.TemporaryContextDeserializer;
import dev.vality.adapter.flow.lib.serde.TemporaryContextSerializer;
import dev.vality.adapter.flow.lib.service.*;
import dev.vality.adapter.flow.lib.utils.AdapterProperties;
import dev.vality.adapter.flow.lib.utils.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.service.CallbackUrlExtractor;
import dev.vality.adapter.flow.lib.utils.TimerProperties;
import dev.vality.adapter.flow.lib.validator.AdapterConfigurationValidator;
import dev.vality.bender.BenderSrv;