use of org.killbill.billing.util.tag.dao.TagModelDao in project killbill by killbill.
the class TestAccountDao method testTags.
@Test(groups = "slow", description = "Test Account DAO: tags")
public void testTags() throws TagApiException, TagDefinitionApiException {
final AccountModelDao account = createTestAccount();
final TagDefinitionModelDao tagDefinition = tagDefinitionDao.create(UUID.randomUUID().toString().substring(0, 4), UUID.randomUUID().toString(), internalCallContext);
final Tag tag = new DescriptiveTag(tagDefinition.getId(), ObjectType.ACCOUNT, account.getId(), internalCallContext.getCreatedDate());
tagDao.create(new TagModelDao(tag), internalCallContext);
final List<TagModelDao> tags = tagDao.getTagsForObject(account.getId(), ObjectType.ACCOUNT, false, internalCallContext);
Assert.assertEquals(tags.size(), 1);
Assert.assertEquals(tags.get(0).getTagDefinitionId(), tagDefinition.getId());
Assert.assertEquals(tags.get(0).getObjectId(), account.getId());
Assert.assertEquals(tags.get(0).getObjectType(), ObjectType.ACCOUNT);
}
use of org.killbill.billing.util.tag.dao.TagModelDao in project killbill by killbill.
the class TestTagStore method testDeleteTagBeforeDeleteTagDefinition.
@Test(groups = "slow")
public void testDeleteTagBeforeDeleteTagDefinition() throws TagDefinitionApiException, TagApiException {
final String definitionName = "TestTag1234567";
eventsListener.pushExpectedEvent(NextEvent.TAG_DEFINITION);
tagDefinitionDao.create(definitionName, "Some test tag", internalCallContext);
assertListenerStatus();
final TagDefinitionModelDao tagDefinition = tagDefinitionDao.getByName(definitionName, internalCallContext);
assertNotNull(tagDefinition);
final UUID objectId = UUID.randomUUID();
final Tag tag = new DescriptiveTag(tagDefinition.getId(), ObjectType.ACCOUNT, objectId, internalCallContext.getCreatedDate());
eventsListener.pushExpectedEvent(NextEvent.TAG);
tagDao.create(new TagModelDao(tag), internalCallContext);
assertListenerStatus();
eventsListener.pushExpectedEvent(NextEvent.TAG);
tagDao.deleteTag(objectId, ObjectType.ACCOUNT, tagDefinition.getId(), internalCallContext);
assertListenerStatus();
eventsListener.pushExpectedEvent(NextEvent.TAG_DEFINITION);
tagDefinitionDao.deleteById(tagDefinition.getId(), internalCallContext);
assertListenerStatus();
}
use of org.killbill.billing.util.tag.dao.TagModelDao in project killbill by killbill.
the class TestTagStore method testControlTagCreation.
@Test(groups = "slow")
public void testControlTagCreation() throws TagApiException {
final UUID accountId = UUID.randomUUID();
final ControlTag tag = new DefaultControlTag(ControlTagType.AUTO_INVOICING_OFF, ObjectType.ACCOUNT, accountId, clock.getUTCNow());
eventsListener.pushExpectedEvent(NextEvent.TAG);
tagDao.create(new TagModelDao(tag), internalCallContext);
assertListenerStatus();
final TagModelDao savedTag = tagDao.getById(tag.getId(), internalCallContext);
assertEquals(savedTag.getTagDefinitionId(), tag.getTagDefinitionId());
assertEquals(savedTag.getId(), tag.getId());
}
use of org.killbill.billing.util.tag.dao.TagModelDao in project killbill by killbill.
the class TestCache method testAllCachesAfterGetById.
@Test(groups = "slow")
public void testAllCachesAfterGetById() throws Exception {
this.transactionalSqlDao = new EntitySqlDaoTransactionalJdbiWrapper(dbi, clock, controlCacheDispatcher, nonEntityDao, internalCallContextFactory);
final TagModelDao tag = new TagModelDao(clock.getUTCNow(), UUID.randomUUID(), UUID.randomUUID(), ObjectType.TAG);
insertTag(tag);
// Verify we start with nothing in the cache
Assert.assertEquals(getCacheSize(CacheType.RECORD_ID), 0);
Assert.assertEquals(getCacheSize(CacheType.ACCOUNT_RECORD_ID), 0);
Assert.assertEquals(getCacheSize(CacheType.TENANT_RECORD_ID), 0);
Assert.assertEquals(getCacheSize(CacheType.OBJECT_ID), 0);
final TagModelDao result = getById(tag.getId());
Assert.assertEquals(getCacheSize(CacheType.RECORD_ID), 1);
Assert.assertEquals(getCacheSize(CacheType.ACCOUNT_RECORD_ID), 1);
Assert.assertEquals(getCacheSize(CacheType.TENANT_RECORD_ID), 1);
Assert.assertEquals(getCacheSize(CacheType.OBJECT_ID), 1);
final Long recordId = (Long) controlCacheDispatcher.getCacheController(CacheType.RECORD_ID).get(tag.getId().toString(), new CacheLoaderArgument(ObjectType.TAG));
Assert.assertEquals(recordId, result.getRecordId());
final Long tenantRecordId = (Long) controlCacheDispatcher.getCacheController(CacheType.TENANT_RECORD_ID).get(tag.getId().toString(), new CacheLoaderArgument(ObjectType.TAG));
Assert.assertEquals(tenantRecordId, result.getTenantRecordId());
final UUID objectId = (UUID) controlCacheDispatcher.getCacheController(CacheType.OBJECT_ID).get(TableName.TAG + CacheControllerDispatcher.CACHE_KEY_SEPARATOR + recordId, new CacheLoaderArgument(ObjectType.TAG));
Assert.assertEquals(objectId, result.getId());
final Long accountRecordId = (Long) controlCacheDispatcher.getCacheController(CacheType.ACCOUNT_RECORD_ID).get(tag.getId().toString(), new CacheLoaderArgument(ObjectType.TAG));
Assert.assertEquals(accountRecordId, result.getAccountRecordId());
}
use of org.killbill.billing.util.tag.dao.TagModelDao in project killbill by killbill.
the class TestDefaultAuditDao method addTag.
private void addTag() throws TagDefinitionApiException, TagApiException {
// Create a tag definition
eventsListener.pushExpectedEvent(NextEvent.TAG_DEFINITION);
final TagDefinitionModelDao tagDefinition = tagDefinitionDao.create(UUID.randomUUID().toString().substring(0, 5), UUID.randomUUID().toString().substring(0, 5), internalCallContext);
assertListenerStatus();
Assert.assertEquals(tagDefinitionDao.getById(tagDefinition.getId(), internalCallContext), tagDefinition);
// Create a tag
final UUID objectId = UUID.randomUUID();
final Tag theTag = new DescriptiveTag(tagDefinition.getId(), ObjectType.ACCOUNT, objectId, clock.getUTCNow());
eventsListener.pushExpectedEvent(NextEvent.TAG);
tagDao.create(new TagModelDao(theTag), internalCallContext);
assertListenerStatus();
final List<TagModelDao> tags = tagDao.getTagsForObject(objectId, ObjectType.ACCOUNT, false, internalCallContext);
Assert.assertEquals(tags.size(), 1);
tag = tags.get(0);
Assert.assertEquals(tag.getTagDefinitionId(), tagDefinition.getId());
}
Aggregations