23
23
public class JacksonFieldUnitTest {
24
24
25
25
@ Test
26
- public final void givenDifferentAccessLevels_whenPrivateOrPackage_thenNotSerializable_whenPublic_thenSerializable () throws JsonProcessingException {
26
+ public final void givenDifferentAccessLevels_whenPublic_thenSerializable () throws JsonProcessingException {
27
27
final ObjectMapper mapper = new ObjectMapper ();
28
28
29
29
final MyDtoAccessLevel dtoObject = new MyDtoAccessLevel ();
@@ -49,42 +49,39 @@ public final void givenDifferentAccessLevels_whenGetterAdded_thenSerializable()
49
49
50
50
@ Test
51
51
public final void givenDifferentAccessLevels_whenGetterAdded_thenDeserializable () throws JsonProcessingException , JsonMappingException , IOException {
52
- final String jsonAsString = "{\" stringValue\" :\" dtoString\" , \" booleanValue \" : \" true \" }" ;
52
+ final String jsonAsString = "{\" stringValue\" :\" dtoString\" }" ;
53
53
final ObjectMapper mapper = new ObjectMapper ();
54
54
55
55
final MyDtoGetterImplicitDeserialization dtoObject = mapper .readValue (jsonAsString , MyDtoGetterImplicitDeserialization .class );
56
56
57
57
assertNotNull (dtoObject );
58
58
assertThat (dtoObject .getStringValue (), equalTo ("dtoString" ));
59
- assertThat (dtoObject .booleanValue , equalTo (true ));
60
59
}
61
60
62
61
@ Test
63
62
public final void givenDifferentAccessLevels_whenSetterAdded_thenDeserializable () throws JsonProcessingException , JsonMappingException , IOException {
64
- final String jsonAsString = "{\" stringValue \" : \" dtoString \" , \" intValue\" :1}" ;
63
+ final String jsonAsString = "{\" intValue\" :1}" ;
65
64
final ObjectMapper mapper = new ObjectMapper ();
66
65
67
66
final MyDtoSetter dtoObject = mapper .readValue (jsonAsString , MyDtoSetter .class );
68
67
69
68
assertNotNull (dtoObject );
70
- assertThat (dtoObject .getStringValue (), equalTo ("dtoString" ));
71
69
assertThat (dtoObject .anotherGetIntValue (), equalTo (1 ));
72
70
}
73
71
74
72
@ Test
75
- public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable () throws JsonProcessingException , JsonMappingException , IOException {
73
+ public final void givenDifferentAccessLevels_whenSetterAdded_thenStillNotSerializable () throws JsonProcessingException {
76
74
final ObjectMapper mapper = new ObjectMapper ();
77
75
78
76
final MyDtoSetter dtoObject = new MyDtoSetter ();
79
77
80
78
final String dtoAsString = mapper .writeValueAsString (dtoObject );
81
- assertThat (dtoAsString , containsString ("stringValue" ));
82
79
assertThat (dtoAsString , not (containsString ("intValue" )));
83
80
System .out .println (dtoAsString );
84
81
}
85
82
86
83
@ Test
87
- public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable () throws JsonProcessingException , JsonMappingException , IOException {
84
+ public final void givenDifferentAccessLevels_whenSetVisibility_thenSerializable () throws JsonProcessingException {
88
85
final ObjectMapper mapper = new ObjectMapper ();
89
86
mapper .setVisibility (PropertyAccessor .ALL , Visibility .NONE );
90
87
mapper .setVisibility (PropertyAccessor .FIELD , Visibility .ANY );
0 commit comments