@Override public boolean apply(final PaymentMethod input) { return input.getId().equals(match); } })) {
private void checkPaymentMethodExistsWithStatus(final List<PaymentMethod> methods, final UUID expectedPaymentMethodId, final boolean expectedActive) { PaymentMethod foundPM = null; for (final PaymentMethod cur : methods) { if (cur.getId().equals(expectedPaymentMethodId)) { foundPM = cur; break; } } Assert.assertNotNull(foundPM); Assert.assertEquals(foundPM.isActive().booleanValue(), expectedActive); }
public static PaymentMethod buildPaymentMethod(final UUID accountId, final UUID paymentMethodId, final String pluginName, @Nullable final OSGIKillbill killbillApi) throws PaymentApiException { final PaymentMethod paymentMethod = Mockito.mock(PaymentMethod.class); Mockito.when(paymentMethod.getId()).thenReturn(paymentMethodId); Mockito.when(paymentMethod.getExternalKey()).thenReturn(UUID.randomUUID().toString()); Mockito.when(paymentMethod.isActive()).thenReturn(true); Mockito.when(paymentMethod.getPluginName()).thenReturn(pluginName); if (killbillApi != null) { Mockito.when(killbillApi.getPaymentApi().getAccountPaymentMethods(Mockito.eq(accountId), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.<Iterable<PluginProperty>>any(), Mockito.<TenantContext>any())).thenReturn(ImmutableList.<PaymentMethod>of(paymentMethod)); Mockito.when(killbillApi.getPaymentApi().getPaymentMethodById(Mockito.eq(paymentMethod.getId()), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.<Iterable<PluginProperty>>any(), Mockito.<TenantContext>any())).thenReturn(paymentMethod); } return paymentMethod; }
public static PaymentMethodJson toPaymentMethodJson(final Account account, final PaymentMethod in, @Nullable final AccountAuditLogs accountAuditLogs) { final boolean isDefault = account.getPaymentMethodId() != null && account.getPaymentMethodId().equals(in.getId()); final PaymentMethodPlugin pluginDetail = in.getPluginDetail(); PaymentMethodPluginDetailJson pluginDetailJson = null; if (pluginDetail != null) { List<PluginPropertyJson> properties = null; if (pluginDetail.getProperties() != null) { properties = new ArrayList<PluginPropertyJson>(Collections2.transform(pluginDetail.getProperties(), new Function<PluginProperty, PluginPropertyJson>() { @Override public PluginPropertyJson apply(final PluginProperty input) { return new PluginPropertyJson(input.getKey(), input.getValue() == null ? null : input.getValue().toString(), input.getIsUpdatable()); } })); } pluginDetailJson = new PaymentMethodPluginDetailJson(pluginDetail.getExternalPaymentMethodId(), pluginDetail.isDefaultPaymentMethod(), properties); } return new PaymentMethodJson(in.getId(), in.getExternalKey(), account.getId(), isDefault, in.getPluginName(), pluginDetailJson, toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForPaymentMethod(in.getId()))); }
final UUID externalPaymentMethodId = paymentMethods.get(0).getId(); for (int i = 0; i < 50; i++) { final ExternalPaymentProviderPlugin foundProviderPlugin = paymentMethodProcessor.createPaymentMethodAndGetExternalPaymentProviderPlugin(UUID.randomUUID().toString(), account, properties, callContext, internalCallContext); Assert.assertEquals(foundPaymentMethods.get(0).getPluginName(), ExternalPaymentProviderPlugin.PLUGIN_NAME); Assert.assertEquals(foundPaymentMethods.get(0).getAccountId(), account.getId()); Assert.assertEquals(foundPaymentMethods.get(0).getId(), externalPaymentMethodId);
return match.getId();
assertEquals(initDefaultMethod.getId(), account.getPaymentMethodId()); paymentApi.deletePaymentMethod(account, initDefaultMethod.getId(), true, false, PLUGIN_PROPERTIES, callContext); methods = paymentApi.getAccountPaymentMethods(account.getId(), false, false, PLUGIN_PROPERTIES, callContext); assertEquals(methods.size(), 1);
@Test(groups = "slow") public void testGetPaymentMethodsWithAndWithoutPluginInfo() throws PaymentApiException, PaymentPluginApiException { final BigDecimal requestedAmount = BigDecimal.TEN; final String paymentExternalKey = "externalKey"; final String transactionExternalKey = "transactionKey"; final Payment payment = paymentApi.createPurchase(account, account.getPaymentMethodId(), null, requestedAmount, Currency.AED, null, paymentExternalKey, transactionExternalKey, ImmutableList.<PluginProperty>of(), callContext); final Pagination<PaymentMethod> paymentMethods = paymentApi.getPaymentMethods(0L, 10L, false, null, callContext); final Pagination<PaymentMethod> paymentMethodsPlugin = paymentApi.getPaymentMethods(0L, 10L, true, null, callContext); Assert.assertTrue(paymentMethods.getTotalNbRecords() == 1); Assert.assertTrue(paymentMethodsPlugin.getTotalNbRecords() == 1); PaymentMethod paymentMethod = paymentMethods.iterator().next(); PaymentMethod paymentMethodPlugin = paymentMethodsPlugin.iterator().next(); Assert.assertEquals(paymentMethod.getAccountId(), paymentMethodPlugin.getAccountId()); Assert.assertEquals(paymentMethod.getId(), paymentMethodPlugin.getId()); Assert.assertEquals(paymentMethod.getExternalKey(), paymentMethodPlugin.getExternalKey()); Assert.assertEquals(paymentMethod.getPluginName(), paymentMethodPlugin.getPluginName()); Assert.assertNull(paymentMethod.getPluginDetail()); Assert.assertNotNull(paymentMethodPlugin.getPluginDetail()); Assert.assertTrue(paymentMethodPlugin.getPluginDetail().getProperties().isEmpty()); }