use of org.killbill.billing.client.model.PaymentMethods in project killbill by killbill.
the class TestAccount method testRefreshPaymentMethods.
@Test(groups = "slow", description = "refresh payment methods")
public void testRefreshPaymentMethods() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod("someExternalKey");
final PaymentMethods paymentMethodsBeforeRefreshing = killBillClient.getPaymentMethodsForAccount(account.getAccountId(), requestOptions);
assertEquals(paymentMethodsBeforeRefreshing.size(), 1);
assertEquals(paymentMethodsBeforeRefreshing.get(0).getExternalKey(), "someExternalKey");
// WITH NAME OF AN EXISTING PLUGIN
killBillClient.refreshPaymentMethods(account.getAccountId(), PLUGIN_NAME, ImmutableMap.<String, String>of(), requestOptions);
final PaymentMethods paymentMethodsAfterExistingPluginCall = killBillClient.getPaymentMethodsForAccount(account.getAccountId(), requestOptions);
assertEquals(paymentMethodsAfterExistingPluginCall.size(), 1);
assertEquals(paymentMethodsAfterExistingPluginCall.get(0).getExternalKey(), "someExternalKey");
// WITHOUT PLUGIN NAME
killBillClient.refreshPaymentMethods(account.getAccountId(), ImmutableMap.<String, String>of(), requestOptions);
final PaymentMethods paymentMethodsAfterNoPluginNameCall = killBillClient.getPaymentMethodsForAccount(account.getAccountId(), requestOptions);
assertEquals(paymentMethodsAfterNoPluginNameCall.size(), 1);
assertEquals(paymentMethodsAfterNoPluginNameCall.get(0).getExternalKey(), "someExternalKey");
// WITH WRONG PLUGIN NAME
try {
killBillClient.refreshPaymentMethods(account.getAccountId(), "GreatestPluginEver", ImmutableMap.<String, String>of(), requestOptions);
Assert.fail();
} catch (final KillBillClientException e) {
Assert.assertEquals(e.getBillingException().getCode(), (Integer) ErrorCode.PAYMENT_NO_SUCH_PAYMENT_PLUGIN.getCode());
}
}
use of org.killbill.billing.client.model.PaymentMethods in project killbill by killbill.
the class TestPaymentMethod method testPaymentMethodsPagination.
@Test(groups = "slow", description = "Can paginate through all payment methods")
public void testPaymentMethodsPagination() throws Exception {
for (int i = 0; i < 5; i++) {
createAccountWithDefaultPaymentMethod();
}
final PaymentMethods allPaymentMethods = killBillClient.getPaymentMethods();
Assert.assertEquals(allPaymentMethods.size(), 5);
PaymentMethods page = killBillClient.getPaymentMethods(0L, 1L);
for (int i = 0; i < 5; i++) {
Assert.assertNotNull(page);
Assert.assertEquals(page.size(), 1);
Assert.assertEquals(page.get(0), allPaymentMethods.get(i));
page = page.getNext();
}
Assert.assertNull(page);
}
Aggregations