Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/main/java/com/microsoft/graph/models/extensions/Multipart.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.math.BigInteger;
import java.security.SecureRandom;

import com.microsoft.graph.options.HeaderOption;

/**
* Helper for submitting multipart data
*
Expand All @@ -29,12 +31,20 @@ public Multipart() {

/**
* Get the multipart boundary for use in the request header
* @return The multipart boundary
* @return the multipart boundary
*/
public String boundary() {
return boundary;
}

/**
* Get the Content-Type header to send the multipart request
* @return the multipart header option
*/
public HeaderOption header() {
return new HeaderOption("Content-Type", "multipart/form-data; boundary=\"" + boundary + "\"");
}

/**
* Add a string part to the multipart body
* @param name The name of the part
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix case

Expand Down Expand Up @@ -75,16 +85,6 @@ public void addHtmlPart(String name, String content) throws IOException {
addPart(name, "text/html", content);
}

/**
* Add an image part to the multipart body
* @param name The name of the part
* @param imageFile The image file
* @throws IOException Throws an exception if the output stream cannot be written to
*/
public void addImagePart(String name, java.io.File imageFile) throws IOException {
addFilePart(name, "image/jpeg", imageFile);
}

/**
* Add a file part to the multipart body
* @param name The name of the part
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix case

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
* The class for the Planner Assignment.
*/
public class PlannerAssignment extends BasePlannerAssignment {

public PlannerAssignment() {
oDataType = "#microsoft.graph.plannerAssignment";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ public class PlannerBucket extends BasePlannerBucket {
@SerializedName("@odata.etag")
@Expose
public String etag;

public PlannerBucket() {
oDataType = "#microsoft.graph.plannerBucket";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
* The class for the Planner Checklist Item.
*/
public class PlannerChecklistItem extends BasePlannerChecklistItem {


public PlannerChecklistItem() {
oDataType = "#microsoft.graph.plannerChecklistItem";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
* The class for the Planner External Reference.
*/
public class PlannerExternalReference extends BasePlannerExternalReference {

public PlannerExternalReference() {
oDataType = "#microsoft.graph.plannerExternalReference";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public class PlannerTask extends BasePlannerTask {
@SerializedName("@odata.etag")
@Expose
public String etag;

public PlannerTask() {
oDataType = "#microsoft.graph.plannerTask";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
* The class for the Planner Task Details.
*/
public class PlannerTaskDetails extends BasePlannerTaskDetails {

/**
* The Etag.
*/
@SerializedName("@odata.etag")
@Expose
public String etag;

public PlannerTaskDetails() {
oDataType = "#microsoft.graph.plannerTaskDetails";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.microsoft.graph.requests.extensions.IOnenotePageCollectionPage;
import com.microsoft.graph.requests.extensions.IOnenoteSectionCollectionPage;
import com.microsoft.graph.requests.extensions.ISectionGroupCollectionPage;
import com.microsoft.graph.serializer.AdditionalDataManager;
import com.microsoft.graph.requests.extensions.IOnenoteRequestBuilder;
import com.microsoft.graph.models.extensions.Multipart;
import com.microsoft.graph.models.extensions.Notebook;
Expand Down Expand Up @@ -403,14 +404,12 @@ public void testMultipartPost(){
File pdfFile = new File("src/test/resources/document.pdf");

multipart.addHtmlPart("Presentation", htmlContent);
multipart.addImagePart("hamilton", imgFile);
multipart.addFilePart("hamilton", "image/jpg", imgFile);
multipart.addFilePart("metadata", "application/pdf", pdfFile);

// Add multipart request header
List<Option> options = new ArrayList<Option>();
options.add(new HeaderOption(
"Content-Type", "multipart/form-data; boundary=\"" + multipart.boundary() + "\""
));
options.add(multipart.header());

// Post the multipart content
OnenotePage page = orb
Expand Down
16 changes: 3 additions & 13 deletions src/test/java/com/microsoft/graph/functional/PlannerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ public void testUpdateTask() throws InterruptedException {

PlannerAssignment assignment = new PlannerAssignment();
assignment.orderHint = " !";
AdditionalDataManager assignmentAdditionalData = assignment.additionalDataManager();
assignmentAdditionalData.put("@odata.type", new JsonPrimitive("#microsoft.graph.plannerAssignment"));
//assignment.oDataType = "#microsoft.graph.plannerAssignment";

PlannerAssignments a2 = new PlannerAssignments();
a2.put(me.id, assignment);
task.assignments = a2;
Expand Down Expand Up @@ -157,32 +153,30 @@ public void testUpdateTaskDetailsChecklist() throws InterruptedException {
JsonObject data = new JsonObject();
Gson gson = new Gson();

Thread.sleep(2000);

PlannerChecklistItem checklistItem1 = new PlannerChecklistItem();
checklistItem1.orderHint = " !!";
checklistItem1.isChecked = true;
checklistItem1.title = "C1";
checklistItem1.additionalDataManager().put("@odata.type", new JsonPrimitive("microsoft.graph.plannerChecklistItem"));
JsonElement checklist1Json = gson.toJsonTree(checklistItem1);
data.add(uuid, checklist1Json);

PlannerChecklistItem checklistItem2 = new PlannerChecklistItem();
checklistItem2.orderHint = " !";
checklistItem2.isChecked = false;
checklistItem2.title = "C2";
checklistItem2.additionalDataManager().put("@odata.type", new JsonPrimitive("microsoft.graph.plannerChecklistItem"));
JsonElement checklist2Json = gson.toJsonTree(checklistItem2);
data.add(UUID.randomUUID().toString(), checklist2Json);

PlannerChecklistItem checklistItem3 = new PlannerChecklistItem();
checklistItem3.orderHint = " !!!";
checklistItem3.isChecked = false;
checklistItem3.title = "C3";
checklistItem3.additionalDataManager().put("@odata.type", new JsonPrimitive("microsoft.graph.plannerChecklistItem"));
JsonElement checklist3Json = gson.toJsonTree(checklistItem3);
data.add(UUID.randomUUID().toString(), checklist3Json);

AdditionalDataManager dataManager = details.additionalDataManager();
details.oDataType = "#microsoft.graph.plannerTaskDetails";
dataManager.put("checklist", data);

PlannerTaskDetails d = prb
Expand All @@ -198,7 +192,7 @@ public void testUpdateTaskDetailsChecklist() throws InterruptedException {
req.addHeader("If-None-Match", d.etag);
req.patch(details);

Thread.sleep(4000);
Thread.sleep(2000);

PlannerTask updatedTask = prb.tasks(planTask.id).buildRequest().get();
int checklistItemCount = updatedTask.getRawObject().get("checklistItemCount").getAsInt();
Expand All @@ -215,7 +209,6 @@ public void testUpdateTaskDetailsReferences() {
JsonObject data = new JsonObject();
PlannerExternalReference reference = new PlannerExternalReference();

reference.additionalDataManager().put("@odata.type", new JsonPrimitive("microsoft.graph.plannerExternalReference"));
reference.alias = "Msn";
reference.previewPriority = " !";
reference.type = "Other";
Expand All @@ -224,7 +217,6 @@ public void testUpdateTaskDetailsReferences() {
data.add("http%3A//www%2Emsn%2Ecom", referenceJson);

AdditionalDataManager dataManager = details.additionalDataManager();
details.oDataType = "#microsoft.graph.plannerTaskDetails";
dataManager.put("references", data);

PlannerTaskDetails d = prb
Expand Down Expand Up @@ -324,7 +316,6 @@ public void testUpdateTaskCategories() {
data.add("category6", new JsonPrimitive(false));

AdditionalDataManager dataManager = task.additionalDataManager();
task.oDataType = "#microsoft.graph.plannerTask";
dataManager.put("appliedCategories", data);

PlannerTask newTask = prb.tasks(planTask.id).buildRequest().get();
Expand Down Expand Up @@ -384,7 +375,6 @@ public void testCreateBucket() {
public void testUpdateBucket() {
PlannerBucket patchBucket = new PlannerBucket();
patchBucket.name = "RenamedBucket";
patchBucket.oDataType = "#microsoft.graph.plannerBucket";

IPlannerBucketRequest req = prb.buckets(planBucket.id).buildRequest();
req.addHeader("If-Match", planBucket.etag);
Expand Down