Search in sources :

Example 11 with PlannerTaskDetails

use of com.microsoft.graph.models.PlannerTaskDetails in project msgraph-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 12 with PlannerTaskDetails

use of com.microsoft.graph.models.PlannerTaskDetails in project msgraph-sdk-java by microsoftgraph.

the class AdditionalDataTests method testHashMapChildAdditionalData.

@Test
public void testHashMapChildAdditionalData() {
    String input = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#planner/tasks('8kUva3lOqkKZ-4_u5tkIC8kAFv2c')/details/$entity\",\"@odata.etag\":\"W/\\\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBAYCc=\\\"\",\"description\":null," + "\"previewType\":\"automatic\",\"id\":\"8kUva3lOqkKZ-4_u5tkIC8kAFv2c\"," + "\"references\":{\"https%3A//testurl/\":{\"@odata.type\":\"#microsoft.graph.plannerExternalReference\",\"alias\":\"test_alias\",\"type\":null,\"previewPriority\":\"8586538193086391421\",\"lastModifiedDateTime\":" + "\"2019-01-18T04:59:36.8384386Z\",\"lastModifiedBy\":{\"user\":{\"displayName\":null,\"id\":\"ec786dee-da15-4896-8e73-57141477bae7\"}}}},\"checklist\":{\"1234\":{\"@odata.type\":\"#microsoft.graph.plannerChecklistItem\"," + "\"isChecked\":false,\"title\":\"Test title\",\"orderHint\":\"8586538194441079237\",\"lastModifiedDateTime\":\"2019-01-18T04:57:21.369657Z\",\"lastModifiedBy\":{\"user\":{\"displayName\":null,\"id\":\"ec786dee-da15-4896-8e73-57141477bae7\"}}}," + "\"66442\":{\"@odata.type\":\"#microsoft.graph.plannerChecklistItem\",\"isChecked\":false,\"title\":\"checklist item 3\",\"orderHint\":\"8586539618F3\",\"lastModifiedDateTime\":\"2019-01-16T13:24:11.4732273Z\",\"lastModifiedBy\":" + "{\"user\":{\"displayName\":null,\"id\":\"ec786dee-da15-4896-8e73-57141477bae7\"}}},\"83642\":{\"@odata.type\":\"#microsoft.graph.plannerChecklistItem\",\"isChecked\":false,\"title\":\"checklist item 1\",\"orderHint\":\"8586539619030374725P_\"," + "\"lastModifiedDateTime\":\"2019-01-16T13:24:02.4557738Z\",\"lastModifiedBy\":{\"user\":{\"displayName\":null,\"id\":\"ec786dee-da15-4896-8e73-57141477bae7\"}}},\"84724\":{\"@odata.type\":\"#microsoft.graph.plannerChecklistItem\"," + "\"isChecked\":false,\"title\":\"checklist item 2\",\"orderHint\":\"8586539618YD\",\"lastModifiedDateTime\":\"2019-01-16T13:24:07.113845Z\",\"lastModifiedBy\":{\"user\":{\"displayName\":null,\"id\":" + "\"ec786dee-da15-4896-8e73-57141477bae7\"}}}}}";
    PlannerTaskDetails deserializedObject = serializer.deserializeObject(input, PlannerTaskDetails.class);
    assertNull(deserializedObject.additionalDataManager().get("1234"));
    assertNull(deserializedObject.additionalDataManager().get("66442"));
    assertNull(deserializedObject.additionalDataManager().get("83642"));
    assertNull(deserializedObject.additionalDataManager().get("84724"));
    assertNull(deserializedObject.additionalDataManager().get("https%3A//testurl/"));
    String serialized = serializer.serializeObject(deserializedObject);
    JsonObject jsonObject = JsonParser.parseString(serialized).getAsJsonObject();
    assertNotNull(jsonObject.get("checklist").getAsJsonObject().get("1234"));
    assertNull(jsonObject.get("checklist").getAsJsonObject().get("1234").getAsJsonObject().get("1234"));
    assertNull(jsonObject.get("checklist").getAsJsonObject().get("1234").getAsJsonObject().get("66442"));
}
Also used : PlannerTaskDetails(com.microsoft.graph.models.PlannerTaskDetails) JsonObject(com.google.gson.JsonObject) Test(org.junit.jupiter.api.Test)

Example 13 with PlannerTaskDetails

use of com.microsoft.graph.models.PlannerTaskDetails in project msgraph-beta-sdk-java by microsoftgraph.

the class AdditionalDataTests method testHashMapProperties.

@Test
public void testHashMapProperties() {
    final String source = "{\"description\": \"Task details properties:\nchecklist:Sub items\nreferences:Related links\",\"previewType\": \"automatic\",\"references\": {\"https%3A//developer%2Emicrosoft%2Ecom/en-us/graph/graph-explorer\": {\"@odata.type\": \"#microsoft.graph.plannerExternalReference\",\"alias\": \"Graph Explorer\",\"type\": \"Other\",\"previewPriority\": \"0009005706180391122\",\"lastModifiedBy\": {\"user\": {\"id\": \"fbab97d0-4932-4511-b675-204639209557\"}},\"lastModifiedDateTime\": \"2017-04-24T22:52:29.814Z\"}},\"checklist\": {\"d280ed1a-9f6b-4f9c-a962-fb4d00dc50ff\": {\"@odata.type\": \"#microsoft.graph.plannerChecklistItem\",\"isChecked\": false,\"title\": \"Try reading task details\",\"orderHint\": \"8587094707721254251P]\",\"lastModifiedBy\": {\"user\": {\"id\": \"e396de0e-4812-4fcb-9f9e-0358744df343\", \"customProp\": \"somestring\"}},\"lastModifiedDateTime\": \"2017-04-14T02:16:14.866Z\"}},\"id\": \"gcrYAaAkgU2EQUvpkNNXLGQAGTtu\"}";
    final PlannerTaskDetails taskDetails = serializer.deserializeObject(source, PlannerTaskDetails.class);
    assertNotNull(taskDetails);
    assertNotNull(taskDetails.checklist);
    assertFalse(taskDetails.checklist.isEmpty());
    assertTrue(taskDetails.checklist.get("d280ed1a-9f6b-4f9c-a962-fb4d00dc50ff").title.equals("Try reading task details"));
    assertTrue(taskDetails.checklist.get("d280ed1a-9f6b-4f9c-a962-fb4d00dc50ff").lastModifiedBy.user.additionalDataManager().get("customProp").getAsString().equals("somestring"));
}
Also used : PlannerTaskDetails(com.microsoft.graph.models.PlannerTaskDetails) Test(org.junit.jupiter.api.Test)

Example 14 with PlannerTaskDetails

use of com.microsoft.graph.models.PlannerTaskDetails in project msgraph-beta-sdk-java by microsoftgraph.

the class PlannerTests method testUpdateTaskDetailsReferences.

// Fails due to delay from service
@Test
public void testUpdateTaskDetailsReferences() {
    try {
        PlannerTaskDetails details = new PlannerTaskDetails();
        Gson gson = new Gson();
        JsonObject data = new JsonObject();
        PlannerExternalReference reference = new PlannerExternalReference();
        reference.alias = "Msn";
        reference.previewPriority = " !";
        reference.type = "Other";
        JsonElement referenceJson = gson.toJsonTree(reference);
        data.add("http%3A//www%2Emsn%2Ecom", referenceJson);
        AdditionalDataManager dataManager = details.additionalDataManager();
        dataManager.put("references", data);
        PlannerTaskDetails d = prb.tasks(planTask.id).details().buildRequest().get();
        PlannerTaskDetailsRequest req = prb.tasks(planTask.id).details().buildRequest();
        req.addHeader("If-Match", d.additionalDataManager().get("@odata.etag").getAsString());
        req.addHeader("If-None-Match", d.additionalDataManager().get("@odata.etag").getAsString());
        req.addHeader("Prefer", "return=representation");
        PlannerTaskDetails updatedTaskDetails = req.patch(details);
        Thread.sleep(4000);
        updatedTaskDetails = prb.tasks(planTask.id).details().buildRequest().get();
        JsonElement obj = updatedTaskDetails.additionalDataManager().get("references");
        JsonArray array = new JsonArray();
        array.add(obj);
        int referencesCount = array.size();
        assertEquals(1, referencesCount);
    } catch (InterruptedException e) {
    }
}
Also used : JsonArray(com.google.gson.JsonArray) PlannerExternalReference(com.microsoft.graph.models.PlannerExternalReference) AdditionalDataManager(com.microsoft.graph.serializer.AdditionalDataManager) JsonElement(com.google.gson.JsonElement) PlannerTaskDetails(com.microsoft.graph.models.PlannerTaskDetails) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) PlannerTaskDetailsRequest(com.microsoft.graph.requests.PlannerTaskDetailsRequest) Test(org.junit.jupiter.api.Test)

Aggregations

PlannerTaskDetails (com.microsoft.graph.models.PlannerTaskDetails)14 Test (org.junit.jupiter.api.Test)14 JsonObject (com.google.gson.JsonObject)6 PlannerChecklistItem (com.microsoft.graph.models.PlannerChecklistItem)6 Gson (com.google.gson.Gson)4 JsonElement (com.google.gson.JsonElement)4 DefaultLogger (com.microsoft.graph.logger.DefaultLogger)4 PlannerTaskDetailsRequest (com.microsoft.graph.requests.PlannerTaskDetailsRequest)4 AdditionalDataManager (com.microsoft.graph.serializer.AdditionalDataManager)4 DefaultSerializer (com.microsoft.graph.serializer.DefaultSerializer)4 JsonArray (com.google.gson.JsonArray)2 PlannerExternalReference (com.microsoft.graph.models.PlannerExternalReference)2 PlannerTask (com.microsoft.graph.models.PlannerTask)2