private boolean responseIsIn(final PaymentResponse actualResponse, final PaymentResponse[] responseForLastFailedPayment) { for (final PaymentResponse response : responseForLastFailedPayment) { if (response.equals(actualResponse)) { return true; } } return false; }
public static Map<String, Object> toMap(final Iterable<PluginProperty>... propertiesLists) { final Map<String, Object> mergedProperties = new HashMap<String, Object>(); for (final Iterable<PluginProperty> propertiesList : propertiesLists) { for (final PluginProperty pluginProperty : propertiesList) { if (pluginProperty.getKey() != null) { mergedProperties.put(pluginProperty.getKey(), pluginProperty.getValue()); } } } return mergedProperties; }
@Override public String apply(final PluginProperty pluginProperty) { return pluginProperty.getKey(); } })
@Test(groups = "fast") public void testBuildPluginProperties() throws Exception { Assert.assertEquals(pluginProperties1.size(), 2); Assert.assertEquals(pluginProperties1.get(0).getKey(), "foo"); Assert.assertEquals(pluginProperties1.get(0).getValue(), "bar"); Assert.assertFalse(pluginProperties1.get(0).getIsUpdatable()); Assert.assertEquals(pluginProperties1.get(1).getKey(), "baz"); Assert.assertEquals(pluginProperties1.get(1).getValue(), (Long) 12L); Assert.assertFalse(pluginProperties1.get(1).getIsUpdatable()); }
@Override public boolean apply(final PaymentTransaction input) { return TransactionType.CHARGEBACK.equals(input.getTransactionType()) && TransactionStatus.SUCCESS.equals(input.getTransactionStatus()); } });
public static PaymentTransaction filterForTransaction(final Payment payment, final TransactionType transactionType) { for (final PaymentTransaction paymentTransaction : payment.getTransactions()) { if (paymentTransaction.getTransactionType().equals(transactionType)) { return paymentTransaction; } } return null; } }
public static PaymentTransaction filterForTransaction(final Payment payment, final UUID kbTransactionId) { for (final PaymentTransaction paymentTransaction : payment.getTransactions()) { if (paymentTransaction.getId().equals(kbTransactionId)) { return paymentTransaction; } } return null; }
@Override public boolean apply(final PaymentTransaction input) { return input.getTransactionType() == transactionType; } });
@Override public Payment apply(@Nullable final Void input) { try { return paymentApi.createChargebackReversalWithPaymentControl(account, payment.getId(), null, chargebackTransactionExternalKey, PAYMENT_OPTIONS, callContext); } catch (final PaymentApiException e) { fail(e.toString()); return null; } } }, events);
public static List<PluginProperty> buildPluginProperties(@Nullable final Map<String, Object> data) { final ImmutableList.Builder<PluginProperty> propertiesBuilder = ImmutableList.<PluginProperty>builder(); if (data != null) { for (final String key : data.keySet()) { final PluginProperty property = new PluginProperty(key, data.get(key), false); propertiesBuilder.add(property); } } return propertiesBuilder.build(); } }
public TestPaymentMethodPlugin(final UUID kbPaymentMethodId, final PaymentMethodPlugin src, final String externalPaymentId) { this.kbPaymentMethodId = kbPaymentMethodId; this.externalPaymentMethodId = externalPaymentId; this.isDefaultPaymentMethod = src.isDefaultPaymentMethod(); this.properties = src.getProperties(); }
@Override public PluginDispatcherReturnType<Void> call() throws Exception { throw new PaymentApiException(ErrorCode.PAYMENT_ADD_PAYMENT_METHOD, "foo", "foo"); } }, 100, TimeUnit.MILLISECONDS);
@Override public List<InvoicePayment> call() throws Exception { return invoicePaymentApi.getInvoicePaymentsByAccount(accountId, tenantContext); } };
@Test(groups = "fast") public void testMerge() throws Exception { final List<PluginProperty> pluginPropertiesRaw = ImmutableList.<PluginProperty>copyOf(PluginProperties.merge(pluginProperties1, pluginProperties2)); final List<PluginProperty> pluginProperties = sort(pluginPropertiesRaw); Assert.assertEquals(pluginProperties.size(), 3); Assert.assertEquals(pluginProperties.get(0).getKey(), "baz"); Assert.assertEquals(pluginProperties.get(0).getValue(), (Long) 12L); Assert.assertFalse(pluginProperties.get(0).getIsUpdatable()); Assert.assertEquals(pluginProperties.get(1).getKey(), "baz2"); Assert.assertEquals(pluginProperties.get(1).getValue(), "something else"); Assert.assertFalse(pluginProperties.get(1).getIsUpdatable()); Assert.assertEquals(pluginProperties.get(2).getKey(), "foo"); Assert.assertEquals(pluginProperties.get(2).getValue(), "override"); Assert.assertFalse(pluginProperties.get(2).getIsUpdatable()); }
@Override public String apply(final PluginProperty pluginProperty) { return pluginProperty.getKey(); } })
@Override public boolean apply(final PaymentTransaction input) { return input.getTransactionType() == TransactionType.PURCHASE; } }).get();
private boolean responseIsIn(final PaymentResponse actualResponse, final PaymentResponse[] responseForLastFailedPayment) { for (final PaymentResponse response : responseForLastFailedPayment) { if (response.equals(actualResponse)) { return true; } } return false; }
@Override public String apply(final PluginProperty pluginProperty) { return pluginProperty.getKey(); } })
@Override public boolean apply(final PaymentTransaction input) { return input.getTransactionType() == TransactionType.REFUND; } }).orNull();
@Override public boolean apply(final PaymentTransaction input) { return input.getTransactionType() == TransactionType.REFUND; } }).get();