File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
gson/src/test/java/org/baeldung/gson/advance Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ public void givenPolymorphicList_whenDeserializeWithTypeAdapter_thenCorrect() {
8181
8282 assertEquals (2 , outList .size ());
8383 assertTrue (outList .get (0 ) instanceof Dog );
84+ assertTrue (outList .get (1 ) instanceof Cow );
8485 }
8586
8687 @ Test
@@ -101,7 +102,7 @@ public void givenPolymorphicList_whenDeserializeWithRuntimeTypeAdapter_thenCorre
101102
102103 Type listOfAnimals = new TypeToken <ArrayList <Animal >>() {}.getType ();
103104
104- RuntimeTypeAdapterFactory <Animal > adapter = RuntimeTypeAdapterFactory .of (Animal .class )
105+ RuntimeTypeAdapterFactory <Animal > adapter = RuntimeTypeAdapterFactory .of (Animal .class , "type" )
105106 .registerSubtype (Dog .class )
106107 .registerSubtype (Cow .class );
107108
@@ -111,5 +112,6 @@ public void givenPolymorphicList_whenDeserializeWithRuntimeTypeAdapter_thenCorre
111112
112113 assertEquals (2 , outList .size ());
113114 assertTrue (outList .get (0 ) instanceof Dog );
115+ assertTrue (outList .get (1 ) instanceof Cow );
114116 }
115117}
You can’t perform that action at this time.
0 commit comments