jackson cleanup

This commit is contained in:
eugenp 2015-05-31 23:26:17 +01:00
parent 524e05de83
commit f1fc00a157
2 changed files with 8 additions and 8 deletions

View File

@ -1,15 +1,15 @@
package org.baeldung.jackson.field; package org.baeldung.jackson.field;
public class MyDtoSetter { public class MyDtoWithSetter {
private int intValue; private int intValue;
public boolean booleanValue; public boolean booleanValue;
public MyDtoSetter() { public MyDtoWithSetter() {
super(); super();
} }
public MyDtoSetter(final int intValue, final boolean booleanValue) { public MyDtoWithSetter(final int intValue, final boolean booleanValue) {
super(); super();
this.intValue = intValue; this.intValue = intValue;
@ -22,7 +22,7 @@ public class MyDtoSetter {
this.intValue = intValue; this.intValue = intValue;
} }
public int alternativeGetIntValue() { public int accessIntValue() {
return intValue; return intValue;
} }

View File

@ -9,7 +9,7 @@ import static org.junit.Assert.assertThat;
import java.io.IOException; import java.io.IOException;
import org.baeldung.jackson.field.MyDtoAccessLevel; import org.baeldung.jackson.field.MyDtoAccessLevel;
import org.baeldung.jackson.field.MyDtoSetter; import org.baeldung.jackson.field.MyDtoWithSetter;
import org.baeldung.jackson.field.MyDtoWithGetter; import org.baeldung.jackson.field.MyDtoWithGetter;
import org.junit.Test; import org.junit.Test;
@ -62,17 +62,17 @@ public class JacksonFieldUnitTest {
final String jsonAsString = "{\"intValue\":1}"; final String jsonAsString = "{\"intValue\":1}";
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
final MyDtoSetter dtoObject = mapper.readValue(jsonAsString, MyDtoSetter.class); final MyDtoWithSetter dtoObject = mapper.readValue(jsonAsString, MyDtoWithSetter.class);
assertNotNull(dtoObject); assertNotNull(dtoObject);
assertThat(dtoObject.alternativeGetIntValue(), equalTo(1)); assertThat(dtoObject.accessIntValue(), equalTo(1));
} }
@Test @Test
public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws IOException { public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws IOException {
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
final MyDtoSetter dtoObject = new MyDtoSetter(); final MyDtoWithSetter dtoObject = new MyDtoWithSetter();
final String dtoAsString = mapper.writeValueAsString(dtoObject); final String dtoAsString = mapper.writeValueAsString(dtoObject);
assertThat(dtoAsString, not(containsString("intValue"))); assertThat(dtoAsString, not(containsString("intValue")));