mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-06-01 02:17:58 +00:00
Refactor: Fixed #1193. Remove assertj-core from acyclic-visitor to prevent inconsistent library versions (#2042)
* Fixed #1193. Remove assertj-core from acyclic-visitor to prevent inconsistent library versions * clean up logger before each run
This commit is contained in:
+17
-8
@@ -24,12 +24,14 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.groups.Tuple.tuple;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static uk.org.lidalia.slf4jext.Level.INFO;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import uk.org.lidalia.slf4jtest.LoggingEvent;
|
||||
import uk.org.lidalia.slf4jtest.TestLogger;
|
||||
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
|
||||
|
||||
@@ -47,9 +49,12 @@ class ConfigureForDosVisitorTest {
|
||||
|
||||
conDos.visit(zoom);
|
||||
|
||||
assertThat(logger.getLoggingEvents())
|
||||
.extracting("level", "message")
|
||||
.contains(tuple(INFO, zoom + " used with Dos configurator."));
|
||||
ImmutableList<LoggingEvent> loggingEvents = logger.getLoggingEvents();
|
||||
assertEquals(1, loggingEvents.size());
|
||||
for (LoggingEvent loggingEvent : loggingEvents) {
|
||||
assertEquals(INFO, loggingEvent.getLevel());
|
||||
assertEquals(zoom + " used with Dos configurator.", loggingEvent.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,11 +64,15 @@ class ConfigureForDosVisitorTest {
|
||||
|
||||
conDos.visit(hayes);
|
||||
|
||||
assertThat(logger.getLoggingEvents())
|
||||
.extracting("level", "message")
|
||||
.contains(tuple(INFO, hayes + " used with Dos configurator."));
|
||||
ImmutableList<LoggingEvent> loggingEvents = logger.getLoggingEvents();
|
||||
assertEquals(1, loggingEvents.size());
|
||||
for (LoggingEvent loggingEvent : loggingEvents) {
|
||||
assertEquals(INFO, loggingEvent.getLevel());
|
||||
assertEquals(hayes + " used with Dos configurator.", loggingEvent.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
public void clearLoggers() {
|
||||
TestLoggerFactory.clear();
|
||||
|
||||
+11
-5
@@ -24,13 +24,15 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import uk.org.lidalia.slf4jtest.LoggingEvent;
|
||||
import uk.org.lidalia.slf4jtest.TestLogger;
|
||||
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.groups.Tuple.tuple;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static uk.org.lidalia.slf4jext.Level.INFO;
|
||||
|
||||
/**
|
||||
@@ -40,6 +42,7 @@ class ConfigureForUnixVisitorTest {
|
||||
|
||||
private static final TestLogger LOGGER = TestLoggerFactory.getTestLogger(ConfigureForUnixVisitor.class);
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
public void clearLoggers() {
|
||||
TestLoggerFactory.clear();
|
||||
@@ -52,8 +55,11 @@ class ConfigureForUnixVisitorTest {
|
||||
|
||||
conUnix.visit(zoom);
|
||||
|
||||
assertThat(LOGGER.getLoggingEvents())
|
||||
.extracting("level", "message")
|
||||
.contains(tuple(INFO, zoom + " used with Unix configurator."));
|
||||
ImmutableList<LoggingEvent> loggingEvents = LOGGER.getLoggingEvents();
|
||||
assertEquals(1, loggingEvents.size());
|
||||
for (LoggingEvent loggingEvent : loggingEvents) {
|
||||
assertEquals(INFO, loggingEvent.getLevel());
|
||||
assertEquals(zoom + " used with Unix configurator.", loggingEvent.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user