Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publication date (issued) added #233

Merged
merged 8 commits into from
Mar 20, 2023
Merged

publication date (issued) added #233

merged 8 commits into from
Mar 20, 2023

Conversation

SrdjanStevanetic
Copy link
Contributor

No description provided.

@@ -70,12 +72,13 @@ public void publishUnpublishUserSet_Success() throws Exception {

// publish set by publisher
// expected change of ownership to editorial team
publishUserSet(userSet, getConfiguration().getEuropeanaPublisherNickname());
String issued = "2018-10-31T01:30:00.000Z";
Copy link
Collaborator

Choose a reason for hiding this comment

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

must be used to verify the value in the response

@@ -70,12 +72,13 @@ public void publishUnpublishUserSet_Success() throws Exception {

// publish set by publisher
// expected change of ownership to editorial team
publishUserSet(userSet, getConfiguration().getEuropeanaPublisherNickname());
String issued = "2018-10-31T01:30:00.000Z";
publishUserSet(userSet, issued, getConfiguration().getEuropeanaPublisherNickname());
Copy link
Collaborator

Choose a reason for hiding this comment

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

response must be validated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is validated in the method publishUserSet.

// unpublished set, the ownership is changed back to current user
assertFalse(containsKeyOrValue(result, getConfiguration().getEuropeanaPublisherNickname()));
assertTrue(containsKeyOrValue(result, USERNAME_PUBLISHER));
assertEquals(HttpStatus.OK.value(), response.getStatus());

publishUserSet(userSet, null, getConfiguration().getEuropeanaPublisherNickname());
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this call is required, the response must be validated

@@ -100,8 +107,7 @@ public void updatePublishedUserSet_Success() throws Exception {
WebUserSetImpl userSet = createTestUserSet(USER_SET_REGULAR, regularUserToken);

// publish userset by other user, the ownership stays with the creator
publishUserSet(userSet, USERNAME_REGULAR);

publishUserSet(userSet, null, USERNAME_REGULAR);
Copy link
Collaborator

Choose a reason for hiding this comment

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

add check for the issued property

@@ -135,7 +141,7 @@ public void updatePublishedUserSetWithVisibility_Success() throws Exception {
WebUserSetImpl userSet = createTestUserSet(USER_SET_REGULAR, regularUserToken);

// publish userset by other user, the ownership stays with the creator
publishUserSet(userSet, USERNAME_REGULAR);
publishUserSet(userSet, null, USERNAME_REGULAR);
Copy link
Collaborator

Choose a reason for hiding this comment

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

should verify the value of the issues field, the current date take before calling the method can be used for comparison as issues.after(requestTime)

HttpServletRequest request) throws HttpException {
// check user credentials, if invalid respond with HTTP 401,
// or if unauthorized respond with HTTP 403
Authentication authentication = verifyWriteAccess(SetOperations.PUBLISH, request);
return publishUnpublishUserSet(identifier, authentication, true, profileStr, request);
return publishUnpublishUserSet(identifier, authentication, true, profileStr, issued, request);
Copy link
Collaborator

Choose a reason for hiding this comment

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

default value for issued must be set if missing in request

@@ -868,6 +867,10 @@ PersistentUserSet updateUserSetForPublish(PersistentUserSet userSet,
userSet.setCreator(creator);
}
userSet.setVisibility(VisibilityTypes.PUBLISHED.getJsonValue());
if(issued==null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

here an exception should be thrown if the value is null, the controller is responsible for setting the default values for the optional fields

@@ -895,6 +898,7 @@ PersistentUserSet updateUserSetForUnpublish(PersistentUserSet userSet,
}

userSet.setVisibility(VisibilityTypes.PUBLIC.getJsonValue());
userSet.setIssued(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this must be executed, on line 891 an exception must be thrown, so that the api returns 400

if(issued==null) {
issued = new Date();
}
userSet.setIssued(issued);
Copy link
Collaborator

Choose a reason for hiding this comment

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

the specs were changed, this needs to be always executed, therefore the check from line 858 must be removed


MockHttpServletResponse response;
String result;

// depublish set
// unpublish set
Copy link
Collaborator

Choose a reason for hiding this comment

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

new tests for publishing published set and unpublishing not published set needs to be added

@gsergiu gsergiu merged commit f3b2116 into develop Mar 20, 2023
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.

2 participants