TD-325: bump protos (#43)

This commit is contained in:
Anatoly Karlov 2022-06-30 15:49:16 +07:00 committed by GitHub
parent 39c863382b
commit 35fa9e4707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 119 deletions

18
pom.xml
View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.vality</groupId>
<artifactId>service-parent-pom</artifactId>
<version>1.0.16</version>
<version>1.0.17</version>
</parent>
<artifactId>anapi-v2</artifactId>
@ -43,7 +43,7 @@
<dependency>
<groupId>dev.vality</groupId>
<artifactId>swag-anapi-v2</artifactId>
<version>1.71-048ff68-server</version>
<version>1.76-ec7a406-server</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
@ -63,7 +63,7 @@
<dependency>
<groupId>dev.vality</groupId>
<artifactId>magista-proto</artifactId>
<version>1.37-ba389d1</version>
<version>1.44-5352f74</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
@ -80,26 +80,22 @@
<artifactId>reporter-proto</artifactId>
<version>1.16-cc187f5</version>
</dependency>
<dependency>
<groupId>dev.vality.geck</groupId>
<artifactId>serializer</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>damsel</artifactId>
<version>1.558-3efe7df</version>
<version>1.566-03bbf48</version>
</dependency>
<dependency>
<groupId>dev.vality.woody</groupId>
<artifactId>woody-thrift</artifactId>
<version>${woody.version}</version>
</dependency>
<dependency>
<groupId>dev.vality.woody</groupId>
<artifactId>woody-api</artifactId>
<version>${woody.version}</version>
</dependency>
<!--spring-->
@ -263,6 +259,12 @@
<version>0.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>2.33.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>

View File

@ -3,9 +3,9 @@ package dev.vality.anapi.v2.converter.magista.request;
import dev.vality.anapi.v2.exception.BadRequestException;
import dev.vality.anapi.v2.model.PaymentStatus;
import dev.vality.anapi.v2.util.ConverterUtil;
import dev.vality.damsel.domain.LegacyBankCardPaymentSystem;
import dev.vality.damsel.domain.LegacyBankCardTokenProvider;
import dev.vality.damsel.domain.LegacyTerminalPaymentProvider;
import dev.vality.damsel.domain.BankCardTokenServiceRef;
import dev.vality.damsel.domain.PaymentServiceRef;
import dev.vality.damsel.domain.PaymentSystemRef;
import dev.vality.magista.*;
import org.springframework.stereotype.Component;
@ -57,9 +57,9 @@ public class ParamsToPaymentSearchQueryConverter {
.setPaymentTool(paymentMethod != null ? mapPaymentTool(paymentMethod) : null)
.setPaymentFlow(paymentFlow != null ? mapInvoicePaymentFlow(paymentFlow) : null)
.setPaymentTerminalProvider(
paymentTerminalProvider != null ? mapTerminalProvider(paymentTerminalProvider) : null)
paymentTerminalProvider != null ? new PaymentServiceRef(paymentTerminalProvider) : null)
.setPaymentTokenProvider(
bankCardTokenProvider != null ? mapTokenProvider(bankCardTokenProvider) : null)
bankCardTokenProvider != null ? new BankCardTokenServiceRef(bankCardTokenProvider) : null)
.setPaymentEmail(payerEmail)
.setPaymentApprovalCode(approvalCode)
.setPaymentCustomerId(customerID)
@ -70,8 +70,7 @@ public class ParamsToPaymentSearchQueryConverter {
.setPaymentIp(payerIP)
.setPaymentRrn(rrn)
.setPaymentStatus(paymentStatus != null ? mapStatus(paymentStatus) : null)
.setPaymentSystem(bankCardPaymentSystem != null
? mapPaymentSystem(bankCardPaymentSystem) : null);
.setPaymentSystem(bankCardPaymentSystem != null ? new PaymentSystemRef(bankCardPaymentSystem) : null);
if (paymentAmountFrom != null) {
paymentParams.setPaymentAmountFrom(paymentAmountFrom);
}
@ -82,31 +81,6 @@ public class ParamsToPaymentSearchQueryConverter {
return query;
}
protected LegacyTerminalPaymentProvider mapTerminalProvider(String provider) {
try {
return LegacyTerminalPaymentProvider.valueOf(provider);
} catch (IllegalArgumentException e) {
throw new BadRequestException(String.format("Terminal provider %s cannot be processed", provider));
}
}
protected LegacyBankCardTokenProvider mapTokenProvider(String provider) {
try {
return LegacyBankCardTokenProvider.valueOf(provider);
} catch (IllegalArgumentException e) {
throw new BadRequestException(String.format("Token provider %s cannot be processed", provider));
}
}
protected LegacyBankCardPaymentSystem mapPaymentSystem(String system) {
try {
return LegacyBankCardPaymentSystem.valueOf(system);
} catch (IllegalArgumentException e) {
throw new BadRequestException(
String.format("Payment system %s cannot be processed", system));
}
}
protected PaymentToolType mapPaymentTool(String paymentMethod) {
return switch (paymentMethod) {
case "bankCard" -> bank_card;

View File

@ -2,18 +2,17 @@ package dev.vality.anapi.v2.converter.magista.response;
import dev.vality.anapi.v2.model.ClientInfo;
import dev.vality.anapi.v2.model.ContactInfo;
import dev.vality.anapi.v2.model.CryptoCurrency;
import dev.vality.anapi.v2.model.CustomerPayer;
import dev.vality.anapi.v2.model.Payer;
import dev.vality.anapi.v2.model.PaymentResourcePayer;
import dev.vality.anapi.v2.model.RecurrentPayer;
import dev.vality.anapi.v2.model.TransactionInfo;
import dev.vality.anapi.v2.model.*;
import dev.vality.anapi.v2.util.MaskUtil;
import dev.vality.damsel.domain.*;
import dev.vality.geck.common.util.TypeUtil;
import dev.vality.magista.InvoicePaymentFlow;
import dev.vality.magista.StatPayment;
import dev.vality.anapi.v2.model.*;
import org.springframework.stereotype.Component;
import java.time.ZoneOffset;
@ -126,42 +125,53 @@ public class StatPaymentToPaymentSearchResultConverter {
}
protected PaymentToolDetails mapPaymentToolDetails(PaymentTool paymentTool) {
var field = dev.vality.damsel.domain.PaymentTool._Fields.findByName(paymentTool.getSetField().getFieldName());
switch (field) {
switch (paymentTool.getSetField()) {
case BANK_CARD -> {
var card = paymentTool.getBankCard();
return new PaymentToolDetailsBankCard()
.bin(card.getBin())
.paymentSystem(card.isSetPaymentSystemDeprecated()
? BankCardPaymentSystem.fromValue(card.getPaymentSystemDeprecated().name())
: null)
.paymentSystem(getPaymentSystem(card))
.cardNumberMask(MaskUtil.constructCardNumber(card))
.lastDigits(card.getLastDigits())
.tokenProvider(card.isSetTokenProviderDeprecated()
? BankCardTokenProvider.fromValue(card.getTokenProviderDeprecated().name())
: null);
.tokenProvider(getTokenProvider(card));
}
case PAYMENT_TERMINAL -> {
var terminal = paymentTool.getPaymentTerminal();
return new PaymentToolDetailsPaymentTerminal()
.provider(terminal.isSetTerminalTypeDeprecated()
? PaymentTerminalProvider.fromValue(terminal.getTerminalTypeDeprecated().name())
: null);
.provider(getProvider(terminal));
}
case MOBILE_COMMERCE -> {
var mobile = paymentTool.getMobileCommerce();
return new PaymentToolDetailsMobileCommerce()
.phoneNumber(MaskUtil.constructPhoneNumber(mobile.getPhone()));
}
case CRYPTO_CURRENCY_DEPRECATED -> {
var cryptoCurrency = paymentTool.getCryptoCurrencyDeprecated();
case CRYPTO_CURRENCY -> {
var cryptoCurrency = paymentTool.getCryptoCurrency();
return new PaymentToolDetailsCryptoWallet()
.cryptoCurrency(CryptoCurrency.fromValue(cryptoCurrency.name()));
.cryptoCurrency(cryptoCurrency.getId());
}
default -> throw new IllegalArgumentException();
}
}
private String getProvider(PaymentTerminal terminal) {
return terminal.isSetPaymentService()
? terminal.getPaymentService().getId()
: null;
}
private String getTokenProvider(BankCard card) {
return card.isSetPaymentToken()
? card.getPaymentToken().getId()
: null;
}
private String getPaymentSystem(BankCard card) {
return card.isSetPaymentSystem()
? card.getPaymentSystem().getId()
: null;
}
protected PaymentSearchResult.StatusEnum mapStatus(InvoicePaymentStatus status) {
try {
var field = InvoicePaymentStatus._Fields.findByName(status.getSetField().getFieldName());
@ -173,7 +183,6 @@ public class StatPaymentToPaymentSearchResultConverter {
case REFUNDED -> REFUNDED;
case FAILED -> FAILED;
case CHARGED_BACK -> CHARGEDBACK;
default -> throw new IllegalArgumentException();
};
} catch (Exception e) {
throw new IllegalArgumentException(

View File

@ -34,7 +34,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
class SearchPaymentsTest extends AbstractKeycloakOpenIdAsWiremockConfig {
@MockBean

View File

@ -2,9 +2,6 @@ package dev.vality.anapi.v2.converter.magista.request;
import dev.vality.anapi.v2.exception.BadRequestException;
import dev.vality.anapi.v2.model.PaymentStatus;
import dev.vality.damsel.domain.LegacyBankCardPaymentSystem;
import dev.vality.damsel.domain.LegacyBankCardTokenProvider;
import dev.vality.damsel.domain.LegacyTerminalPaymentProvider;
import dev.vality.magista.InvoicePaymentFlowType;
import dev.vality.magista.PaymentSearchQuery;
import dev.vality.magista.PaymentToolType;
@ -73,28 +70,4 @@ class ParamsToPaymentSearchQueryConverterTest {
assertThrows(BadRequestException.class, () -> converter.mapStatus("unexpected"));
}
@Test
void mapTerminalProvider() {
for (LegacyTerminalPaymentProvider provider : LegacyTerminalPaymentProvider.values()) {
assertEquals(provider, converter.mapTerminalProvider(provider.name()));
}
assertThrows(BadRequestException.class, () -> converter.mapTerminalProvider("unexpected"));
}
@Test
void mapTokenProvider() {
for (LegacyBankCardTokenProvider provider : LegacyBankCardTokenProvider.values()) {
assertEquals(provider, converter.mapTokenProvider(provider.name()));
}
assertThrows(BadRequestException.class, () -> converter.mapTokenProvider("unexpected"));
}
@Test
void mapPaymentSystem() {
for (LegacyBankCardPaymentSystem system : LegacyBankCardPaymentSystem.values()) {
assertEquals(system, converter.mapPaymentSystem(system.name()));
}
assertThrows(BadRequestException.class, () -> converter.mapPaymentSystem("unexpected"));
}
}

View File

@ -1,9 +1,9 @@
package dev.vality.anapi.v2.converter.magista.response;
import dev.vality.anapi.v2.model.*;
import dev.vality.anapi.v2.util.MaskUtil;
import dev.vality.anapi.v2.testutil.MagistaUtil;
import dev.vality.anapi.v2.testutil.RandomUtil;
import dev.vality.anapi.v2.util.MaskUtil;
import dev.vality.damsel.domain.ClientInfo;
import dev.vality.damsel.domain.ContactInfo;
import dev.vality.damsel.domain.InvoicePaymentStatus;
@ -68,9 +68,8 @@ class StatPaymentToPaymentSearchResultConverterTest {
.setLastDigits("5678")
.setBankName("Bank")
.setToken("1111")
.setPaymentSystemDeprecated(LegacyBankCardPaymentSystem.maestro)
.setTokenProviderDeprecated(LegacyBankCardTokenProvider.applepay)
);
.setPaymentSystem(new PaymentSystemRef("maestro"))
.setPaymentToken(new BankCardTokenServiceRef("applepay")));
customerPayer.setPaymentTool(tool)
.setCustomerId("1");
var openapiCustomerPayer =
@ -81,8 +80,8 @@ class StatPaymentToPaymentSearchResultConverterTest {
() -> assertEquals("1111", openapiCustomerPayer.getPaymentToolToken()),
() -> assertEquals("1234", paymentToolDetails.getBin()),
() -> assertEquals("5678", paymentToolDetails.getLastDigits()),
() -> assertEquals("maestro", paymentToolDetails.getPaymentSystem().getValue()),
() -> assertEquals("applepay", paymentToolDetails.getTokenProvider().getValue())
() -> assertEquals("maestro", paymentToolDetails.getPaymentSystem()),
() -> assertEquals("applepay", paymentToolDetails.getTokenProvider())
);
@ -112,8 +111,8 @@ class StatPaymentToPaymentSearchResultConverterTest {
() -> assertEquals("88005553535", paymentResourcePayer.getContactInfo().getPhoneNumber()),
() -> assertEquals("1234", resourcePayerPaymentToolDetails.getBin()),
() -> assertEquals("5678", resourcePayerPaymentToolDetails.getLastDigits()),
() -> assertEquals("maestro", resourcePayerPaymentToolDetails.getPaymentSystem().getValue()),
() -> assertEquals("applepay", resourcePayerPaymentToolDetails.getTokenProvider().getValue())
() -> assertEquals("maestro", resourcePayerPaymentToolDetails.getPaymentSystem()),
() -> assertEquals("applepay", resourcePayerPaymentToolDetails.getTokenProvider())
);
payer = new Payer();
@ -136,8 +135,8 @@ class StatPaymentToPaymentSearchResultConverterTest {
() -> assertEquals("88005553535", openapiRecurrentPayer.getContactInfo().getPhoneNumber()),
() -> assertEquals("1234", recurrentPayerPaymentToolDetails.getBin()),
() -> assertEquals("5678", recurrentPayerPaymentToolDetails.getLastDigits()),
() -> assertEquals("maestro", recurrentPayerPaymentToolDetails.getPaymentSystem().getValue()),
() -> assertEquals("applepay", recurrentPayerPaymentToolDetails.getTokenProvider().getValue())
() -> assertEquals("maestro", recurrentPayerPaymentToolDetails.getPaymentSystem()),
() -> assertEquals("applepay", recurrentPayerPaymentToolDetails.getTokenProvider())
);
}
@ -194,7 +193,7 @@ class StatPaymentToPaymentSearchResultConverterTest {
() -> assertNull(converter.getPaymentToolToken(PaymentTool.payment_terminal(new PaymentTerminal()))),
() -> assertNull(converter.getPaymentToolToken(PaymentTool.crypto_currency(new CryptoCurrencyRef()))),
() -> assertNull(converter.getPaymentToolToken(
PaymentTool.crypto_currency_deprecated(LegacyCryptoCurrency.bitcoin)))
PaymentTool.crypto_currency(new CryptoCurrencyRef("bitcoin"))))
);
}
@ -206,10 +205,10 @@ class StatPaymentToPaymentSearchResultConverterTest {
assertAll(
() -> assertEquals(expectedCardDetails.getLastDigits(), actualCardDetails.getLastDigits()),
() -> assertEquals(expectedCardDetails.getBin(), actualCardDetails.getBin()),
() -> assertEquals(expectedCardDetails.getTokenProviderDeprecated().name(),
actualCardDetails.getTokenProvider().getValue()),
() -> assertEquals(expectedCardDetails.getPaymentSystemDeprecated().name(),
actualCardDetails.getPaymentSystem().getValue()),
() -> assertEquals(expectedCardDetails.getPaymentToken().getId(),
actualCardDetails.getTokenProvider()),
() -> assertEquals(expectedCardDetails.getPaymentSystem().getId(),
actualCardDetails.getPaymentSystem()),
() -> assertTrue(actualCardDetails.getCardNumberMask().startsWith(expectedCardDetails.getBin())),
() -> assertTrue(actualCardDetails.getCardNumberMask().endsWith(expectedCardDetails.getLastDigits()))
);
@ -217,8 +216,8 @@ class StatPaymentToPaymentSearchResultConverterTest {
tool = MagistaUtil.createPaymentTerminalPaymentTool();
var expectedTerminalDetails = tool.getPaymentTerminal();
var actualTerminalDetails = (PaymentToolDetailsPaymentTerminal) converter.mapPaymentToolDetails(tool);
assertEquals(expectedTerminalDetails.getTerminalTypeDeprecated().name(),
actualTerminalDetails.getProvider().getValue());
assertEquals(expectedTerminalDetails.getPaymentService().getId(),
actualTerminalDetails.getProvider());
tool = MagistaUtil.createMobileCommercePaymentTool();
var expectedMobileDetails = tool.getMobileCommerce();
@ -227,14 +226,9 @@ class StatPaymentToPaymentSearchResultConverterTest {
actualMobileDetails.getPhoneNumber());
tool = MagistaUtil.createLegacyCryptoCurrencyPaymentTool();
var expectedLegacyCryptoDetails = tool.getCryptoCurrencyDeprecated();
var expectedLegacyCryptoDetails = tool.getCryptoCurrency().getId();
var actualLegacyCryptoDetails = (PaymentToolDetailsCryptoWallet) converter.mapPaymentToolDetails(tool);
assertEquals(expectedLegacyCryptoDetails.name(),
actualLegacyCryptoDetails.getCryptoCurrency().getValue());
assertThrows(IllegalArgumentException.class,
() -> converter.mapPaymentToolDetails(MagistaUtil.createCryptoCurrencyPaymentTool()));
assertEquals(expectedLegacyCryptoDetails,
actualLegacyCryptoDetails.getCryptoCurrency());
}
}

View File

@ -192,19 +192,17 @@ public class MagistaUtil {
.setLastDigits(RandomUtil.randomString(4))
.setBankName(RandomUtil.randomString(4))
.setToken(RandomUtil.randomString(4))
.setPaymentSystemDeprecated(LegacyBankCardPaymentSystem.maestro)
.setTokenProviderDeprecated(LegacyBankCardTokenProvider.applepay)
);
.setPaymentSystem(new PaymentSystemRef("maestro"))
.setPaymentToken(new BankCardTokenServiceRef("applepay")));
}
public static PaymentTool createPaymentTerminalPaymentTool() {
return PaymentTool.payment_terminal(new PaymentTerminal()
.setTerminalTypeDeprecated(LegacyTerminalPaymentProvider.alipay));
.setPaymentService(new PaymentServiceRef("alipay")));
}
public static PaymentTool createMobileCommercePaymentTool() {
return PaymentTool.mobile_commerce(new MobileCommerce()
.setOperatorDeprecated(LegacyMobileOperator.mts)
return PaymentTool.mobile_commerce(new MobileCommerce().setOperator(new MobileOperatorRef("mts"))
.setPhone(new MobilePhone()
.setCc("7")
.setCtn("1234567890")));
@ -216,7 +214,7 @@ public class MagistaUtil {
}
public static PaymentTool createLegacyCryptoCurrencyPaymentTool() {
return PaymentTool.crypto_currency_deprecated(LegacyCryptoCurrency.bitcoin);
return PaymentTool.crypto_currency(new CryptoCurrencyRef("bitcoin"));
}
}

View File

@ -5,7 +5,6 @@ import dev.vality.anapi.v2.model.ChargebackStage;
import dev.vality.anapi.v2.model.ChargebackStatus;
import dev.vality.anapi.v2.model.PaymentStatus;
import dev.vality.damsel.domain.PaymentInstitutionRealm;
import dev.vality.damsel.merch_stat.TerminalPaymentProvider;
import lombok.experimental.UtilityClass;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@ -35,7 +34,7 @@ public class OpenApiUtil {
params.add("paymentStatus", PaymentStatus.StatusEnum.PENDING.getValue());
params.add("paymentFlow", "instant");
params.add("paymentMethod", "paymentTerminal");
params.add("paymentTerminalProvider", TerminalPaymentProvider.alipay.name());
params.add("paymentTerminalProvider", "alipay");
params.add("invoiceID", randomIntegerAsString(1, 1000));
params.add("paymentID", randomIntegerAsString(1, 1000));
params.add("externalID", randomIntegerAsString(1, 1000));