@Override public Void inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { entitySqlDaoWrapperFactory.become(RefundSqlDao.class).updateStatus(refundId.toString(), refundStatus.toString(), processedAmount, processedCurrency, context); return null; } });
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (paymentId != null ? paymentId.hashCode() : 0); result = 31 * result + (amount != null ? amount.hashCode() : 0); result = 31 * result + (currency != null ? currency.hashCode() : 0); result = 31 * result + (isAdjusted ? 1 : 0); result = 31 * result + (effectiveDate != null ? effectiveDate.hashCode() : 0); result = 31 * result + (refundStatus != null ? refundStatus.hashCode() : 0); result = 31 * result + (refundInfoPlugin != null ? refundInfoPlugin.hashCode() : 0); return result; } }
private boolean refundObjectsMatch(final RefundModelDao refundModelDao, final RefundInfoPlugin refundInfoPlugin) { return (refundInfoPlugin.getKbPaymentId() != null && refundModelDao.getPaymentId() != null && refundInfoPlugin.getKbPaymentId().equals(refundModelDao.getPaymentId())) && (refundInfoPlugin.getAmount() != null && refundModelDao.getProcessedAmount() != null && refundInfoPlugin.getAmount().compareTo(refundModelDao.getProcessedAmount()) == 0) && (refundInfoPlugin.getCurrency() != null && refundModelDao.getProcessedCurrency() != null && refundInfoPlugin.getCurrency().equals(refundModelDao.getProcessedCurrency())) && ( (refundInfoPlugin.getStatus().equals(RefundPluginStatus.PROCESSED) && refundModelDao.getRefundStatus().equals(RefundStatus.COMPLETED)) || (refundInfoPlugin.getStatus().equals(RefundPluginStatus.PENDING) && refundModelDao.getRefundStatus().equals(RefundStatus.PENDING)) ); }
public RefundJson(final Refund refund, @Nullable final List<InvoiceItem> adjustments, @Nullable final List<AuditLog> auditLogs) { this(refund.getId().toString(), refund.getPaymentId().toString(), refund.getRefundAmount(), refund.getCurrency().toString(), refund.getRefundStatus().toString(), refund.isAdjusted(), refund.getEffectiveDate(), refund.getEffectiveDate(), adjustments == null ? null : ImmutableList.<InvoiceItemJson>copyOf(Collections2.transform(adjustments, new Function<InvoiceItem, InvoiceItemJson>() { @Override public InvoiceItemJson apply(@Nullable final InvoiceItem input) { return new InvoiceItemJson(input); } })), toAuditLogJson(auditLogs)); }
@Override public int hashCode() { int result = accountId != null ? accountId.hashCode() : 0; result = 31 * result + (paymentId != null ? paymentId.hashCode() : 0); result = 31 * result + (amount != null ? amount.hashCode() : 0); result = 31 * result + (currency != null ? currency.hashCode() : 0); result = 31 * result + (processedAmount != null ? processedAmount.hashCode() : 0); result = 31 * result + (processedCurrency != null ? processedCurrency.hashCode() : 0); result = 31 * result + (isAdjusted ? 1 : 0); result = 31 * result + (refundStatus != null ? refundStatus.hashCode() : 0); result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0); result = 31 * result + (updatedDate != null ? updatedDate.hashCode() : 0); return result; }
@Test(groups = "fast") public void testJson() throws Exception { final String refundId = UUID.randomUUID().toString(); final String paymentId = UUID.randomUUID().toString(); final BigDecimal amount = BigDecimal.TEN; final String currency = "USD"; final boolean isAdjusted = true; final DateTime requestedDate = clock.getUTCNow(); final DateTime effectiveDate = clock.getUTCNow(); final RefundStatus status = RefundStatus.COMPLETED; final List<InvoiceItemJson> adjustments = ImmutableList.<InvoiceItemJson>of(createInvoiceItemJson()); final List<AuditLogJson> auditLogs = createAuditLogsJson(clock.getUTCNow()); final RefundJson refundJson = new RefundJson(refundId, paymentId, amount, currency, status.toString(), isAdjusted, requestedDate, effectiveDate, adjustments, auditLogs); Assert.assertEquals(refundJson.getRefundId(), refundId); Assert.assertEquals(refundJson.getPaymentId(), paymentId); Assert.assertEquals(refundJson.getAmount(), amount); Assert.assertEquals(refundJson.getCurrency(), currency); Assert.assertEquals(refundJson.isAdjusted(), isAdjusted); Assert.assertEquals(refundJson.getRequestedDate(), requestedDate); Assert.assertEquals(refundJson.getEffectiveDate(), effectiveDate); Assert.assertEquals(refundJson.getAdjustments(), adjustments); Assert.assertEquals(refundJson.getAuditLogs(), auditLogs); final String asJson = mapper.writeValueAsString(refundJson); final RefundJson fromJson = mapper.readValue(asJson, RefundJson.class); Assert.assertEquals(fromJson, refundJson); }