use of org.killbill.billing.events.TagDefinitionInternalEvent in project killbill by killbill.
the class TestTagEventBuilder method testNewUserTagDefinitionCreationEvent.
@Test(groups = "fast")
public void testNewUserTagDefinitionCreationEvent() throws Exception {
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 = internalCallContext.getUserToken();
final TagEventBuilder tagEventBuilder = new TagEventBuilder();
final TagDefinitionInternalEvent event = tagEventBuilder.newUserTagDefinitionCreationEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
Assert.assertTrue(event instanceof UserTagDefinitionCreationInternalEvent);
Assert.assertEquals(event, new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
Assert.assertTrue(event.equals(new DefaultUserTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
use of org.killbill.billing.events.TagDefinitionInternalEvent in project killbill by killbill.
the class DefaultTagDefinitionDao method postBusEventFromTransaction.
protected void postBusEventFromTransaction(final TagDefinitionModelDao tagDefinition, final TagDefinitionModelDao savedTagDefinition, final ChangeType changeType, final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InternalCallContext context) throws BillingExceptionBase {
final TagDefinitionInternalEvent tagDefinitionEvent;
final boolean isControlTag = TagModelDaoHelper.isControlTag(tagDefinition.getName());
switch(changeType) {
case INSERT:
tagDefinitionEvent = (isControlTag) ? tagEventBuilder.newControlTagDefinitionCreationEvent(tagDefinition.getId(), tagDefinition, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()) : tagEventBuilder.newUserTagDefinitionCreationEvent(tagDefinition.getId(), tagDefinition, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
break;
case DELETE:
tagDefinitionEvent = (isControlTag) ? tagEventBuilder.newControlTagDefinitionDeletionEvent(tagDefinition.getId(), tagDefinition, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()) : tagEventBuilder.newUserTagDefinitionDeletionEvent(tagDefinition.getId(), tagDefinition, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
break;
default:
return;
}
try {
bus.postFromTransaction(tagDefinitionEvent, entitySqlDaoWrapperFactory.getHandle().getConnection());
} catch (final PersistentBus.EventBusException e) {
log.warn("Failed to post tag definition event for tagDefinitionId='{}'", tagDefinition.getId().toString(), e);
}
}
use of org.killbill.billing.events.TagDefinitionInternalEvent in project killbill by killbill.
the class TestTagEventBuilder method testNewControlTagDefinitionDeletionEvent.
@Test(groups = "fast")
public void testNewControlTagDefinitionDeletionEvent() throws Exception {
final UUID tagDefinitionId = ControlTagType.AUTO_PAY_OFF.getId();
final String tagDefinitionName = UUID.randomUUID().toString();
final String tagDefinitionDescription = UUID.randomUUID().toString();
final boolean controlTag = true;
final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
final UUID userToken = internalCallContext.getUserToken();
final TagEventBuilder tagEventBuilder = new TagEventBuilder();
final TagDefinitionInternalEvent event = tagEventBuilder.newControlTagDefinitionDeletionEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
Assert.assertTrue(event instanceof ControlTagDefinitionDeletionInternalEvent);
Assert.assertEquals(event, new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
Assert.assertTrue(event.equals(new DefaultControlTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
use of org.killbill.billing.events.TagDefinitionInternalEvent in project killbill by killbill.
the class TestTagEventBuilder method testNewUserTagDefinitionDeletionEvent.
@Test(groups = "fast")
public void testNewUserTagDefinitionDeletionEvent() throws Exception {
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 = internalCallContext.getUserToken();
final TagEventBuilder tagEventBuilder = new TagEventBuilder();
final TagDefinitionInternalEvent event = tagEventBuilder.newUserTagDefinitionDeletionEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
Assert.assertTrue(event instanceof UserTagDefinitionDeletionInternalEvent);
Assert.assertEquals(event, new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
Assert.assertTrue(event.equals(new DefaultUserTagDefinitionDeletionEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
use of org.killbill.billing.events.TagDefinitionInternalEvent in project killbill by killbill.
the class TestTagEventBuilder method testNewControlTagDefinitionCreationEvent.
@Test(groups = "fast")
public void testNewControlTagDefinitionCreationEvent() throws Exception {
final UUID tagDefinitionId = ControlTagType.AUTO_PAY_OFF.getId();
final String tagDefinitionName = UUID.randomUUID().toString();
final String tagDefinitionDescription = UUID.randomUUID().toString();
final boolean controlTag = true;
final TagDefinition tagDefinition = new DefaultTagDefinition(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, controlTag);
final UUID userToken = internalCallContext.getUserToken();
final TagEventBuilder tagEventBuilder = new TagEventBuilder();
final TagDefinitionInternalEvent event = tagEventBuilder.newControlTagDefinitionCreationEvent(tagDefinitionId, new TagDefinitionModelDao(tagDefinition), 1L, 2L, UUID.randomUUID());
Assert.assertTrue(event instanceof ControlTagDefinitionCreationInternalEvent);
Assert.assertEquals(event, new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID()));
Assert.assertTrue(event.equals(new DefaultControlTagDefinitionCreationEvent(tagDefinitionId, tagDefinition, 1L, 2L, UUID.randomUUID())));
verifyTagDefinitionEvent(tagDefinitionId, tagDefinitionName, tagDefinitionDescription, tagDefinition, userToken, event);
}
Aggregations