Skip to content

Commit

Permalink
Merge pull request #571 from gbif/improve-error-messages-griscicoll
Browse files Browse the repository at this point in the history
error messages modified (#565)
  • Loading branch information
ahakanzn authored May 15, 2024
2 parents 482c013 + 52b8d2d commit eb4e4b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public EntityOperationResponse allowedToCreateInstitution(
return new EntityOperationResponse(true);
} else {
return new EntityOperationResponse(
false, "Not allowed to create institutions for the country: " + country);
false, "Not allowed to create institutions for the country: " + (country == null ? "empty (Please provide a country with one of the addresses.)" : country));
}
}

Expand Down Expand Up @@ -287,9 +287,9 @@ public EntityOperationResponse allowedToCreateCollection(
return new EntityOperationResponse(
false,
"Not allowed to create collections under the institution: "
+ institutionKey
+ (institutionKey == null ? "empty" : institutionKey)
+ " or in the country: "
+ country);
+ (country == null ? "empty (Please provide a country with one of the addresses.)" : country));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,21 @@ public void collectionCreationAsMediatorAndCountryRightsTest() throws JsonProces
assertDoesNotThrow(() -> filter.doFilter(mockRequest, mockResponse, mockFilterChain));
}

@Test
public void collectionCreationAsMediatorTest() throws JsonProcessingException {
// GIVEN
mockCollectionCreation(ROLES_GRSCICOLL_MEDIATOR_ONLY, false, false);

// WHEN
WebApplicationException ex =
assertThrows(
WebApplicationException.class,
() -> filter.doFilter(mockRequest, mockResponse, mockFilterChain));

// THEN
assertEquals(HttpStatus.FORBIDDEN.value(), ex.getStatus());
}

@Test
public void institutionUpdateAsEditorWithEntityRightsTest() throws JsonProcessingException {
// GIVEN
Expand Down

0 comments on commit eb4e4b9

Please sign in to comment.