Search in sources :

Example 11 with CreditNoteModel

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");
}
Also used : HyperwalletPayment(com.hyperwallet.clientsdk.model.HyperwalletPayment) CreditNoteModel(com.paypal.invoices.invoicesextract.model.CreditNoteModel) Test(org.junit.jupiter.api.Test)

Example 12 with CreditNoteModel

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) HyperwalletPayment(com.hyperwallet.clientsdk.model.HyperwalletPayment) CreditNoteModel(com.paypal.invoices.invoicesextract.model.CreditNoteModel) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

CreditNoteModel (com.paypal.invoices.invoicesextract.model.CreditNoteModel)12 Test (org.junit.jupiter.api.Test)11 Date (java.util.Date)8 LocalDateTime (java.time.LocalDateTime)6 MiraklGetShopsRequest (com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest)4 HyperwalletPayment (com.hyperwallet.clientsdk.model.HyperwalletPayment)3 MiraklErrorResponseBean (com.mirakl.client.core.error.MiraklErrorResponseBean)2 MiraklApiException (com.mirakl.client.core.exception.MiraklApiException)2 MiraklInvoice (com.mirakl.client.mmp.domain.invoice.MiraklInvoice)2 MiraklGetInvoicesRequest (com.mirakl.client.mmp.operator.request.payment.invoice.MiraklGetInvoicesRequest)2 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)1 PENDING (com.mirakl.client.mmp.domain.accounting.document.MiraklAccountingDocumentPaymentStatus.PENDING)1 MANUAL_CREDIT (com.mirakl.client.mmp.domain.accounting.document.MiraklAccountingDocumentType.MANUAL_CREDIT)1 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)1 MiraklShops (com.mirakl.client.mmp.domain.shop.MiraklShops)1 COMPLETE (com.mirakl.client.mmp.request.payment.invoice.MiraklAccountingDocumentState.COMPLETE)1 MIRAKL_MAX_RESULTS_PER_PAGE (com.paypal.infrastructure.constants.HyperWalletConstants.MIRAKL_MAX_RESULTS_PER_PAGE)1 Converter (com.paypal.infrastructure.converter.Converter)1 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)1 MiraklMarketplacePlatformOperatorApiWrapper (com.paypal.infrastructure.sdk.mirakl.MiraklMarketplacePlatformOperatorApiWrapper)1