DS-3230 Browse by author broken if author name has special character - add tests

This commit is contained in:
Samuel
2021-05-20 13:01:43 +02:00
parent 3c1b90d603
commit 8795a568e6

View File

@@ -13,6 +13,7 @@ import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
@@ -1140,6 +1141,58 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
;
}
@Test
public void discoverSearchObjectsWithSpecialCharacterTest() throws Exception {
context.turnOffAuthorisationSystem();
parentCommunity = CommunityBuilder.createCommunity(context).build();
Collection collection = CollectionBuilder.createCollection(context, parentCommunity).build();
ItemBuilder.createItem(context, collection)
.withAuthor("Atmire & friends")
.build();
context.restoreAuthSystemState();
getClient().perform(
get("/api/discover/search/objects")
.param("sort", "score,DESC")
.param("page", "0")
.param("size", "10"))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.facets", hasItem(allOf(
hasJsonPath("$.name", is("author")),
hasJsonPath("$._embedded.values", hasItem(
hasJsonPath("$._links.search.href", containsString("Atmire%20%26%20friends"))
))
))));
}
@Test
public void discoverSearchBrowsesWithSpecialCharacterTest() throws Exception {
context.turnOffAuthorisationSystem();
parentCommunity = CommunityBuilder.createCommunity(context).build();
Collection collection = CollectionBuilder.createCollection(context, parentCommunity).build();
ItemBuilder.createItem(context, collection)
.withAuthor("Atmire & friends")
.build();
context.restoreAuthSystemState();
getClient().perform(
get("/api/discover/browses/author/entries")
.param("sort", "default,ASC")
.param("page", "0")
.param("size", "20"))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.entries", hasItem(allOf(
hasJsonPath("$.value", is("Atmire & friends")),
hasJsonPath("$._links.items.href", containsString("Atmire%20%26%20friends"))
))));
}
@Test
public void discoverSearchObjectsTestHasMoreAuthorFacet() throws Exception {
//We turn off the authorization system in order to create the structure defined below