@Test public void testNewFlow() { BDDMockito.<FlowConfiguration<?>>given(flowConfigurationMap.get(any())).willReturn(flowConfig); given(flowConfig.createFlow(anyString(), anyLong())).willReturn(flow); given(flowConfig.getFlowTriggerCondition()).willReturn(flowTriggerCondition); given(flowTriggerCondition.isFlowTriggerable(anyLong())).willReturn(true); given(flow.getCurrentState()).willReturn(flowState); Event<Payload> event = new Event<>(payload); event.setKey("KEY"); underTest.accept(event); verify(flowConfigurationMap, times(1)).get(anyString()); verify(runningFlows, times(1)).put(eq(flow), isNull(String.class)); verify(flowLogService, times(1)) .save(any(FlowParameters.class), nullable(String.class), eq("KEY"), any(Payload.class), any(), eq(flowConfig.getClass()), eq(flowState)); verify(flow, times(1)).sendEvent(anyString(), isNull(), any(), any()); }
@Override public void accept(Event<? extends Payload> event) { String key = (String) event.getKey(); Payload payload = event.getData(); String flowId = getFlowId(event); String flowChainId = getFlowChainId(event); String flowTriggerUserCrn = getFlowTriggerUserCrn(event); Span activeSpan = tracer.activeSpan(); SpanContext spanContext = event.getHeaders().get(FlowConstants.SPAN_CONTEXT); String operationName = event.getKey().toString(); if (FlowTracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) { LOGGER.debug("Reusing existing span. {}", activeSpan.context()); doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } else { Span span = FlowTracingUtil.getSpan(tracer, operationName, spanContext, flowId, flowChainId, flowTriggerUserCrn); spanContext = FlowTracingUtil.useOrCreateSpanContext(spanContext, span); try (Scope ignored = tracer.activateSpan(span)) { doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } finally { span.finish(); } } }
Flow2Handler implements Consumer<Event<? extends Payload>> { @Override public void accept(Event<? extends Payload> event) { String key = (String) event.getKey(); Payload payload = event.getData(); String flowId = getFlowId(event); String flowChainId = getFlowChainId(event); String flowTriggerUserCrn = getFlowTriggerUserCrn(event); Span activeSpan = tracer.activeSpan(); SpanContext spanContext = event.getHeaders().get(FlowConstants.SPAN_CONTEXT); String operationName = event.getKey().toString(); if (FlowTracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) { LOGGER.debug("Reusing existing span. {}", activeSpan.context()); doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } else { Span span = FlowTracingUtil.getSpan(tracer, operationName, spanContext, flowId, flowChainId, flowTriggerUserCrn); spanContext = FlowTracingUtil.useOrCreateSpanContext(spanContext, span); try (Scope ignored = tracer.activateSpan(span)) { doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } finally { span.finish(); } } } }
Flow2Handler implements Consumer<Event<? extends Payload>> { @Override public void accept(Event<? extends Payload> event) { String key = (String) event.getKey(); Payload payload = event.getData(); String flowId = getFlowId(event); String flowChainId = getFlowChainId(event); String flowTriggerUserCrn = getFlowTriggerUserCrn(event); Span activeSpan = tracer.activeSpan(); SpanContext spanContext = event.getHeaders().get(FlowConstants.SPAN_CONTEXT); String operationName = event.getKey().toString(); if (FlowTracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) { LOGGER.debug("Reusing existing span. {}", activeSpan.context()); doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } else { Span span = FlowTracingUtil.getSpan(tracer, operationName, spanContext, flowId, flowChainId, flowTriggerUserCrn); spanContext = FlowTracingUtil.useOrCreateSpanContext(spanContext, span); try (Scope ignored = tracer.activateSpan(span)) { doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } finally { span.finish(); } } }  }
Flow2Handler implements Consumer<Event<? extends Payload>> { @Override public void accept(Event<? extends Payload> event) { String key = (String) event.getKey(); Payload payload = event.getData(); String flowId = getFlowId(event); String flowChainId = getFlowChainId(event); String flowTriggerUserCrn = getFlowTriggerUserCrn(event); Span activeSpan = tracer.activeSpan(); SpanContext spanContext = event.getHeaders().get(FlowConstants.SPAN_CONTEXT); String operationName = event.getKey().toString(); if (FlowTracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) { LOGGER.debug("Reusing existing span. {}", activeSpan.context()); doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } else { Span span = FlowTracingUtil.getSpan(tracer, operationName, spanContext, flowId, flowChainId, flowTriggerUserCrn); spanContext = FlowTracingUtil.useOrCreateSpanContext(spanContext, span); try (Scope ignored = tracer.activateSpan(span)) { doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } finally { span.finish(); } } }  @Override void accept(Event<? extends Payload> event); void cancelFlow(Long stackId, String flowId); void restartFlow(String flowId); void restartFlow(FlowLog flowLog); }
Flow2Handler implements Consumer<Event<? extends Payload>> { @Override public void accept(Event<? extends Payload> event) { String key = (String) event.getKey(); Payload payload = event.getData(); String flowId = getFlowId(event); String flowChainId = getFlowChainId(event); String flowTriggerUserCrn = getFlowTriggerUserCrn(event); Span activeSpan = tracer.activeSpan(); SpanContext spanContext = event.getHeaders().get(FlowConstants.SPAN_CONTEXT); String operationName = event.getKey().toString(); if (FlowTracingUtil.isActiveSpanReusable(activeSpan, spanContext, operationName)) { LOGGER.debug("Reusing existing span. {}", activeSpan.context()); doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } else { Span span = FlowTracingUtil.getSpan(tracer, operationName, spanContext, flowId, flowChainId, flowTriggerUserCrn); spanContext = FlowTracingUtil.useOrCreateSpanContext(spanContext, span); try (Scope ignored = tracer.activateSpan(span)) { doAccept(event, key, payload, flowId, flowChainId, flowTriggerUserCrn, spanContext); } finally { span.finish(); } } }  @Override void accept(Event<? extends Payload> event); void cancelFlow(Long stackId, String flowId); void restartFlow(String flowId); void restartFlow(FlowLog flowLog); static final String FLOW_ID; static final String FLOW_CHAIN_ID; static final String FLOW_FINAL; static final String FLOW_CANCEL; }