private void verifyPayment(final Payment payment, final String paymentExternalKey, final BigDecimal authAmount, final BigDecimal capturedAmount, final BigDecimal refundedAmount, final int transactionsSize) { Assert.assertEquals(payment.getAccountId(), account.getId()); // We cannot assume the number to be 1 here as the auto_increment implementation // depends on the database. On h2, it is implemented as a sequence, and the payment number // would be 33, 34, 35, etc. depending on the test // See also http://h2database.com/html/grammar.html#create_sequence Assert.assertTrue(payment.getPaymentNumber() > 0); Assert.assertEquals(payment.getExternalKey(), paymentExternalKey); Assert.assertEquals(payment.getAuthAmount().compareTo(authAmount), 0); Assert.assertEquals(payment.getCapturedAmount().compareTo(capturedAmount), 0); Assert.assertEquals(payment.getRefundedAmount().compareTo(refundedAmount), 0); Assert.assertEquals(payment.getCurrency(), CURRENCY); Assert.assertEquals(payment.getTransactions().size(), transactionsSize); }
public static Payment buildPayment(final UUID accountId, final UUID paymentMethodId, final UUID paymentId, final Currency currency, final String paymentExternalKey, @Nullable final OSGIKillbill killbillApi) throws PaymentApiException { final Payment payment = Mockito.mock(Payment.class); Mockito.when(payment.getId()).thenReturn(paymentId); Mockito.when(payment.getExternalKey()).thenReturn(paymentExternalKey); Mockito.when(payment.getAccountId()).thenReturn(accountId); Mockito.when(payment.getPaymentMethodId()).thenReturn(paymentMethodId); Mockito.when(payment.getPaymentNumber()).thenReturn(1); Mockito.when(payment.getCapturedAmount()).thenReturn(new BigDecimal("199999")); Mockito.when(payment.getRefundedAmount()).thenReturn(new BigDecimal("199998")); Mockito.when(payment.getCurrency()).thenReturn(currency); Mockito.when(payment.getTransactions()).thenReturn(new LinkedList<PaymentTransaction>()); Mockito.when(payment.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 56, DateTimeZone.UTC)); if (killbillApi != null) { Mockito.when(killbillApi.getPaymentApi().getPayment(Mockito.eq(payment.getId()), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.<Iterable<PluginProperty>>any(), Mockito.<TenantContext>any())).thenReturn(payment); final List<Payment> payments = MoreObjects.firstNonNull(killbillApi.getPaymentApi().getAccountPayments(accountId, false, false, ImmutableList.<PluginProperty>of(), Mockito.mock(TenantContext.class)), new LinkedList<Payment>()); payments.add(payment); Mockito.when(killbillApi.getPaymentApi().getAccountPayments(Mockito.eq(accountId), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.<Iterable<PluginProperty>>any(), Mockito.<TenantContext>any())).thenReturn(payments); } return payment; }
assertNotNull(paymentInfo.getPaymentNumber()); assertEquals(paymentInfo.getExternalKey(), invoice.getId().toString()); assertEquals(paymentInfo.getCurrency(), Currency.USD);
public PaymentJson(final Payment dp, @Nullable final AccountAuditLogs accountAuditLogs) { this(dp.getAccountId(), dp.getId(), dp.getPaymentNumber().toString(), dp.getExternalKey(), dp.getAuthAmount(), dp.getCapturedAmount(), dp.getPurchasedAmount(), dp.getRefundedAmount(), dp.getCreditedAmount(), dp.getCurrency() != null ? dp.getCurrency() : null, dp.getPaymentMethodId(), getTransactions(dp.getTransactions(), dp.getExternalKey(), accountAuditLogs), getAttempts(dp.getPaymentAttempts(), dp.getExternalKey(), accountAuditLogs), toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForPayment(dp.getId()))); }