Search in sources :

Example 1 with PlannerTask

use of com.microsoft.graph.models.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;
    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();
    JsonElement createdAssignment = updatedTask.additionalDataManager().get("assignments").getAsJsonObject().get(me.id);
    assertNotNull(createdAssignment);
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask) PlannerTaskRequest(com.microsoft.graph.requests.PlannerTaskRequest) PlannerAssignments(com.microsoft.graph.models.PlannerAssignments) User(com.microsoft.graph.models.User) JsonElement(com.google.gson.JsonElement) PlannerAssignment(com.microsoft.graph.models.PlannerAssignment) Test(org.junit.jupiter.api.Test)

Example 2 with PlannerTask

use of com.microsoft.graph.models.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();
    PlannerTaskRequest req = prb.tasks(planTask.id).buildRequest();
    req.addHeader("If-Match", newTask.additionalDataManager().get("@odata.etag").getAsString());
    req.addHeader("If-None-Match", newTask.additionalDataManager().get("@odata.etag").getAsString());
    req.addHeader("Prefer", "return=representation");
    PlannerTask updatedTask = req.patch(task);
    JsonElement appliedCategories = updatedTask.additionalDataManager().get("appliedCategories");
    assertNotNull(appliedCategories);
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask) PlannerTaskRequest(com.microsoft.graph.requests.PlannerTaskRequest) AdditionalDataManager(com.microsoft.graph.serializer.AdditionalDataManager) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) Test(org.junit.jupiter.api.Test)

Example 3 with PlannerTask

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

the class PlannerTests method testPostTask.

// @Test
public void testPostTask() {
    PlannerTask newTask = new PlannerTask();
    newTask.title = "Test1";
    newTask.planId = planId;
    newTask.bucketId = planBucket.id;
    PlannerTask task = prb.tasks().buildRequest().post(newTask);
    assertNotNull(task);
}
Also used : PlannerTask(com.microsoft.graph.models.PlannerTask)

Example 4 with PlannerTask

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

the class PlannerTests method setUp.

@BeforeEach
public 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.PlannerTask) PlannerBucket(com.microsoft.graph.models.PlannerBucket) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with PlannerTask

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

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