Skip to content

Commit ef1aa2f

Browse files
author
Caitlin Bales (MSFT)
committed
Derived type deserialization test
1 parent d99901f commit ef1aa2f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/test/java/com/microsoft/graph/serializer/DefaultSeralizerTests.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import org.junit.Test;
88

99
import com.microsoft.graph.models.extensions.Drive;
10+
import com.microsoft.graph.models.extensions.FileAttachment;
1011
import com.microsoft.graph.models.generated.RecurrenceRangeType;
1112
import com.microsoft.graph.models.generated.BaseRecurrenceRange;
1213
import com.microsoft.graph.logger.DefaultLogger;
14+
import com.microsoft.graph.models.extensions.Attachment;
1315
import com.microsoft.graph.models.extensions.DateOnly;
1416

1517
public class DefaultSeralizerTests {
@@ -64,5 +66,16 @@ public void testRecurrenceRangeSerialization() throws Exception {
6466
assertNotNull(jsonOut);
6567
assertEquals(expected, jsonOut);
6668
}
67-
69+
70+
@Test
71+
public void testDeserializeDerivedType() throws Exception {
72+
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
73+
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\"}";
74+
Attachment result = serializer.deserializeObject(source, Attachment.class);
75+
76+
assert(result instanceof FileAttachment);
77+
78+
FileAttachment fileAttachment = (FileAttachment) result;
79+
assertNotNull(fileAttachment.contentBytes);
80+
}
6881
}

0 commit comments

Comments
 (0)