@Test void beforeProcessingWithoutStateVariables() { MDC.clear(); Map<String, String> stateVariables = spy(new HashMap<String, String>()); WorkflowInstance instance = new WorkflowInstance.Builder().setType("type").setId(1).setExternalId("extId") .setBusinessKey("businessKey").setStateVariables(stateVariables).build(); ListenerContext context = new ListenerContext(definition, instance, stateExecution); listener.beforeProcessing(context); assertThat(MDC.get(LOG_CONTEXT), is(equalTo("type:type, instanceId:1, extId:extId, businessKey:businessKey"))); verify(stateVariables, never()).entrySet(); }
@Override public void beforeProcessing(ListenerContext listenerContext) { WorkflowInstance instance = listenerContext.instance; MDC.put(logContext, format(LOG_CONTEXT_FORMAT, instance.type, instance.id, instance.externalId, instance.businessKey)); if (LOG.isDebugEnabled() && !instance.stateVariables.isEmpty()) { LOG.debug("State variables:\n{}", instance.stateVariables.entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).collect(joining("\n"))); } }
WorkflowLogContextListener implements WorkflowExecutorListener { @Override public void beforeProcessing(ListenerContext listenerContext) { WorkflowInstance instance = listenerContext.instance; MDC.put(logContext, format(LOG_CONTEXT_FORMAT, instance.type, instance.id, instance.externalId, instance.businessKey)); if (LOG.isDebugEnabled() && !instance.stateVariables.isEmpty()) { LOG.debug("State variables:\n{}", instance.stateVariables.entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).collect(joining("\n"))); } } }
WorkflowLogContextListener implements WorkflowExecutorListener { @Override public void beforeProcessing(ListenerContext listenerContext) { WorkflowInstance instance = listenerContext.instance; MDC.put(logContext, format(LOG_CONTEXT_FORMAT, instance.type, instance.id, instance.externalId, instance.businessKey)); if (LOG.isDebugEnabled() && !instance.stateVariables.isEmpty()) { LOG.debug("State variables:\n{}", instance.stateVariables.entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).collect(joining("\n"))); } } WorkflowLogContextListener(String logContext); }
WorkflowLogContextListener implements WorkflowExecutorListener { @Override public void beforeProcessing(ListenerContext listenerContext) { WorkflowInstance instance = listenerContext.instance; MDC.put(logContext, format(LOG_CONTEXT_FORMAT, instance.type, instance.id, instance.externalId, instance.businessKey)); if (LOG.isDebugEnabled() && !instance.stateVariables.isEmpty()) { LOG.debug("State variables:\n{}", instance.stateVariables.entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).collect(joining("\n"))); } } WorkflowLogContextListener(String logContext); @Override void beforeProcessing(ListenerContext listenerContext); @Override void afterProcessing(ListenerContext listenerContext); @Override void afterFailure(ListenerContext listenerContext, Throwable throwable); }
WorkflowLogContextListener implements WorkflowExecutorListener { @Override public void beforeProcessing(ListenerContext listenerContext) { WorkflowInstance instance = listenerContext.instance; MDC.put(logContext, format(LOG_CONTEXT_FORMAT, instance.type, instance.id, instance.externalId, instance.businessKey)); if (LOG.isDebugEnabled() && !instance.stateVariables.isEmpty()) { LOG.debug("State variables:\n{}", instance.stateVariables.entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).collect(joining("\n"))); } } WorkflowLogContextListener(String logContext); @Override void beforeProcessing(ListenerContext listenerContext); @Override void afterProcessing(ListenerContext listenerContext); @Override void afterFailure(ListenerContext listenerContext, Throwable throwable);  }