public static void assertStackElements(FlowCallStack flowStack, Matcher<FlowStackElement>... flowStackElementMatchers) { assertThat(flowStack.toString(), flowStack.getElements(), hasSize(flowStackElementMatchers.length)); int i = 0; for (Matcher<FlowStackElement> flowStackElementMatcher : flowStackElementMatchers) { assertThat(flowStack.toString(), flowStack.getElements().get(i), flowStackElementMatcher); ++i; } }
@Test public void splitStack() { CoreEvent event = buildEvent("newAnnotatedComponentCall"); PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName()); assertThat(getContextInfo(event, rootFlowConstruct), is("")); manager.onPipelineNotificationStart(pipelineNotification); assertThat(getContextInfo(event, rootFlowConstruct), startsWith("at " + rootFlowConstruct.getName())); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/comp", false))); assertThat(getContextInfo(event, rootFlowConstruct), startsWith("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)")); CoreEvent eventCopy = buildEvent("newAnnotatedComponentCall", event.getFlowCallStack().clone()); assertThat(getContextInfo(eventCopy, rootFlowConstruct), startsWith("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)")); manager.onPipelineNotificationComplete(pipelineNotification); assertThat(getContextInfo(event, rootFlowConstruct), is("")); final FlowConstruct asyncFlowConstruct = mock(FlowConstruct.class); when(asyncFlowConstruct.getName()).thenReturn("asyncFlow"); manager.onPipelineNotificationStart(buildPipelineNotification(eventCopy, asyncFlowConstruct.getName())); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy, createMockProcessor("/asyncComp", false))); assertThat(getContextInfo(eventCopy, asyncFlowConstruct).split(quote(lineSeparator()))[0], startsWith("at " + asyncFlowConstruct.getName() + "(/asyncComp @ " + APP_ID + ":unknown:-1)")); assertThat(getContextInfo(eventCopy, asyncFlowConstruct).split(quote(lineSeparator()))[1], startsWith("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)")); }
private ChildEventContext(BaseEventContext parent, ComponentLocation componentLocation, FlowExceptionHandler messagingExceptionHandler) { super(messagingExceptionHandler, empty()); this.flowCallStack = parent.getFlowCallStack().clone(); this.parent = parent; this.componentLocation = componentLocation; this.id = parent.getId() + identityHashCode(this); }
@Test public void joinStackEnd() { CoreEvent event = buildEvent("joinStack"); PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName()); manager.onPipelineNotificationStart(pipelineNotification); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/scatter-gather", false))); FlowCallStack flowCallStack = event.getFlowCallStack(); CoreEvent eventCopy0 = buildEvent("joinStack_0", flowCallStack.clone()); CoreEvent eventCopy1 = buildEvent("joinStack_1", flowCallStack.clone()); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy0, createMockProcessor("/route_0", false))); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy1, createMockProcessor(NESTED_FLOW_NAME + "_ref", false))); PipelineMessageNotification pipelineNotificationNested = buildPipelineNotification(eventCopy1, NESTED_FLOW_NAME); manager.onPipelineNotificationStart(pipelineNotificationNested); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy1, createMockProcessor("/route_1", false))); manager.onPipelineNotificationComplete(pipelineNotificationNested); manager.onPipelineNotificationComplete(pipelineNotification); assertThat(((BaseEventContext) event.getContext()).getProcessorsTrace(), hasExecutedProcessors("/scatter-gather @ " + APP_ID + ":unknown:-1", "/route_0 @ " + APP_ID + ":unknown:-1", NESTED_FLOW_NAME + "_ref @ " + APP_ID + ":unknown:-1", "/route_1 @ " + APP_ID + ":unknown:-1")); }
public DefaultFlowStackEntry(BaseEventContext context) { this.serverId = context.getServerId(); this.eventId = context.getId(); this.flowCallStack = context.getFlowCallStack().clone(); }
@Test public void splitStackEnd() { CoreEvent event = buildEvent("newAnnotatedComponentCall"); PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName()); manager.onPipelineNotificationStart(pipelineNotification); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/comp", false))); FlowCallStack flowCallStack = event.getFlowCallStack(); CoreEvent eventCopy = buildEvent("newAnnotatedComponentCall", flowCallStack.clone()); manager.onPipelineNotificationComplete(pipelineNotification); String asyncFlowName = "asyncFlow"; manager.onPipelineNotificationStart(buildPipelineNotification(eventCopy, asyncFlowName)); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy, createMockProcessor("/asyncComp", false))); assertThat(((BaseEventContext) event.getContext()).getProcessorsTrace(), hasExecutedProcessors("/comp @ " + APP_ID + ":unknown:-1", "/asyncComp @ " + APP_ID + ":unknown:-1")); }
@Test public void splitStack() { CoreEvent event = buildEvent("newAnnotatedComponentCall"); PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName()); assertThat(getContextInfo(event, rootFlowConstruct), is("")); manager.onPipelineNotificationStart(pipelineNotification); assertThat(getContextInfo(event, rootFlowConstruct), is("at " + rootFlowConstruct.getName())); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/comp", false))); assertThat(getContextInfo(event, rootFlowConstruct), is("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)")); CoreEvent eventCopy = buildEvent("newAnnotatedComponentCall", event.getFlowCallStack().clone()); assertThat(getContextInfo(eventCopy, rootFlowConstruct), is("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)")); manager.onPipelineNotificationComplete(pipelineNotification); assertThat(getContextInfo(event, rootFlowConstruct), is("")); final FlowConstruct asyncFlowConstruct = mock(FlowConstruct.class); when(asyncFlowConstruct.getName()).thenReturn("asyncFlow"); manager.onPipelineNotificationStart(buildPipelineNotification(eventCopy, asyncFlowConstruct.getName())); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy, createMockProcessor("/asyncComp", false))); assertThat(getContextInfo(eventCopy, asyncFlowConstruct), is("at " + asyncFlowConstruct.getName() + "(/asyncComp @ " + APP_ID + ":unknown:-1)" + lineSeparator() + "at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":unknown:-1)")); }
@Test public void joinStackEnd() { CoreEvent event = buildEvent("joinStack"); PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName()); manager.onPipelineNotificationStart(pipelineNotification); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/scatter-gather", false))); FlowCallStack flowCallStack = event.getFlowCallStack(); CoreEvent eventCopy0 = buildEvent("joinStack_0", flowCallStack.clone()); CoreEvent eventCopy1 = buildEvent("joinStack_1", flowCallStack.clone()); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy0, createMockProcessor("/route_0", false))); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy1, createMockProcessor(NESTED_FLOW_NAME + "_ref", false))); PipelineMessageNotification pipelineNotificationNested = buildPipelineNotification(eventCopy1, NESTED_FLOW_NAME); manager.onPipelineNotificationStart(pipelineNotificationNested); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy1, createMockProcessor("/route_1", false))); manager.onPipelineNotificationComplete(pipelineNotificationNested); manager.onPipelineNotificationComplete(pipelineNotification); assertThat(((BaseEventContext) event.getContext()).getProcessorsTrace(), hasExecutedProcessors("/scatter-gather @ " + APP_ID + ":unknown:-1", "/route_0 @ " + APP_ID + ":unknown:-1", NESTED_FLOW_NAME + "_ref @ " + APP_ID + ":unknown:-1", "/route_1 @ " + APP_ID + ":unknown:-1")); }
@Test public void splitStackEnd() { CoreEvent event = buildEvent("newAnnotatedComponentCall"); PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName()); manager.onPipelineNotificationStart(pipelineNotification); manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, createMockProcessor("/comp", false))); FlowCallStack flowCallStack = event.getFlowCallStack(); CoreEvent eventCopy = buildEvent("newAnnotatedComponentCall", flowCallStack.clone()); manager.onPipelineNotificationComplete(pipelineNotification); String asyncFlowName = "asyncFlow"; manager.onPipelineNotificationStart(buildPipelineNotification(eventCopy, asyncFlowName)); manager .onMessageProcessorNotificationPreInvoke(buildProcessorNotification(eventCopy, createMockProcessor("/asyncComp", false))); assertThat(((BaseEventContext) event.getContext()).getProcessorsTrace(), hasExecutedProcessors("/comp @ " + APP_ID + ":unknown:-1", "/asyncComp @ " + APP_ID + ":unknown:-1")); }