use of com.paypal.infrastructure.constants.HyperWalletConstants.MIRAKL_MAX_RESULTS_PER_PAGE in project mirakl-hyperwallet-connector by paypal.
the class MiraklInvoicesExtractServiceImplTest method getAccountingDocument_whenRequestNeedsPagination_shouldRepeatRequestAndReturnAllInvoices.
@Test
void getAccountingDocument_whenRequestNeedsPagination_shouldRepeatRequestAndReturnAllInvoices() {
TimeMachine.useFixedClockAt(LocalDateTime.of(2020, 11, 10, 20, 0, 55));
final Date now = DateUtil.convertToDate(TimeMachine.now(), ZoneId.systemDefault());
final List<HMCMiraklInvoice> firstPageResponseInvoices = getListOfHMCMiraklInvoiceMocks(MIRAKL_MAX_RESULTS_PER_PAGE);
final List<HMCMiraklInvoice> secondPageResponseInvoices = getListOfHMCMiraklInvoiceMocks(MIRAKL_MAX_RESULTS_PER_PAGE / 2);
final long totalResponseInvoices = firstPageResponseInvoices.size() + secondPageResponseInvoices.size();
when(miraklMarketplacePlatformOperatorApiClientMock.getInvoices(argThat(request -> request != null && request.getOffset() == 0))).thenReturn(miraklInvoicesOneMock);
when(miraklMarketplacePlatformOperatorApiClientMock.getInvoices(argThat(request -> request != null && request.getOffset() == MIRAKL_MAX_RESULTS_PER_PAGE))).thenReturn(miraklInvoicesTwoMock);
when(miraklInvoicesOneMock.getTotalCount()).thenReturn(totalResponseInvoices);
when(miraklInvoicesOneMock.getHmcInvoices()).thenReturn(firstPageResponseInvoices);
when(miraklInvoicesTwoMock.getTotalCount()).thenReturn(totalResponseInvoices);
when(miraklInvoicesTwoMock.getHmcInvoices()).thenReturn(secondPageResponseInvoices);
final List<InvoiceModel> expectedCreditNotes = Stream.concat(firstPageResponseInvoices.stream(), secondPageResponseInvoices.stream()).map(invoice -> mockAndReturn(invoice)).collect(Collectors.toList());
final List<InvoiceModel> result = testObj.getAccountingDocuments(now);
assertThat(result).containsExactlyElementsOf(expectedCreditNotes);
}
use of com.paypal.infrastructure.constants.HyperWalletConstants.MIRAKL_MAX_RESULTS_PER_PAGE in project mirakl-hyperwallet-connector by paypal.
the class MiraklCreditNotesExtractServiceImplTest method getAccountingDocuments_whenRequestNeedsPagination_shouldRepeatRequestAndReturnAllInvoices.
@Test
void getAccountingDocuments_whenRequestNeedsPagination_shouldRepeatRequestAndReturnAllInvoices() {
TimeMachine.useFixedClockAt(LocalDateTime.of(2020, 11, 10, 20, 0, 55));
final Date now = DateUtil.convertToDate(TimeMachine.now(), ZoneId.systemDefault());
final List<HMCMiraklInvoice> firstPageResponseInvoices = getListOfHMCMiraklInvoiceMocks(MIRAKL_MAX_RESULTS_PER_PAGE);
final List<HMCMiraklInvoice> secondPageResponseInvoices = getListOfHMCMiraklInvoiceMocks(MIRAKL_MAX_RESULTS_PER_PAGE / 2);
final long totalResponseInvoices = firstPageResponseInvoices.size() + secondPageResponseInvoices.size();
when(miraklMarketplacePlatformOperatorApiClientMock.getInvoices(argThat(request -> request != null && request.getOffset() == 0))).thenReturn(miraklInvoicesOneMock);
when(miraklMarketplacePlatformOperatorApiClientMock.getInvoices(argThat(request -> request != null && request.getOffset() == MIRAKL_MAX_RESULTS_PER_PAGE))).thenReturn(miraklInvoicesTwoMock);
when(miraklInvoicesOneMock.getTotalCount()).thenReturn(totalResponseInvoices);
when(miraklInvoicesOneMock.getHmcInvoices()).thenReturn(firstPageResponseInvoices);
when(miraklInvoicesTwoMock.getTotalCount()).thenReturn(totalResponseInvoices);
when(miraklInvoicesTwoMock.getHmcInvoices()).thenReturn(secondPageResponseInvoices);
final List<CreditNoteModel> expectedCreditNotes = Stream.concat(firstPageResponseInvoices.stream(), secondPageResponseInvoices.stream()).map(invoice -> mockAndReturn(invoice)).collect(Collectors.toList());
final List<CreditNoteModel> result = testObj.getAccountingDocuments(now);
assertThat(result).containsExactlyElementsOf(expectedCreditNotes);
}
Aggregations