From b75927789902ee4741ca190eb356ddad3132b9a1 Mon Sep 17 00:00:00 2001 From: DiegoMarti2 <150871541+DiegoMarti2@users.noreply.github.com> Date: Sat, 16 Dec 2023 14:40:56 +0200 Subject: [PATCH] Update ByteArrayToJsonAndViseVerseUnitTest.java --- .../ByteArrayToJsonAndViseVerseUnitTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/json-modules/json-conversion/src/test/java/com/baeldung/bytearraytojsonandviseverse/ByteArrayToJsonAndViseVerseUnitTest.java b/json-modules/json-conversion/src/test/java/com/baeldung/bytearraytojsonandviseverse/ByteArrayToJsonAndViseVerseUnitTest.java index 1fb6133ee3..b86d6e0187 100644 --- a/json-modules/json-conversion/src/test/java/com/baeldung/bytearraytojsonandviseverse/ByteArrayToJsonAndViseVerseUnitTest.java +++ b/json-modules/json-conversion/src/test/java/com/baeldung/bytearraytojsonandviseverse/ByteArrayToJsonAndViseVerseUnitTest.java @@ -12,7 +12,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class ByteArrayToJsonAndViseVerseUnitTest { - byte[] byteArray = {34, 123, 92, 34, 110, 97, 109, 101, 92, 34, 58, 92, 34, 65, 108, 105, 99, 101, 92, 34, 44, 92, 34, 97, 103, 101, 92, 34, 58, 50, 53, 44, 92, 34, 105, 115, 83, 116, 117, 100, 101, 110, 116, 92, 34, 58, 116, 114, 117, 101, 44, 92, 34, 104, 111, 98, 98, 105, 101, 115, 92, 34, 58, 91, 92, 34, 114, 101, 97, 100, 105, 110, 103, 92, 34, 44, 92, 34, 112, 97, 105, 110, 116, 105, 110, 103, 92, 34, 93, 44, 92, 34, 97, 100, 100, 114, 101, 115, 115, 92, 34, 58, 123, 92, 34, 99, 105, 116, 121, 92, 34, 58, 92, 34, 83, 109, 97, 108, 108, 118, 105, 108, 108, 101, 92, 34, 44, 92, 34, 122, 105, 112, 99, 111, 100, 101, 92, 34, 58, 92, 34, 49, 50, 51, 52, 53, 92, 34, 125, 125, 34}; + byte[] byteArray = {34, 123, 92, 34, 110, 97, 109, 101, 92, 34, 58, 92, 34, 65, 108, 105, 99, 101, 92, 34, 44, 92, 34, 97, 103, 101, 92, + 34, 58, 50, 53, 44, 92, 34, 105, 115, 83, 116, 117, 100, 101, 110, 116, 92, 34, 58, 116, 114, 117, 101, 44, 92, 34, + 104, 111, 98, 98, 105, 101, 115, 92, 34, 58, 91, 92, 34, 114, 101, 97, 100, 105, 110, 103, 92, 34, 44, 92, 34, 112, + 97, 105, 110, 116, 105, 110, 103, 92, 34, 93, 44, 92, 34, 97, 100, 100, 114, 101, 115, 115, 92, 34, 58, 123, 92, 34, + 99, 105, 116, 121, 92, 34, 58, 92, 34, 83, 109, 97, 108, 108, 118, 105, 108, 108, 101, 92, 34, 44, 92, 34, 122, 105, + 112, 99, 111, 100, 101, 92, 34, 58, 92, 34, 49, 50, 51, 52, 53, 92, 34, 125, 125, 34}; + String jsonString = "{\"name\":\"Alice\",\"age\":25,\"isStudent\":true,\"hobbies\":[\"reading\",\"painting\"],\"address\":{\"city\":\"Smallville\",\"zipcode\":\"12345\"}}"; @Test @@ -34,7 +40,6 @@ public class ByteArrayToJsonAndViseVerseUnitTest { @Test void givenJsonString_whenConvertingToByteArrayUsingJackson_thenByteArray() throws JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); byte[] actualByteArray = objectMapper.writeValueAsBytes(jsonString);