public DefaultPagination(final Pagination original, final Long limit, final Iterator<T> delegate) { this(original.getCurrentOffset(), limit, original.getTotalNbRecords(), original.getMaxNbRecords(), delegate); }
totalNbRecords += pages.getTotalNbRecords(); if (!maxStatsCrossPlugins) { maxNbRecords += pages.getMaxNbRecords(); } else { maxNbRecords = Math.max(maxNbRecords, pages.getMaxNbRecords());
private void checkPagination(final long nbRecords) { final Pagination<CustomField> foundCustomFields = customFieldUserApi.searchCustomFields("ACCOUNT", 0L, nbRecords + 1L, callContext); Assert.assertEquals(foundCustomFields.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(foundCustomFields.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(foundCustomFields.getTotalNbRecords(), (Long) nbRecords); final Pagination<CustomField> gotCustomFields = customFieldUserApi.getCustomFields(0L, nbRecords + 1L, callContext); Assert.assertEquals(gotCustomFields.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(gotCustomFields.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(gotCustomFields.getTotalNbRecords(), (Long) nbRecords); } }
private void checkPagination(final long nbRecords) { final Pagination<Tag> foundTags = tagUserApi.searchTags("ACCOUNT", 0L, nbRecords + 1L, callContext); Assert.assertEquals(foundTags.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(foundTags.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(foundTags.getTotalNbRecords(), (Long) nbRecords); final Pagination<Tag> gotTags = tagUserApi.getTags(0L, nbRecords + 1L, callContext); Assert.assertEquals(gotTags.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(gotTags.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(gotTags.getTotalNbRecords(), (Long) nbRecords); } }
Assert.assertEquals(search1.getCurrentOffset(), (Long) 0L); Assert.assertNull(search1.getNextOffset()); Assert.assertEquals(search1.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(search1.getTotalNbRecords(), (Long) 2L); Assert.assertEquals(ImmutableList.<Account>copyOf(search1.iterator()).size(), 2); Assert.assertEquals(search2.getCurrentOffset(), (Long) 0L); Assert.assertEquals(search2.getNextOffset(), (Long) 1L); Assert.assertEquals(search2.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(search2.getTotalNbRecords(), (Long) 2L); Assert.assertEquals(ImmutableList.<Account>copyOf(search2.iterator()).size(), 1); Assert.assertEquals(search3.getCurrentOffset(), (Long) 0L); Assert.assertNull(search3.getNextOffset()); Assert.assertEquals(search3.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(search3.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(ImmutableList.<Account>copyOf(search3.iterator()).size(), 1); Assert.assertNull(search4.getNextOffset()); Assert.assertNull(search4.getMaxNbRecords()); Assert.assertEquals(search4.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(ImmutableList.<Account>copyOf(search4.iterator()).size(), 0); Assert.assertNull(search5.getMaxNbRecords()); Assert.assertEquals(search5.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(ImmutableList.<Account>copyOf(search5.iterator()).size(), 1);
public DefaultPagination(final Pagination original, final Long limit, final Iterator<T> delegate) { this(original.getCurrentOffset(), limit, original.getTotalNbRecords(), original.getMaxNbRecords(), delegate); }
totalNbRecords += pages.getTotalNbRecords(); if (!maxStatsCrossPlugins) { maxNbRecords += pages.getMaxNbRecords(); } else { maxNbRecords = Math.max(maxNbRecords, pages.getMaxNbRecords());
.header(HDR_PAGINATION_NEXT_OFFSET, entities.getNextOffset()) .header(HDR_PAGINATION_TOTAL_NB_RECORDS, entities.getTotalNbRecords()) .header(HDR_PAGINATION_MAX_NB_RECORDS, entities.getMaxNbRecords()) .header(HDR_PAGINATION_NEXT_PAGE_URI, nextPageUri) .build();
.header(HDR_PAGINATION_NEXT_OFFSET, tags.getNextOffset()) .header(HDR_PAGINATION_TOTAL_NB_RECORDS, tags.getTotalNbRecords()) .header(HDR_PAGINATION_MAX_NB_RECORDS, tags.getMaxNbRecords()) .header(HDR_PAGINATION_NEXT_PAGE_URI, nextPageUri) .build();
private void checkPagination(final long nbRecords) { final Pagination<CustomField> foundCustomFields = customFieldUserApi.searchCustomFields("ACCOUNT", 0L, nbRecords + 1L, callContext); Assert.assertEquals(foundCustomFields.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(foundCustomFields.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(foundCustomFields.getTotalNbRecords(), (Long) nbRecords); final Pagination<CustomField> gotCustomFields = customFieldUserApi.getCustomFields(0L, nbRecords + 1L, callContext); Assert.assertEquals(gotCustomFields.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(gotCustomFields.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(gotCustomFields.getTotalNbRecords(), (Long) nbRecords); } }
private void checkPagination(final long nbRecords) { final Pagination<Tag> foundTags = tagUserApi.searchTags("ACCOUNT", 0L, nbRecords + 1L, callContext); Assert.assertEquals(foundTags.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(foundTags.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(foundTags.getTotalNbRecords(), (Long) nbRecords); final Pagination<Tag> gotTags = tagUserApi.getTags(0L, nbRecords + 1L, callContext); Assert.assertEquals(gotTags.iterator().hasNext(), nbRecords > 0); Assert.assertEquals(gotTags.getMaxNbRecords(), (Long) nbRecords); Assert.assertEquals(gotTags.getTotalNbRecords(), (Long) nbRecords); } }
@Test(groups = "slow") public void testAddRemovePaymentMethodWithForcedDeletion() throws Exception { final Long baseNbRecords = paymentApi.getPaymentMethods(0L, 1000L, false, ImmutableList.<PluginProperty>of(), callContext).getMaxNbRecords(); Assert.assertEquals(baseNbRecords, (Long) 1L); final Account account = testHelper.createTestAccount(UUID.randomUUID().toString(), true); final UUID paymentMethodId = account.getPaymentMethodId(); checkPaymentMethodPagination(paymentMethodId, baseNbRecords + 1, false); paymentApi.deletePaymentMethod(account, paymentMethodId, false, true, ImmutableList.<PluginProperty>of(), callContext); checkPaymentMethodPagination(paymentMethodId, baseNbRecords, true); }
@Test(groups = "slow") public void testAddRemovePaymentMethodWithoutForcedDeletion() throws Exception { final Long baseNbRecords = paymentApi.getPaymentMethods(0L, 1000L, false, ImmutableList.<PluginProperty>of(), callContext).getMaxNbRecords(); Assert.assertEquals(baseNbRecords, (Long) 1L); final Account account = testHelper.createTestAccount(UUID.randomUUID().toString(), true); final UUID paymentMethodId = account.getPaymentMethodId(); try { paymentApi.deletePaymentMethod(account, paymentMethodId, false, false, ImmutableList.<PluginProperty>of(), callContext); } catch (final PaymentApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.PAYMENT_INTERNAL_ERROR.getCode()); } checkPaymentMethodPagination(paymentMethodId, baseNbRecords + 1, false); }
@Test(groups = "slow") public void testAddRemovePaymentMethod() throws Exception { final Long baseNbRecords = paymentApi.getPaymentMethods(0L, 1000L, false, ImmutableList.<PluginProperty>of(), callContext).getMaxNbRecords(); Assert.assertEquals(baseNbRecords, (Long) 1L); final Account account = testHelper.createTestAccount(UUID.randomUUID().toString(), true); final UUID paymentMethodId = account.getPaymentMethodId(); checkPaymentMethodPagination(paymentMethodId, baseNbRecords + 1, false); paymentApi.deletePaymentMethod(account, paymentMethodId, true, false, ImmutableList.<PluginProperty>of(), callContext); List<PaymentMethod> paymentMethods = paymentApi.getAccountPaymentMethods(account.getId(), false, false, ImmutableList.<PluginProperty>of(), callContext); assertEquals(paymentMethods.size(), 0); paymentMethods = paymentApi.getAccountPaymentMethods(account.getId(), true, false, ImmutableList.<PluginProperty>of(), callContext); assertEquals(paymentMethods.size(), 1); checkPaymentMethodPagination(paymentMethodId, baseNbRecords, true); }
private void checkPaymentMethodPagination(final UUID paymentMethodId, final Long maxNbRecords, final boolean deleted) throws PaymentApiException { final Pagination<PaymentMethod> foundPaymentMethods = paymentApi.searchPaymentMethods(paymentMethodId.toString(), 0L, maxNbRecords + 1, false, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(foundPaymentMethods.iterator().hasNext(), !deleted); Assert.assertEquals(foundPaymentMethods.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(foundPaymentMethods.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(foundPaymentMethodsWithPluginInfo.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(foundPaymentMethodsWithPluginInfo.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(foundPaymentMethods2.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(foundPaymentMethods2.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(foundPaymentMethods2WithPluginInfo.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(foundPaymentMethods2WithPluginInfo.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(gotPaymentMethods.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods.getTotalNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethodsWithPluginInfo.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethodsWithPluginInfo.getTotalNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods2.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods2.getTotalNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods2WithPluginInfo.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods2WithPluginInfo.getTotalNbRecords(), maxNbRecords);
Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.iterator().next().getId(), payment1.getId()); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 2L); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.iterator().next().getId(), payment1.getId()); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.iterator().next().getId(), payment2.getId());