2020
2121import java .io .IOException ;
2222import java .nio .charset .Charset ;
23- import java .util .Arrays ;
2423
2524import static org .hamcrest .CoreMatchers .not ;
2625import static org .hamcrest .CoreMatchers .containsString ;
2726
2827import static org .junit .Assert .assertEquals ;
2928import static org .junit .Assert .assertThat ;
30- import static org .junit .Assert .assertTrue ;
29+ import static org .junit .Assert .assertArrayEquals ;
3130
3231public class MessagePackDataformatForPojoTest
3332 extends MessagePackDataformatTestBase
@@ -44,7 +43,7 @@ public void testNormal()
4443 assertEquals (normalPojo .l , value .l );
4544 assertEquals (normalPojo .f , value .f , 0.000001f );
4645 assertEquals (normalPojo .d , value .d , 0.000001f );
47- assertTrue ( Arrays . equals ( normalPojo .b , value .b ) );
46+ assertArrayEquals ( normalPojo .b , value .b );
4847 assertEquals (normalPojo .bi , value .bi );
4948 assertEquals (normalPojo .suit , Suit .HEART );
5049 }
@@ -56,7 +55,7 @@ public void testNestedList()
5655 byte [] bytes = objectMapper .writeValueAsBytes (nestedListPojo );
5756 NestedListPojo value = objectMapper .readValue (bytes , NestedListPojo .class );
5857 assertEquals (nestedListPojo .s , value .s );
59- assertTrue ( Arrays . equals ( nestedListPojo .strs .toArray (), value .strs .toArray () ));
58+ assertArrayEquals ( nestedListPojo .strs .toArray (), value .strs .toArray ());
6059 }
6160
6261 @ Test
@@ -112,12 +111,13 @@ public void testSerializationWithoutSchema()
112111 {
113112 ObjectMapper objectMapper = new ObjectMapper (factory ); // to not affect shared objectMapper state
114113 objectMapper .setAnnotationIntrospector (new JsonArrayFormat ());
115- UsingCustomConstructorPojo orig = new UsingCustomConstructorPojo ("komamitsu" , 55 );
116- byte [] bytes = objectMapper .writeValueAsBytes (orig );
114+ byte [] bytes = objectMapper .writeValueAsBytes (complexPojo );
117115 String scheme = new String (bytes , Charset .forName ("UTF-8" ));
118- assertThat (scheme , not (containsString ("name" )));
119- UsingCustomConstructorPojo value = objectMapper .readValue (bytes , UsingCustomConstructorPojo .class );
116+ assertThat (scheme , not (containsString ("name" ))); // validating schema doesn't contains keys, that's just array
117+ ComplexPojo value = objectMapper .readValue (bytes , ComplexPojo .class );
120118 assertEquals ("komamitsu" , value .name );
121- assertEquals (55 , value .age );
119+ assertEquals (20 , value .age );
120+ assertArrayEquals (complexPojo .values .toArray (), value .values .toArray ());
121+ assertEquals (complexPojo .grades .get ("math" ), value .grades .get ("math" ));
122122 }
123123}
0 commit comments