Skip to content

Commit

Permalink
Add a basic test that refactoring of code results in correct logo URL…
Browse files Browse the repository at this point in the history
…s. Also enable/fix a test for special characters.
  • Loading branch information
tdonohue committed May 13, 2024
1 parent 47b79bb commit 8c22915
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ public void findResultSimpleTest() throws Exception {
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
// Add a fake logo to the Collection
Collection col1 = CollectionBuilder.createCollection(context, child1)
.withName("Collection 1")
.withLogo("logo_collection")
.build();
String colLogoUuid = col1.getLogo().getID().toString();

Item publicItem1 = ItemBuilder.createItem(context, col1)
.withTitle("Boars at Yellowstone")
Expand All @@ -118,10 +123,24 @@ public void findResultSimpleTest() throws Exception {
.andExpect(xpath("feed/Query/@searchTerms").string("Yellowstone"))
.andExpect(xpath("feed/totalResults").string("2"))
;

// When we search at the Collection level (scope = Collection UUID)
getClient().perform(get("/opensearch/search")
.param("scope", col1.getID().toString())
.param("query", "Yellowstone"))
//The status has to be 200 OK
.andExpect(status().isOk())
// We expect the content type to be "application/atom+xml;charset=UTF-8"
.andExpect(content().contentType("application/atom+xml;charset=UTF-8"))
.andExpect(xpath("feed/Query/@searchTerms").string("Yellowstone"))
.andExpect(xpath("feed/totalResults").string("2"))
// We expect feed will have the Collection logo
.andExpect(xpath("feed/logo")
.string("http://localhost:4000/bitstreams/" + colLogoUuid + "/download"))
;
}

// This test does not find the record, so there are obviously issues with special chars
@Ignore
@Test
public void findResultWithSpecialCharsTest() throws Exception {
//Turn off the authorization system, otherwise we can't make the objects
Expand All @@ -144,12 +163,12 @@ public void findResultWithSpecialCharsTest() throws Exception {
.build();
//When we call the root endpoint
getClient().perform(get("/opensearch/search")
.param("query", "Bär"))
.param("query", "Bären"))
//The status has to be 200 OK
.andExpect(status().isOk())
//We expect the content type to be "application/atom+xml;charset=UTF-8"
.andExpect(content().contentType("application/atom+xml;charset=UTF-8"))
.andExpect(xpath("feed/Query/@searchTerms").string("B%C3%A4r"))
.andExpect(xpath("feed/Query/@searchTerms").string("B%C3%A4ren"))
.andExpect(xpath("feed/totalResults").string("1"))
;
}
Expand Down

0 comments on commit 8c22915

Please sign in to comment.