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);
}
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);
}
}
Aggregations