Search in sources :

Example 1 with PlannerTask

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

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

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

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

the class PlannerTests method setUp.

@BeforeClass
public static void setUp() {
    testBase = new TestBase();
    prb = testBase.graphClient.planner();
    PlannerBucket newBucket = new PlannerBucket();
    newBucket.name = "Test Bucket";
    newBucket.planId = planId;
    planBucket = prb.buckets().buildRequest().post(newBucket);
    PlannerTask newTask = new PlannerTask();
    newTask.title = "Test Task";
    newTask.planId = planId;
    newTask.bucketId = planBucket.id;
    planTask = prb.tasks().buildRequest().post(newTask);
}
Also used : PlannerTask(com.microsoft.graph.models.extensions.PlannerTask) PlannerBucket(com.microsoft.graph.models.extensions.PlannerBucket) BeforeClass(org.junit.BeforeClass)

Example 5 with PlannerTask

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

Aggregations

PlannerTask (com.microsoft.graph.models.extensions.PlannerTask)11 Test (org.junit.Test)8 IPlannerTaskRequest (com.microsoft.graph.requests.extensions.IPlannerTaskRequest)7 JsonElement (com.google.gson.JsonElement)3 JsonObject (com.google.gson.JsonObject)2 JsonPrimitive (com.google.gson.JsonPrimitive)2 PlannerAssignment (com.microsoft.graph.models.extensions.PlannerAssignment)2 PlannerAssignments (com.microsoft.graph.models.extensions.PlannerAssignments)2 PlannerBucket (com.microsoft.graph.models.extensions.PlannerBucket)2 AdditionalDataManager (com.microsoft.graph.serializer.AdditionalDataManager)2 Gson (com.google.gson.Gson)1 PlannerChecklistItem (com.microsoft.graph.models.extensions.PlannerChecklistItem)1 PlannerTaskDetails (com.microsoft.graph.models.extensions.PlannerTaskDetails)1 User (com.microsoft.graph.models.extensions.User)1 IPlannerBucketRequest (com.microsoft.graph.requests.extensions.IPlannerBucketRequest)1 IPlannerTaskDetailsRequest (com.microsoft.graph.requests.extensions.IPlannerTaskDetailsRequest)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1