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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations