Search in sources :

Example 26 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class CollectionPageSerializerTests method deltaLinkEndtoEndTest.

@Test
public void deltaLinkEndtoEndTest() throws Exception {
    final String jsonString = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#users\",\"@odata.deltaLink\":\"https://graph.microsoft.com/v1.0/users/delta?$deltatoken=iW6HI4gRQf_CNwkN_2YR_wZsbUvU92el3RLdsbOM_4ZSC9GlnuDQvR2Xy0DDbLeJHde01ChMf5TmFQhCNFFwoil_n6kD8qDh5afldOw_CAj71jPUSP5Fwi3_PqeWMhN3LdX6oFBE5T-RyeUJaXsP9b4DLxYnmOrlb9EyOd4LP-kffRADZDN30aTt402EhIx-s0UWAEkKuSEVw2C2QyzqWQFO_PrC5wRXXVi6DiQf715QDXkxDmpNkgcS_jzINs2u9HbZzIpj170ZOx52vE_3eaI150SAd8qXOg9DEFPc5KUwAeOyEruCnqGuN07TuOc7L8eXa96_R-snlCNjB4R7qOWXQcbhRejm0izYC8w7g3uu1l3cPdhZURDsioOlO1xQGTa_upsvqMiVZBaNgMzZlRvy3GZmNTW-zQA1PFfKgwaVpWB8DcvG2CagEXE_Run7zFav00LHlKc8mEpQnfzYrbNct_sgpBGdK7-alRFg_-x0gHqMuzIznmYn6mQ_Nh_e-s57wtHDNgTYAKKMjlJlOoHig2G3aTHc4zdg0zQ_LFTi1EiIxh5a1tZQuGhxp2-ky4_kfnl0qekJvkchqHquWMRm0iQ4Dja3VEFI7AIBxhNG4VBDibOm_HZd7Jtm9nxT_bCI5ji5aaaFMvy16Ei11sAWf9390ly9-HscR2zr2RHu1hReVxkVt-nUA-lhXmxWBrM64NJUae0JbF5s68QWCEBhWvGBYYclMjMvQfHG5R7yJ7Kosp_Afxg4Vna1cvCXuHLBe0RiCCMg88dnQreMiFC6rWRmltuJ8Ryk7u_ZFU_g0mPc904dhnJ5SfUJRnjQAkL-4I5LSDgGOR3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5Cum9xzAjq_NXkabHBU56GpHf0G8RpnRTabIqXx-bCgfLlF9wwpuupu7hINPNmdBJI1ZyqiWqeWG7KD47k7OBtPQ7Yuq.ElDr4hD2Tb9PoZex2ONMAModMdlpfXqklPlnRuLo5QA\",\"value\":[]}";
    final DefaultSerializer defaultSerializer = new DefaultSerializer(logger);
    final UserDeltaCollectionResponse response = defaultSerializer.deserializeObject(jsonString, UserDeltaCollectionResponse.class);
    final UserDeltaCollectionPage page = new UserDeltaCollectionPage(response, null);
    assertNotNull(page.deltaLink);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) UserDeltaCollectionPage(com.microsoft.graph.requests.UserDeltaCollectionPage) UserDeltaCollectionResponse(com.microsoft.graph.requests.UserDeltaCollectionResponse) Test(org.junit.jupiter.api.Test)

Example 27 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class PlannerTests method testPlannerTaskDetailsDeserialization.

@Test
public void testPlannerTaskDetailsDeserialization() {
    String input = "{\r\n" + "	\"references\": {},\r\n" + "	\"@odata.etag\": \"W/\\\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBAUCc=\\\"\",\r\n" + "	\"description\": null,\r\n" + "	\"checklist\": {\r\n" + "		\"42660\": {\r\n" + "			\"lastModifiedDateTime\": \"2018-10-28T14:29:37.7423391Z\",\r\n" + "			\"@odata.type\": \"#microsoft.graph.plannerChecklistItem\",\r\n" + "			\"orderHint\": \"8586608699726429822PK\",\r\n" + "			\"lastModifiedBy\": {\r\n" + "				\"user\": {\r\n" + "					\"displayName\": null,\r\n" + "					\"id\": \"f3a1dfe8-f2ef-4870-9642-413d468c571c\"\r\n" + "				}\r\n" + "			},\r\n" + "			\"title\": \"Ein Checklisteneintrag\",\r\n" + "			\"isChecked\": false\r\n" + "		}\r\n" + "	},\r\n" + "	\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#planner/tasks('C6iIn6oJcEGcLX5XAiKeCZcAOv30')/details/$entity\",\r\n" + "	\"previewType\": \"automatic\",\r\n" + "	\"id\": \"C6iIn6oJcEGcLX5XAiKeCZcAOv30\"\r\n" + "}";
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    PlannerTaskDetails ptd = serializer.deserializeObject(input, PlannerTaskDetails.class);
    assertNotNull(ptd);
    PlannerChecklistItem item = ptd.checklist.get("42660");
    assertEquals(item.title, "Ein Checklisteneintrag");
    assertEquals(item.isChecked, false);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) PlannerTaskDetails(com.microsoft.graph.models.PlannerTaskDetails) PlannerChecklistItem(com.microsoft.graph.models.PlannerChecklistItem) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 28 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class PlannerTests method testPlannerChecklistItemDeserialization.

@Test
public void testPlannerChecklistItemDeserialization() throws Exception {
    String input = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#planner/tasks('433tZlfn_USJwWRL9khDx8kALTM7')/details/$entity\",\"@odata.etag\":\"W/\\\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBAcCc=\\\"\",\"description\":\"This is a test description of test event two.\",\"previewType\":\"automatic\",\"id\":\"433tZlfn_USJwWRL9khDx8kALTM7\",\"references\":{},\"checklist\":{\"55554\":{\"@odata.type\":\"#microsoft.graph.plannerChecklistItem\",\"isChecked\":false,\"title\":\"Test Item 2\",\"orderHint\":\"8586580527[2\",\"lastModifiedDateTime\":\"2018-11-30T05:01:53.0387892Z\",\"lastModifiedBy\":{\"user\":{\"displayName\":null,\"id\":\"ec786dee-da15-4896-8e73-57141477bae7\"}}},\"91100\":{\"@odata.type\":\"#microsoft.graph.plannerChecklistItem\",\"isChecked\":true,\"title\":\"Test Item 1 \",\"orderHint\":\"8586580528393292964Pc\",\"lastModifiedDateTime\":\"2018-11-30T05:01:47.4138223Z\",\"lastModifiedBy\":{\"user\":{\"displayName\":null,\"id\":\"ec786dee-da15-4896-8e73-57141477bae7\"}}}}}";
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    PlannerTaskDetails ptd = serializer.deserializeObject(input, PlannerTaskDetails.class);
    assertNotNull(ptd);
    PlannerChecklistItem item1 = ptd.checklist.get("91100");
    assertEquals(item1.title, "Test Item 1 ");
    PlannerChecklistItem item2 = ptd.checklist.get("55554");
    assertEquals(item2.title, "Test Item 2");
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) PlannerTaskDetails(com.microsoft.graph.models.PlannerTaskDetails) PlannerChecklistItem(com.microsoft.graph.models.PlannerChecklistItem) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 29 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class DefaultSerializerTests method testDriveItemChildAdditionalDataDeserialization.

/**
 * Make sure that deserializing a DriveItems also deserializes child additionalData
 *
 * @throws Exception If there is an exception during the test
 */
@Test
public void testDriveItemChildAdditionalDataDeserialization() throws Exception {
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    String source = "{\n" + "    \"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users('02008492-3fec-4ce4-bb54-980ad856856f')/drive/root/children\",\n" + "    \"value\": [\n" + "        {\n" + "            \"createdBy\": {\n" + "                \"user\": {\n" + "                    \"email\": \"the@email.com\",\n" + "                    \"id\": \"02008492-3fec-4ce4-bb54-980ad856856f\",\n" + "                    \"displayName\": \"John Doe\"\n" + "                }\n" + "            }\n" + "        }\n" + "    ]\n" + "}";
    DriveItemDeltaCollectionResponse result = serializer.deserializeObject(source, DriveItemDeltaCollectionResponse.class);
    assertNotNull(result);
    assertNotNull(result.value);
    assertEquals(1, result.value.size());
    assertNotNull(result.value.get(0));
    assertNotNull(result.value.get(0).createdBy);
    assertNotNull(result.value.get(0).createdBy.user);
    assertNotNull(result.value.get(0).createdBy.user.additionalDataManager());
    assertNotNull(result.value.get(0).createdBy.user.additionalDataManager().get("email"));
    assertEquals("the@email.com", result.value.get(0).createdBy.user.additionalDataManager().get("email").getAsString());
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) DriveItemDeltaCollectionResponse(com.microsoft.graph.requests.DriveItemDeltaCollectionResponse) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 30 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class DefaultSerializerTests method testSerializerCanSerializeVoidWithoutEmittingWarning.

@Test
public void testSerializerCanSerializeVoidWithoutEmittingWarning() {
    // Unfortunately does not assert for existence of Java 9 illegal access warnings
    // which seem to written to the console without use of System.err/System.out (so cannot be captured AFAIK).
    // @davidmoten
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    HasVoidMember t = new HasVoidMember();
    String json = serializer.serializeObject(t);
    // this line will emit a warning from Java 9 about illegal access to the constructor of Void
    // if gson TypeAdapterFactory is not handling Void properly
    HasVoidMember t2 = serializer.deserializeObject(json, HasVoidMember.class);
    assertEquals(t.x, t2.x);
    assertEquals(t.y, t2.y);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultSerializer (com.microsoft.graph.serializer.DefaultSerializer)59 Test (org.junit.jupiter.api.Test)54 DefaultLogger (com.microsoft.graph.logger.DefaultLogger)32 IHttpRequest (com.microsoft.graph.http.IHttpRequest)6 URL (java.net.URL)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 ILogger (com.microsoft.graph.logger.ILogger)5 JsonElement (com.google.gson.JsonElement)4 MediaStream (com.microsoft.graph.callrecords.models.MediaStream)4 GraphErrorResponse (com.microsoft.graph.http.GraphErrorResponse)4 PlannerChecklistItem (com.microsoft.graph.models.PlannerChecklistItem)4 PlannerTaskDetails (com.microsoft.graph.models.PlannerTaskDetails)4 RecurrenceRange (com.microsoft.graph.models.RecurrenceRange)4 User (com.microsoft.graph.models.User)4 ISerializer (com.microsoft.graph.serializer.ISerializer)4 GraphServiceException (com.microsoft.graph.http.GraphServiceException)3 OkHttpClient (okhttp3.OkHttpClient)3 Request (okhttp3.Request)3 JsonObject (com.google.gson.JsonObject)2 DateOnly (com.microsoft.graph.core.DateOnly)2