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);
}
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);
}
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);
}
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) {
}
}
}
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);
}
Aggregations