Skip to content

Commit

Permalink
Add task assignment setters (#886)
Browse files Browse the repository at this point in the history
* Add task assignment setters

* Update CHANGELOG.md
  • Loading branch information
swfree committed Apr 30, 2021
1 parent 500ac74 commit 9cef5d9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __New Features and Enhancements:__
__Bug Fixes:__

- Add setters for `BoxLegalHoldPolicy` ([#885](https://github.com/box/box-java-sdk/pull/885))
- Add setters for `BoxTaskAssignment` ([#886](https://github.com/box/box-java-sdk/pull/886))

## 2.54.0 [2021-04-01]

Expand Down
2 changes: 1 addition & 1 deletion doc/retention_policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Updating a retention policy's information is done by calling
```java
BoxRetentionPolicy policy = new BoxRetentionPolicy(api, id);
BoxRetentionPolicy.Info policyInfo = policy.new Info();
policyInfo.addPendingChange("policy_name", "new policy name");
policyInfo.setPolicyName("new policy name");
policy.updateInfo(policyInfo);
```

Expand Down
4 changes: 2 additions & 2 deletions doc/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Updating the resolution state:
String assignmentID = "12345";
BoxTaskAssignment taskAssignment = new BoxTaskAssignment(api, assignmentID);
BoxTaskAssignment.Info info = taskAssignment.getInfo();
info.addPendingChange("resolution_state", "approved");
info.setResolutionState(BoxTaskAssignment.ResolutionState.APPROVED);
taskAssignment.updateInfo(info);
```

Expand All @@ -175,7 +175,7 @@ Updating the message:
String assignmentID = "12345";
BoxTaskAssignment taskAssignment = new BoxTaskAssignment(api, assignmentID);
BoxTaskAssignment.Info info = taskAssignment.getInfo();
info.addPendingChange("message", "Please review the meeting notes");
info.setMessage("Please review the meeting notes");
taskAssignment.updateInfo(info);
```

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/box/sdk/BoxTaskAssignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ public String getMessage() {
return this.message;
}

/**
* Sets the message for the assignment.
* @param message the message to be set on the assignment.
*/
public void setMessage(String message) {
this.message = message;
this.addPendingChange("message", message);
}

/**
* Gets the date the assignment is to be completed at.
* @return the date the assignment is to be completed at.
Expand Down Expand Up @@ -188,6 +197,15 @@ public ResolutionState getResolutionState() {
return this.resolutionState;
}

/**
* Sets the resolution state for the assignment.
* @param resolutionState the resolution state to be set on the assignment.
*/
public void setResolutionState(ResolutionState resolutionState) {
this.resolutionState = resolutionState;
this.addPendingChange("resolution_state", resolutionState.toJSONString());
}

/**
* Gets the current status of the assignment.
* @return the current status of the assignment.
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/box/sdk/BoxRetentionPolicyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public void testUpdateRetentionPolicyInfoSendsCorrectJson() throws IOException {

BoxRetentionPolicy policy = new BoxRetentionPolicy(this.api, policyID);
BoxRetentionPolicy.Info policyInfo = policy.new Info();
policyInfo.addPendingChange("policy_name", updatedPolicyName);
policyInfo.addPendingChange("status", updatedPolicyStatus);
policyInfo.setPolicyName(updatedPolicyName);
policyInfo.setStatus(updatedPolicyStatus);
policy.updateInfo(policyInfo);
}
}
5 changes: 3 additions & 2 deletions src/test/java/com/box/sdk/BoxTaskAssignmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void testUpdateTaskAssignmentInfoSucceeds() throws IOException {
final String assignedToID = "33333";
final String assignedToLogin = "testuser@example.com";
final String updatedMessage = "Looks good to me!";
final String updatedState = "completed";
final BoxTaskAssignment.ResolutionState updatedState = BoxTaskAssignment.ResolutionState.COMPLETED;
final String assignmentURL = "/task_assignments/" + assignmentID;

JsonObject updateObject = new JsonObject()
Expand All @@ -208,7 +208,8 @@ public void testUpdateTaskAssignmentInfoSucceeds() throws IOException {

BoxTaskAssignment taskAssignment = new BoxTaskAssignment(this.api, assignmentID);
BoxTaskAssignment.Info info = taskAssignment.getInfo();
info.addPendingChange("resolution_state", updatedState);
info.setResolutionState(updatedState);
info.setMessage(updatedMessage);
taskAssignment.updateInfo(info);

Assert.assertEquals(assignmentID, info.getID());
Expand Down

0 comments on commit 9cef5d9

Please sign in to comment.