Search in sources :

Example 21 with AuditLogWithHistory

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

the class PaymentResource method getPaymentAuditLogsWithHistory.

@TimedResource
@GET
@Path("/{paymentId:" + UUID_PATTERN + "}/" + AUDIT_LOG_WITH_HISTORY)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve payment audit logs with history by id", response = AuditLogJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Account not found") })
public Response getPaymentAuditLogsWithHistory(@PathParam("paymentId") final UUID paymentId, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
    final TenantContext tenantContext = context.createTenantContextNoAccountId(request);
    final List<AuditLogWithHistory> auditLogWithHistory = paymentApi.getPaymentAuditLogsWithHistoryForId(paymentId, 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 22 with AuditLogWithHistory

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

the class PaymentMethodResource method getPaymentMethodAuditLogsWithHistory.

@TimedResource
@GET
@Path("/{paymentMethodId:" + UUID_PATTERN + "}/" + AUDIT_LOG_WITH_HISTORY)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve payment method audit logs with history by id", response = AuditLogJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Account not found") })
public Response getPaymentMethodAuditLogsWithHistory(@PathParam("paymentMethodId") final UUID paymentMethodId, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
    final TenantContext tenantContext = context.createTenantContextNoAccountId(request);
    final List<AuditLogWithHistory> auditLogWithHistory = paymentApi.getPaymentMethodAuditLogsWithHistoryForId(paymentMethodId, 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 23 with AuditLogWithHistory

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

the class TestPaymentMethodProcessorWithDB method testDeletePaymentMethod.

@Test(groups = "slow")
public void testDeletePaymentMethod() throws Exception {
    final Account account = testHelper.createTestAccount("foo@bar.com", true);
    final UUID paymentMethodId = paymentMethodProcessor.createOrGetExternalPaymentMethod("pmExternalKey", account, PLUGIN_PROPERTIES, callContext, internalCallContext);
    final PaymentMethodModelDao paymentMethodModelDao = paymentDao.getPaymentMethod(paymentMethodId, internalCallContext);
    List<AuditLogWithHistory> auditLogsWithHistory = paymentDao.getPaymentMethodAuditLogsWithHistoryForId(paymentMethodModelDao.getId(), AuditLevel.FULL, internalCallContext);
    Assert.assertEquals(auditLogsWithHistory.size(), 1);
    PaymentMethodModelDao history1 = (PaymentMethodModelDao) auditLogsWithHistory.get(0).getEntity();
    Assert.assertEquals(auditLogsWithHistory.get(0).getChangeType(), ChangeType.INSERT);
    Assert.assertEquals(history1.getAccountRecordId(), paymentMethodModelDao.getAccountRecordId());
    Assert.assertEquals(history1.getTenantRecordId(), paymentMethodModelDao.getTenantRecordId());
    Assert.assertEquals(history1.getExternalKey(), paymentMethodModelDao.getExternalKey());
    Assert.assertTrue(history1.isActive());
    paymentMethodProcessor.deletedPaymentMethod(account, paymentMethodId, true, true, ImmutableList.<PluginProperty>of(), callContext, internalCallContext);
    auditLogsWithHistory = paymentDao.getPaymentMethodAuditLogsWithHistoryForId(paymentMethodModelDao.getId(), AuditLevel.FULL, internalCallContext);
    Assert.assertEquals(auditLogsWithHistory.size(), 2);
    history1 = (PaymentMethodModelDao) auditLogsWithHistory.get(0).getEntity();
    PaymentMethodModelDao history2 = (PaymentMethodModelDao) auditLogsWithHistory.get(1).getEntity();
    Assert.assertEquals(auditLogsWithHistory.get(0).getChangeType(), ChangeType.INSERT);
    Assert.assertEquals(history1.getAccountRecordId(), paymentMethodModelDao.getAccountRecordId());
    Assert.assertEquals(history1.getTenantRecordId(), paymentMethodModelDao.getTenantRecordId());
    Assert.assertEquals(history1.getExternalKey(), paymentMethodModelDao.getExternalKey());
    Assert.assertTrue(history1.isActive());
    Assert.assertEquals(auditLogsWithHistory.get(1).getChangeType(), ChangeType.DELETE);
    Assert.assertEquals(history2.getAccountRecordId(), paymentMethodModelDao.getAccountRecordId());
    Assert.assertEquals(history2.getTenantRecordId(), paymentMethodModelDao.getTenantRecordId());
    Assert.assertEquals(history2.getExternalKey(), paymentMethodModelDao.getExternalKey());
    Assert.assertFalse(history2.isActive());
}
Also used : Account(org.killbill.billing.account.api.Account) PaymentMethodModelDao(org.killbill.billing.payment.dao.PaymentMethodModelDao) UUID(java.util.UUID) AuditLogWithHistory(org.killbill.billing.util.audit.AuditLogWithHistory) 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