@Test public void constructor_shouldSafelyCopyTheProvidedContextInformationIntoANewMap() throws Exception { Map<String, String> expectedContext = new HashMap<>(); expectedContext.put("baker", "a"); expectedContext.put("able", "a"); expectedContext.put("charlie", "a"); Map<String, String> actualContext = new DiagnosticContext(() -> expectedContext).getContext(); assertNotSame(expectedContext, actualContext); assertEquals(expectedContext, actualContext); expectedContext.clear(); assertNotEquals(expectedContext, actualContext); }
public Map<String, String> getContext() { return context; }
DiagnosticContext { public Map<String, String> getContext() { return context; } }
DiagnosticContext { public Map<String, String> getContext() { return context; } DiagnosticContext(DiagnosticContextSupplier supplier); }
DiagnosticContext { public Map<String, String> getContext() { return context; } DiagnosticContext(DiagnosticContextSupplier supplier); Map<String, String> getContext(); void printContextInformation(StringBuilder result); }
DiagnosticContext { public Map<String, String> getContext() { return context; } DiagnosticContext(DiagnosticContextSupplier supplier); Map<String, String> getContext(); void printContextInformation(StringBuilder result);  }