From c96bdead45c4106ef780dc219e1727c89f2eaac3 Mon Sep 17 00:00:00 2001 From: Rachel Shu Date: Mon, 21 Jul 2014 08:05:53 -0400 Subject: [PATCH] Changes to reduce fields not necessary. --- .../test/java/org/baeldung/jackson/field/MyDtoGetter.java | 4 +--- .../jackson/field/MyDtoGetterImplicitDeserialization.java | 6 ------ .../test/java/org/baeldung/jackson/field/MyDtoSetter.java | 2 -- .../org/baeldung/jackson/test/JacksonFieldUnitTest.java | 8 ++------ 4 files changed, 3 insertions(+), 17 deletions(-) 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 12feb98628..ea4ae529fe 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetter.java @@ -3,8 +3,7 @@ package org.baeldung.jackson.field; public class MyDtoGetter { private String stringValue; - int intValue; - public boolean booleanValue; + private int intValue; public MyDtoGetter() { super(); @@ -15,7 +14,6 @@ public class MyDtoGetter { this.stringValue = stringValue; this.intValue = intValue; - this.booleanValue = booleanValue; } // API 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 ee9d346a0a..da4e5ebe42 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoGetterImplicitDeserialization.java @@ -3,7 +3,6 @@ package org.baeldung.jackson.field; public class MyDtoGetterImplicitDeserialization { private String stringValue; - int intValue; public boolean booleanValue; public MyDtoGetterImplicitDeserialization() { @@ -14,7 +13,6 @@ public class MyDtoGetterImplicitDeserialization { super(); this.stringValue = stringValue; - this.intValue = intValue; this.booleanValue = booleanValue; } @@ -24,8 +22,4 @@ public class MyDtoGetterImplicitDeserialization { return stringValue; } - public int getIntValue() { - return intValue; - } - } 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 391b1959ae..11e4bee6eb 100644 --- a/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java +++ b/jackson/src/test/java/org/baeldung/jackson/field/MyDtoSetter.java @@ -4,7 +4,6 @@ public class MyDtoSetter { private String stringValue; int intValue; - public boolean booleanValue; public MyDtoSetter() { super(); @@ -15,7 +14,6 @@ public class MyDtoSetter { this.stringValue = stringValue; this.intValue = intValue; - this.booleanValue = booleanValue; } // API 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 a7394d9129..fc8c7ff176 100644 --- a/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java +++ b/jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java @@ -44,26 +44,24 @@ public class JacksonFieldUnitTest { final String dtoAsString = mapper.writeValueAsString(dtoObject); assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); System.out.println(dtoAsString); } @Test public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"booleanValue\":\"true\"}"; + final String jsonAsString = "{\"stringValue\":\"dtoString\",\"booleanValue\":\"true\"}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoGetterImplicitDeserialization dtoObject = mapper.readValue(jsonAsString, MyDtoGetterImplicitDeserialization.class); assertNotNull(dtoObject); assertThat(dtoObject.getStringValue(), equalTo("dtoString")); - assertThat(dtoObject.getIntValue(), equalTo(1)); assertThat(dtoObject.booleanValue, equalTo(true)); } @Test public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException { - final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1,\"booleanValue\":\"true\"}"; + final String jsonAsString = "{\"stringValue\":\"dtoString\",\"intValue\":1}"; final ObjectMapper mapper = new ObjectMapper(); final MyDtoSetter dtoObject = mapper.readValue(jsonAsString, MyDtoSetter.class); @@ -71,7 +69,6 @@ public class JacksonFieldUnitTest { assertNotNull(dtoObject); assertThat(dtoObject.getStringValue(), equalTo("dtoString")); assertThat(dtoObject.anotherGetIntValue(), equalTo(1)); - assertThat(dtoObject.booleanValue, equalTo(true)); } @Test @@ -83,7 +80,6 @@ public class JacksonFieldUnitTest { final String dtoAsString = mapper.writeValueAsString(dtoObject); assertThat(dtoAsString, containsString("stringValue")); assertThat(dtoAsString, not(containsString("intValue"))); - assertThat(dtoAsString, containsString("booleanValue")); System.out.println(dtoAsString); }