use of com.microsoft.graph.models.extensions.Attachment in project msgraph-sdk-java by microsoftgraph.
the class DefaultSeralizerTests method testDeserializeDerivedType.
@Test
public void testDeserializeDerivedType() throws Exception {
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
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\"}";
Attachment result = serializer.deserializeObject(source, Attachment.class);
assert (result instanceof FileAttachment);
FileAttachment fileAttachment = (FileAttachment) result;
assertNotNull(fileAttachment.contentBytes);
JsonObject o = fileAttachment.getRawObject();
assertNotNull(o);
assertEquals("#microsoft.graph.fileAttachment", o.get("@odata.type").getAsString());
}
Aggregations