diff --git a/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinder.java b/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinder.java index bd191bc..0f0364b 100644 --- a/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinder.java +++ b/src/main/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinder.java @@ -48,7 +48,7 @@ public MockitoLoggerFinder() { */ @Override public Logger getLogger(String name, Module module) { - return loggers.computeIfAbsent(name, key -> mock(Logger.class)); + return loggers.computeIfAbsent(name, key -> mock(Logger.class, "Mock for logger " + key)); } } diff --git a/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinderFastTest.java b/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinderFastTest.java index 7a649c1..7d5aa40 100644 --- a/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinderFastTest.java +++ b/src/test/java/io/github/vitalijr2/mock/jdk/platform/logging/MockitoLoggerFinderFastTest.java @@ -5,6 +5,8 @@ import static org.hamcrest.collection.IsMapWithSize.aMapWithSize; import static org.hamcrest.core.Is.isA; import static org.hamcrest.core.IsEqual.equalTo; +import static org.hamcrest.core.StringStartsWith.startsWith; +import static org.hamcrest.object.HasToString.hasToString; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.Mockito.mock; @@ -30,7 +32,8 @@ void createLogger() { // then assertAll("Logger was created", () -> assertThat("size", loggers, aMapWithSize(1)), - () -> assertThat("entry", loggers, hasEntry(equalTo("test"), isA(Logger.class)))); + () -> assertThat("entry", loggers, hasEntry(equalTo("test"), isA(Logger.class))), + () -> assertThat(loggers.values().iterator().next(), hasToString("Mock for logger test"))); } @DisplayName("Reuse existing logger") @@ -45,7 +48,8 @@ void reuseExistingLogger() { // then assertAll("Logger was reused", () -> assertThat("size", loggers, aMapWithSize(1)), - () -> assertThat("entry", loggers, hasEntry(equalTo("test"), isA(Logger.class)))); + () -> assertThat("entry", loggers, hasEntry(equalTo("test"), isA(Logger.class))), + () -> assertThat(loggers.values().iterator().next(), hasToString(startsWith("Mock for Logger, hashCode:")))); } } \ No newline at end of file