Search in sources :

Example 11 with AuditLogWithHistory

use of org.killbill.billing.util.audit.AuditLogWithHistory in project killbill by killbill.

the class SubscriptionResource method getSubscriptionEventAuditLogsWithHistory.

@TimedResource
@GET
@Path("/" + EVENTS + "/{eventId:" + UUID_PATTERN + "}/" + AUDIT_LOG_WITH_HISTORY)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve subscription event audit logs with history by id", response = AuditLogJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Subscription event not found") })
public Response getSubscriptionEventAuditLogsWithHistory(@PathParam("eventId") final UUID eventId, @javax.ws.rs.core.Context final HttpServletRequest request) {
    final TenantContext tenantContext = context.createTenantContextNoAccountId(request);
    final List<AuditLogWithHistory> auditLogWithHistory = subscriptionApi.getSubscriptionEventAuditLogsWithHistoryForId(eventId, AuditLevel.FULL, tenantContext);
    return Response.status(Status.OK).entity(getAuditLogsWithHistory(auditLogWithHistory)).build();
}
Also used : TenantContext(org.killbill.billing.util.callcontext.TenantContext) AuditLogWithHistory(org.killbill.billing.util.audit.AuditLogWithHistory) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with AuditLogWithHistory

use of org.killbill.billing.util.audit.AuditLogWithHistory in project killbill by killbill.

the class TagDefinitionResource method getTagDefinitionAuditLogsWithHistory.

@TimedResource
@GET
@Path("/{tagDefinitionId:" + UUID_PATTERN + "}/" + AUDIT_LOG_WITH_HISTORY)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve tag definition audit logs with history by id", response = AuditLogJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Account not found") })
public Response getTagDefinitionAuditLogsWithHistory(@PathParam("tagDefinitionId") final UUID tagDefinitionId, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
    final TenantContext tenantContext = context.createTenantContextNoAccountId(request);
    final List<AuditLogWithHistory> auditLogWithHistory = tagUserApi.getTagDefinitionAuditLogsWithHistoryForId(tagDefinitionId, AuditLevel.FULL, tenantContext);
    return Response.status(Status.OK).entity(getAuditLogsWithHistory(auditLogWithHistory)).build();
}
Also used : TenantContext(org.killbill.billing.util.callcontext.TenantContext) AuditLogWithHistory(org.killbill.billing.util.audit.AuditLogWithHistory) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 13 with AuditLogWithHistory

use of org.killbill.billing.util.audit.AuditLogWithHistory in project killbill by killbill.

the class TransactionResource method getTransactionAuditLogsWithHistory.

@TimedResource
@GET
@Path("/{transactionId:" + UUID_PATTERN + "}/" + AUDIT_LOG_WITH_HISTORY)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve payment transaction audit logs with history by id", response = AuditLogJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Account not found") })
public Response getTransactionAuditLogsWithHistory(@PathParam("transactionId") final UUID transactionId, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
    final TenantContext tenantContext = context.createTenantContextNoAccountId(request);
    final List<AuditLogWithHistory> auditLogWithHistory = paymentApi.getPaymentTransactionAuditLogsWithHistoryForId(transactionId, AuditLevel.FULL, tenantContext);
    return Response.status(Status.OK).entity(getAuditLogsWithHistory(auditLogWithHistory)).build();
}
Also used : TenantContext(org.killbill.billing.util.callcontext.TenantContext) AuditLogWithHistory(org.killbill.billing.util.audit.AuditLogWithHistory) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 14 with AuditLogWithHistory

use of org.killbill.billing.util.audit.AuditLogWithHistory in project killbill by killbill.

the class TestSubscriptionDao method testWithAuditAndHistory.

@Test(groups = "slow")
public void testWithAuditAndHistory() throws SubscriptionBaseApiException {
    final String bundleExternalKey = "54341455sttfs1";
    final DateTime startDate = clock.getUTCNow();
    final DefaultSubscriptionBaseBundle bundleDef = new DefaultSubscriptionBaseBundle(bundleExternalKey, accountId, startDate, startDate, startDate, startDate);
    final SubscriptionBaseBundle bundle = dao.createSubscriptionBundle(bundleDef, catalog, true, internalCallContext);
    final List<AuditLogWithHistory> bundleHistory1 = dao.getSubscriptionBundleAuditLogsWithHistoryForId(bundle.getId(), AuditLevel.FULL, internalCallContext);
    assertEquals(bundleHistory1.size(), 1);
    final AuditLogWithHistory bundleHistoryRow1 = bundleHistory1.get(0);
    assertEquals(bundleHistoryRow1.getChangeType(), ChangeType.INSERT);
    final SubscriptionBundleModelDao historyRow1 = (SubscriptionBundleModelDao) bundleHistoryRow1.getEntity();
    assertEquals(historyRow1.getExternalKey(), bundle.getExternalKey());
    assertEquals(historyRow1.getAccountId(), bundle.getAccountId());
    dao.updateBundleExternalKey(bundle.getId(), "you changed me!", internalCallContext);
    final List<AuditLogWithHistory> bundleHistory2 = dao.getSubscriptionBundleAuditLogsWithHistoryForId(bundle.getId(), AuditLevel.FULL, internalCallContext);
    assertEquals(bundleHistory2.size(), 2);
    final AuditLogWithHistory bundleHistoryRow2 = bundleHistory2.get(1);
    assertEquals(bundleHistoryRow2.getChangeType(), ChangeType.UPDATE);
    final SubscriptionBundleModelDao historyRow2 = (SubscriptionBundleModelDao) bundleHistoryRow2.getEntity();
    assertEquals(historyRow2.getExternalKey(), "you changed me!");
    assertEquals(historyRow2.getAccountId(), bundle.getAccountId());
    final SubscriptionBuilder builder = new SubscriptionBuilder().setId(UUIDs.randomUUID()).setBundleId(bundle.getId()).setBundleExternalKey(bundle.getExternalKey()).setCategory(ProductCategory.BASE).setBundleStartDate(startDate).setAlignStartDate(startDate).setMigrated(false);
    final ApiEventBuilder createBuilder = new ApiEventBuilder().setSubscriptionId(builder.getId()).setEventPlan("shotgun-monthly").setEventPlanPhase("shotgun-monthly-trial").setEventPriceList(DefaultPriceListSet.DEFAULT_PRICELIST_NAME).setEffectiveDate(startDate).setFromDisk(true);
    final SubscriptionBaseEvent creationEvent = new ApiEventCreate(createBuilder);
    final DefaultSubscriptionBase subscription = new DefaultSubscriptionBase(builder);
    testListener.pushExpectedEvents(NextEvent.CREATE);
    final SubscriptionBaseWithAddOns subscriptionBaseWithAddOns = new DefaultSubscriptionBaseWithAddOns(bundle, ImmutableList.<SubscriptionBase>of(subscription));
    final List<SubscriptionBaseEvent> resultSubscriptions = dao.createSubscriptionsWithAddOns(ImmutableList.<SubscriptionBaseWithAddOns>of(subscriptionBaseWithAddOns), ImmutableMap.<UUID, List<SubscriptionBaseEvent>>of(subscription.getId(), ImmutableList.<SubscriptionBaseEvent>of(creationEvent)), catalog, internalCallContext);
    assertListenerStatus();
    assertEquals(resultSubscriptions.size(), 1);
    final SubscriptionBaseEvent subscriptionBaseEvent = resultSubscriptions.get(0);
    final List<AuditLogWithHistory> subscriptionHistory = dao.getSubscriptionAuditLogsWithHistoryForId(subscriptionBaseEvent.getSubscriptionId(), AuditLevel.FULL, internalCallContext);
    assertEquals(subscriptionHistory.size(), 1);
    final AuditLogWithHistory subscriptionHistoryRow1 = subscriptionHistory.get(0);
    assertEquals(subscriptionHistoryRow1.getChangeType(), ChangeType.INSERT);
    final SubscriptionModelDao subHistoryRow1 = (SubscriptionModelDao) subscriptionHistoryRow1.getEntity();
    assertEquals(subHistoryRow1.getBundleId(), bundle.getId());
    assertEquals(subHistoryRow1.getCategory(), ProductCategory.BASE);
    final List<AuditLogWithHistory> subscriptionEventHistory = dao.getSubscriptionEventAuditLogsWithHistoryForId(subscriptionBaseEvent.getId(), AuditLevel.FULL, internalCallContext);
    final AuditLogWithHistory subscriptionEventHistoryRow1 = subscriptionEventHistory.get(0);
    assertEquals(subscriptionEventHistoryRow1.getChangeType(), ChangeType.INSERT);
    final SubscriptionEventModelDao subEventHistoryRow1 = (SubscriptionEventModelDao) subscriptionEventHistoryRow1.getEntity();
    assertEquals(subEventHistoryRow1.getSubscriptionId(), subscriptionBaseEvent.getSubscriptionId());
    assertEquals(subEventHistoryRow1.getEventType(), EventType.API_USER);
    assertEquals(subEventHistoryRow1.getUserType(), ApiEventType.CREATE);
    assertEquals(subEventHistoryRow1.getPlanName(), "shotgun-monthly");
    assertEquals(subEventHistoryRow1.getIsActive(), true);
}
Also used : ApiEventCreate(org.killbill.billing.subscription.events.user.ApiEventCreate) SubscriptionModelDao(org.killbill.billing.subscription.engine.dao.model.SubscriptionModelDao) DefaultSubscriptionBaseWithAddOns(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseWithAddOns) SubscriptionBaseWithAddOns(org.killbill.billing.subscription.api.SubscriptionBaseWithAddOns) DefaultSubscriptionBaseBundle(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseBundle) SubscriptionBundleModelDao(org.killbill.billing.subscription.engine.dao.model.SubscriptionBundleModelDao) SubscriptionBuilder(org.killbill.billing.subscription.api.user.SubscriptionBuilder) SubscriptionEventModelDao(org.killbill.billing.subscription.engine.dao.model.SubscriptionEventModelDao) DateTime(org.joda.time.DateTime) ApiEventBuilder(org.killbill.billing.subscription.events.user.ApiEventBuilder) SubscriptionBaseBundle(org.killbill.billing.subscription.api.user.SubscriptionBaseBundle) DefaultSubscriptionBaseBundle(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseBundle) DefaultSubscriptionBase(org.killbill.billing.subscription.api.user.DefaultSubscriptionBase) AuditLogWithHistory(org.killbill.billing.util.audit.AuditLogWithHistory) SubscriptionBaseEvent(org.killbill.billing.subscription.events.SubscriptionBaseEvent) DefaultSubscriptionBaseWithAddOns(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseWithAddOns) Test(org.testng.annotations.Test)

Example 15 with AuditLogWithHistory

use of org.killbill.billing.util.audit.AuditLogWithHistory in project killbill by killbill.

the class TestPaymentDao method testPaymentAndTransactions.

// Flaky, see https://github.com/killbill/killbill/issues/860
@Test(groups = "slow", retryAnalyzer = FlakyRetryAnalyzer.class)
public void testPaymentAndTransactions() {
    final UUID paymentMethodId = UUID.randomUUID();
    final UUID accountId = UUID.randomUUID();
    final String externalKey = UUID.randomUUID().toString();
    final String transactionExternalKey = UUID.randomUUID().toString();
    final String transactionExternalKey2 = UUID.randomUUID().toString();
    final DateTime utcNow = clock.getUTCNow();
    final PaymentModelDao paymentModelDao = new PaymentModelDao(utcNow, utcNow, accountId, paymentMethodId, externalKey);
    final PaymentTransactionModelDao transactionModelDao = new PaymentTransactionModelDao(utcNow, utcNow, null, transactionExternalKey, paymentModelDao.getId(), TransactionType.AUTHORIZE, utcNow, TransactionStatus.SUCCESS, BigDecimal.TEN, Currency.AED, "success", "");
    final PaymentModelDao savedPayment = paymentDao.insertPaymentWithFirstTransaction(paymentModelDao, transactionModelDao, internalCallContext).getPaymentModelDao();
    assertEquals(savedPayment.getId(), paymentModelDao.getId());
    assertEquals(savedPayment.getAccountId(), paymentModelDao.getAccountId());
    assertEquals(savedPayment.getExternalKey(), paymentModelDao.getExternalKey());
    assertEquals(savedPayment.getPaymentMethodId(), paymentModelDao.getPaymentMethodId());
    assertNull(savedPayment.getStateName());
    List<AuditLogWithHistory> auditLogsWithHistory = paymentDao.getPaymentAuditLogsWithHistoryForId(savedPayment.getId(), AuditLevel.FULL, internalCallContext);
    Assert.assertEquals(auditLogsWithHistory.size(), 1);
    PaymentModelDao history1 = (PaymentModelDao) auditLogsWithHistory.get(0).getEntity();
    Assert.assertEquals(auditLogsWithHistory.get(0).getChangeType(), ChangeType.INSERT);
    Assert.assertEquals(history1.getAccountRecordId(), savedPayment.getAccountRecordId());
    Assert.assertEquals(history1.getTenantRecordId(), savedPayment.getTenantRecordId());
    Assert.assertEquals(history1.getExternalKey(), savedPayment.getExternalKey());
    Assert.assertEquals(history1.getStateName(), savedPayment.getStateName());
    Assert.assertEquals(history1.getLastSuccessStateName(), savedPayment.getLastSuccessStateName());
    Assert.assertNull(history1.getStateName());
    Assert.assertNull(history1.getLastSuccessStateName());
    final PaymentModelDao savedPayment2 = paymentDao.getPayment(savedPayment.getId(), internalCallContext);
    assertEquals(savedPayment2.getId(), paymentModelDao.getId());
    assertEquals(savedPayment2.getAccountId(), paymentModelDao.getAccountId());
    assertEquals(savedPayment2.getExternalKey(), paymentModelDao.getExternalKey());
    assertEquals(savedPayment2.getPaymentMethodId(), paymentModelDao.getPaymentMethodId());
    assertNull(savedPayment2.getStateName());
    final PaymentModelDao savedPayment3 = paymentDao.getPaymentByExternalKey(externalKey, internalCallContext);
    assertEquals(savedPayment3.getId(), paymentModelDao.getId());
    assertEquals(savedPayment3.getAccountId(), paymentModelDao.getAccountId());
    assertEquals(savedPayment3.getExternalKey(), paymentModelDao.getExternalKey());
    assertEquals(savedPayment3.getPaymentMethodId(), paymentModelDao.getPaymentMethodId());
    assertNull(savedPayment3.getStateName());
    final PaymentTransactionModelDao savedTransaction = paymentDao.getPaymentTransaction(transactionModelDao.getId(), internalCallContext);
    assertEquals(savedTransaction.getTransactionExternalKey(), transactionExternalKey);
    assertEquals(savedTransaction.getPaymentId(), paymentModelDao.getId());
    assertEquals(savedTransaction.getTransactionType(), TransactionType.AUTHORIZE);
    assertEquals(savedTransaction.getTransactionStatus(), TransactionStatus.SUCCESS);
    assertEquals(savedTransaction.getAmount().compareTo(BigDecimal.TEN), 0);
    assertEquals(savedTransaction.getCurrency(), Currency.AED);
    final List<PaymentTransactionModelDao> savedTransactions = paymentDao.getPaymentTransactionsByExternalKey(transactionExternalKey, internalCallContext);
    assertEquals(savedTransactions.size(), 1);
    final PaymentTransactionModelDao savedTransaction2 = savedTransactions.get(0);
    assertEquals(savedTransaction2.getTransactionExternalKey(), transactionExternalKey);
    assertEquals(savedTransaction2.getPaymentId(), paymentModelDao.getId());
    assertEquals(savedTransaction2.getTransactionType(), TransactionType.AUTHORIZE);
    assertEquals(savedTransaction2.getTransactionStatus(), TransactionStatus.SUCCESS);
    assertEquals(savedTransaction2.getAmount().compareTo(BigDecimal.TEN), 0);
    assertEquals(savedTransaction2.getCurrency(), Currency.AED);
    final PaymentTransactionModelDao transactionModelDao2 = new PaymentTransactionModelDao(utcNow, utcNow, null, transactionExternalKey2, paymentModelDao.getId(), TransactionType.AUTHORIZE, utcNow, TransactionStatus.UNKNOWN, BigDecimal.TEN, Currency.AED, "success", "");
    final PaymentTransactionModelDao savedTransactionModelDao2 = paymentDao.updatePaymentWithNewTransaction(savedPayment.getId(), transactionModelDao2, internalCallContext);
    assertEquals(savedTransactionModelDao2.getTransactionExternalKey(), transactionExternalKey2);
    assertEquals(savedTransactionModelDao2.getPaymentId(), paymentModelDao.getId());
    assertEquals(savedTransactionModelDao2.getTransactionType(), TransactionType.AUTHORIZE);
    assertEquals(savedTransactionModelDao2.getTransactionStatus(), TransactionStatus.UNKNOWN);
    assertEquals(savedTransactionModelDao2.getAmount().compareTo(BigDecimal.TEN), 0);
    assertEquals(savedTransactionModelDao2.getCurrency(), Currency.AED);
    auditLogsWithHistory = paymentDao.getPaymentAuditLogsWithHistoryForId(savedPayment.getId(), AuditLevel.FULL, internalCallContext);
    Assert.assertEquals(auditLogsWithHistory.size(), 2);
    history1 = (PaymentModelDao) auditLogsWithHistory.get(0).getEntity();
    PaymentModelDao history2 = (PaymentModelDao) auditLogsWithHistory.get(1).getEntity();
    Assert.assertEquals(auditLogsWithHistory.get(0).getChangeType(), ChangeType.INSERT);
    Assert.assertEquals(history1.getAccountRecordId(), savedPayment.getAccountRecordId());
    Assert.assertEquals(history1.getTenantRecordId(), savedPayment.getTenantRecordId());
    Assert.assertEquals(history1.getExternalKey(), savedPayment.getExternalKey());
    Assert.assertEquals(auditLogsWithHistory.get(1).getChangeType(), ChangeType.UPDATE);
    Assert.assertEquals(history2.getAccountRecordId(), savedPayment.getAccountRecordId());
    Assert.assertEquals(history2.getTenantRecordId(), savedPayment.getTenantRecordId());
    Assert.assertEquals(history2.getExternalKey(), savedPayment.getExternalKey());
    Assert.assertTrue(history2.getUpdatedDate().compareTo(history2.getUpdatedDate()) >= 0);
    Assert.assertNull(history2.getStateName());
    Assert.assertNull(history2.getLastSuccessStateName());
    final List<PaymentTransactionModelDao> transactions = paymentDao.getTransactionsForPayment(savedPayment.getId(), internalCallContext);
    assertEquals(transactions.size(), 2);
    paymentDao.updatePaymentAndTransactionOnCompletion(accountId, savedTransactionModelDao2.getAttemptId(), savedPayment.getId(), savedTransactionModelDao2.getTransactionType(), "AUTH_ABORTED", "AUTH_SUCCESS", transactionModelDao2.getId(), TransactionStatus.SUCCESS, BigDecimal.ONE, Currency.USD, null, "nothing", true, internalCallContext);
    final PaymentModelDao savedPayment4 = paymentDao.getPayment(savedPayment.getId(), internalCallContext);
    assertEquals(savedPayment4.getId(), paymentModelDao.getId());
    assertEquals(savedPayment4.getAccountId(), paymentModelDao.getAccountId());
    assertEquals(savedPayment4.getExternalKey(), paymentModelDao.getExternalKey());
    assertEquals(savedPayment4.getPaymentMethodId(), paymentModelDao.getPaymentMethodId());
    assertEquals(savedPayment4.getStateName(), "AUTH_ABORTED");
    assertEquals(savedPayment4.getLastSuccessStateName(), "AUTH_SUCCESS");
    auditLogsWithHistory = paymentDao.getPaymentAuditLogsWithHistoryForId(savedPayment.getId(), AuditLevel.FULL, internalCallContext);
    Assert.assertEquals(auditLogsWithHistory.size(), 3);
    history1 = (PaymentModelDao) auditLogsWithHistory.get(0).getEntity();
    history2 = (PaymentModelDao) auditLogsWithHistory.get(1).getEntity();
    final PaymentModelDao history3 = (PaymentModelDao) auditLogsWithHistory.get(2).getEntity();
    Assert.assertEquals(auditLogsWithHistory.get(0).getChangeType(), ChangeType.INSERT);
    Assert.assertEquals(history1.getAccountRecordId(), savedPayment.getAccountRecordId());
    Assert.assertEquals(history1.getTenantRecordId(), savedPayment.getTenantRecordId());
    Assert.assertEquals(history1.getExternalKey(), savedPayment.getExternalKey());
    Assert.assertEquals(auditLogsWithHistory.get(1).getChangeType(), ChangeType.UPDATE);
    Assert.assertEquals(history2.getAccountRecordId(), savedPayment.getAccountRecordId());
    Assert.assertEquals(history2.getTenantRecordId(), savedPayment.getTenantRecordId());
    Assert.assertEquals(history2.getExternalKey(), savedPayment.getExternalKey());
    Assert.assertTrue(auditLogsWithHistory.get(1).getEntity().getUpdatedDate().compareTo(auditLogsWithHistory.get(0).getEntity().getUpdatedDate()) >= 0);
    Assert.assertEquals(auditLogsWithHistory.get(2).getChangeType(), ChangeType.UPDATE);
    Assert.assertEquals(history3.getAccountRecordId(), savedPayment.getAccountRecordId());
    Assert.assertEquals(history3.getTenantRecordId(), savedPayment.getTenantRecordId());
    Assert.assertEquals(history3.getExternalKey(), savedPayment.getExternalKey());
    Assert.assertTrue(history3.getUpdatedDate().compareTo(history3.getUpdatedDate()) >= 0);
    Assert.assertEquals(history3.getStateName(), savedPayment4.getStateName());
    Assert.assertEquals(history3.getLastSuccessStateName(), savedPayment4.getLastSuccessStateName());
    final PaymentTransactionModelDao savedTransactionModelDao4 = paymentDao.getPaymentTransaction(savedTransactionModelDao2.getId(), internalCallContext);
    assertEquals(savedTransactionModelDao4.getTransactionExternalKey(), transactionExternalKey2);
    assertEquals(savedTransactionModelDao4.getPaymentId(), paymentModelDao.getId());
    assertEquals(savedTransactionModelDao4.getTransactionType(), TransactionType.AUTHORIZE);
    assertEquals(savedTransactionModelDao4.getTransactionStatus(), TransactionStatus.SUCCESS);
    assertEquals(savedTransactionModelDao4.getAmount().compareTo(BigDecimal.TEN), 0);
    assertEquals(savedTransactionModelDao4.getCurrency(), Currency.AED);
    assertEquals(savedTransactionModelDao4.getProcessedAmount().compareTo(BigDecimal.ONE), 0);
    assertEquals(savedTransactionModelDao4.getProcessedCurrency(), Currency.USD);
    assertNull(savedTransactionModelDao4.getGatewayErrorCode());
    assertEquals(savedTransactionModelDao4.getGatewayErrorMsg(), "nothing");
    paymentDao.updatePaymentAndTransactionOnCompletion(accountId, savedTransactionModelDao2.getAttemptId(), savedPayment.getId(), savedTransactionModelDao2.getTransactionType(), "AUTH_ABORTED", null, transactionModelDao2.getId(), TransactionStatus.SUCCESS, BigDecimal.ONE, Currency.USD, null, "nothing", true, internalCallContext);
    final PaymentModelDao savedPayment4Again = paymentDao.getPayment(savedPayment.getId(), internalCallContext);
    assertEquals(savedPayment4Again.getId(), paymentModelDao.getId());
    assertEquals(savedPayment4Again.getStateName(), "AUTH_ABORTED");
    assertNull(savedPayment4Again.getLastSuccessStateName());
    paymentDao.updatePaymentAndTransactionOnCompletion(accountId, savedTransactionModelDao2.getAttemptId(), savedPayment.getId(), savedTransactionModelDao2.getTransactionType(), "AUTH_ABORTED", "AUTH_SUCCESS", transactionModelDao2.getId(), TransactionStatus.SUCCESS, BigDecimal.ONE, Currency.USD, null, "nothing", true, internalCallContext);
    final PaymentModelDao savedPayment4Final = paymentDao.getPayment(savedPayment.getId(), internalCallContext);
    assertEquals(savedPayment4Final.getId(), paymentModelDao.getId());
    assertEquals(savedPayment4Final.getStateName(), "AUTH_ABORTED");
    assertEquals(savedPayment4Final.getLastSuccessStateName(), "AUTH_SUCCESS");
    final List<PaymentModelDao> payments = paymentDao.getPaymentsForAccount(accountId, internalCallContext);
    assertEquals(payments.size(), 1);
    final List<PaymentTransactionModelDao> transactions2 = paymentDao.getTransactionsForAccount(accountId, internalCallContext);
    assertEquals(transactions2.size(), 2);
}
Also used : UUID(java.util.UUID) AuditLogWithHistory(org.killbill.billing.util.audit.AuditLogWithHistory) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

AuditLogWithHistory (org.killbill.billing.util.audit.AuditLogWithHistory)23 ApiOperation (io.swagger.annotations.ApiOperation)16 ApiResponses (io.swagger.annotations.ApiResponses)16 GET (javax.ws.rs.GET)16 Path (javax.ws.rs.Path)16 Produces (javax.ws.rs.Produces)16 TenantContext (org.killbill.billing.util.callcontext.TenantContext)16 TimedResource (org.killbill.commons.metrics.TimedResource)16 Test (org.testng.annotations.Test)7 UUID (java.util.UUID)3 BigDecimal (java.math.BigDecimal)2 DateTime (org.joda.time.DateTime)2 Payment (org.killbill.billing.payment.api.Payment)2 Account (org.killbill.billing.account.api.Account)1 AccountData (org.killbill.billing.account.api.AccountData)1 DefaultAccount (org.killbill.billing.account.api.DefaultAccount)1 DefaultMutableAccountData (org.killbill.billing.account.api.DefaultMutableAccountData)1 MutableAccountData (org.killbill.billing.account.api.MutableAccountData)1 BlockingState (org.killbill.billing.entitlement.api.BlockingState)1 DefaultBlockingState (org.killbill.billing.junction.DefaultBlockingState)1