use of com.paypal.invoices.invoicesextract.model.CreditNoteModel in project mirakl-hyperwallet-connector by paypal.
the class PayeeCreditNoteModelToHyperwalletPaymentConverterTest method convert_populatesHyperwalletPaymentWithCreditNotesInformationAndPurposeOther.
@Test
void convert_populatesHyperwalletPaymentWithCreditNotesInformationAndPurposeOther() {
when(hyperwalletSDKServiceMock.getProgramTokenByHyperwalletProgram("myProgramToken")).thenReturn("the-real-token");
final CreditNoteModel creditNoteModelStub = CreditNoteModel.builder().destinationToken("destination-token").creditAmount(20.00D).currencyIsoCode("EUR").hyperwalletProgram("myProgramToken").invoiceNumber("invoiceNumber").build();
final HyperwalletPayment result = testObj.convert(creditNoteModelStub);
assertThat(result.getAmount()).isEqualTo(20.00D);
assertThat(result.getCurrency()).isEqualTo("EUR");
assertThat(result.getProgramToken()).isEqualTo("the-real-token");
assertThat(result.getDestinationToken()).isEqualTo("destination-token");
assertThat(result.getClientPaymentId()).isEqualTo("invoiceNumber");
assertThat(result.getPurpose()).isEqualTo("OTHER");
}
use of com.paypal.invoices.invoicesextract.model.CreditNoteModel in project mirakl-hyperwallet-connector by paypal.
the class AbstractInvoiceExtractServiceImplTest method extractCreditNotes_shouldCallMiraklInvoiceExtractServiceAndHyperwalletPaymentExtractServiceAndCollectCreditNotesWithDeltaPassedAsArgument.
@Test
void extractCreditNotes_shouldCallMiraklInvoiceExtractServiceAndHyperwalletPaymentExtractServiceAndCollectCreditNotesWithDeltaPassedAsArgument() {
testObj = new MyInvoiceExtractService(miraklAccountingDocumentInvoicesExtractServiceMock, miraklAccountingDocumentCreditNotesExtractServiceMock, hyperWalletPaymentExtractServiceMock, List.of());
final LocalDateTime now = TimeMachine.now();
TimeMachine.useFixedClockAt(now);
final Date delta = DateUtil.convertToDate(now, ZoneId.systemDefault());
final List<CreditNoteModel> creditNotes = List.of(creditNoteOneMock, creditNoteTwoMock);
when(miraklAccountingDocumentCreditNotesExtractServiceMock.extractAccountingDocument(delta)).thenReturn(creditNotes);
final List<HyperwalletPayment> creditNotesCreatedPayments = List.of(creditNoteHyperWalletOneMock, creditNoteHyperWalletTwoMock);
when(hyperWalletPaymentExtractServiceMock.payPayeeCreditNote(creditNotes)).thenReturn(creditNotesCreatedPayments);
final List<HyperwalletPayment> result = testObj.extractCreditNotes(delta);
verify(miraklAccountingDocumentCreditNotesExtractServiceMock).extractAccountingDocument(delta);
verify(hyperWalletPaymentExtractServiceMock).payPayeeCreditNote(creditNotes);
assertThat(result).containsExactlyInAnyOrder(creditNoteHyperWalletOneMock, creditNoteHyperWalletTwoMock);
}
Aggregations