Search in sources :

Example 1 with FileAttachment

use of com.microsoft.graph.models.extensions.FileAttachment 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());
}
Also used : FileAttachment(com.microsoft.graph.models.extensions.FileAttachment) JsonObject(com.google.gson.JsonObject) Attachment(com.microsoft.graph.models.extensions.Attachment) FileAttachment(com.microsoft.graph.models.extensions.FileAttachment) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.Test)

Aggregations

JsonObject (com.google.gson.JsonObject)1 DefaultLogger (com.microsoft.graph.logger.DefaultLogger)1 Attachment (com.microsoft.graph.models.extensions.Attachment)1 FileAttachment (com.microsoft.graph.models.extensions.FileAttachment)1 Test (org.junit.Test)1