Search in sources :

Example 56 with PaymentApiException

use of org.killbill.billing.payment.api.PaymentApiException in project killbill by killbill.

the class TestPluginDispatcher method testDispatchWithPaymentApiException.

@Test(groups = "fast")
public void testDispatchWithPaymentApiException() throws TimeoutException, PaymentApiException {
    boolean gotIt = false;
    try {
        voidPluginDispatcher.dispatchWithTimeout(new Callable<PluginDispatcherReturnType<Void>>() {

            @Override
            public PluginDispatcherReturnType<Void> call() throws Exception {
                throw new PaymentApiException(ErrorCode.PAYMENT_ADD_PAYMENT_METHOD, "foo", "foo");
            }
        }, 100, TimeUnit.MILLISECONDS);
        Assert.fail("Failed : should have had Timeout exception");
    } catch (final TimeoutException e) {
        Assert.fail("Failed : should have had PaymentApiException exception");
    } catch (InterruptedException e) {
        Assert.fail("Failed : should have had PaymentApiException exception");
    } catch (ExecutionException e) {
        if (e.getCause() instanceof PaymentApiException) {
            gotIt = true;
        } else {
            Assert.fail("Failed : should have had PaymentApiException exception");
        }
    }
    Assert.assertTrue(gotIt);
}
Also used : PluginDispatcherReturnType(org.killbill.billing.payment.dispatcher.PluginDispatcher.PluginDispatcherReturnType) PaymentApiException(org.killbill.billing.payment.api.PaymentApiException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) PaymentApiException(org.killbill.billing.payment.api.PaymentApiException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test)

Example 57 with PaymentApiException

use of org.killbill.billing.payment.api.PaymentApiException in project killbill by killbill.

the class TestPluginOperation method testOperationThrowsPaymentApiException.

@Test(groups = "fast")
public void testOperationThrowsPaymentApiException() throws Exception {
    final CallbackTest callback = new CallbackTest(new PaymentApiException(ErrorCode.__UNKNOWN_ERROR_CODE));
    final PaymentOperation pluginOperation = getPluginOperation();
    try {
        pluginOperation.dispatchWithAccountLockAndTimeout(PLUGIN_NAME_PLACEHOLDER, callback);
        Assert.fail();
    } catch (final OperationException e) {
        Assert.assertEquals(e.getOperationResult(), OperationResult.EXCEPTION);
        Assert.assertTrue(e.getCause() instanceof PaymentApiException);
    }
}
Also used : PaymentOperation(org.killbill.billing.payment.core.sm.payments.PaymentOperation) PaymentApiException(org.killbill.billing.payment.api.PaymentApiException) OperationException(org.killbill.automaton.OperationException) Test(org.testng.annotations.Test)

Aggregations

PaymentApiException (org.killbill.billing.payment.api.PaymentApiException)57 UUID (java.util.UUID)20 Test (org.testng.annotations.Test)19 PaymentTransactionModelDao (org.killbill.billing.payment.dao.PaymentTransactionModelDao)14 Account (org.killbill.billing.account.api.Account)12 Payment (org.killbill.billing.payment.api.Payment)12 PaymentAttemptModelDao (org.killbill.billing.payment.dao.PaymentAttemptModelDao)11 BigDecimal (java.math.BigDecimal)10 OperationException (org.killbill.automaton.OperationException)10 PaymentModelDao (org.killbill.billing.payment.dao.PaymentModelDao)9 Predicate (com.google.common.base.Predicate)7 PaymentControlApiException (org.killbill.billing.control.plugin.api.PaymentControlApiException)7 PluginDispatcherReturnType (org.killbill.billing.payment.dispatcher.PluginDispatcher.PluginDispatcherReturnType)7 PaymentPluginApi (org.killbill.billing.payment.plugin.api.PaymentPluginApi)7 LinkedList (java.util.LinkedList)6 AccountApiException (org.killbill.billing.account.api.AccountApiException)6 Invoice (org.killbill.billing.invoice.api.Invoice)6 PluginProperty (org.killbill.billing.payment.api.PluginProperty)6 PaymentPluginApiException (org.killbill.billing.payment.plugin.api.PaymentPluginApiException)6 DateTime (org.joda.time.DateTime)5