@Override protected boolean testUriEquivalency(URI incomingUri, URI expectedUri) { try { URI modifiedIncomingUri = getModifiedUri(incomingUri); URI modifiedExpectedUri = getModifiedUri(expectedUri); return super.testUriEquivalency(modifiedIncomingUri, modifiedExpectedUri); } catch (URISyntaxException | UnsupportedEncodingException e) { LOGGER.error("Caught exception " + e + " while constructing modified URI"); } return false; }
/** * @return rule to match request URI, blacklisting the specified query parameters */ public static MatchRule matchUriWithQueryBlacklist(Set<String> blackList) { return new MatchUriWithQueryTransform(new MatchRuleBlacklistTransform(blackList)); }
/** * @return rule to match request URI, whitelisting the specified query parameters */ public static MatchRule matchUriWithQueryWhitelist(Set<String> whiteList) { return new MatchUriWithQueryTransform(new MatchRuleWhitelistTransform(whiteList)); }
@Override public String getMatchFailureDescriptionForRequests(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest) { StringBuilder resultBuilder = new StringBuilder("URI Mismatch"); if (_transform instanceof MatchRuleBlacklistTransform) { resultBuilder.append(" (with Query Blacklist)"); } else if (_transform instanceof MatchRuleWhitelistTransform) { resultBuilder.append(" (with Query Whitelist)"); } try { URI modifiedIncomingUri = getModifiedUri(incomingRequest.getUri()); URI modifiedExpectedUri = getModifiedUri(expectedRequest.getUri()); resultBuilder.append("%n") .append(String.format("Incoming URI: %s%n", modifiedIncomingUri)) .append(String.format("Expected URI: %s%n", modifiedExpectedUri)); } catch (URISyntaxException | UnsupportedEncodingException e) { LOGGER.error("Caught exception " + e + " while constructing modified URI"); } return resultBuilder.toString(); }