Fix after review

This commit is contained in:
k.struzhkin 2020-07-02 15:47:09 +03:00
parent ad48595835
commit 53b6c8cb8f
6 changed files with 14 additions and 16 deletions

View File

@ -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);
}

View File

@ -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));

View File

@ -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))

View File

@ -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))

View File

@ -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) {

View File

@ -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()))