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

This commit is contained in:
Samuel
2021-05-20 15:19:12 +02:00
parent a47f8d9476
commit a1906e83b3
2 changed files with 11 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
*/ */
package org.dspace.app.rest; package org.dspace.app.rest;
import static com.google.common.net.UrlEscapers.urlPathSegmentEscaper;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath; import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.contains;
@@ -5764,7 +5765,9 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
.andExpect(jsonPath("$._embedded.values[0].label", is("Smith, Donald"))) .andExpect(jsonPath("$._embedded.values[0].label", is("Smith, Donald")))
.andExpect(jsonPath("$._embedded.values[0].count", is(1))) .andExpect(jsonPath("$._embedded.values[0].count", is(1)))
.andExpect(jsonPath("$._embedded.values[0]._links.search.href", .andExpect(jsonPath("$._embedded.values[0]._links.search.href",
containsString("api/discover/search/objects?query=Donald&f.author=Smith, Donald,equals"))) containsString("api/discover/search/objects?query=Donald&f.author=" +
urlPathSegmentEscaper().escape("Smith, Donald,equals")
)))
.andExpect(jsonPath("$._embedded.values").value(Matchers.hasSize(1))); .andExpect(jsonPath("$._embedded.values").value(Matchers.hasSize(1)));
} }
@@ -5817,7 +5820,9 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
.andExpect(jsonPath("$._embedded.values[0].label", is("2017 - 2020"))) .andExpect(jsonPath("$._embedded.values[0].label", is("2017 - 2020")))
.andExpect(jsonPath("$._embedded.values[0].count", is(3))) .andExpect(jsonPath("$._embedded.values[0].count", is(3)))
.andExpect(jsonPath("$._embedded.values[0]._links.search.href", .andExpect(jsonPath("$._embedded.values[0]._links.search.href",
containsString("api/discover/search/objects?dsoType=Item&f.dateIssued=[2017 TO 2020],equals"))) containsString("api/discover/search/objects?dsoType=Item&f.dateIssued=" +
urlPathSegmentEscaper().escape("[2017 TO 2020],equals")
)))
.andExpect(jsonPath("$._embedded.values").value(Matchers.hasSize(1))); .andExpect(jsonPath("$._embedded.values").value(Matchers.hasSize(1)));
} }

View File

@@ -7,6 +7,7 @@
*/ */
package org.dspace.app.rest.matcher; package org.dspace.app.rest.matcher;
import static com.google.common.net.UrlEscapers.urlPathSegmentEscaper;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath; import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
@@ -24,7 +25,9 @@ public class FacetValueMatcher {
hasJsonPath("$.label", is(label)), hasJsonPath("$.label", is(label)),
hasJsonPath("$.type", is("discover")), hasJsonPath("$.type", is("discover")),
hasJsonPath("$._links.search.href", containsString("api/discover/search/objects")), hasJsonPath("$._links.search.href", containsString("api/discover/search/objects")),
hasJsonPath("$._links.search.href", containsString("f.author=" + label + ",equals")) hasJsonPath("$._links.search.href", containsString(
"f.author=" + urlPathSegmentEscaper().escape(label) + ",equals"
))
); );
} }