Search in sources :

Example 1 with PlannerExternalReference

use of com.microsoft.graph.models.extensions.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();
        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)

Aggregations

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