paymentMethods = paymentApi.getPaymentMethods(offset, limit, withPluginInfo, pluginProperties, tenantContext); } else { paymentMethods = paymentApi.getPaymentMethods(offset, limit, pluginName, withPluginInfo, pluginProperties, tenantContext);
@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); }
Assert.assertEquals(foundPaymentMethods2WithPluginInfo.getTotalNbRecords(), (Long) (!deleted ? 1L : 0L)); final Pagination<PaymentMethod> gotPaymentMethods = paymentApi.getPaymentMethods(0L, maxNbRecords + 1L, false, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(gotPaymentMethods.iterator().hasNext(), maxNbRecords > 0); Assert.assertEquals(gotPaymentMethods.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods.getTotalNbRecords(), maxNbRecords); final Pagination<PaymentMethod> gotPaymentMethodsWithPluginInfo = paymentApi.getPaymentMethods(0L, maxNbRecords + 1L, true, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(gotPaymentMethodsWithPluginInfo.iterator().hasNext(), maxNbRecords > 0); Assert.assertEquals(gotPaymentMethodsWithPluginInfo.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethodsWithPluginInfo.getTotalNbRecords(), maxNbRecords); final Pagination<PaymentMethod> gotPaymentMethods2 = paymentApi.getPaymentMethods(0L, maxNbRecords + 1L, MockPaymentProviderPlugin.PLUGIN_NAME, false, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(gotPaymentMethods2.iterator().hasNext(), maxNbRecords > 0); Assert.assertEquals(gotPaymentMethods2.getMaxNbRecords(), maxNbRecords); Assert.assertEquals(gotPaymentMethods2.getTotalNbRecords(), maxNbRecords); final Pagination<PaymentMethod> gotPaymentMethods2WithPluginInfo = paymentApi.getPaymentMethods(0L, maxNbRecords + 1L, MockPaymentProviderPlugin.PLUGIN_NAME, true, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(gotPaymentMethods2WithPluginInfo.iterator().hasNext(), maxNbRecords > 0); Assert.assertEquals(gotPaymentMethods2WithPluginInfo.getMaxNbRecords(), 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()); }