Search in sources :

Example 1 with PlannerExternalReference

use of com.microsoft.graph.models.PlannerExternalReference 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 PlannerExternalReference

use of com.microsoft.graph.models.PlannerExternalReference 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

Gson (com.google.gson.Gson)2 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 PlannerExternalReference (com.microsoft.graph.models.PlannerExternalReference)2 PlannerTaskDetails (com.microsoft.graph.models.PlannerTaskDetails)2 PlannerTaskDetailsRequest (com.microsoft.graph.requests.PlannerTaskDetailsRequest)2 AdditionalDataManager (com.microsoft.graph.serializer.AdditionalDataManager)2 Test (org.junit.jupiter.api.Test)2