RequestMatchers { public static RequestMatcher pathEndsWithIgnoringQueryParams(final String endOfUrlPath) { return new RequestMatcher("path ends with: ${endOfUrlPath}") { protected boolean matchesSafely(RecordedRequest item) { String endOfPathSanitized = sanitizePath(endOfUrlPath); String recordedPathSanitized = sanitizePath(item.getPath()); return recordedPathSanitized.endsWith(endOfPathSanitized); } }; } private  RequestMatchers(); static RequestMatcher pathContains(final String urlPart); static RequestMatcher pathDoesNotContain(final String urlPart); static RequestMatcher pathMatchesRegex(final String pattern); static RequestMatcher pathEndsWith(final String urlPart); static RequestMatcher pathEndsWithIgnoringQueryParams(final String endOfUrlPath); static RequestMatcher pathStartsWith(final String urlPart); static RequestMatcher hasHeaderNames(final String... headerNames); static RequestMatcher hasQueryParameters(); static RequestMatcher hasQueryParameterNames(final String... expectedParamsNames); static RequestMatcher hasExactQueryParameters(final QueryParam... expectedParams); static RequestMatcher httpMethodIs(final String method); static RequestMatcher isGET(); static RequestMatcher isPOST(); static RequestMatcher isPATCH(); static RequestMatcher isDELETE(); static RequestMatcher isPUT(); static RequestMatcher isHEAD();  }
@Test public void queryParamsAreIgnored() throws IOException { RecordedRequest recordedRequest = createRecordedRequest("/foo/bar?baz=boo"); RequestMatcher matcher = RequestMatchers.pathEndsWithIgnoringQueryParams("bar"); assertTrue(matcher.matches(recordedRequest)); }