Redesign integration with adapter-bank-spring-boot-starter (#4)

This commit is contained in:
Baikov Dmitrii 2019-06-11 17:28:54 +03:00 committed by GitHub
parent 72128b3bc9
commit c115f73db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 39 deletions

View File

@ -8,7 +8,7 @@
<groupId>com.rbkmoney</groupId>
<artifactId>adapter-common-lib</artifactId>
<version>0.0.3-SNAPSHOT</version>
<version>0.0.4-SNAPSHOT</version>
<description></description>

View File

@ -17,7 +17,7 @@ import java.util.function.BiFunction;
@Slf4j
@RequiredArgsConstructor
public abstract class AdapterController {
public class AdapterController {
private final HellgateAdapterClient hgClient;

View File

@ -3,7 +3,7 @@ package com.rbkmoney.adapter.common.handler.callback;
import com.rbkmoney.adapter.common.enums.Step;
import com.rbkmoney.adapter.common.model.AdapterContext;
import com.rbkmoney.adapter.common.model.Callback;
import com.rbkmoney.adapter.common.properties.TimerProperties;
import com.rbkmoney.adapter.common.properties.CommonTimerProperties;
import com.rbkmoney.adapter.common.serializer.AdapterSerializer;
import com.rbkmoney.adapter.common.serializer.CallbackSerializer;
import com.rbkmoney.damsel.proxy_provider.PaymentCallbackProxyResult;
@ -26,7 +26,7 @@ public class PaymentCallbackHandler implements CallbackHandler<PaymentCallbackRe
private final CallbackSerializer callbackSerializer;
private final TimerProperties timerProperties;
private final CommonTimerProperties timerProperties;
@Override
public PaymentCallbackResult handleCallback(ByteBuffer callback, PaymentContext context) {

View File

@ -3,7 +3,7 @@ package com.rbkmoney.adapter.common.handler.callback;
import com.rbkmoney.adapter.common.enums.Step;
import com.rbkmoney.adapter.common.model.AdapterContext;
import com.rbkmoney.adapter.common.model.Callback;
import com.rbkmoney.adapter.common.properties.TimerProperties;
import com.rbkmoney.adapter.common.properties.CommonTimerProperties;
import com.rbkmoney.adapter.common.serializer.AdapterSerializer;
import com.rbkmoney.adapter.common.serializer.CallbackSerializer;
import com.rbkmoney.damsel.proxy_provider.RecurrentTokenCallbackResult;
@ -28,7 +28,7 @@ public class RecurrentTokenCallbackHandler implements CallbackHandler<RecurrentT
private final CallbackSerializer callbackSerializer;
private final TimerProperties timerProperties;
private final CommonTimerProperties timerProperties;
@Override
public RecurrentTokenCallbackResult handleCallback(ByteBuffer callback, RecurrentTokenContext context) {

View File

@ -2,26 +2,24 @@ package com.rbkmoney.adapter.common.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
@Getter
@Setter
public abstract class AdapterProperties {
@Validated
public class CommonAdapterProperties {
@NotEmpty
private String url;
@NotEmpty
private String callbackUrl;
@NotEmpty
private String pathCallbackUrl;
@NotEmpty
private String pathRecurrentCallbackUrl;
@NotEmpty
private String tagPrefix;
}

View File

@ -2,12 +2,14 @@ package com.rbkmoney.adapter.common.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
@Getter
@Setter
public abstract class TimerProperties {
@Validated
public class CommonTimerProperties {
@NotNull
private int redirectTimeout;

View File

@ -12,7 +12,7 @@ import java.math.BigDecimal;
import java.util.Random;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class PaymentDataConverterUtils {
public final class PaymentDataConverter {
private static final String DEFAULT_ID = "1";
@ -47,30 +47,4 @@ public final class PaymentDataConverterUtils {
}
}
public static TargetStatus getTargetStatus(PaymentContext paymentContext) {
if (paymentContext == null) {
throw new IllegalArgumentException("PaymentContext cannot be empty");
} else if (paymentContext.getSession() == null) {
throw new IllegalArgumentException("Payment context session cannot be empty");
} else {
return getTargetStatus(paymentContext.getSession().getTarget());
}
}
public static TargetStatus getTargetStatus(TargetInvoicePaymentStatus targetInvoicePaymentStatus) {
if (targetInvoicePaymentStatus != null) {
if (targetInvoicePaymentStatus.isSetProcessed()) {
return TargetStatus.PROCESSED;
} else if (targetInvoicePaymentStatus.isSetCancelled()) {
return TargetStatus.CANCELLED;
} else if (targetInvoicePaymentStatus.isSetCaptured()) {
return TargetStatus.CAPTURED;
} else if (targetInvoicePaymentStatus.isSetRefunded()) {
return TargetStatus.REFUNDED;
}
}
throw new UnknownTargetStatusException();
}
}

View File

@ -0,0 +1,36 @@
package com.rbkmoney.adapter.common.utils.converter;
import com.rbkmoney.adapter.common.enums.TargetStatus;
import com.rbkmoney.adapter.common.exception.UnknownTargetStatusException;
import com.rbkmoney.damsel.domain.TargetInvoicePaymentStatus;
import com.rbkmoney.damsel.proxy_provider.PaymentContext;
public final class TargetStatusResolver {
public static TargetStatus getTargetStatus(PaymentContext paymentContext) {
if (paymentContext == null) {
throw new IllegalArgumentException("PaymentContext cannot be empty");
} else if (paymentContext.getSession() == null) {
throw new IllegalArgumentException("Payment context session cannot be empty");
} else {
return getTargetStatus(paymentContext.getSession().getTarget());
}
}
public static TargetStatus getTargetStatus(TargetInvoicePaymentStatus targetInvoicePaymentStatus) {
if (targetInvoicePaymentStatus != null) {
if (targetInvoicePaymentStatus.isSetProcessed()) {
return TargetStatus.PROCESSED;
} else if (targetInvoicePaymentStatus.isSetCancelled()) {
return TargetStatus.CANCELLED;
} else if (targetInvoicePaymentStatus.isSetCaptured()) {
return TargetStatus.CAPTURED;
} else if (targetInvoicePaymentStatus.isSetRefunded()) {
return TargetStatus.REFUNDED;
}
}
throw new UnknownTargetStatusException();
}
}