@Test(groups = "slow") public void testCreatePurchaseWithControlPluginRuntimeException() throws Exception { mockPaymentControlProviderPlugin.throwsException(new IllegalStateException()); final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "pay controle external key"; final String transactionExternalKey = "txn control external key"; try { paymentApi.createPurchaseWithPaymentControl( account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), CONTROL_PLUGIN_OPTIONS, callContext); fail(); } catch (PaymentApiException e) { assertTrue(e.getCause() instanceof IllegalStateException); } }
@Test(groups = "slow") public void testCreatePurchasePaymentPluginException() { mockPaymentProviderPlugin.makeNextPaymentFailWithException(); final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "pay external key"; final String transactionExternalKey = "txn external key"; try { paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); fail(); } catch (PaymentApiException e) { assertTrue(e.getCause() instanceof PaymentPluginApiException); } }
@Test(groups = "slow") public void testCreatePurchaseWithControlPaymentPluginException() throws Exception { mockPaymentProviderPlugin.makeNextPaymentFailWithException(); final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "pay controle external key"; final String transactionExternalKey = "txn control external key"; try { paymentApi.createPurchaseWithPaymentControl( account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), CONTROL_PLUGIN_OPTIONS, callContext); fail(); } catch (PaymentApiException e) { assertTrue(e.getCause() instanceof PaymentPluginApiException); } }
@Test(groups = "slow") public void testFailedRefundWithInvoiceAdjustment() throws Exception { try { invoicePaymentApi.createRefundForInvoicePayment(true, null, account, payment.getId(), payment.getPurchasedAmount(), payment.getCurrency(), null, UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext); fail("Refund with invoice adjustment should now throw an Exception"); } catch (final PaymentApiException e) { Assert.assertEquals(e.getCause(), null); // Unfortunately we lose the original error code : INVOICE_ITEMS_ADJUSTMENT_MISSING Assert.assertEquals(e.getCode(), ErrorCode.PAYMENT_PLUGIN_EXCEPTION.getCode()); } }
@Test(groups = "slow") public void testCreatePurchaseWithControlPluginException() throws Exception { mockPaymentControlProviderPlugin.throwsException(new PaymentControlApiException()); final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "pay controle external key"; final String transactionExternalKey = "txn control external key"; try { paymentApi.createPurchaseWithPaymentControl( account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), CONTROL_PLUGIN_OPTIONS, callContext); fail(); } catch (PaymentApiException e) { assertTrue(e.getCause() instanceof PaymentControlApiException); } }
refundProperties, INVOICE_PAYMENT, callContext); } catch (final PaymentApiException e) { assertTrue(e.getCause() instanceof PaymentControlApiException);