Search in sources :

Example 1 with TagDefinitionInternalEvent

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);
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) TagDefinitionInternalEvent(org.killbill.billing.events.TagDefinitionInternalEvent) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UUID(java.util.UUID) UserTagDefinitionCreationInternalEvent(org.killbill.billing.events.UserTagDefinitionCreationInternalEvent) Test(org.testng.annotations.Test)

Example 2 with TagDefinitionInternalEvent

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);
    }
}
Also used : TagDefinitionInternalEvent(org.killbill.billing.events.TagDefinitionInternalEvent) PersistentBus(org.killbill.bus.api.PersistentBus)

Example 3 with TagDefinitionInternalEvent

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);
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) TagDefinitionInternalEvent(org.killbill.billing.events.TagDefinitionInternalEvent) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UUID(java.util.UUID) ControlTagDefinitionDeletionInternalEvent(org.killbill.billing.events.ControlTagDefinitionDeletionInternalEvent) Test(org.testng.annotations.Test)

Example 4 with TagDefinitionInternalEvent

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);
}
Also used : TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) TagDefinitionInternalEvent(org.killbill.billing.events.TagDefinitionInternalEvent) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UUID(java.util.UUID) UserTagDefinitionDeletionInternalEvent(org.killbill.billing.events.UserTagDefinitionDeletionInternalEvent) Test(org.testng.annotations.Test)

Example 5 with TagDefinitionInternalEvent

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);
}
Also used : ControlTagDefinitionCreationInternalEvent(org.killbill.billing.events.ControlTagDefinitionCreationInternalEvent) TagDefinition(org.killbill.billing.util.tag.TagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) DefaultTagDefinition(org.killbill.billing.util.tag.DefaultTagDefinition) TagDefinitionInternalEvent(org.killbill.billing.events.TagDefinitionInternalEvent) TagDefinitionModelDao(org.killbill.billing.util.tag.dao.TagDefinitionModelDao) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Aggregations

TagDefinitionInternalEvent (org.killbill.billing.events.TagDefinitionInternalEvent)5 UUID (java.util.UUID)4 DefaultTagDefinition (org.killbill.billing.util.tag.DefaultTagDefinition)4 TagDefinition (org.killbill.billing.util.tag.TagDefinition)4 TagDefinitionModelDao (org.killbill.billing.util.tag.dao.TagDefinitionModelDao)4 Test (org.testng.annotations.Test)4 ControlTagDefinitionCreationInternalEvent (org.killbill.billing.events.ControlTagDefinitionCreationInternalEvent)1 ControlTagDefinitionDeletionInternalEvent (org.killbill.billing.events.ControlTagDefinitionDeletionInternalEvent)1 UserTagDefinitionCreationInternalEvent (org.killbill.billing.events.UserTagDefinitionCreationInternalEvent)1 UserTagDefinitionDeletionInternalEvent (org.killbill.billing.events.UserTagDefinitionDeletionInternalEvent)1 PersistentBus (org.killbill.bus.api.PersistentBus)1