@AllowConcurrentEvents @Subscribe public void handlePaymentInfoEvent(final InvoicePaymentInfoInternalEvent event) { log.debug("Received InvoicePaymentInfo event {}", event); insertBusEventIntoNotificationQueue(event.getAccountId(), event); }
@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); }
@Override public void onInvoicePaymentInfo(final InvoicePaymentInfoInternalEvent event) { log.info("Got event InvoicePaymentInfo token='{}'", event.getUserToken()); notifyForCompletion(); }
@Test(groups = "fast") public void testJsonProcessingException() throws Exception { InvoicePaymentInfoInternalEvent event = mock(InvoicePaymentInfoInternalEvent.class); when(event.getBusEventType()).thenReturn(BusInternalEventType.INVOICE_PAYMENT_INFO); when(objectMapper.writeValueAsString(anyObject())).thenThrow(JsonProcessingException.class); // Just make sure exception gets swallowed. beatrixListener.handleAllInternalKillbillEvents(event); }
@AllowConcurrentEvents @Subscribe public void handlePaymentInfoEvent(final InvoicePaymentInfoInternalEvent event) { log.debug("Received InvoicePaymentInfo event {}", event); insertBusEventIntoNotificationQueue(event.getAccountId(), event); }