Search in sources :

Example 11 with PlannerTask

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

the class PlannerTests method tearDown.

@AfterEach
public void tearDown() throws InterruptedException {
    Thread.sleep(4000);
    // This may have updated since we last saw it
    PlannerTask task = testBase.graphClient.planner().tasks(planTask.id).buildRequest().get();
    PlannerTaskRequest taskReq = testBase.graphClient.planner().tasks(planTask.id).buildRequest();
    taskReq.addHeader("If-Match", task.additionalDataManager().get("@odata.etag").getAsString());
    taskReq.delete();
    PlannerBucket bucket = testBase.graphClient.planner().buckets(planBucket.id).buildRequest().get();
    PlannerBucketRequest bucketReq = testBase.graphClient.planner().buckets(planBucket.id).buildRequest();
    bucketReq.addHeader("If-Match", bucket.additionalDataManager().get("@odata.etag").getAsString());
    bucketReq.delete();
// Fails with 403 Forbidden
// PlannerPlan plan = testBase.graphClient.getPlanner().getPlans(planId).buildRequest().get();
// IPlannerPlanRequest planReq = testBase.graphClient.getPlanner().getPlans(planId).buildRequest();
// planReq.addHeader("If-Match", getEtag(plan.getRawObject()));
// planReq.delete();
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask) PlannerTaskRequest(com.microsoft.graph.requests.PlannerTaskRequest) PlannerBucket(com.microsoft.graph.models.PlannerBucket) PlannerBucketRequest(com.microsoft.graph.requests.PlannerBucketRequest) AfterEach(org.junit.jupiter.api.AfterEach)

Example 12 with PlannerTask

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

the class PlannerTests method testUpdateTaskCompletion.

@Test
public void testUpdateTaskCompletion() throws InterruptedException {
    PlannerTask task = new PlannerTask();
    task.percentComplete = 50;
    PlannerTaskRequest req = prb.tasks(planTask.id).buildRequest();
    req.addHeader("If-Match", planTask.additionalDataManager().get("@odata.etag").getAsString());
    req.patch(task);
    Thread.sleep(4000);
    PlannerTask updatedTask = prb.tasks(planTask.id).buildRequest().get();
    assertEquals(task.percentComplete, updatedTask.percentComplete);
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask) PlannerTaskRequest(com.microsoft.graph.requests.PlannerTaskRequest) Test(org.junit.jupiter.api.Test)

Example 13 with PlannerTask

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

Example 14 with PlannerTask

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

the class PlannerTests method testUpdateTaskCompletion.

@Test
public void testUpdateTaskCompletion() throws InterruptedException {
    PlannerTask task = new PlannerTask();
    task.percentComplete = 50;
    PlannerTaskRequest req = prb.tasks(planTask.id).buildRequest();
    req.addHeader("If-Match", planTask.additionalDataManager().get("@odata.etag").getAsString());
    req.patch(task);
    Thread.sleep(4000);
    PlannerTask updatedTask = prb.tasks(planTask.id).buildRequest().get();
    assertEquals(task.percentComplete, updatedTask.percentComplete);
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask) PlannerTaskRequest(com.microsoft.graph.requests.PlannerTaskRequest) Test(org.junit.jupiter.api.Test)

Example 15 with PlannerTask

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

the class PlannerTests method testDeleteTask.

@Test
public void testDeleteTask() {
    PlannerTask newTask = new PlannerTask();
    newTask.title = "Delete Me";
    newTask.planId = planId;
    newTask.bucketId = planBucket.id;
    PlannerTask task = prb.tasks().buildRequest().post(newTask);
    PlannerTaskRequest req = testBase.graphClient.planner().tasks(task.id).buildRequest();
    req.addHeader("If-Match", task.additionalDataManager().get("@odata.etag").getAsString());
    req.delete();
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask) PlannerTaskRequest(com.microsoft.graph.requests.PlannerTaskRequest) Test(org.junit.jupiter.api.Test)

Aggregations

PlannerTask (com.microsoft.graph.models.PlannerTask)22 Test (org.junit.jupiter.api.Test)16 PlannerTaskRequest (com.microsoft.graph.requests.PlannerTaskRequest)14 JsonElement (com.google.gson.JsonElement)6 JsonObject (com.google.gson.JsonObject)4 JsonPrimitive (com.google.gson.JsonPrimitive)4 PlannerAssignment (com.microsoft.graph.models.PlannerAssignment)4 PlannerAssignments (com.microsoft.graph.models.PlannerAssignments)4 PlannerBucket (com.microsoft.graph.models.PlannerBucket)4 AdditionalDataManager (com.microsoft.graph.serializer.AdditionalDataManager)4 Gson (com.google.gson.Gson)2 PlannerChecklistItem (com.microsoft.graph.models.PlannerChecklistItem)2 PlannerTaskDetails (com.microsoft.graph.models.PlannerTaskDetails)2 User (com.microsoft.graph.models.User)2 PlannerBucketRequest (com.microsoft.graph.requests.PlannerBucketRequest)2 PlannerTaskDetailsRequest (com.microsoft.graph.requests.PlannerTaskDetailsRequest)2 AfterEach (org.junit.jupiter.api.AfterEach)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2