From 8c22915adf9ce39e29a03034c0ebde3321188840 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Mon, 13 May 2024 15:16:14 -0500 Subject: [PATCH] Add a basic test that refactoring of code results in correct logo URLs. Also enable/fix a test for special characters. --- .../opensearch/OpenSearchControllerIT.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/opensearch/OpenSearchControllerIT.java b/dspace-server-webapp/src/test/java/org/dspace/app/opensearch/OpenSearchControllerIT.java index b533e14568e..645d52df59f 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/opensearch/OpenSearchControllerIT.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/opensearch/OpenSearchControllerIT.java @@ -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") @@ -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 @@ -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")) ; }