|
|
|
|
@ -26,6 +26,7 @@ import org.mockito.Mock;
@@ -26,6 +26,7 @@ import org.mockito.Mock;
|
|
|
|
|
import org.mockito.junit.jupiter.MockitoExtension; |
|
|
|
|
|
|
|
|
|
import org.springframework.boot.json.JsonWriter; |
|
|
|
|
import org.springframework.boot.json.JsonWriter.Members; |
|
|
|
|
import org.springframework.boot.json.JsonWriter.NameProcessor; |
|
|
|
|
import org.springframework.boot.util.Instantiator; |
|
|
|
|
|
|
|
|
|
@ -95,13 +96,13 @@ class StructuredLoggingJsonPropertiesJsonMembersCustomizerTests {
@@ -95,13 +96,13 @@ class StructuredLoggingJsonPropertiesJsonMembersCustomizerTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@SuppressWarnings("rawtypes") |
|
|
|
|
@SuppressWarnings({ "rawtypes", "unchecked" }) |
|
|
|
|
void customizeWhenHasCustomizerCustomizesMember() { |
|
|
|
|
StructureLoggingJsonMembersCustomizer<?> uppercaseCustomizer = (members) -> members |
|
|
|
|
.applyingNameProcessor(NameProcessor.of(String::toUpperCase)); |
|
|
|
|
given(((Instantiator) this.instantiator).instantiate("test")).willReturn(uppercaseCustomizer); |
|
|
|
|
given(((Instantiator) this.instantiator).instantiateType(TestCustomizer.class)).willReturn(uppercaseCustomizer); |
|
|
|
|
StructuredLoggingJsonProperties properties = new StructuredLoggingJsonProperties(Collections.emptySet(), |
|
|
|
|
Collections.emptySet(), Collections.emptyMap(), Collections.emptyMap(), "test"); |
|
|
|
|
Collections.emptySet(), Collections.emptyMap(), Collections.emptyMap(), TestCustomizer.class); |
|
|
|
|
StructuredLoggingJsonPropertiesJsonMembersCustomizer customizer = new StructuredLoggingJsonPropertiesJsonMembersCustomizer( |
|
|
|
|
this.instantiator, properties); |
|
|
|
|
assertThat(writeSampleJson(customizer)).contains("\"A\":\"a\""); |
|
|
|
|
@ -117,4 +118,12 @@ class StructuredLoggingJsonPropertiesJsonMembersCustomizerTests {
@@ -117,4 +118,12 @@ class StructuredLoggingJsonPropertiesJsonMembersCustomizerTests {
|
|
|
|
|
}).writeToString(new Object()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static class TestCustomizer implements StructureLoggingJsonMembersCustomizer<String> { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void customize(Members<String> members) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|