diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java index ea4ae529fe..b0725b9d65 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java @@ -9,7 +9,7 @@ public class MyDtoGetter { super(); } - public MyDtoGetter(final String stringValue, final int intValue, final boolean booleanValue) { + public MyDtoGetter(final String stringValue, final int intValue) { super(); this.stringValue = stringValue; diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java index da4e5ebe42..0c5027ac24 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java @@ -3,17 +3,15 @@ package org.baeldung.jackson.field; public class MyDtoGetterImplicitDeserialization { private String stringValue; - public boolean booleanValue; public MyDtoGetterImplicitDeserialization() { super(); } - public MyDtoGetterImplicitDeserialization(final String stringValue, final int intValue, final boolean booleanValue) { + public MyDtoGetterImplicitDeserialization(final String stringValue) { super(); this.stringValue = stringValue; - this.booleanValue = booleanValue; } // API diff --git a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java index 11e4bee6eb..47c7938743 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java @@ -2,26 +2,22 @@ package org.baeldung.jackson.field; public class MyDtoSetter { - private String stringValue; - int intValue; + private int intValue; + public boolean booleanValue; public MyDtoSetter() { super(); } - public MyDtoSetter(final String stringValue, final int intValue, final boolean booleanValue) { + public MyDtoSetter(final int intValue, final boolean booleanValue) { super(); - this.stringValue = stringValue; this.intValue = intValue; + this.booleanValue = booleanValue; } // API - public String getStringValue() { - return stringValue; - } - public void setIntValue(final int intValue) { this.intValue = intValue; } diff --git a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java index 5acc3a92af..e1194a0829 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class JacksonFieldUnitTest { @Test - public final void givenDifferentAccessLevels_whenSerializing_thenPublicFieldsAreSerialized() throws JsonProcessingException { + public final void givenDifferentAccessLevels_whenPublic_thenSerializable() throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper(); final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel(); @@ -48,25 +48,23 @@ public class JacksonFieldUnitTest { @Test public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"booleanValue\":\"true\"}"; + final String jsonAsString = "{\"stringValue\":\"dtoString\"}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoGetterImplicitDeserialization dtoObject = mapper.readValue(jsonAsString, MyDtoGetterImplicitDeserialization.class); assertNotNull(dtoObject); assertThat(dtoObject.getStringValue(), equalTo("dtoString")); - assertThat(dtoObject.booleanValue, equalTo(true)); } @Test public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1}"; + final String jsonAsString = "{\"intValue\":1}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoSetter dtoObject = mapper.readValue(jsonAsString, MyDtoSetter.class); assertNotNull(dtoObject); - assertThat(dtoObject.getStringValue(), equalTo("dtoString")); assertThat(dtoObject.anotherGetIntValue(), equalTo(1)); } @@ -77,7 +75,6 @@ public class JacksonFieldUnitTest { final MyDtoSetter dtoObject = new MyDtoSetter(); final String dtoAsString = mapper.writeValueAsString(dtoObject); - assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, not(containsString("intValue"))); System.out.println(dtoAsString); }