use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testInvoiceNotification.
@Test(groups = "fast")
public void testInvoiceNotification() throws Exception {
InvoiceNotificationInternalEvent event = mock(InvoiceNotificationInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.INVOICE_NOTIFICATION);
when(event.getAccountId()).thenReturn(ACCOUNT_ID);
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.INVOICE);
assertEquals(postedEvent.getEventType(), ExtBusEventType.INVOICE_NOTIFICATION);
assertNull(postedEvent.getMetaData());
assertCommonFieldsWithAccountId(postedEvent);
}
use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testControlTagCreation.
@Test(groups = "fast")
public void testControlTagCreation() throws Exception {
ControlTagCreationInternalEvent event = mock(ControlTagCreationInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.CONTROL_TAG_CREATION);
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_CREATION);
assertEquals(postedEvent.getMetaData(), "MY_TAG");
assertCommonFieldsWithAccountId(postedEvent);
}
use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testUserTagDeletion.
@Test(groups = "fast")
public void testUserTagDeletion() throws Exception {
UserTagDeletionInternalEvent event = mock(UserTagDeletionInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.USER_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 testCustomFieldDeletion.
@Test(groups = "fast")
public void testCustomFieldDeletion() throws Exception {
CustomFieldDeletionEvent event = mock(CustomFieldDeletionEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.CUSTOM_FIELD_DELETION);
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_DELETION);
assertNull(postedEvent.getMetaData());
assertCommonFieldsWithAccountId(postedEvent);
}
use of org.killbill.bus.api.BusEvent in project killbill by killbill.
the class TestBeatrixListener method testPaymentPluginError.
@Test(groups = "fast")
public void testPaymentPluginError() throws Exception {
PaymentPluginErrorInternalEvent event = mock(PaymentPluginErrorInternalEvent.class);
provideCommonBusEventInfo(event);
when(event.getBusEventType()).thenReturn(BusInternalEventType.PAYMENT_PLUGIN_ERROR);
when(event.getPaymentId()).thenReturn(OBJECT_ID);
provideCommonPaymentInfo(event);
ArgumentCaptor<PaymentMetadata> metadataCaptor = ArgumentCaptor.forClass(PaymentMetadata.class);
when(objectMapper.writeValueAsString(metadataCaptor.capture())).thenReturn(METADATA);
when(internalCallContextFactory.getAccountId(OBJECT_ID, ObjectType.PAYMENT, 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.PAYMENT);
assertEquals(postedEvent.getEventType(), ExtBusEventType.PAYMENT_FAILED);
assertEquals(postedEvent.getMetaData(), METADATA);
assertCommonFieldsWithAccountId(postedEvent);
PaymentMetadata paymentMetadata = metadataCaptor.getValue();
assertPaymentMetadataFields(paymentMetadata);
}
Aggregations