mirror of
https://github.com/valitydev/hooker.git
synced 2024-11-06 08:15:17 +00:00
JD-239: add mamsel to handle migration from enums to strings in damsel (#144)
JD-239: add mamsel to handle migration from enums to strings in damsel, bump service-parent-pom to 1.1.1
This commit is contained in:
parent
ed4d71b23f
commit
ffb3087e73
8
pom.xml
8
pom.xml
@ -13,7 +13,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.rbkmoney</groupId>
|
<groupId>com.rbkmoney</groupId>
|
||||||
<artifactId>service-parent-pom</artifactId>
|
<artifactId>service-parent-pom</artifactId>
|
||||||
<version>1.0.9</version>
|
<version>1.1.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -83,6 +83,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rbkmoney</groupId>
|
<groupId>com.rbkmoney</groupId>
|
||||||
<artifactId>damsel</artifactId>
|
<artifactId>damsel</artifactId>
|
||||||
|
<version>1.489-8851c24</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.rbkmoney</groupId>
|
||||||
|
<artifactId>mamsel</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rbkmoney.logback</groupId>
|
<groupId>com.rbkmoney.logback</groupId>
|
||||||
|
@ -3,10 +3,15 @@ package com.rbkmoney.hooker.utils;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.rbkmoney.damsel.domain.BankCard;
|
import com.rbkmoney.damsel.domain.BankCard;
|
||||||
import com.rbkmoney.damsel.domain.DigitalWalletProvider;
|
import com.rbkmoney.damsel.domain.LegacyDigitalWalletProvider;
|
||||||
import com.rbkmoney.damsel.domain.MobilePhone;
|
import com.rbkmoney.damsel.domain.MobilePhone;
|
||||||
import com.rbkmoney.damsel.domain.PaymentTool;
|
import com.rbkmoney.damsel.domain.PaymentTool;
|
||||||
import com.rbkmoney.hooker.model.PaymentToolDetailsDigitalWallet;
|
import com.rbkmoney.hooker.model.PaymentToolDetailsDigitalWallet;
|
||||||
|
import com.rbkmoney.mamsel.CryptoCurrencyUtil;
|
||||||
|
import com.rbkmoney.mamsel.DigitalWalletUtil;
|
||||||
|
import com.rbkmoney.mamsel.PaymentSystemUtil;
|
||||||
|
import com.rbkmoney.mamsel.TerminalPaymentUtil;
|
||||||
|
import com.rbkmoney.mamsel.TokenProviderUtil;
|
||||||
import com.rbkmoney.swag_webhook_events.model.CryptoCurrency;
|
import com.rbkmoney.swag_webhook_events.model.CryptoCurrency;
|
||||||
import com.rbkmoney.swag_webhook_events.model.DigitalWalletDetailsQIWI;
|
import com.rbkmoney.swag_webhook_events.model.DigitalWalletDetailsQIWI;
|
||||||
import com.rbkmoney.swag_webhook_events.model.PaymentToolDetails;
|
import com.rbkmoney.swag_webhook_events.model.PaymentToolDetails;
|
||||||
@ -32,27 +37,29 @@ public class PaymentToolUtils {
|
|||||||
.lastDigits(paymentTool.getBankCard().getLastDigits())
|
.lastDigits(paymentTool.getBankCard().getLastDigits())
|
||||||
.cardNumberMask(
|
.cardNumberMask(
|
||||||
paymentTool.getBankCard().getBin() + "******" + paymentTool.getBankCard().getLastDigits())
|
paymentTool.getBankCard().getBin() + "******" + paymentTool.getBankCard().getLastDigits())
|
||||||
.tokenProvider(paymentTool.getBankCard().isSetTokenProvider()
|
.tokenProvider(TokenProviderUtil.isSetTokenProvider(paymentTool.getBankCard())
|
||||||
? PaymentToolDetailsBankCard.TokenProviderEnum
|
? PaymentToolDetailsBankCard.TokenProviderEnum
|
||||||
.fromValue(paymentTool.getBankCard().getTokenProvider().name()) : null)
|
.fromValue(TokenProviderUtil.getTokenProviderName(paymentTool.getBankCard())) : null)
|
||||||
.paymentSystem(paymentTool.getBankCard().getPaymentSystem().name())
|
.paymentSystem(PaymentSystemUtil.getPaymentSystemName(paymentTool.getBankCard()))
|
||||||
.issuerCountry(paymentTool.getBankCard().getIssuerCountry() != null
|
.issuerCountry(paymentTool.getBankCard().getIssuerCountry() != null
|
||||||
? paymentTool.getBankCard().getIssuerCountry().name() : null)
|
? paymentTool.getBankCard().getIssuerCountry().name() : null)
|
||||||
.bankName(paymentTool.getBankCard().getBankName());
|
.bankName(paymentTool.getBankCard().getBankName());
|
||||||
} else if (paymentTool.isSetPaymentTerminal()) {
|
} else if (paymentTool.isSetPaymentTerminal()) {
|
||||||
return new PaymentToolDetailsPaymentTerminal()
|
return new PaymentToolDetailsPaymentTerminal()
|
||||||
.provider(PaymentToolDetailsPaymentTerminal.ProviderEnum
|
.provider(PaymentToolDetailsPaymentTerminal.ProviderEnum.fromValue(
|
||||||
.fromValue(paymentTool.getPaymentTerminal().getTerminalType().name()));
|
TerminalPaymentUtil.getTerminalPaymentProviderName(paymentTool.getPaymentTerminal())));
|
||||||
} else if (paymentTool.isSetDigitalWallet()) {
|
} else if (paymentTool.isSetDigitalWallet()) {
|
||||||
if (paymentTool.getDigitalWallet().getProvider() == DigitalWalletProvider.qiwi) {
|
LegacyDigitalWalletProvider walletProvider = LegacyDigitalWalletProvider.valueOf(
|
||||||
|
DigitalWalletUtil.getDigitalWalletName(paymentTool.getDigitalWallet()));
|
||||||
|
if (walletProvider == LegacyDigitalWalletProvider.qiwi) {
|
||||||
return new PaymentToolDetailsDigitalWallet(new DigitalWalletDetailsQIWI()
|
return new PaymentToolDetailsDigitalWallet(new DigitalWalletDetailsQIWI()
|
||||||
.phoneNumberMask(paymentTool.getDigitalWallet().getId()));
|
.phoneNumberMask(paymentTool.getDigitalWallet().getId()));
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("Unknown digital wallet type");
|
throw new UnsupportedOperationException("Unknown digital wallet type");
|
||||||
}
|
}
|
||||||
} else if (paymentTool.isSetCryptoCurrency()) {
|
} else if (CryptoCurrencyUtil.isSetCryptoCurrency(paymentTool)) {
|
||||||
return new PaymentToolDetailsCryptoWallet()
|
return new PaymentToolDetailsCryptoWallet()
|
||||||
.cryptoCurrency(CryptoCurrency.fromValue(paymentTool.getCryptoCurrency().name()));
|
.cryptoCurrency(CryptoCurrency.fromValue(CryptoCurrencyUtil.getCryptoCurrencyName(paymentTool)));
|
||||||
} else if (paymentTool.isSetMobileCommerce()) {
|
} else if (paymentTool.isSetMobileCommerce()) {
|
||||||
return new PaymentToolDetailsMobileCommerce()
|
return new PaymentToolDetailsMobileCommerce()
|
||||||
.phoneNumber(paymentTool.getMobileCommerce().getPhone().getCc() +
|
.phoneNumber(paymentTool.getMobileCommerce().getPhone().getCc() +
|
||||||
@ -69,22 +76,25 @@ public class PaymentToolUtils {
|
|||||||
BankCard paymentCard = paymentTool.getBankCard();
|
BankCard paymentCard = paymentTool.getBankCard();
|
||||||
rootNode.put("type", "bank_card");
|
rootNode.put("type", "bank_card");
|
||||||
rootNode.put("token", paymentCard.getToken());
|
rootNode.put("token", paymentCard.getToken());
|
||||||
rootNode.put("payment_system", paymentCard.getPaymentSystem().toString());
|
rootNode.put("payment_system", PaymentSystemUtil.getPaymentSystemName(paymentCard));
|
||||||
rootNode.put("bin", paymentCard.getBin());
|
rootNode.put("bin", paymentCard.getBin());
|
||||||
rootNode.put("masked_pan", paymentCard.getLastDigits());
|
rootNode.put("masked_pan", paymentCard.getLastDigits());
|
||||||
if (paymentCard.isSetTokenProvider()) {
|
if (TokenProviderUtil.isSetTokenProvider(paymentCard)) {
|
||||||
rootNode.put("token_provider", paymentCard.getTokenProvider().name());
|
rootNode.put("token_provider", TokenProviderUtil.getTokenProviderName(paymentCard));
|
||||||
}
|
}
|
||||||
} else if (paymentTool.isSetPaymentTerminal()) {
|
} else if (paymentTool.isSetPaymentTerminal()) {
|
||||||
rootNode.put("type", "payment_terminal");
|
rootNode.put("type", "payment_terminal");
|
||||||
rootNode.put("terminal_type", paymentTool.getPaymentTerminal().getTerminalType().toString());
|
rootNode.put(
|
||||||
|
"terminal_type",
|
||||||
|
TerminalPaymentUtil.getTerminalPaymentProviderName(paymentTool.getPaymentTerminal())
|
||||||
|
);
|
||||||
} else if (paymentTool.isSetDigitalWallet()) {
|
} else if (paymentTool.isSetDigitalWallet()) {
|
||||||
rootNode.put("type", "digital_wallet");
|
rootNode.put("type", "digital_wallet");
|
||||||
rootNode.put("provider", paymentTool.getDigitalWallet().getProvider().name());
|
rootNode.put("provider", DigitalWalletUtil.getDigitalWalletName(paymentTool.getDigitalWallet()));
|
||||||
rootNode.put("id", paymentTool.getDigitalWallet().getId());
|
rootNode.put("id", paymentTool.getDigitalWallet().getId());
|
||||||
} else if (paymentTool.isSetCryptoCurrency()) {
|
} else if (CryptoCurrencyUtil.isSetCryptoCurrency(paymentTool)) {
|
||||||
rootNode.put("type", "crypto_currency");
|
rootNode.put("type", "crypto_currency");
|
||||||
rootNode.put("crypto_currency", paymentTool.getCryptoCurrency().name());
|
rootNode.put("crypto_currency",CryptoCurrencyUtil.getCryptoCurrencyName(paymentTool));
|
||||||
} else if (paymentTool.isSetMobileCommerce()) {
|
} else if (paymentTool.isSetMobileCommerce()) {
|
||||||
rootNode.put("type", "mobile_commerce");
|
rootNode.put("type", "mobile_commerce");
|
||||||
MobilePhone mobilePhone = paymentTool.getMobileCommerce().getPhone();
|
MobilePhone mobilePhone = paymentTool.getMobileCommerce().getPhone();
|
||||||
|
@ -2,7 +2,6 @@ package com.rbkmoney.hooker.service;
|
|||||||
|
|
||||||
import com.rbkmoney.damsel.base.Content;
|
import com.rbkmoney.damsel.base.Content;
|
||||||
import com.rbkmoney.damsel.domain.BankCard;
|
import com.rbkmoney.damsel.domain.BankCard;
|
||||||
import com.rbkmoney.damsel.domain.BankCardPaymentSystem;
|
|
||||||
import com.rbkmoney.damsel.domain.Cash;
|
import com.rbkmoney.damsel.domain.Cash;
|
||||||
import com.rbkmoney.damsel.domain.ClientInfo;
|
import com.rbkmoney.damsel.domain.ClientInfo;
|
||||||
import com.rbkmoney.damsel.domain.ContactInfo;
|
import com.rbkmoney.damsel.domain.ContactInfo;
|
||||||
@ -19,6 +18,7 @@ import com.rbkmoney.damsel.domain.InvoicePaymentProcessed;
|
|||||||
import com.rbkmoney.damsel.domain.InvoicePaymentStatus;
|
import com.rbkmoney.damsel.domain.InvoicePaymentStatus;
|
||||||
import com.rbkmoney.damsel.domain.InvoiceStatus;
|
import com.rbkmoney.damsel.domain.InvoiceStatus;
|
||||||
import com.rbkmoney.damsel.domain.InvoiceUnpaid;
|
import com.rbkmoney.damsel.domain.InvoiceUnpaid;
|
||||||
|
import com.rbkmoney.damsel.domain.LegacyBankCardPaymentSystem;
|
||||||
import com.rbkmoney.damsel.domain.Payer;
|
import com.rbkmoney.damsel.domain.Payer;
|
||||||
import com.rbkmoney.damsel.domain.PaymentResourcePayer;
|
import com.rbkmoney.damsel.domain.PaymentResourcePayer;
|
||||||
import com.rbkmoney.damsel.domain.PaymentTool;
|
import com.rbkmoney.damsel.domain.PaymentTool;
|
||||||
@ -187,7 +187,7 @@ public class BatchProcessingTest extends AbstractIntegrationTest {
|
|||||||
.setResource(new DisposablePaymentResource()
|
.setResource(new DisposablePaymentResource()
|
||||||
.setPaymentTool(PaymentTool.bank_card(new BankCard()
|
.setPaymentTool(PaymentTool.bank_card(new BankCard()
|
||||||
.setToken("token")
|
.setToken("token")
|
||||||
.setPaymentSystem(BankCardPaymentSystem.amex)
|
.setPaymentSystemDeprecated(LegacyBankCardPaymentSystem.amex)
|
||||||
.setBin("bin")
|
.setBin("bin")
|
||||||
.setLastDigits("masked")))
|
.setLastDigits("masked")))
|
||||||
.setClientInfo(new ClientInfo()))
|
.setClientInfo(new ClientInfo()))
|
||||||
|
@ -6,10 +6,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.rbkmoney.damsel.domain.BankCard;
|
import com.rbkmoney.damsel.domain.BankCard;
|
||||||
import com.rbkmoney.damsel.domain.CryptoCurrency;
|
import com.rbkmoney.damsel.domain.CryptoCurrency;
|
||||||
import com.rbkmoney.damsel.domain.DigitalWallet;
|
import com.rbkmoney.damsel.domain.DigitalWallet;
|
||||||
import com.rbkmoney.damsel.domain.DigitalWalletProvider;
|
import com.rbkmoney.damsel.domain.LegacyCryptoCurrency;
|
||||||
|
import com.rbkmoney.damsel.domain.LegacyDigitalWalletProvider;
|
||||||
|
import com.rbkmoney.damsel.domain.LegacyTerminalPaymentProvider;
|
||||||
import com.rbkmoney.damsel.domain.PaymentTerminal;
|
import com.rbkmoney.damsel.domain.PaymentTerminal;
|
||||||
import com.rbkmoney.damsel.domain.PaymentTool;
|
import com.rbkmoney.damsel.domain.PaymentTool;
|
||||||
import com.rbkmoney.damsel.domain.TerminalPaymentProvider;
|
|
||||||
import com.rbkmoney.geck.serializer.kit.mock.MockMode;
|
import com.rbkmoney.geck.serializer.kit.mock.MockMode;
|
||||||
import com.rbkmoney.geck.serializer.kit.mock.MockTBaseProcessor;
|
import com.rbkmoney.geck.serializer.kit.mock.MockTBaseProcessor;
|
||||||
import com.rbkmoney.geck.serializer.kit.tbase.TBaseHandler;
|
import com.rbkmoney.geck.serializer.kit.tbase.TBaseHandler;
|
||||||
@ -29,7 +30,7 @@ public class PaymentToolUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPaymentToolDetailsCryptoWallet() {
|
public void testGetPaymentToolDetailsCryptoWallet() {
|
||||||
PaymentTool paymentTool = PaymentTool.crypto_currency(CryptoCurrency.bitcoin);
|
PaymentTool paymentTool = PaymentTool.crypto_currency_deprecated(LegacyCryptoCurrency.bitcoin);
|
||||||
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||||
assertTrue(paymentToolDetails instanceof PaymentToolDetailsCryptoWallet);
|
assertTrue(paymentToolDetails instanceof PaymentToolDetailsCryptoWallet);
|
||||||
assertNull(paymentToolDetails.getDetailsType());
|
assertNull(paymentToolDetails.getDetailsType());
|
||||||
@ -39,7 +40,9 @@ public class PaymentToolUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDigitalWalletJson() throws JsonProcessingException {
|
public void testDigitalWalletJson() throws JsonProcessingException {
|
||||||
PaymentTool paymentTool = PaymentTool.digital_wallet(new DigitalWallet(DigitalWalletProvider.qiwi, "kke"));
|
PaymentTool paymentTool =
|
||||||
|
PaymentTool.digital_wallet(new DigitalWallet("kke"));
|
||||||
|
paymentTool.getDigitalWallet().setProviderDeprecated(LegacyDigitalWalletProvider.qiwi);
|
||||||
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||||
String json = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
String json = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||||
.writeValueAsString(paymentToolDetails);
|
.writeValueAsString(paymentToolDetails);
|
||||||
@ -52,7 +55,7 @@ public class PaymentToolUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetPaymentToolDetailsPaymentTerminal() {
|
public void testGetPaymentToolDetailsPaymentTerminal() {
|
||||||
PaymentTool paymentTool = PaymentTool.payment_terminal(new PaymentTerminal()
|
PaymentTool paymentTool = PaymentTool.payment_terminal(new PaymentTerminal()
|
||||||
.setTerminalType(TerminalPaymentProvider.alipay)
|
.setTerminalTypeDeprecated(LegacyTerminalPaymentProvider.alipay)
|
||||||
);
|
);
|
||||||
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
PaymentToolDetails paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||||
assertTrue(paymentToolDetails instanceof PaymentToolDetailsPaymentTerminal);
|
assertTrue(paymentToolDetails instanceof PaymentToolDetailsPaymentTerminal);
|
||||||
@ -61,7 +64,7 @@ public class PaymentToolUtilsTest {
|
|||||||
((PaymentToolDetailsPaymentTerminal) paymentToolDetails).getProvider().getValue());
|
((PaymentToolDetailsPaymentTerminal) paymentToolDetails).getProvider().getValue());
|
||||||
|
|
||||||
paymentTool = PaymentTool.payment_terminal(new PaymentTerminal()
|
paymentTool = PaymentTool.payment_terminal(new PaymentTerminal()
|
||||||
.setTerminalType(TerminalPaymentProvider.wechat)
|
.setTerminalTypeDeprecated(LegacyTerminalPaymentProvider.wechat)
|
||||||
);
|
);
|
||||||
paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
paymentToolDetails = PaymentToolUtils.getPaymentToolDetails(paymentTool);
|
||||||
assertTrue(paymentToolDetails instanceof PaymentToolDetailsPaymentTerminal);
|
assertTrue(paymentToolDetails instanceof PaymentToolDetailsPaymentTerminal);
|
||||||
|
Loading…
Reference in New Issue
Block a user