Fix Eclipse warnings caused by deprecation of Jackson 2 support

See gh-45535
This commit is contained in:
Andy Wilkinson
2025-05-14 10:21:30 +01:00
parent ee90996e5f
commit 379b2ceb56
16 changed files with 70 additions and 79 deletions

View File

@@ -21,8 +21,6 @@ import java.util.Collections;
import org.json.JSONObject;
import org.junit.jupiter.api.Test;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -71,11 +69,13 @@ class AuditEventTests {
}
@Test
@SuppressWarnings("removal")
@SuppressWarnings({ "removal", "deprecation" })
void jsonFormat() throws Exception {
AuditEvent event = new AuditEvent("johannes", "UNKNOWN",
Collections.singletonMap("type", (Object) "BadCredentials"));
String json = Jackson2ObjectMapperBuilder.json().build().writeValueAsString(event);
String json = org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.json()
.build()
.writeValueAsString(event);
JSONObject jsonObject = new JSONObject(json);
assertThat(jsonObject.getString("type")).isEqualTo("UNKNOWN");
assertThat(jsonObject.getJSONObject("data").getString("type")).isEqualTo("BadCredentials");