Search in sources :

Example 1 with PlannerTaskDetails

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

Example 2 with PlannerTaskDetails

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

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

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

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

the class PlannerTests method testUpdateTaskDetailsChecklist.

@Test
public void testUpdateTaskDetailsChecklist() throws InterruptedException {
    PlannerTaskDetails details = new PlannerTaskDetails();
    String uuid = UUID.randomUUID().toString();
    JsonObject data = new JsonObject();
    Gson gson = new Gson();
    Thread.sleep(2000);
    PlannerChecklistItem checklistItem1 = new PlannerChecklistItem();
    checklistItem1.orderHint = "  !!";
    checklistItem1.isChecked = true;
    checklistItem1.title = "C1";
    JsonElement checklist1Json = gson.toJsonTree(checklistItem1);
    data.add(uuid, checklist1Json);
    PlannerChecklistItem checklistItem2 = new PlannerChecklistItem();
    checklistItem2.orderHint = " !";
    checklistItem2.isChecked = false;
    checklistItem2.title = "C2";
    JsonElement checklist2Json = gson.toJsonTree(checklistItem2);
    data.add(UUID.randomUUID().toString(), checklist2Json);
    PlannerChecklistItem checklistItem3 = new PlannerChecklistItem();
    checklistItem3.orderHint = "   !!!";
    checklistItem3.isChecked = false;
    checklistItem3.title = "C3";
    JsonElement checklist3Json = gson.toJsonTree(checklistItem3);
    data.add(UUID.randomUUID().toString(), checklist3Json);
    AdditionalDataManager dataManager = details.additionalDataManager();
    dataManager.put("checklist", 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.patch(details);
    Thread.sleep(2000);
    PlannerTask updatedTask = prb.tasks(planTask.id).buildRequest().get();
    int checklistItemCount = updatedTask.additionalDataManager().get("checklistItemCount").getAsInt();
    assertEquals(3, checklistItemCount);
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask) AdditionalDataManager(com.microsoft.graph.serializer.AdditionalDataManager) JsonElement(com.google.gson.JsonElement) PlannerTaskDetails(com.microsoft.graph.models.PlannerTaskDetails) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) PlannerChecklistItem(com.microsoft.graph.models.PlannerChecklistItem) 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