use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testCustomFieldCreation.
@Test(groups = "fast")
public void testCustomFieldCreation() throws Exception {
CustomFieldCreationEvent event = mock(CustomFieldCreationEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.CUSTOM_FIELD_CREATION);
when(event.getCustomFieldId()).thenReturn(OBJECT_ID);
when(internalCallContextFactory.getAccountId(OBJECT_ID, ObjectType.CUSTOM_FIELD, tenantContext)).thenReturn(ACCOUNT_ID);
ArgumentCaptor<BusEvent> eventCaptor = ArgumentCaptor.forClass(BusEvent.class);
beatrixListener.handleAllInternalKillbillEvents(event);
verify(externalBus).post(eventCaptor.capture());
DefaultBusExternalEvent postedEvent = (DefaultBusExternalEvent) eventCaptor.getValue();
assertEquals(postedEvent.getObjectId(), OBJECT_ID);
assertEquals(postedEvent.getObjectType(), ObjectType.CUSTOM_FIELD);
assertEquals(postedEvent.getEventType(), ExtBusEventType.CUSTOM_FIELD_CREATION);
assertNull(postedEvent.getMetaData());
assertCommonFieldsWithAccountId(postedEvent);
}
use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testAccountChange.
@Test(groups = "fast")
public void testAccountChange() throws Exception {
AccountChangeInternalEvent event = mock(AccountChangeInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.ACCOUNT_CHANGE);
when(event.getAccountId()).thenReturn(ACCOUNT_ID);
when(internalCallContextFactory.getAccountId(ACCOUNT_ID, ObjectType.ACCOUNT, tenantContext)).thenReturn(ACCOUNT_ID);
ArgumentCaptor<BusEvent> eventCaptor = ArgumentCaptor.forClass(BusEvent.class);
beatrixListener.handleAllInternalKillbillEvents(event);
verify(externalBus).post(eventCaptor.capture());
DefaultBusExternalEvent postedEvent = (DefaultBusExternalEvent) eventCaptor.getValue();
assertEquals(postedEvent.getObjectId(), ACCOUNT_ID);
assertEquals(postedEvent.getObjectType(), ObjectType.ACCOUNT);
assertEquals(postedEvent.getEventType(), ExtBusEventType.ACCOUNT_CHANGE);
assertNull(postedEvent.getMetaData());
assertCommonFieldsWithAccountId(postedEvent);
}
use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testInvoicePaymentInfo.
@Test(groups = "fast")
public void testInvoicePaymentInfo() throws Exception {
InvoicePaymentInfoInternalEvent event = mock(InvoicePaymentInfoInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.INVOICE_PAYMENT_INFO);
when(event.getInvoiceId()).thenReturn(OBJECT_ID);
provideCommonInvoicePaymentInfo(event);
ArgumentCaptor<InvoicePaymentMetadata> metadataCaptor = ArgumentCaptor.forClass(InvoicePaymentMetadata.class);
when(objectMapper.writeValueAsString(metadataCaptor.capture())).thenReturn(METADATA);
when(internalCallContextFactory.getAccountId(OBJECT_ID, ObjectType.INVOICE, tenantContext)).thenReturn(ACCOUNT_ID);
ArgumentCaptor<BusEvent> eventCaptor = ArgumentCaptor.forClass(BusEvent.class);
beatrixListener.handleAllInternalKillbillEvents(event);
verify(externalBus).post(eventCaptor.capture());
DefaultBusExternalEvent postedEvent = (DefaultBusExternalEvent) eventCaptor.getValue();
assertEquals(postedEvent.getObjectId(), OBJECT_ID);
assertEquals(postedEvent.getObjectType(), ObjectType.INVOICE);
assertEquals(postedEvent.getEventType(), ExtBusEventType.INVOICE_PAYMENT_SUCCESS);
assertEquals(postedEvent.getMetaData(), METADATA);
assertCommonFieldsWithAccountId(postedEvent);
InvoicePaymentMetadata invoicePaymentMetadata = metadataCaptor.getValue();
assertInvoicePaymentMetadataFields(invoicePaymentMetadata);
}
use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testControlTagDeletion.
@Test(groups = "fast")
public void testControlTagDeletion() throws Exception {
ControlTagDeletionInternalEvent event = mock(ControlTagDeletionInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.CONTROL_TAG_DELETION);
when(event.getTagId()).thenReturn(OBJECT_ID);
when(event.getTagDefinition()).thenReturn(new DefaultTagDefinition("MY_TAG", "", false));
when(internalCallContextFactory.getAccountId(OBJECT_ID, ObjectType.TAG, tenantContext)).thenReturn(ACCOUNT_ID);
ArgumentCaptor<BusEvent> eventCaptor = ArgumentCaptor.forClass(BusEvent.class);
beatrixListener.handleAllInternalKillbillEvents(event);
verify(externalBus).post(eventCaptor.capture());
DefaultBusExternalEvent postedEvent = (DefaultBusExternalEvent) eventCaptor.getValue();
assertEquals(postedEvent.getObjectId(), OBJECT_ID);
assertEquals(postedEvent.getObjectType(), ObjectType.TAG);
assertEquals(postedEvent.getEventType(), ExtBusEventType.TAG_DELETION);
assertEquals(postedEvent.getMetaData(), "MY_TAG");
assertCommonFieldsWithAccountId(postedEvent);
}
use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testTenantConfigDeletion.
@Test(groups = "fast")
public void testTenantConfigDeletion() throws Exception {
TenantConfigDeletionInternalEvent event = mock(TenantConfigDeletionInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.TENANT_CONFIG_DELETION);
when(event.getKey()).thenReturn(METADATA);
ArgumentCaptor<BusEvent> eventCaptor = ArgumentCaptor.forClass(BusEvent.class);
beatrixListener.handleAllInternalKillbillEvents(event);
verify(externalBus).post(eventCaptor.capture());
DefaultBusExternalEvent postedEvent = (DefaultBusExternalEvent) eventCaptor.getValue();
assertNull(postedEvent.getObjectId());
assertEquals(postedEvent.getObjectType(), ObjectType.TENANT_KVS);
assertEquals(postedEvent.getEventType(), ExtBusEventType.TENANT_CONFIG_DELETION);
assertEquals(postedEvent.getMetaData(), METADATA);
assertCommonFieldsWithNoAccountId(postedEvent);
}
Aggregations