22
33import static org .junit .Assert .assertEquals ;
44import static org .junit .Assert .assertNotNull ;
5+ import static org .junit .Assert .assertTrue ;
56
67import com .google .gson .JsonElement ;
78import com .google .gson .JsonObject ;
1718import com .microsoft .graph .models .extensions .User ;
1819import com .microsoft .graph .models .generated .RecurrenceRangeType ;
1920import com .microsoft .graph .requests .extensions .DriveItemDeltaCollectionResponse ;
21+ import com .microsoft .graph .models .extensions .UploadSession ;
2022import org .junit .Test ;
2123
2224public class DefaultSerializerTests {
@@ -127,14 +129,14 @@ public void testResponseHeaders() throws Exception {
127129 @ Test
128130 public void testDeserializeDerivedType () throws Exception {
129131 final DefaultSerializer serializer = new DefaultSerializer (new DefaultLogger ());
130- String source = "{\" @odata.context\" : \" /attachments/$entity\" ,\" @odata.type\" : \" #microsoft.graph.fileAttachment\" ,\" id\" : \" AAMkAGQ0MjBmNWVkLTYxZjUtNDRmYi05Y2NiLTBlYjIwNzJjNmM1NgBGAAAAAAC6ff7latYeQqu_gLrhSAIhBwCF7iGjpaOmRqVwbZc-xXzwAAAAAAEMAACF7iGjpaOmRqVwbZc-xXzwAABQStA0AAABEgAQAFbGmeisbjtLnQdp7kC_9Fk=\" ,\" lastModifiedDateTime\" : \" 2018-01-23T21:50:22Z\" ,\" name\" : \" Test Book.xlsx\" ,\" contentType\" : \" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\" ,\" size\" : 8457,\" isInline\" : false,\" contentId\" : null,\" contentLocation\" : null,\" contentBytes\" : \" bytedata\" }" ;
131- Attachment result = serializer .deserializeObject (source , Attachment .class );
132+ final String source = "{\" @odata.context\" : \" /attachments/$entity\" ,\" @odata.type\" : \" #microsoft.graph.fileAttachment\" ,\" id\" : \" AAMkAGQ0MjBmNWVkLTYxZjUtNDRmYi05Y2NiLTBlYjIwNzJjNmM1NgBGAAAAAAC6ff7latYeQqu_gLrhSAIhBwCF7iGjpaOmRqVwbZc-xXzwAAAAAAEMAACF7iGjpaOmRqVwbZc-xXzwAABQStA0AAABEgAQAFbGmeisbjtLnQdp7kC_9Fk=\" ,\" lastModifiedDateTime\" : \" 2018-01-23T21:50:22Z\" ,\" name\" : \" Test Book.xlsx\" ,\" contentType\" : \" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\" ,\" size\" : 8457,\" isInline\" : false,\" contentId\" : null,\" contentLocation\" : null,\" contentBytes\" : \" bytedata\" }" ;
133+ final Attachment result = serializer .deserializeObject (source , Attachment .class );
132134
133135 assert (result instanceof FileAttachment );
134136
135- FileAttachment fileAttachment = (FileAttachment ) result ;
137+ final FileAttachment fileAttachment = (FileAttachment ) result ;
136138 assertNotNull (fileAttachment .contentBytes );
137- JsonObject o = fileAttachment .getRawObject ();
139+ final JsonObject o = fileAttachment .getRawObject ();
138140 assertNotNull (o );
139141 assertEquals ("#microsoft.graph.fileAttachment" , o . get ("@odata.type" ).getAsString ());
140142 }
@@ -153,6 +155,15 @@ public void testSerializerCanSerializeVoidWithoutEmittingWarning() {
153155 assertEquals (t .x , t2 .x );
154156 assertEquals (t .y , t2 .y );
155157 }
158+ @ Test
159+ public void testDeserializerWhenCasingRespondedByServiceIsWrong () {
160+ final DefaultSerializer serializer = new DefaultSerializer (new DefaultLogger ());
161+ final String source = "{\" @odata.context\" : \" https://outlook.office.com/api/v2.0/$metadata#Users('e45f52f5-f2dd-4359-abc5-e74f2960b831')/Messages/AAMkAGQ0MjBmNWVkLTYxZjUtNDRmYi05Y2NiLTBlYjIwNzJjNmM1NgBGAAAAAAC6ff7latYeQqu_gLrhSAIhBwCF7iGjpaOmRqVwbZc-xXzwAAAAAAEMAACF7iGjpaOmRqVwbZc-xXzwAABQStA0AAABEgAQAFbGmeisbjtLnQdp7kC_9Fk=/AttachmentSessions/$entity\" ,\" ExpirationDateTime\" : \" 2020-10-06T14:23:42.1027521Z\" ,\" NextExpectedRanges\" : [\" 5242880\" ]}" ;
162+ final UploadSession result = serializer .deserializeObject (source , UploadSession .class );
163+ assertNotNull (result );
164+ assertNotNull (result .nextExpectedRanges );
165+ assertTrue (result .nextExpectedRanges .size () > 0 );
166+ }
156167
157168 public static final class HasVoidMember {
158169 @ SerializedName ("x" )
0 commit comments