mirror of
https://github.com/valitydev/fraudbusters-mg-connector.git
synced 2024-11-06 01:15:17 +00:00
Fix after review
This commit is contained in:
parent
ad48595835
commit
53b6c8cb8f
@ -5,6 +5,8 @@ import com.rbkmoney.fraudbusters.mg.connector.constant.EventType;
|
||||
|
||||
public interface Mapper<C, P, R> {
|
||||
|
||||
String DELIMITER = ".";
|
||||
|
||||
default boolean accept(C change) {
|
||||
return getChangeType().getFilter().match(change);
|
||||
}
|
||||
|
@ -51,8 +51,9 @@ public class ChargebackPaymentMapper implements Mapper<InvoiceChange, MachineEve
|
||||
.setCost(invoicePayment.getPayment().getCost())
|
||||
.setReferenceInfo(generalInfoInitiator.initReferenceInfo(invoice))
|
||||
.setPaymentTool(generalInfoInitiator.initPaymentTool(payer))
|
||||
.setId(invoice.getId() + invoicePaymentChargebackChange.getId())
|
||||
.setPaymentId(invoice.getId() + invoicePayment.getPayment().getId())
|
||||
.setId(String.join(DELIMITER, invoice.getId(), invoicePayment.getPayment().getId(),
|
||||
invoicePaymentChargebackChange.getId()))
|
||||
.setPaymentId(String.join(DELIMITER, invoice.getId(), invoicePayment.getPayment().getId()))
|
||||
.setEventTime(event.getCreatedAt())
|
||||
.setClientInfo(generalInfoInitiator.initClientInfo(payer))
|
||||
.setProviderInfo(generalInfoInitiator.initProviderInfo(invoicePayment));
|
||||
|
@ -54,7 +54,7 @@ public class PaymentMapper implements Mapper<InvoiceChange, MachineEvent, Paymen
|
||||
.setCost(invoicePayment.getPayment().getCost())
|
||||
.setReferenceInfo(generalInfoInitiator.initReferenceInfo(invoice))
|
||||
.setPaymentTool(generalInfoInitiator.initPaymentTool(payer))
|
||||
.setId(invoice.getId() + invoicePayment.getPayment().getId())
|
||||
.setId(String.join(DELIMITER, invoice.getId(), invoicePayment.getPayment().getId()))
|
||||
.setEventTime(event.getCreatedAt())
|
||||
.setClientInfo(generalInfoInitiator.initClientInfo(payer))
|
||||
.setProviderInfo(generalInfoInitiator.initProviderInfo(invoicePayment))
|
||||
|
@ -50,8 +50,9 @@ public class RefundPaymentMapper implements Mapper<InvoiceChange, MachineEvent,
|
||||
.setCost(invoicePayment.getPayment().getCost())
|
||||
.setReferenceInfo(generalInfoInitiator.initReferenceInfo(invoice))
|
||||
.setPaymentTool(generalInfoInitiator.initPaymentTool(payer))
|
||||
.setId(invoice.getId() + invoicePaymentRefundChange.getId())
|
||||
.setPaymentId(invoice.getId() + invoicePayment.getPayment().getId())
|
||||
.setId(String.join(DELIMITER, invoice.getId(), invoicePayment.getPayment().getId(),
|
||||
invoicePaymentRefundChange.getId()))
|
||||
.setPaymentId(String.join(DELIMITER, invoice.getId(), invoicePayment.getPayment().getId()))
|
||||
.setEventTime(event.getCreatedAt())
|
||||
.setClientInfo(generalInfoInitiator.initClientInfo(payer))
|
||||
.setProviderInfo(generalInfoInitiator.initProviderInfo(invoicePayment))
|
||||
|
@ -77,20 +77,17 @@ public class GeneralInfoInitiator implements InfoInitializer<InvoicePaymentStatu
|
||||
}
|
||||
|
||||
public PaymentTool initPaymentTool(Payer payer) {
|
||||
PaymentTool paymentTool = null;
|
||||
if (payer.isSetPaymentResource() && payer.getPaymentResource().isSetResource()) {
|
||||
DisposablePaymentResource resource = payer.getPaymentResource().getResource();
|
||||
paymentTool = resource.getPaymentTool();
|
||||
return payer.getPaymentResource().getResource().getPaymentTool();
|
||||
} else if (payer.isSetCustomer()) {
|
||||
CustomerPayer customer = payer.getCustomer();
|
||||
paymentTool = customer.getPaymentTool();
|
||||
return customer.getPaymentTool();
|
||||
} else if (payer.isSetRecurrent()) {
|
||||
RecurrentPayer recurrent = payer.getRecurrent();
|
||||
paymentTool = recurrent.getPaymentTool();
|
||||
} else {
|
||||
log.warn("Unknown payment tool in payer: {}", payer);
|
||||
return recurrent.getPaymentTool();
|
||||
}
|
||||
return paymentTool;
|
||||
log.warn("Unknown payment tool in payer: {}", payer);
|
||||
return null;
|
||||
}
|
||||
|
||||
public ReferenceInfo initReferenceInfo(com.rbkmoney.damsel.domain.Invoice invoice) {
|
||||
|
@ -50,9 +50,6 @@ public class IntegrationTest extends KafkaAbstractTest {
|
||||
@MockBean
|
||||
InvoicingSrv.Iface invoicingClient;
|
||||
|
||||
@Autowired
|
||||
private EventRangeFactory eventRangeFactory;
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws TException, IOException, InterruptedException {
|
||||
Mockito.when(invoicingClient.get(any(), any(), any()))
|
||||
|
Loading…
Reference in New Issue
Block a user