close
Skip to content

Terms of Service - #484

Merged
iamharish merged 20 commits into
masterfrom
terms_of_service
Jan 4, 2018
Merged

Terms of Service#484
iamharish merged 20 commits into
masterfrom
terms_of_service

Conversation

@carycheng

Copy link
Copy Markdown

Thanks Karthik!

@boxcla

boxcla commented Nov 17, 2017

Copy link
Copy Markdown

Verified that @carycheng77 has signed the CLA. Thanks for the pull request!

}

return new BoxResourceIterable<BoxTermsOfService.Info>(api,
ALL_TERMS_OF_SERVICES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString()), limit) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

buildwith query as a separate line for better readbility.

this.modifiedAt = BoxDateFormat.parse(value.asString());
}
} catch (ParseException e) {
assert false : "A ParseException indicates a bug in the SDK.";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please change the comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hey @KarthikShanmugasundaram wondering comment we should put here. Reason being I followed how it was built in BoxRetentionPolicy, BoxDevicePin, and other files and the ParseException e is followed by: "A ParseException indicates a bug in in the SDK". Any input is greatly appreciated!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For example: Terms of Service Parsing failed. {the message from parse exception to understand more on the error)

}

return new BoxResourceIterable<BoxTermsOfServiceUserStatus.Info>(api,
ALL_TERMS_OF_SERVICE_USER_STATUSES_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please move the statement as a separate one.

this.type = value.asString();
} else if (memberName.equals("tos_type")) {
this.tosType = value.asString();
} else if (memberName.equals("text")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

value is mandatory field? if there is any optional fields, the null checks are done?

String userID = userJSON.get("id").asString();
BoxUser user = new BoxUser(getAPI(), userID);
this.user = user.new Info(userJSON);
} else if (memberName.equals("is_accepted")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if there is any optional fields, the null checks are done?

BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
String newStatus = "enabled";
String newText = "New text";
BoxTermsOfService termsOfService = new BoxTermsOfService(api, "2778");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add more negative test cases

@Test
@Category(IntegrationTest.class)
public void getUserStatusInfoOnTermsOfServiceWithUserIDSucceeds() {
BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add more negative test cases

@carycheng
carycheng requested a review from iamharish November 20, 2017 19:29
Comment thread doc/terms_of_service.md Outdated
* [Create a Terms of Service](#create-a-terms-of-service)
* [Edit a Terms of Service](#edit-a-terms-of-service)
* [Get a Terms of Service](#get-a-terms-of-service)
* [Get all Terms of Service](#get-all-terms-of-service)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be Services as it's more than one

Comment thread doc/terms_of_service.md Outdated
BoxTermsOfService.Info newUserStatus = BoxTermsOfServiceUserStatus.create(api, "tos-id", true, "user-id");
```

You can only create a new user status on a terms of service if the user has never accepted/declines a terms of service.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

accepted/decline_d_ seems right usage

"2778", "");

} catch (Exception e) {
fail("Exception during test execution: " + e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you validate that the exception and message is what you anticipate to be thrown

"", "");

} catch (Exception e) {
fail("Exception during test execution: " + e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you validate that the exception and message is what you anticipate to be thrown

tosUserStatus.updateInfo(userStatusInfo);

} catch (Exception e) {
fail("Exception during test execution: " + e);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you validate that the exception and message is what you anticipate to be thrown

userStatusInfo.setIsAccepted(isAccepted);
tosUserStatus.updateInfo(userStatusInfo);

assertThat(userStatusInfo.getIsAccepted(), is(equalTo(isAccepted)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use assertEqual fo simplicity

userStatusInfo.setIsAccepted(true);
toUserStatus.updateInfo(userStatusInfo);

Assert.assertEquals(isAccepted, userStatusInfo.getIsAccepted());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assert other important fields are being set

api.setRequestInterceptor(JSONRequestInterceptor.respondWith(fakeJSONResponse));
BoxTermsOfServiceUserStatus toUserStatus = new BoxTermsOfServiceUserStatus(api, "1939280");
BoxTermsOfServiceUserStatus.Info userStatusInfo = toUserStatus.new Info();
userStatusInfo.setIsAccepted(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this line

@iamharish
iamharish merged commit 9ffb86c into master Jan 4, 2018
@mattwiller
mattwiller deleted the terms_of_service branch December 15, 2018 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants