Search in sources :

Example 16 with ObjectType

use of org.killbill.billing.ObjectType in project killbill by killbill.

the class DefaultAccountInternalApi method createBCDCacheLoaderArgument.

private CacheLoaderArgument createBCDCacheLoaderArgument(final InternalTenantContext context) {
    final AccountBCDCacheLoader.LoaderCallback loaderCallback = new AccountBCDCacheLoader.LoaderCallback() {

        @Override
        public Integer loadAccountBCD(final UUID accountId, final InternalTenantContext context) {
            Integer result = accountDao.getAccountBCD(accountId, context);
            if (result != null) {
                // If the value is 0, then account BCD was not set so we don't want to create a cache entry
                result = result.equals(DefaultMutableAccountData.DEFAULT_BILLING_CYCLE_DAY_LOCAL) ? null : result;
            }
            return result;
        }
    };
    final Object[] args = new Object[1];
    args[0] = loaderCallback;
    final ObjectType irrelevant = null;
    return new CacheLoaderArgument(irrelevant, args, context);
}
Also used : ObjectType(org.killbill.billing.ObjectType) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) AccountBCDCacheLoader(org.killbill.billing.util.cache.AccountBCDCacheLoader) UUID(java.util.UUID) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument)

Example 17 with ObjectType

use of org.killbill.billing.ObjectType in project killbill by killbill.

the class TestCustomFieldJson method testJson.

@Test(groups = "fast")
public void testJson() throws Exception {
    final UUID customFieldId = UUID.randomUUID();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.INVOICE;
    final String name = UUID.randomUUID().toString();
    final String value = UUID.randomUUID().toString();
    final CustomFieldJson customFieldJson = new CustomFieldJson(customFieldId, objectId, objectType, name, value, null);
    Assert.assertEquals(customFieldJson.getCustomFieldId(), customFieldId);
    Assert.assertEquals(customFieldJson.getObjectId(), objectId);
    Assert.assertEquals(customFieldJson.getObjectType(), objectType);
    Assert.assertEquals(customFieldJson.getName(), name);
    Assert.assertEquals(customFieldJson.getValue(), value);
    Assert.assertEquals(customFieldJson.getAuditLogs().size(), 0);
    final String asJson = mapper.writeValueAsString(customFieldJson);
    final CustomFieldJson fromJson = mapper.readValue(asJson, CustomFieldJson.class);
    Assert.assertEquals(fromJson, customFieldJson);
}
Also used : ObjectType(org.killbill.billing.ObjectType) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Example 18 with ObjectType

use of org.killbill.billing.ObjectType in project killbill by killbill.

the class TestAuditLogJson method testJson.

@Test(groups = "fast")
public void testJson() throws Exception {
    final String changeType = UUID.randomUUID().toString();
    final DateTime changeDate = clock.getUTCNow();
    final String changedBy = UUID.randomUUID().toString();
    final String reasonCode = UUID.randomUUID().toString();
    final String comments = UUID.randomUUID().toString();
    final String userToken = UUID.randomUUID().toString();
    final UUID objectId = UUID.randomUUID();
    final ObjectType objectType = ObjectType.BUNDLE;
    final AuditLogJson auditLogJson = new AuditLogJson(changeType, changeDate, objectType, objectId, changedBy, reasonCode, comments, userToken, null);
    Assert.assertEquals(auditLogJson.getChangeType(), changeType);
    Assert.assertEquals(auditLogJson.getChangeDate(), changeDate);
    Assert.assertEquals(auditLogJson.getChangedBy(), changedBy);
    Assert.assertEquals(auditLogJson.getReasonCode(), reasonCode);
    Assert.assertEquals(auditLogJson.getComments(), comments);
    Assert.assertEquals(auditLogJson.getUserToken(), userToken);
    Assert.assertEquals(auditLogJson.getObjectType(), objectType);
    Assert.assertEquals(auditLogJson.getObjectId(), objectId);
    final String asJson = mapper.writeValueAsString(auditLogJson);
    Assert.assertEquals(asJson, "{\"changeType\":\"" + auditLogJson.getChangeType() + "\"," + "\"changeDate\":\"" + auditLogJson.getChangeDate().toDateTimeISO().toString() + "\"," + "\"objectType\":\"" + auditLogJson.getObjectType().toString() + "\"," + "\"objectId\":\"" + auditLogJson.getObjectId().toString() + "\"," + "\"changedBy\":\"" + auditLogJson.getChangedBy() + "\"," + "\"reasonCode\":\"" + auditLogJson.getReasonCode() + "\"," + "\"comments\":\"" + auditLogJson.getComments() + "\"," + "\"userToken\":\"" + auditLogJson.getUserToken() + "\"," + "\"history\":" + auditLogJson.getHistory() + "}");
    final AuditLogJson fromJson = mapper.readValue(asJson, AuditLogJson.class);
    Assert.assertEquals(fromJson, auditLogJson);
}
Also used : ObjectType(org.killbill.billing.ObjectType) UUID(java.util.UUID) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 19 with ObjectType

use of org.killbill.billing.ObjectType in project killbill by killbill.

the class TestTag method testTagErrorHandling.

@Test(groups = "slow", description = "Cannot add badly formatted TagDefinition")
public void testTagErrorHandling() throws Exception {
    final TagDefinition[] tagDefinitions = { new TagDefinition(null, false, null, null, ImmutableList.<ObjectType>of(ObjectType.ACCOUNT), null), new TagDefinition(null, false, "something", null, ImmutableList.<ObjectType>of(ObjectType.INVOICE), null), new TagDefinition(null, false, null, "something", ImmutableList.<ObjectType>of(ObjectType.TRANSACTION), null) };
    for (final TagDefinition tagDefinition : tagDefinitions) {
        try {
            tagDefinitionApi.createTagDefinition(tagDefinition, requestOptions);
            fail();
        } catch (final KillBillClientException e) {
        }
    }
}
Also used : TagDefinition(org.killbill.billing.client.model.gen.TagDefinition) ObjectType(org.killbill.billing.ObjectType) KillBillClientException(org.killbill.billing.client.KillBillClientException) Test(org.testng.annotations.Test)

Example 20 with ObjectType

use of org.killbill.billing.ObjectType in project killbill by killbill.

the class CacheConfig method initializeCacheLoaderArgument.

private CacheLoaderArgument initializeCacheLoaderArgument() {
    final LoaderCallback loaderCallback = new LoaderCallback() {

        @Override
        public PerTenantConfig loadConfig(@Nullable final String inputJson) throws IOException {
            return inputJson != null ? objectMapper.readValue(inputJson, PerTenantConfig.class) : new PerTenantConfig();
        }
    };
    final Object[] args = new Object[1];
    args[0] = loaderCallback;
    final ObjectType irrelevant = null;
    final InternalTenantContext notUsed = null;
    return new CacheLoaderArgument(irrelevant, args, notUsed);
}
Also used : ObjectType(org.killbill.billing.ObjectType) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) LoaderCallback(org.killbill.billing.util.cache.TenantConfigCacheLoader.LoaderCallback) Nullable(javax.annotation.Nullable) CacheLoaderArgument(org.killbill.billing.util.cache.CacheLoaderArgument)

Aggregations

ObjectType (org.killbill.billing.ObjectType)41 UUID (java.util.UUID)27 Test (org.testng.annotations.Test)25 DefaultTagDefinition (org.killbill.billing.util.tag.DefaultTagDefinition)12 TagDefinition (org.killbill.billing.util.tag.TagDefinition)12 CacheLoaderArgument (org.killbill.billing.util.cache.CacheLoaderArgument)11 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)9 ObjectMapper (org.killbill.billing.util.jackson.ObjectMapper)6 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 TagInternalEvent (org.killbill.billing.events.TagInternalEvent)3 DescriptiveTag (org.killbill.billing.util.tag.DescriptiveTag)3 TagDefinitionModelDao (org.killbill.billing.util.tag.dao.TagDefinitionModelDao)3 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 DefaultPlan (org.killbill.billing.catalog.DefaultPlan)2 DefaultPlanPhasePriceOverride (org.killbill.billing.catalog.DefaultPlanPhasePriceOverride)2 PlanPhasePriceOverride (org.killbill.billing.catalog.api.PlanPhasePriceOverride)2 ControlTagCreationInternalEvent (org.killbill.billing.events.ControlTagCreationInternalEvent)2 ControlTagDeletionInternalEvent (org.killbill.billing.events.ControlTagDeletionInternalEvent)2