use of org.killbill.billing.ObjectType in project killbill by killbill.
the class TestDefaultControlTagDeletionEvent method testSerialization.
@Test(groups = "fast")
public void testSerialization() throws Exception {
final ObjectMapper objectMapper = new ObjectMapper();
final UUID tagId = UUID.randomUUID();
final UUID objectId = UUID.randomUUID();
final ObjectType objectType = ObjectType.ACCOUNT_EMAIL;
final UUID tagDefinitionId = UUID.randomUUID();
final String tagDefinitionName = UUID.randomUUID().toString();
final String tagDefinitionDescription = UUID.randomUUID().toString();
final boolean controlTag = false;
final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
final UUID userToken = UUID.randomUUID();
final DefaultControlTagDeletionEvent event = new DefaultControlTagDeletionEvent(tagId, objectId, objectType, tagDefinition, 1L, 2L, UUID.randomUUID());
final String json = objectMapper.writeValueAsString(event);
final DefaultControlTagDeletionEvent fromJson = objectMapper.readValue(json, DefaultControlTagDeletionEvent.class);
Assert.assertEquals(fromJson, event);
}
use of org.killbill.billing.ObjectType in project killbill by killbill.
the class TestFieldStore method testCreateCustomField.
@Test(groups = "slow")
public void testCreateCustomField() throws CustomFieldApiException {
final UUID id = UUID.randomUUID();
final ObjectType objectType = ObjectType.ACCOUNT;
String fieldName = "TestField1";
String fieldValue = "Kitty Hawk";
eventsListener.pushExpectedEvent(NextEvent.CUSTOM_FIELD);
customFieldDao.create(new CustomFieldModelDao(internalCallContext.getCreatedDate(), fieldName, fieldValue, id, objectType), internalCallContext);
assertListenerStatus();
fieldName = "TestField2";
fieldValue = "Cape Canaveral";
eventsListener.pushExpectedEvent(NextEvent.CUSTOM_FIELD);
customFieldDao.create(new CustomFieldModelDao(internalCallContext.getCreatedDate(), fieldName, fieldValue, id, objectType), internalCallContext);
assertListenerStatus();
}
use of org.killbill.billing.ObjectType in project killbill by killbill.
the class EhCacheCatalogCache method initializeCacheLoaderArgument.
//
// Build the LoaderCallback that is required to build the catalog from the xml from a module that knows
// nothing about catalog.
//
// This is a contract between the TenantCatalogCacheLoader and the EhCacheCatalogCache
private CacheLoaderArgument initializeCacheLoaderArgument(final boolean filterTemplateCatalog) {
final LoaderCallback loaderCallback = new LoaderCallback() {
@Override
public Object loadCatalog(final List<String> catalogXMLs, final Long tenantRecordId) throws CatalogApiException {
return loader.load(catalogXMLs, filterTemplateCatalog, tenantRecordId);
}
};
final Object[] args = new Object[1];
args[0] = loaderCallback;
final ObjectType irrelevant = null;
final InternalTenantContext notUsed = null;
return new CacheLoaderArgument(irrelevant, args, notUsed);
}
use of org.killbill.billing.ObjectType in project killbill by killbill.
the class EntitySqlDaoWrapperInvocationHandler method getObjectType.
/**
* Extract object from sqlDaoClass by looking at first parameter type (EntityModelDao) and
* constructing an empty object so we can call the getObjectType method on it.
*
* @return the objectType associated to that handler
* @throws InstantiationException
* @throws IllegalAccessException
* @throws ClassNotFoundException
*/
private ObjectType getObjectType() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
int foundIndexForEntitySqlDao = -1;
// If the sqlDaoClass implements multiple interfaces, first figure out which one is the EntitySqlDao
for (int i = 0; i < sqlDaoClass.getGenericInterfaces().length; i++) {
final Type type = sqlDaoClass.getGenericInterfaces()[0];
if (!(type instanceof java.lang.reflect.ParameterizedType)) {
// AuditSqlDao for example won't extend EntitySqlDao
return null;
}
if (EntitySqlDao.class.getName().equals(((Class) ((java.lang.reflect.ParameterizedType) type).getRawType()).getName())) {
foundIndexForEntitySqlDao = i;
break;
}
}
// Find out from the parameters of the EntitySqlDao which one is the EntityModelDao, and extract his (sub)type to finally return the ObjectType
if (foundIndexForEntitySqlDao >= 0) {
final Type[] types = ((java.lang.reflect.ParameterizedType) sqlDaoClass.getGenericInterfaces()[foundIndexForEntitySqlDao]).getActualTypeArguments();
int foundIndexForEntityModelDao = -1;
for (int i = 0; i < types.length; i++) {
final Class clz = ((Class) types[i]);
if (EntityModelDao.class.getName().equals(((Class) ((java.lang.reflect.ParameterizedType) clz.getGenericInterfaces()[0]).getRawType()).getName())) {
foundIndexForEntityModelDao = i;
break;
}
}
if (foundIndexForEntityModelDao >= 0) {
final String modelClassName = ((Class) types[foundIndexForEntityModelDao]).getName();
final Class<? extends EntityModelDao<?>> clz = (Class<? extends EntityModelDao<?>>) Class.forName(modelClassName);
final EntityModelDao<?> modelDao = (EntityModelDao<?>) clz.newInstance();
return modelDao.getTableName().getObjectType();
}
}
return null;
}
use of org.killbill.billing.ObjectType in project killbill by killbill.
the class BaseIdCacheLoader method load.
@Override
public Object load(final Object key, final Object argument) {
checkCacheLoaderStatus();
if (!(key instanceof String)) {
throw new IllegalArgumentException("Unexpected key type of " + key.getClass().getName());
}
if (!(argument instanceof CacheLoaderArgument)) {
throw new IllegalArgumentException("Unexpected key type of " + argument.getClass().getName());
}
final String rawKey;
if (getCacheType().isKeyPrefixedWithTableName()) {
final String[] parts = ((String) key).split(CacheControllerDispatcher.CACHE_KEY_SEPARATOR);
rawKey = parts[1];
} else {
rawKey = (String) key;
}
final ObjectType objectType = ((CacheLoaderArgument) argument).getObjectType();
final Handle handle = ((CacheLoaderArgument) argument).getHandle();
return doRetrieveOperation(rawKey, objectType, handle);
}
Aggregations