Merge remote-tracking branch 'upstream/master'

Conflicts:
	jackson/src/test/java/org/baeldung/jackson/test/JacksonFieldUnitTest.java
This commit is contained in:
Rachel Shu
2014-07-22 13:33:48 -04:00
50 changed files with 2270 additions and 263 deletions
@@ -1,4 +1,4 @@
package org.baeldung.jackson.dtos;
package org.baeldung.jackson.serialization;
import java.io.IOException;
@@ -11,9 +11,7 @@ public class MyDtoNullKeySerializer extends JsonSerializer<Object> {
@Override
public void serialize(final Object value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeFieldName("");
}
}
@@ -17,13 +17,12 @@ import org.junit.Test;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JacksonFieldUnitTest {
@Test
public final void givenDifferentAccessLevels_whenPublic_thenSerializable() throws JsonProcessingException {
public final void givenDifferentAccessLevels_whenSerializing_thenPublicFieldsAreSerialized() throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper();
final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel();
@@ -48,7 +47,7 @@ public class JacksonFieldUnitTest {
}
@Test
public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException {
public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable() throws IOException {
final String jsonAsString = "{\"stringValue\":\"dtoString\"}";
final ObjectMapper mapper = new ObjectMapper();
@@ -59,7 +58,7 @@ public class JacksonFieldUnitTest {
}
@Test
public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws JsonProcessingException, JsonMappingException, IOException {
public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable() throws IOException {
final String jsonAsString = "{\"intValue\":1}";
final ObjectMapper mapper = new ObjectMapper();
@@ -70,7 +69,7 @@ public class JacksonFieldUnitTest {
}
@Test
public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws JsonProcessingException {
public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
final MyDtoSetter dtoObject = new MyDtoSetter();
@@ -81,7 +80,7 @@ public class JacksonFieldUnitTest {
}
@Test
public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws JsonProcessingException {
public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
@@ -10,12 +10,12 @@ import java.util.Map;
import org.baeldung.jackson.dtos.MyDto;
import org.baeldung.jackson.dtos.MyDtoIncludeNonDefault;
import org.baeldung.jackson.dtos.MyDtoNullKeySerializer;
import org.baeldung.jackson.dtos.MyDtoWithFilter;
import org.baeldung.jackson.dtos.MyMixInForString;
import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreField;
import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreFieldByName;
import org.baeldung.jackson.dtos.ignore.MyDtoIgnoreNull;
import org.baeldung.jackson.serialization.MyDtoNullKeySerializer;
import org.junit.Test;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -187,6 +187,8 @@ public class JacksonSerializationIgnoreUnitTest {
System.out.println(dtoAsString);
}
// map
@Test
public final void givenIgnoringMapNullValue_whenWritingMapObjectWithNullValue_thenIgnored() throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper();