mirror of
https://github.com/valitydev/adapter-common-lib.git
synced 2024-11-06 02:05:18 +00:00
fix error mapping, bump libs (#73)
* fix error mapping, bump libs * remove deprecated
This commit is contained in:
parent
dc7cdd30a6
commit
60eab70aa1
32
pom.xml
32
pom.xml
@ -12,7 +12,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>adapter-common-lib</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>adapter-common-lib</name>
|
||||
@ -107,19 +107,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
<version>1.18.32</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -187,31 +175,37 @@
|
||||
<dependency>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>damsel</artifactId>
|
||||
<version>1.563-d384c12</version>
|
||||
<version>1.641-6051aa9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>cds-proto</artifactId>
|
||||
<version>1.66-01353ce</version>
|
||||
<version>1.71-b3db02c</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.vality.woody</groupId>
|
||||
<artifactId>woody-thrift</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<version>2.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>bender-proto</artifactId>
|
||||
<version>1.20-be9cdeb</version>
|
||||
<version>1.27-753b935</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.vality</groupId>
|
||||
<artifactId>msgpack-proto</artifactId>
|
||||
<version>1.17-7481bb4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.vality.geck</groupId>
|
||||
<artifactId>serializer</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<version>1.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -43,30 +43,6 @@ public class DomainPackageCreators {
|
||||
return new Cash(amount, currency);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static BankCard createBankCardWithExpDate(String bin,
|
||||
String token,
|
||||
LegacyBankCardPaymentSystem bankCardPaymentSystem,
|
||||
String month,
|
||||
String year,
|
||||
String cardholderName) {
|
||||
return createBankCard(bin, token, bankCardPaymentSystem, createBankCardExpDate(month, year), cardholderName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static BankCard createBankCard(String bin,
|
||||
String token,
|
||||
LegacyBankCardPaymentSystem bankCardPaymentSystem,
|
||||
BankCardExpDate bankCardExpDate,
|
||||
String cardholderName) {
|
||||
return new BankCard()
|
||||
.setBin(bin)
|
||||
.setToken(token)
|
||||
.setPaymentSystemDeprecated(bankCardPaymentSystem)
|
||||
.setExpDate(bankCardExpDate)
|
||||
.setCardholderName(cardholderName);
|
||||
}
|
||||
|
||||
public static BankCard createBankCard(String month, String year, String cardholderName) {
|
||||
return new BankCard().setExpDate(createBankCardExpDate(month, year)).setCardholderName(cardholderName);
|
||||
}
|
||||
|
@ -381,13 +381,6 @@ public class ProxyProviderPackageCreators {
|
||||
return BrowserHTTPRequest.get_request(new BrowserGetRequest(url));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static BankCard createBankCardWithToken(BankCard bankCard,
|
||||
LegacyBankCardTokenProvider bankCardTokenProvider) {
|
||||
bankCard.setTokenProviderDeprecated(bankCardTokenProvider);
|
||||
return bankCard;
|
||||
}
|
||||
|
||||
public static TransactionInfo extractTransactionInfo(PaymentContext context) {
|
||||
return context.getPaymentInfo().getPayment().getTrx();
|
||||
}
|
||||
|
@ -115,30 +115,6 @@ public class ProxyProviderPackageExtractors {
|
||||
return context.getPaymentInfo().getPayment().getTrx();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static LegacyBankCardPaymentSystem extractBankCardPaymentSystem(PaymentResource paymentResource) {
|
||||
if (paymentResource.isSetDisposablePaymentResource()) {
|
||||
return extractBankCardPaymentSystem(paymentResource.getDisposablePaymentResource());
|
||||
}
|
||||
return extractBankCardPaymentSystem(paymentResource.getRecurrentPaymentResource());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static LegacyBankCardPaymentSystem extractBankCardPaymentSystem(PaymentContext context) {
|
||||
return extractBankCardPaymentSystem(extractPaymentResource(context));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static LegacyBankCardPaymentSystem extractBankCardPaymentSystem(RecurrentPaymentResource paymentResource) {
|
||||
return paymentResource.getPaymentTool().getBankCard().getPaymentSystemDeprecated();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static LegacyBankCardPaymentSystem extractBankCardPaymentSystem(DisposablePaymentResource paymentResource) {
|
||||
return paymentResource.getPaymentTool().getBankCard().getPaymentSystemDeprecated();
|
||||
}
|
||||
|
||||
|
||||
public static String extractTargetInvoicePaymentStatus(PaymentContext paymentContext) {
|
||||
return extractTargetInvoicePaymentStatus(paymentContext.getSession().getTarget());
|
||||
}
|
||||
@ -165,26 +141,4 @@ public class ProxyProviderPackageExtractors {
|
||||
}
|
||||
throw new RuntimeException("Unknown Payment Resource");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static LegacyBankCardTokenProvider extractBankCardTokenProvider(PaymentContext context) {
|
||||
PaymentResource paymentResource = context.getPaymentInfo().getPayment().getPaymentResource();
|
||||
if (paymentResource.isSetDisposablePaymentResource()) {
|
||||
PaymentTool paymentTool = paymentResource.getDisposablePaymentResource().getPaymentTool();
|
||||
if (paymentTool.isSetBankCard() && paymentTool.getBankCard().isSetTokenProviderDeprecated()) {
|
||||
return paymentTool.getBankCard().getTokenProviderDeprecated();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static LegacyBankCardTokenProvider extractBankCardTokenProvider(RecurrentTokenContext context) {
|
||||
PaymentTool paymentTool = context.getTokenInfo().getPaymentTool().getPaymentResource().getPaymentTool();
|
||||
if (paymentTool.isSetBankCard() && paymentTool.getBankCard().isSetTokenProviderDeprecated()) {
|
||||
return paymentTool.getBankCard().getTokenProviderDeprecated();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ import dev.vality.adapter.common.mapper.model.Error;
|
||||
import dev.vality.adapter.common.mapper.model.MappingExceptions;
|
||||
import dev.vality.damsel.domain.Failure;
|
||||
import dev.vality.geck.serializer.kit.tbase.TErrorUtil;
|
||||
import dev.vality.woody.api.flow.error.*;
|
||||
import dev.vality.woody.api.flow.error.WUnavailableResultException;
|
||||
import dev.vality.woody.api.flow.error.WUndefinedResultException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -78,7 +79,8 @@ public class ErrorMapping {
|
||||
|
||||
private Error findError(String code, String description, String state) {
|
||||
return findErrorInConfig(code, description, state)
|
||||
.orElseThrow(() -> getUnexpectedError(code, description, state));
|
||||
.orElseThrow(() -> new ErrorMappingException(
|
||||
String.format("Error not found. Code %s, description %s, state %s", code, description, state)));
|
||||
}
|
||||
|
||||
private Optional<Error> findErrorInConfig(String code, String description, String state) {
|
||||
@ -128,17 +130,9 @@ public class ErrorMapping {
|
||||
throw new WUnavailableResultException(
|
||||
String.format("Unavailable result %s, code = %s, description = %s", error, code, description));
|
||||
} else if (MappingExceptions.RESULT_UNEXPECTED.getMappingException().equals(error.getMapping())) {
|
||||
throw getUnexpectedError(code, description, null);
|
||||
throw new RuntimeException(
|
||||
String.format("Unexpected error %s, code = %s, description = %s", error, code, description)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private WRuntimeException getUnexpectedError(String code, String description, String state) {
|
||||
String errorMessage = String.format("Unexpected result, code = %s, description = %s, state = %s",
|
||||
code, description, state);
|
||||
|
||||
var errorDefinition = new WErrorDefinition(WErrorSource.INTERNAL);
|
||||
errorDefinition.setErrorType(WErrorType.UNEXPECTED_ERROR);
|
||||
errorDefinition.setErrorReason(errorMessage);
|
||||
return new WRuntimeException(errorMessage, errorDefinition);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.vality.adapter.common.mapper;
|
||||
|
||||
import dev.vality.adapter.common.mapper.model.Error;
|
||||
import dev.vality.woody.api.flow.error.WRuntimeException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
@ -21,8 +20,8 @@ public class ErrorMappingTest {
|
||||
error1.setCodeRegex("00002");
|
||||
error1.setDescriptionRegex("Invalid Merchant Name");
|
||||
var errorMapping = new ErrorMapping("'%s' - '%s'", List.of(error, error1));
|
||||
assertThrows(WRuntimeException.class, () -> errorMapping.mapFailure("unknown"));
|
||||
assertThrows(WRuntimeException.class, () -> errorMapping.mapFailure("00001"));
|
||||
assertThrows(RuntimeException.class, () -> errorMapping.mapFailure("unknown"));
|
||||
assertThrows(RuntimeException.class, () -> errorMapping.mapFailure("00001"));
|
||||
|
||||
var error2 = new Error();
|
||||
error2.setMapping("authorization_failed:insufficient_funds");
|
||||
@ -40,7 +39,7 @@ public class ErrorMappingTest {
|
||||
error.setDescriptionRegex("desc");
|
||||
error.setMapping("authorization_failed:unknown");
|
||||
var errorMapping = new ErrorMapping("'%s' - '%s'", List.of(error));
|
||||
assertThrows(WRuntimeException.class, () -> errorMapping.mapFailure("01"));
|
||||
assertThrows(RuntimeException.class, () -> errorMapping.mapFailure("01"));
|
||||
|
||||
error.setDescriptionRegex(null);
|
||||
assertNotNull(errorMapping.mapFailure("01"));
|
||||
|
Loading…
Reference in New Issue
Block a user