@Test public void fireNotificationForEvent() { when(messageSource.getLocation()).thenReturn(TEST_CONNECTOR_LOCATION); final FlowConstruct flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class)); when(flowConstruct.getMuleContext()).thenReturn(muleContext); final int action = 100; helper.fireNotification(messageSource, event, TEST_CONNECTOR_LOCATION, action); assertConnectorMessageNotification(eventNotificationHandler, messageSource, TEST_CONNECTOR_LOCATION, action); }
@Test public void fireSpecificNotificationForEvent() { TestServerNotification notification = new TestServerNotification(); helper.fireNotification(notification); verify(eventNotificationHandler).fireNotification(notification); }
@Test public void fireSpecificNotificationOnDefaultHandler() { TestServerNotification notification = new TestServerNotification(); helper.fireNotification(notification); verify(eventNotificationHandler).fireNotification(notification); }
@Test public void fireNotificationUsingLocation() { final LocationPart flowPart = mock(LocationPart.class); when(flowPart.getPartPath()).thenReturn("flowName"); final ComponentLocation location = mock(ComponentLocation.class); when(location.getParts()).thenReturn(Collections.singletonList(flowPart)); when(location.getComponentIdentifier()).thenReturn(TypedComponentIdentifier.builder() .type(SOURCE) .identifier(buildFromStringRepresentation("http:listener")) .build()); when(messageSource.getLocation()).thenReturn(location); final FlowConstruct flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class)); when(flowConstruct.getMuleContext()).thenReturn(muleContext); final int action = 100; helper.fireNotification(messageSource, event, location, action); assertConnectorMessageNotification(eventNotificationHandler, messageSource, location, action); }
protected void fireNotification(Component source, CoreEvent event, FlowConstruct flow, int action) { try { if (event == null) { // Null result only happens when there's a filter in the chain. // Unfortunately a filter causes the whole chain to return null // and there's no other way to retrieve the last event but using the RequestContext. // see https://www.mulesoft.org/jira/browse/MULE-8670 event = getCurrentEvent(); if (event == null) { return; } } notificationHelper.fireNotification(source, event, ((Component) flow).getLocation(), action); } catch (Exception e) { logger.warn("Could not fire notification. Action: " + action, e); } }
@Test public void fireSpecificNotificationForEvent() { TestServerNotification notification = new TestServerNotification(); helper.fireNotification(notification); verify(eventNotificationHandler).fireNotification(notification); }
@Test public void fireSpecificNotificationOnDefaultHandler() { TestServerNotification notification = new TestServerNotification(); helper.fireNotification(notification); verify(eventNotificationHandler).fireNotification(notification); }
@Test public void fireNotificationForEvent() { when(messageSource.getLocation()).thenReturn(TEST_CONNECTOR_LOCATION); final FlowConstruct flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class)); when(flowConstruct.getMuleContext()).thenReturn(muleContext); final int action = 100; helper.fireNotification(messageSource, event, TEST_CONNECTOR_LOCATION, action); assertConnectorMessageNotification(eventNotificationHandler, messageSource, TEST_CONNECTOR_LOCATION, action); }
@Test public void fireNotificationUsingLocation() { final LocationPart flowPart = mock(LocationPart.class); when(flowPart.getPartPath()).thenReturn("flowName"); final ComponentLocation location = mock(ComponentLocation.class); when(location.getParts()).thenReturn(Collections.singletonList(flowPart)); when(location.getComponentIdentifier()).thenReturn(TypedComponentIdentifier.builder() .type(SOURCE) .identifier(buildFromStringRepresentation("http:listener")) .build()); when(messageSource.getLocation()).thenReturn(location); final FlowConstruct flowConstruct = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class)); when(flowConstruct.getMuleContext()).thenReturn(muleContext); final int action = 100; helper.fireNotification(messageSource, event, location, action); assertConnectorMessageNotification(eventNotificationHandler, messageSource, location, action); }
private void pollWith(final Message request) { try { just(request) .map(message -> InternalEvent.builder(create(flowConstruct, getLocation())).message(request) .build()) .doOnNext(event -> setCurrentEvent(event)) .doOnNext(event -> notificationHelper.fireNotification(this, event, getLocation(), MESSAGE_RECEIVED)) .cast(CoreEvent.class) .transform(listener) .doOnError(MessagingException.class, me -> ((BaseEventContext) me.getEvent().getContext()).error(me)) .doOnSuccess(result -> ((BaseEventContext) result.getContext()).success()) .doFinally(s -> { synchronized (DefaultSchedulerMessageSource.this) { executing = false; } }) .subscribe(requestUnbounded()); } catch (Exception e) { muleContext.getExceptionListener().handleException(e); } }