Search in sources :

Example 1 with IPlannerTaskRequest

use of com.microsoft.graph.requests.extensions.IPlannerTaskRequest in project msgraph-sdk-java by microsoftgraph.

the class PlannerTests method testUpdateTaskDueDate.

// Failing due to millisecond precision off by 1
@Test
public void testUpdateTaskDueDate() throws InterruptedException {
    PlannerTask task = new PlannerTask();
    task.dueDateTime = Calendar.getInstance();
    IPlannerTaskRequest req = prb.tasks(planTask.id).buildRequest();
    planTask = prb.tasks(planTask.id).buildRequest().get();
    req.addHeader("If-Match", planTask.etag);
    req.patch(task);
    Thread.sleep(6000);
    PlannerTask updatedTask = prb.tasks(planTask.id).buildRequest().get();
    updatedTask = prb.tasks(planTask.id).buildRequest().get();
    assertEquals(task.dueDateTime, updatedTask.dueDateTime);
}
Also used : PlannerTask(com.microsoft.graph.models.extensions.PlannerTask) IPlannerTaskRequest(com.microsoft.graph.requests.extensions.IPlannerTaskRequest) Test(org.junit.Test)

Example 2 with IPlannerTaskRequest

use of com.microsoft.graph.requests.extensions.IPlannerTaskRequest 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 3 with IPlannerTaskRequest

use of com.microsoft.graph.requests.extensions.IPlannerTaskRequest in project msgraph-sdk-java by microsoftgraph.

the class PlannerTests method testUpdateTask.

// https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/plannerAssignments
@Test
public void testUpdateTask() throws InterruptedException {
    PlannerTask task = new PlannerTask();
    User me = testBase.graphClient.me().buildRequest().get();
    PlannerAssignment assignment = new PlannerAssignment();
    assignment.orderHint = " !";
    PlannerAssignments a2 = new PlannerAssignments();
    a2.put(me.id, assignment);
    task.assignments = a2;
    IPlannerTaskRequest req = prb.tasks(planTask.id).buildRequest();
    req.addHeader("If-Match", planTask.etag);
    req.patch(task);
    Thread.sleep(4000);
    PlannerTask updatedTask = prb.tasks(planTask.id).buildRequest().get();
    JsonElement createdAssignment = updatedTask.getRawObject().get("assignments").getAsJsonObject().get(me.id);
    assertNotNull(createdAssignment);
}
Also used : PlannerTask(com.microsoft.graph.models.extensions.PlannerTask) PlannerAssignments(com.microsoft.graph.models.extensions.PlannerAssignments) User(com.microsoft.graph.models.extensions.User) JsonElement(com.google.gson.JsonElement) PlannerAssignment(com.microsoft.graph.models.extensions.PlannerAssignment) IPlannerTaskRequest(com.microsoft.graph.requests.extensions.IPlannerTaskRequest) Test(org.junit.Test)

Example 4 with IPlannerTaskRequest

use of com.microsoft.graph.requests.extensions.IPlannerTaskRequest in project msgraph-sdk-java by microsoftgraph.

the class PlannerTests method tearDown.

@AfterClass
public static 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();
    IPlannerTaskRequest taskReq = testBase.graphClient.planner().tasks(planTask.id).buildRequest();
    taskReq.addHeader("If-Match", task.etag);
    taskReq.delete();
    PlannerBucket bucket = testBase.graphClient.planner().buckets(planBucket.id).buildRequest().get();
    IPlannerBucketRequest bucketReq = testBase.graphClient.planner().buckets(planBucket.id).buildRequest();
    bucketReq.addHeader("If-Match", bucket.etag);
    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.extensions.PlannerTask) PlannerBucket(com.microsoft.graph.models.extensions.PlannerBucket) IPlannerTaskRequest(com.microsoft.graph.requests.extensions.IPlannerTaskRequest) IPlannerBucketRequest(com.microsoft.graph.requests.extensions.IPlannerBucketRequest) AfterClass(org.junit.AfterClass)

Example 5 with IPlannerTaskRequest

use of com.microsoft.graph.requests.extensions.IPlannerTaskRequest 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);
    IPlannerTaskRequest req = testBase.graphClient.planner().tasks(task.id).buildRequest();
    req.addHeader("If-Match", task.etag);
    req.delete();
}
Also used : PlannerTask(com.microsoft.graph.models.extensions.PlannerTask) IPlannerTaskRequest(com.microsoft.graph.requests.extensions.IPlannerTaskRequest) Test(org.junit.Test)

Aggregations

PlannerTask (com.microsoft.graph.models.extensions.PlannerTask)7 IPlannerTaskRequest (com.microsoft.graph.requests.extensions.IPlannerTaskRequest)7 Test (org.junit.Test)6 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 PlannerAssignment (com.microsoft.graph.models.extensions.PlannerAssignment)1 PlannerAssignments (com.microsoft.graph.models.extensions.PlannerAssignments)1 PlannerBucket (com.microsoft.graph.models.extensions.PlannerBucket)1 User (com.microsoft.graph.models.extensions.User)1 IPlannerBucketRequest (com.microsoft.graph.requests.extensions.IPlannerBucketRequest)1 AdditionalDataManager (com.microsoft.graph.serializer.AdditionalDataManager)1 AfterClass (org.junit.AfterClass)1