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();
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.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.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.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.assertEquals(search4.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(ImmutableList.<Account>copyOf(search4.iterator()).size(), 0); 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); }
.header(HDR_PAGINATION_CURRENT_OFFSET, entities.getCurrentOffset()) .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)
totalNbRecords += pages.getTotalNbRecords(); if (!maxStatsCrossPlugins) { maxNbRecords += pages.getMaxNbRecords();
.header(HDR_PAGINATION_CURRENT_OFFSET, tags.getCurrentOffset()) .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)
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(foundPaymentMethods.iterator().hasNext(), !deleted); Assert.assertEquals(foundPaymentMethods.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(foundPaymentMethods.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(foundPaymentMethodsWithPluginInfo.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(foundPaymentMethods2.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(foundPaymentMethods2WithPluginInfo.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); Assert.assertEquals(gotPaymentMethods.getTotalNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethodsWithPluginInfo.getTotalNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods2.getTotalNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods2WithPluginInfo.getTotalNbRecords(), maxNbRecords);
@Test(groups = "slow") public void testGetPaymentMethodsWithAndWithoutPluginInfo() throws PaymentApiException, PaymentPluginApiException { final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "externalKey"; final String transactionExternalKey = "transactionKey"; final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); final Pagination<PaymentMethod> paymentMethods = paymentApi.getPaymentMethods(0L, 10L, false, null, callContext); final Pagination<PaymentMethod> paymentMethodsPlugin = paymentApi.getPaymentMethods(0L, 10L, true, null, callContext); Assert.assertTrue(paymentMethods.getTotalNbRecords() == 1); Assert.assertTrue(paymentMethodsPlugin.getTotalNbRecords() == 1); PaymentMethod paymentMethod = paymentMethods.iterator().next(); PaymentMethod paymentMethodPlugin = paymentMethodsPlugin.iterator().next(); Assert.assertEquals(paymentMethod.getAccountId(), paymentMethodPlugin.getAccountId()); Assert.assertEquals(paymentMethod.getId(), paymentMethodPlugin.getId()); Assert.assertEquals(paymentMethod.getExternalKey(), paymentMethodPlugin.getExternalKey()); Assert.assertEquals(paymentMethod.getPluginName(), paymentMethodPlugin.getPluginName()); Assert.assertNull(paymentMethod.getPluginDetail()); Assert.assertNotNull(paymentMethodPlugin.getPluginDetail()); Assert.assertTrue(paymentMethodPlugin.getPluginDetail().getProperties().isEmpty()); }
@Test(groups = "slow") public void testPaginationForPaymentByStatesAcrossTenants() throws Exception { final DateTime createdDate1 = clock.getUTCNow().minusHours(1); clock.setTime(createdDate1); final Account account = testHelper.createTestAccount(UUID.randomUUID().toString(), true); final int NB_ENTRIES = 30; for (int i = 0; i < NB_ENTRIES; i++) { final PaymentModelDao paymentModelDao1 = new PaymentModelDao(createdDate1, createdDate1, account.getId(), account.getPaymentMethodId(), UUID.randomUUID().toString()); final PaymentTransactionModelDao transaction1 = new PaymentTransactionModelDao(createdDate1, createdDate1, null, UUID.randomUUID().toString(), paymentModelDao1.getId(), TransactionType.AUTHORIZE, createdDate1, TransactionStatus.UNKNOWN, BigDecimal.TEN, Currency.AED, "unknown", ""); paymentDao.insertPaymentWithFirstTransaction(paymentModelDao1, transaction1, internalCallContext); } clock.setTime(createdDate1.plusHours(1)); final Pagination<PaymentTransactionModelDao> result = paymentDao.getByTransactionStatusAcrossTenants(ImmutableList.of(TransactionStatus.UNKNOWN), clock.getUTCNow(), createdDate1, 0L, (long) NB_ENTRIES); Assert.assertEquals(result.getTotalNbRecords(), new Long(NB_ENTRIES)); final Iterator<PaymentTransactionModelDao> iterator = result.iterator(); for (int i = 0; i < NB_ENTRIES; i++) { Assert.assertTrue(iterator.hasNext()); final PaymentTransactionModelDao nextEntry = iterator.next(); Assert.assertEquals(nextEntry.getTransactionStatus(), TransactionStatus.UNKNOWN); } }
@Test(groups = "slow") public void testPaymentAttemptsByStateAcrossTenants() throws Exception { final String externalKey1 = "gfhfg"; final String transactionExternalKey1 = "sadas"; final String externalKey2 = "asdwqeqw"; final String transactionExternalKey2 = "fghfg"; final DateTime createdAfterDate = clock.getUTCNow().minusDays(10); final DateTime createdBeforeDate = clock.getUTCNow().minusDays(1); final String stateName = "FOO"; final String pluginName = "miraculous"; clock.setTime(createdAfterDate); Account account = testHelper.createTestAccount(UUID.randomUUID().toString(), true); final PaymentAttemptModelDao attempt1 = new PaymentAttemptModelDao(account.getId(), account.getPaymentMethodId(), createdAfterDate, createdAfterDate, externalKey1, UUID.randomUUID(), transactionExternalKey1, TransactionType.AUTHORIZE, stateName, BigDecimal.ONE, Currency.USD, ImmutableList.<String>of(pluginName), null); paymentDao.insertPaymentAttemptWithProperties(attempt1, internalCallContext); account = testHelper.createTestAccount(UUID.randomUUID().toString(), true); final PaymentAttemptModelDao attempt2 = new PaymentAttemptModelDao(account.getId(), account.getPaymentMethodId(), createdAfterDate, createdAfterDate, externalKey2, UUID.randomUUID(), transactionExternalKey2, TransactionType.AUTHORIZE, stateName, BigDecimal.ONE, Currency.USD, ImmutableList.<String>of(pluginName), null); paymentDao.insertPaymentAttemptWithProperties(attempt2, internalCallContext); final Pagination<PaymentAttemptModelDao> result = paymentDao.getPaymentAttemptsByStateAcrossTenants(stateName, createdBeforeDate, 0L, 2L); Assert.assertEquals(result.getTotalNbRecords().longValue(), 2L); }
Assert.assertFalse(foundPayments.iterator().hasNext()); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertTrue(foundPayments.iterator().hasNext()); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.iterator().next().getId(), payment1.getId()); Assert.assertFalse(foundPayments.iterator().hasNext()); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 0L); Assert.assertTrue(foundPayments.iterator().hasNext()); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 2L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L); Assert.assertEquals(foundPayments.iterator().next().getId(), payment1.getId()); Assert.assertTrue(foundPayments.iterator().hasNext()); Assert.assertEquals(foundPayments.getMaxNbRecords(), (Long) 2L); Assert.assertEquals(foundPayments.getTotalNbRecords(), (Long) 1L);