minor jackson testing work
This commit is contained in:
parent
04f7919eb3
commit
3074920322
@ -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_whenPrivateOrPackage_thenNotSerializable_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\",\"booleanValue\":\"true\"}";
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@ -60,7 +59,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 = "{\"stringValue\":\"dtoString\",\"intValue\":1}";
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@ -72,7 +71,7 @@ public class JacksonFieldUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws JsonProcessingException, JsonMappingException, IOException {
|
||||
public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable() throws IOException {
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
final MyDtoSetter dtoObject = new MyDtoSetter();
|
||||
@ -84,7 +83,7 @@ public class JacksonFieldUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable() throws JsonProcessingException, JsonMappingException, IOException {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user