ConnectionLogUtil { public static void enhanceLogWithCorrelationIdAndConnectionId(final String correlationId, final CharSequence connectionId) { enhanceLogWithConnectionId(connectionId); LogUtil.enhanceLogWithCorrelationId(correlationId); } private  ConnectionLogUtil(); static void enhanceLogWithConnectionId(final CharSequence connectionId); static void enhanceLogWithCorrelationIdAndConnectionId(final String correlationId,
            final CharSequence connectionId); static void enhanceLogWithConnectionId(final DiagnosticLoggingAdapter loggingAdapter,
            final CharSequence connectionId); static void removeConnectionId(final DiagnosticLoggingAdapter loggingAdapter); static void enhanceLogWithCorrelationIdAndConnectionId(final DiagnosticLoggingAdapter loggingAdapter,
            final WithDittoHeaders<?> signal,
            final CharSequence connectionId); static void enhanceLogWithCorrelationIdAndConnectionId(final DiagnosticLoggingAdapter loggingAdapter,
            final String correlationId,
            final CharSequence connectionId);  }
@Test public void enhanceLogWithCorrelationIdAndConnectionId() { final String connectionId = "theConnection"; final String correlationId = "theCorrelationId"; final WithDittoHeaders<?> withDittoHeaders = RetrieveThing.of(ThingId.of("any", "Thing"), DittoHeaders.newBuilder().correlationId(correlationId).build()); final Map<String, Object> expectedMap = new HashMap<>(DEFAULT_MDC); expectedMap.put("connection-id", connectionId); expectedMap.put(LogUtil.X_CORRELATION_ID, correlationId); ConnectionLogUtil.enhanceLogWithCorrelationIdAndConnectionId(log, withDittoHeaders, connectionId); Mockito.verify(log).setMDC(expectedMap); }
@Test public void enhanceLogWithCorrelationIdAndConnectionId1() { final String connectionId = "theConnection"; final String correlationId = "theCorrelationId"; final Map<String, Object> expectedMap = new HashMap<>(DEFAULT_MDC); expectedMap.put("connection-id", connectionId); expectedMap.put(LogUtil.X_CORRELATION_ID, correlationId); ConnectionLogUtil.enhanceLogWithCorrelationIdAndConnectionId(log, correlationId, connectionId); Mockito.verify(log).setMDC(expectedMap); }