예제 #1
0
 private List<PaymentTransactionInfoPlugin> getPaymentTransactionInfoPlugins(
     final PaymentPluginApi plugin,
     final PaymentModelDao paymentModelDao,
     final Iterable<PluginProperty> properties,
     final TenantContext context)
     throws PaymentApiException {
   try {
     return plugin.getPaymentInfo(
         paymentModelDao.getAccountId(), paymentModelDao.getId(), properties, context);
   } catch (final PaymentPluginApiException e) {
     throw new PaymentApiException(
         ErrorCode.PAYMENT_PLUGIN_GET_PAYMENT_INFO, paymentModelDao.getId(), e.toString());
   }
 }
  @Test(groups = "slow")
  public void testBasicProcessPaymentWithPaymentPluginApiException() throws Exception {

    boolean gotException = false;
    try {
      final PaymentPluginApiWithTestControl paymentPluginApi = getTestPluginPaymentApi();
      final PaymentPluginApiException e = new PaymentPluginApiException("test-error", "foo");

      paymentPluginApi.setPaymentPluginApiExceptionOnNextCalls(e);
      paymentPluginApi.processPayment(
          UUID.randomUUID(),
          UUID.randomUUID(),
          UUID.randomUUID(),
          BigDecimal.TEN,
          Currency.USD,
          ImmutableList.<PluginProperty>of(),
          callContext);
      Assert.fail("Expected to fail with " + e.toString());
    } catch (final PaymentPluginApiException e) {
      gotException = true;
    }
    Assert.assertTrue(gotException);
  }