EnclosedInSquareBracketsConverterTests Class — spring-boot Architecture
Architecture documentation for the EnclosedInSquareBracketsConverterTests class in EnclosedInSquareBracketsConverterTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/test/java/org/springframework/boot/logging/logback/EnclosedInSquareBracketsConverterTests.java lines 36–99
class EnclosedInSquareBracketsConverterTests {
private final EnclosedInSquareBracketsConverter converter;
private final LoggingEvent event = new LoggingEvent();
EnclosedInSquareBracketsConverterTests() {
this.converter = new EnclosedInSquareBracketsConverter();
this.converter.setContext(new LoggerContext());
this.event.setLoggerContextRemoteView(
new LoggerContextVO("test", Collections.emptyMap(), System.currentTimeMillis()));
}
@Test
void transformWhenNull() {
assertThat(this.converter.transform(this.event, null)).isEqualTo("");
}
@Test
void transformWhenEmpty() {
assertThat(this.converter.transform(this.event, "")).isEqualTo("");
}
@Test
void transformWhenName() {
assertThat(this.converter.transform(this.event, "My Application")).isEqualTo("[My Application] ");
}
@Test
void transformWhenEmptyFromFirstOption() {
withLoggedApplicationName("spring", null, () -> {
this.converter.setOptionList(List.of("spring"));
this.converter.start();
String converted = this.converter.convert(this.event);
assertThat(converted).isEqualTo("");
});
}
@Test
void transformWhenNameFromFirstOption() {
withLoggedApplicationName("spring", "boot", () -> {
this.converter.setOptionList(List.of("spring"));
this.converter.start();
String converted = this.converter.convert(this.event);
assertThat(converted).isEqualTo("[boot] ");
});
}
private void withLoggedApplicationName(String name, @Nullable String value, Runnable action) {
if (value == null) {
System.clearProperty(name);
}
else {
System.setProperty(name, value);
}
try {
action.run();
}
finally {
System.clearProperty(name);
}
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free