Search in sources :

Example 1 with AdditionalDataManager

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

the class PlannerTests method testUpdateTaskCategories.

@Test
public void testUpdateTaskCategories() {
    PlannerTask task = new PlannerTask();
    JsonObject data = new JsonObject();
    data.add("category1", new JsonPrimitive(false));
    data.add("category2", new JsonPrimitive(true));
    data.add("category3", new JsonPrimitive(false));
    data.add("category4", new JsonPrimitive(false));
    data.add("category5", new JsonPrimitive(false));
    data.add("category6", new JsonPrimitive(false));
    AdditionalDataManager dataManager = task.additionalDataManager();
    dataManager.put("appliedCategories", data);
    PlannerTask newTask = prb.tasks(planTask.id).buildRequest().get();
    IPlannerTaskRequest req = prb.tasks(planTask.id).buildRequest();
    req.addHeader("If-Match", newTask.etag);
    req.addHeader("If-None-Match", newTask.etag);
    req.addHeader("Prefer", "return=representation");
    PlannerTask updatedTask = req.patch(task);
    JsonElement appliedCategories = updatedTask.getRawObject().get("appliedCategories");
    assertNotNull(appliedCategories);
}
Also used : PlannerTask(com.microsoft.graph.models.extensions.PlannerTask) AdditionalDataManager(com.microsoft.graph.serializer.AdditionalDataManager) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) IPlannerTaskRequest(com.microsoft.graph.requests.extensions.IPlannerTaskRequest) Test(org.junit.Test)

Example 2 with AdditionalDataManager

use of com.microsoft.graph.serializer.AdditionalDataManager 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();
        IPlannerTaskDetailsRequest req = prb.tasks(planTask.id).details().buildRequest();
        req.addHeader("If-Match", d.etag);
        req.addHeader("If-None-Match", d.etag);
        req.addHeader("Prefer", "return=representation");
        PlannerTaskDetails updatedTaskDetails = req.patch(details);
        Thread.sleep(4000);
        updatedTaskDetails = prb.tasks(planTask.id).details().buildRequest().get();
        JsonElement obj = updatedTaskDetails.getRawObject().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.extensions.PlannerExternalReference) AdditionalDataManager(com.microsoft.graph.serializer.AdditionalDataManager) JsonElement(com.google.gson.JsonElement) PlannerTaskDetails(com.microsoft.graph.models.extensions.PlannerTaskDetails) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) IPlannerTaskDetailsRequest(com.microsoft.graph.requests.extensions.IPlannerTaskDetailsRequest) Test(org.junit.Test)

Example 3 with AdditionalDataManager

use of com.microsoft.graph.serializer.AdditionalDataManager in project msgraph-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();
    IPlannerTaskDetailsRequest req = prb.tasks(planTask.id).details().buildRequest();
    req.addHeader("If-Match", d.etag);
    req.addHeader("If-None-Match", d.etag);
    req.patch(details);
    Thread.sleep(2000);
    PlannerTask updatedTask = prb.tasks(planTask.id).buildRequest().get();
    int checklistItemCount = updatedTask.getRawObject().get("checklistItemCount").getAsInt();
    assertEquals(3, checklistItemCount);
}
Also used : PlannerTask(com.microsoft.graph.models.extensions.PlannerTask) AdditionalDataManager(com.microsoft.graph.serializer.AdditionalDataManager) JsonElement(com.google.gson.JsonElement) PlannerTaskDetails(com.microsoft.graph.models.extensions.PlannerTaskDetails) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) IPlannerTaskDetailsRequest(com.microsoft.graph.requests.extensions.IPlannerTaskDetailsRequest) PlannerChecklistItem(com.microsoft.graph.models.extensions.PlannerChecklistItem) Test(org.junit.Test)

Aggregations

JsonElement (com.google.gson.JsonElement)3 JsonObject (com.google.gson.JsonObject)3 AdditionalDataManager (com.microsoft.graph.serializer.AdditionalDataManager)3 Test (org.junit.Test)3 Gson (com.google.gson.Gson)2 PlannerTask (com.microsoft.graph.models.extensions.PlannerTask)2 PlannerTaskDetails (com.microsoft.graph.models.extensions.PlannerTaskDetails)2 IPlannerTaskDetailsRequest (com.microsoft.graph.requests.extensions.IPlannerTaskDetailsRequest)2 JsonArray (com.google.gson.JsonArray)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 PlannerChecklistItem (com.microsoft.graph.models.extensions.PlannerChecklistItem)1 PlannerExternalReference (com.microsoft.graph.models.extensions.PlannerExternalReference)1 IPlannerTaskRequest (com.microsoft.graph.requests.extensions.IPlannerTaskRequest)1