Search in sources :

Example 81 with CallContext

use of org.killbill.billing.util.callcontext.CallContext in project killbill by killbill.

the class TestDefaultAuditLog method testEquals.

@Test(groups = "fast")
public void testEquals() throws Exception {
    final TableName tableName = TableName.ACCOUNT_EMAIL_HISTORY;
    final long recordId = Long.MAX_VALUE;
    final ChangeType changeType = ChangeType.DELETE;
    final EntityAudit entityAudit = new EntityAudit(tableName, recordId, changeType, null);
    final UUID tenantId = UUID.randomUUID();
    final String userName = UUID.randomUUID().toString();
    final CallOrigin callOrigin = CallOrigin.EXTERNAL;
    final UserType userType = UserType.CUSTOMER;
    final UUID userToken = UUID.randomUUID();
    final ClockMock clock = new ClockMock();
    final CallContext callContext = new DefaultCallContext(tenantId, userName, callOrigin, userType, userToken, clock);
    final AuditLogModelDao auditLog = new AuditLogModelDao(entityAudit, callContext);
    Assert.assertEquals(auditLog, auditLog);
    final AuditLogModelDao sameAuditLog = new AuditLogModelDao(entityAudit, callContext);
    Assert.assertEquals(sameAuditLog, auditLog);
    clock.addMonths(1);
    final CallContext otherCallContext = new DefaultCallContext(tenantId, userName, callOrigin, userType, userToken, clock);
    final AuditLogModelDao otherAuditLog = new AuditLogModelDao(entityAudit, otherCallContext);
    Assert.assertNotEquals(otherAuditLog, auditLog);
}
Also used : EntityAudit(org.killbill.billing.util.dao.EntityAudit) TableName(org.killbill.billing.util.dao.TableName) DefaultCallContext(org.killbill.billing.callcontext.DefaultCallContext) AuditLogModelDao(org.killbill.billing.util.audit.dao.AuditLogModelDao) CallOrigin(org.killbill.billing.util.callcontext.CallOrigin) ClockMock(org.killbill.clock.ClockMock) UUID(java.util.UUID) UserType(org.killbill.billing.util.callcontext.UserType) CallContext(org.killbill.billing.util.callcontext.CallContext) DefaultCallContext(org.killbill.billing.callcontext.DefaultCallContext) Test(org.testng.annotations.Test)

Example 82 with CallContext

use of org.killbill.billing.util.callcontext.CallContext in project killbill by killbill.

the class TestPublicBus method testTenantKVChange.

@Test(groups = "slow")
public void testTenantKVChange() throws Exception {
    final TenantData tenantData = new DefaultTenant(null, clock.getUTCNow(), clock.getUTCNow(), "MY_TENANT", "key", "s3Cr3T");
    final CallContext contextWithNoTenant = new DefaultCallContext(null, "loulou", CallOrigin.EXTERNAL, UserType.ADMIN, "no reason", "hum", UUID.randomUUID(), clock);
    final Tenant tenant = tenantUserApi.createTenant(tenantData, contextWithNoTenant);
    final CallContext contextWithTenant = new DefaultCallContext(tenant.getId(), "loulou", CallOrigin.EXTERNAL, UserType.ADMIN, "no reason", "hum", UUID.randomUUID(), clock);
    final String tenantKey = TenantKey.PLUGIN_CONFIG_ + "FOO";
    tenantUserApi.addTenantKeyValue(tenantKey, "FOO", contextWithTenant);
    await().atMost(10, SECONDS).until(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            // expecting  TENANT_CONFIG_CHANGE
            return externalBusCount.get() == 1;
        }
    });
}
Also used : DefaultTenant(org.killbill.billing.tenant.api.DefaultTenant) Tenant(org.killbill.billing.tenant.api.Tenant) DefaultTenant(org.killbill.billing.tenant.api.DefaultTenant) DefaultCallContext(org.killbill.billing.callcontext.DefaultCallContext) TenantData(org.killbill.billing.tenant.api.TenantData) CallContext(org.killbill.billing.util.callcontext.CallContext) DefaultCallContext(org.killbill.billing.callcontext.DefaultCallContext) JsonParseException(com.fasterxml.jackson.core.JsonParseException) IOException(java.io.IOException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Test(org.testng.annotations.Test)

Aggregations

CallContext (org.killbill.billing.util.callcontext.CallContext)82 ApiOperation (io.swagger.annotations.ApiOperation)51 ApiResponses (io.swagger.annotations.ApiResponses)51 Produces (javax.ws.rs.Produces)48 TimedResource (org.killbill.commons.metrics.TimedResource)48 Consumes (javax.ws.rs.Consumes)47 Path (javax.ws.rs.Path)43 UUID (java.util.UUID)40 Account (org.killbill.billing.account.api.Account)38 POST (javax.ws.rs.POST)35 PluginProperty (org.killbill.billing.payment.api.PluginProperty)29 LocalDate (org.joda.time.LocalDate)16 Payment (org.killbill.billing.payment.api.Payment)15 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)14 DefaultCallContext (org.killbill.billing.callcontext.DefaultCallContext)11 Invoice (org.killbill.billing.invoice.api.Invoice)10 PaymentOptions (org.killbill.billing.payment.api.PaymentOptions)10 PUT (javax.ws.rs.PUT)9 Entitlement (org.killbill.billing.entitlement.api.Entitlement)9 DELETE (javax.ws.rs.DELETE)7