HttpUtils { public static List<Integer> calculatePathMatchScore(String path) { path = normaliseUriPath(path); UriTemplateParser templateParser = getUriParserForPattern(path); int pathScore = templateParser.getNumberOfLiteralCharacters(); int paramScore = templateParser.getNumberOfRegexGroups() - templateParser.getNumberOfExplicitRegexes(); int regexScore = templateParser.getNumberOfExplicitRegexes(); List<Integer> scores = Arrays.asList(pathScore, paramScore, regexScore); return scores; } private  HttpUtils(); static KeyStore getKeyStore(ScenarioContext context, String trustStoreFile, String password, String type); static boolean isPrintable(String mediaType); static Charset parseContentTypeCharset(String mimeType); static Map<String, String> parseContentTypeParams(String mimeType); static String getContentType(ScriptValue sv); static Map<String, Cookie> parseCookieHeaderString(String header); static String createCookieHeaderValue(Collection<Cookie> cookies); static Map<String, String> parseUriPattern(String pattern, String url); static final String normaliseUriPath(String uri); static List<Integer> calculatePathMatchScore(String path); static String generateMimeBoundaryMarker(); static String multiPartToString(List<MultiPartItem> items, String boundary); static final String HEADER_CONTENT_TYPE; static final String HEADER_CONTENT_LENGTH; static final String HEADER_ACCEPT; static final String HEADER_ALLOW; static final String HEADER_AC_ALLOW_ORIGIN; static final String HEADER_AC_ALLOW_METHODS; static final String HEADER_AC_REQUEST_HEADERS; static final String HEADER_AC_ALLOW_HEADERS; static final String CHARSET; static final Set<String> HTTP_METHODS; static final List<Integer> DEFAULT_PATH_SCORE; }
@Test public void testCalculatePathMatchScore() { List<Integer> score = HttpUtils.calculatePathMatchScore("/cats/{id}"); Match.equals(score, "[6,1,0]"); score = HttpUtils.calculatePathMatchScore("/cats/1"); Match.equals(score, "[7,0,0]"); score = HttpUtils.calculatePathMatchScore("/cats/1/"); Match.equals(score, "[7,0,0]"); score = HttpUtils.calculatePathMatchScore("cats/1/"); Match.equals(score, "[7,0,0]"); }