use of com.hyperwallet.clientsdk.model.HyperwalletPayment in project mirakl-hyperwallet-connector by paypal.
the class PayeeInvoiceModelToHyperwalletPaymentConverterTest method convert_shouldConvertAnInvoiceIntoHyperwalletPayment.
@Test
void convert_shouldConvertAnInvoiceIntoHyperwalletPayment() {
when(hyperwalletSDKServiceMock.getProgramTokenByHyperwalletProgram(HYPERWALLET_PROGRAM)).thenReturn(PROGRAM_TOKEN);
// @formatter:off
final InvoiceModel invoice = InvoiceModel.builder().destinationToken(DESTINATION_TOKEN).shopId(SHOP_ID).invoiceNumber(INVOICE_NUMBER).transferAmount(TRANSFER_AMOUNT).currencyIsoCode(CURRENCY_ISO_CODE).hyperwalletProgram(HYPERWALLET_PROGRAM).build();
// @formatter:on
final HyperwalletPayment result = testObj.convert(invoice);
assertThat(result.getDestinationToken()).isEqualTo(DESTINATION_TOKEN);
assertThat(result.getClientPaymentId()).isEqualTo(INVOICE_NUMBER);
assertThat(result.getAmount()).isEqualTo(TRANSFER_AMOUNT);
assertThat(result.getCurrency()).isEqualTo(CURRENCY_ISO_CODE);
assertThat(result.getPurpose()).isEqualTo("OTHER");
assertThat(result.getProgramToken()).isEqualTo(PROGRAM_TOKEN);
}
use of com.hyperwallet.clientsdk.model.HyperwalletPayment in project mirakl-hyperwallet-connector by paypal.
the class AbstractInvoiceExtractServiceImplTest method extractInvoices_shouldCallMiraklInvoiceExtractServiceAndHyperwalletPaymentExtractServiceAndCollectInvoicesPaidForOperatorAndPayeeWithDeltaPassedAsArgument.
@Test
void extractInvoices_shouldCallMiraklInvoiceExtractServiceAndHyperwalletPaymentExtractServiceAndCollectInvoicesPaidForOperatorAndPayeeWithDeltaPassedAsArgument() {
testObj = new MyInvoiceExtractService(miraklAccountingDocumentInvoicesExtractServiceMock, miraklAccountingDocumentCreditNotesExtractServiceMock, hyperWalletPaymentExtractServiceMock, List.of(operatorHyperWalletPaymentOneMock, operatorHyperWalletPaymentTwoMock));
final LocalDateTime now = TimeMachine.now();
TimeMachine.useFixedClockAt(now);
final Date delta = DateUtil.convertToDate(now, ZoneId.systemDefault());
final List<InvoiceModel> invoices = List.of(payeeInvoiceModelOneMock, payeeInvoiceModelTwoMock, operatorInvoiceModelOneMock, operatorInvoiceModelTwoMock);
doReturn(invoices).when(miraklAccountingDocumentInvoicesExtractServiceMock).extractAccountingDocument(delta);
final List<HyperwalletPayment> payeeCreatedPayments = List.of(payeeHyperWalletPaymentOneMock, payeeHyperWalletPaymentTwoMock);
when(hyperWalletPaymentExtractServiceMock.payPayeeInvoice(invoices)).thenReturn(payeeCreatedPayments);
final List<HyperwalletPayment> result = testObj.extractInvoices(delta);
verify(miraklAccountingDocumentInvoicesExtractServiceMock).extractAccountingDocument(delta);
verify(hyperWalletPaymentExtractServiceMock).payPayeeInvoice(invoices);
assertThat(result).containsExactlyInAnyOrder(payeeHyperWalletPaymentOneMock, payeeHyperWalletPaymentTwoMock, operatorHyperWalletPaymentOneMock, operatorHyperWalletPaymentTwoMock);
}
use of com.hyperwallet.clientsdk.model.HyperwalletPayment in project mirakl-hyperwallet-connector by paypal.
the class PayeeInvoiceModelToHyperwalletPaymentConverter method convert.
/**
* {@inheritDoc}
*/
@Override
public HyperwalletPayment convert(@NonNull final InvoiceModel source) {
final HyperwalletPayment target = new HyperwalletPayment();
target.setProgramToken(invoicesHyperwalletSDKService.getProgramTokenByHyperwalletProgram(source.getHyperwalletProgram()));
target.setDestinationToken(source.getDestinationToken());
target.setClientPaymentId(source.getInvoiceNumber());
target.setAmount(source.getTransferAmount());
target.setCurrency(source.getCurrencyIsoCode());
target.setPurpose(PURPOSE);
return target;
}
use of com.hyperwallet.clientsdk.model.HyperwalletPayment in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletPaymentExtractServiceImplTest method payPayeeCreditNote_shouldReturnOnlyPaymentsSuccessfullyCreatedOnHyperwallet.
@Test
void payPayeeCreditNote_shouldReturnOnlyPaymentsSuccessfullyCreatedOnHyperwallet() {
final List<CreditNoteModel> creditNoteList = List.of(creditNoteModelOneMock, creditNoteModelTwoMock);
when(creditNoteModelHyperwalletPaymentConverterMock.convert(creditNoteModelOneMock)).thenReturn(paymentOneMock);
when(creditNoteModelHyperwalletPaymentConverterMock.convert(creditNoteModelTwoMock)).thenReturn(paymentTwoMock);
when(hyperwalletMock.createPayment(paymentOneMock)).thenReturn(createdPaymentOneMock);
when(paymentOneMock.getProgramToken()).thenReturn(PROGRAM_TOKEN);
when(paymentTwoMock.getProgramToken()).thenReturn(PROGRAM_TOKEN);
when(hyperwalletSDKService.getHyperwalletInstanceWithProgramToken(PROGRAM_TOKEN)).thenReturn(hyperwalletMock);
doThrow(new HyperwalletException("Something went wrong")).when(hyperwalletMock).createPayment(paymentTwoMock);
final List<HyperwalletPayment> result = testObj.payPayeeCreditNote(creditNoteList);
verify(creditNoteModelHyperwalletPaymentConverterMock).convert(creditNoteModelOneMock);
verify(creditNoteModelHyperwalletPaymentConverterMock).convert(creditNoteModelTwoMock);
verify(hyperwalletMock).createPayment(paymentOneMock);
verify(hyperwalletMock).createPayment(paymentTwoMock);
assertThat(result).containsExactlyInAnyOrder(createdPaymentOneMock);
}
use of com.hyperwallet.clientsdk.model.HyperwalletPayment in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletPaymentExtractServiceImplTest method payInvoice_shouldReturnOnlyPaymentsSuccessfullyCreatedOnHyperwallet.
@Test
void payInvoice_shouldReturnOnlyPaymentsSuccessfullyCreatedOnHyperwallet() {
final List<InvoiceModel> invoices = List.of(invoiceModelOneMock, invoiceModelTwoMock);
when(invoiceModelToHyperwalletPaymentConverterMock.convert(invoiceModelOneMock)).thenReturn(paymentOneMock);
when(invoiceModelToHyperwalletPaymentConverterMock.convert(invoiceModelTwoMock)).thenReturn(paymentTwoMock);
when(hyperwalletMock.createPayment(paymentOneMock)).thenReturn(createdPaymentOneMock);
when(paymentOneMock.getProgramToken()).thenReturn(PROGRAM_TOKEN);
when(paymentTwoMock.getProgramToken()).thenReturn(PROGRAM_TOKEN);
when(hyperwalletSDKService.getHyperwalletInstanceWithProgramToken(PROGRAM_TOKEN)).thenReturn(hyperwalletMock);
doThrow(new HyperwalletException("Something went wrong")).when(hyperwalletMock).createPayment(paymentTwoMock);
final List<HyperwalletPayment> result = testObj.payInvoice(invoices, invoiceModelToHyperwalletPaymentConverterMock);
verify(invoiceModelToHyperwalletPaymentConverterMock).convert(invoiceModelOneMock);
verify(invoiceModelToHyperwalletPaymentConverterMock).convert(invoiceModelTwoMock);
verify(hyperwalletMock).createPayment(paymentOneMock);
verify(hyperwalletMock).createPayment(paymentTwoMock);
assertThat(result).containsExactlyInAnyOrder(createdPaymentOneMock);
}
Aggregations