Skip to content

Commit 3a3dde2

Browse files
committed
Test
1 parent 1d61249 commit 3a3dde2

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

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

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import static org.junit.Assert.assertEquals;
44
import static org.junit.Assert.assertNotNull;
55

6-
import org.junit.Test;
7-
86
import com.google.gson.JsonElement;
97
import com.google.gson.JsonObject;
108
import com.google.gson.annotations.Expose;
@@ -15,9 +13,11 @@
1513
import com.microsoft.graph.models.extensions.DateOnly;
1614
import com.microsoft.graph.models.extensions.Drive;
1715
import com.microsoft.graph.models.extensions.FileAttachment;
18-
import com.microsoft.graph.models.extensions.User;
1916
import com.microsoft.graph.models.extensions.RecurrenceRange;
17+
import com.microsoft.graph.models.extensions.User;
2018
import com.microsoft.graph.models.generated.RecurrenceRangeType;
19+
import com.microsoft.graph.requests.extensions.DriveItemDeltaCollectionResponse;
20+
import org.junit.Test;
2121

2222
public class DefaultSerializerTests {
2323

@@ -26,7 +26,7 @@ public class DefaultSerializerTests {
2626
*
2727
* @throws Exception If there is an exception during the test
2828
*/
29-
@Test
29+
@Test
3030
public void testDriveDeserialization() throws Exception {
3131
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
3232
String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#drives/$entity\",\"id\":\"8bf6ae90006c4a4c\",\"driveType\":\"personal\",\"owner\":{\"user\":{\"displayName\":\"Peter\",\"id\":\"8bf6ae90006c4a4c\"}},\"quota\":{\"deleted\":1485718314,\"remaining\":983887466461,\"state\":\"normal\",\"total\":1142461300736,\"used\":158573834275}}";
@@ -38,6 +38,43 @@ public void testDriveDeserialization() throws Exception {
3838

3939
}
4040

41+
/**
42+
* Make sure that deserializing a DriveItems also deserializes child additionalData
43+
*
44+
* @throws Exception If there is an exception during the test
45+
*/
46+
@Test
47+
public void testDriveItemChildAdditionalDataDeserialization() throws Exception {
48+
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
49+
String source = "{\n"
50+
+ " \"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users('02008492-3fec-4ce4-bb54-980ad856856f')/drive/root/children\",\n"
51+
+ " \"value\": [\n"
52+
+ " {\n"
53+
+ " \"createdBy\": {\n"
54+
+ " \"user\": {\n"
55+
+ " \"email\": \"[email protected]\",\n"
56+
+ " \"id\": \"02008492-3fec-4ce4-bb54-980ad856856f\",\n"
57+
+ " \"displayName\": \"John Doe\"\n"
58+
+ " }\n"
59+
+ " }\n"
60+
+ " }\n"
61+
+ " ]\n"
62+
+ "}";
63+
64+
DriveItemDeltaCollectionResponse result = serializer
65+
.deserializeObject(source, DriveItemDeltaCollectionResponse.class);
66+
assertNotNull(result);
67+
assertNotNull(result.value);
68+
assertEquals(1, result.value.size());
69+
assertNotNull(result.value.get(0));
70+
assertNotNull(result.value.get(0).createdBy);
71+
assertNotNull(result.value.get(0).createdBy.user);
72+
assertNotNull(result.value.get(0).createdBy.user.additionalDataManager());
73+
assertNotNull(result.value.get(0).createdBy.user.additionalDataManager().get("email"));
74+
assertEquals("[email protected]",
75+
result.value.get(0).createdBy.user.additionalDataManager().get("email").getAsString());
76+
}
77+
4178
@Test
4279
public void testRecurrenceRangeDeserialization() throws Exception {
4380
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());

0 commit comments

Comments
 (0)