-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Support creating ongoing Legal Hold policy with start date (#1281)
Closes: SDK-4293
- Loading branch information
1 parent
8cf8696
commit d9564e2
Showing
5 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/test/Fixtures/BoxLegalHold/PostOngoingWithStartDateLegalHoldPolicies201.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"type": "legal_hold_policy", | ||
"id": "11111", | ||
"policy_name": "Trial Documents", | ||
"description": "This is a description.", | ||
"status": "active", | ||
"assignment_counts": { | ||
"user": 0, | ||
"folder": 0, | ||
"file": 0, | ||
"file_version": 0 | ||
}, | ||
"is_ongoing": true, | ||
"created_by": { | ||
"type": "user", | ||
"id": "33333", | ||
"name": "Test User", | ||
"login": "[email protected]" | ||
}, | ||
"created_at": "2018-04-25T16:37:05-07:00", | ||
"modified_at": "2018-04-25T16:37:05-07:00", | ||
"deleted_at": null, | ||
"filter_started_at": "2018-04-25T16:37:05-07:00", | ||
"filter_ended_at": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,47 @@ public void testCreateOngoingNewLegalHoldPolicySucceedsAndSendsCorrectJson() { | |
Assert.assertTrue(policyInfo.getIsOngoing()); | ||
} | ||
|
||
@Test | ||
public void testCreateOngoingWithStartDateNewLegalHoldPolicySucceedsAndSendsCorrectJson() throws ParseException { | ||
final String legalHoldsURL = "/2.0/legal_hold_policies"; | ||
final String policyID = "11111"; | ||
final String createdByID = "33333"; | ||
final String createdByName = "Test User"; | ||
final String createdByLogin = "[email protected]"; | ||
final String policyName = "Trial Documents"; | ||
final String description = "This is a description."; | ||
final String startTimeString = "2018-04-25T23:37:05Z"; | ||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); | ||
final Date startTime = dateFormat.parse("2018-04-25T16:37:05-07:00"); | ||
|
||
JsonObject policyObject = new JsonObject() | ||
.add("policy_name", policyName) | ||
.add("is_ongoing", true) | ||
.add("description", description) | ||
.add("filter_started_at", startTimeString); | ||
|
||
String result = TestUtils.getFixture("BoxLegalHold/PostOngoingWithStartDateLegalHoldPolicies201"); | ||
|
||
wireMockRule.stubFor(WireMock.post(WireMock.urlPathEqualTo(legalHoldsURL)) | ||
.withRequestBody(WireMock.equalToJson(policyObject.toString())) | ||
.willReturn(WireMock.aResponse() | ||
.withHeader("Content-Type", APPLICATION_JSON) | ||
.withBody(result))); | ||
|
||
BoxLegalHoldPolicy.Info policyInfo = BoxLegalHoldPolicy.createOngoing( | ||
this.api, policyName, description, startTime | ||
); | ||
|
||
Assert.assertEquals(policyID, policyInfo.getID()); | ||
Assert.assertEquals(createdByID, policyInfo.getCreatedBy().getID()); | ||
Assert.assertEquals(createdByName, policyInfo.getCreatedBy().getName()); | ||
Assert.assertEquals(createdByLogin, policyInfo.getCreatedBy().getLogin()); | ||
Assert.assertEquals(policyName, policyInfo.getPolicyName()); | ||
Assert.assertEquals(description, policyInfo.getDescription()); | ||
Assert.assertEquals(startTime, policyInfo.getFilterStartedAt()); | ||
Assert.assertTrue(policyInfo.getIsOngoing()); | ||
} | ||
|
||
|
||
@Test | ||
public void testUpdateLegalHoldPolicySucceedsAndSendsCorrectJson() { | ||
|