URISignatureHandler { public static List<String> extractPlaceholders(String uriSignature) { return new ArrayList<>(extractPlaceholdersWithPositions(uriSignature) .keySet()); }  static LinkedHashMap<String, Integer> extractPlaceholdersWithPositions(
			String uriSignature); static List<String> extractPlaceholders(String uriSignature); static void validate(String uriSignature); static void checkForUnsafeCharacters(String candidateURLSignature); static boolean isValid(String uriSignature); static String generateCompleteURI(String uriSignature,
			Map<String, String> specifiedParameters, boolean escapeParameters); static String urlEncodeQuery(String query); static final char PLACEHOLDER_START_SYMBOL; static final char PLACEHOLDER_END_SYMBOL; }
@Test public void extractPlaceholders_validURI_NoPlaceholders() { List<String> placeholders = URISignatureHandler .extractPlaceholders(validURI_NoPlaceholders); assertNotNull(placeholders); assertEquals(0, placeholders.size()); }
@Test public void extractPlaceholders_validURI_PlaceholdersInMainPartOfURIOnly() { List<String> placeholders = URISignatureHandler .extractPlaceholders(validURI_PlaceholdersInMainPartOfURIOnly); assertNotNull(placeholders); assertEquals(2, placeholders.size()); assertEquals("Wrong first placeholder", "sop_id", placeholders.get(0)); assertEquals("Wrong second placeholder", "cond_id", placeholders.get(1)); }
@Test public void extractPlaceholders_validURI_PlaceholdersInQueryStringOnly() { List<String> placeholders = URISignatureHandler .extractPlaceholders(validURI_PlaceholdersInQueryStringOnly); assertNotNull(placeholders); assertEquals(1, placeholders.size()); assertEquals("Wrong first placeholder", "user_id", placeholders.get(0)); }
@Test public void extractPlaceholders_validURI_MixedPlaceholders() { List<String> placeholders = URISignatureHandler .extractPlaceholders(validURI_3MixedPlaceholders); assertNotNull(placeholders); assertEquals("Wrong number of placeholders extracted", 3, placeholders .size()); assertEquals("Wrong first placeholder", "sop_id", placeholders.get(0)); assertEquals("Wrong second placeholder", "cond_id", placeholders.get(1)); assertEquals("Wrong third placeholder", "unit", placeholders.get(2)); }
@Test public void extractPlaceholders_validURI_MultipleQueryString() { List<String> placeholders = URISignatureHandler .extractPlaceholders(validURI_MultipleQueryString); assertNotNull(placeholders); assertEquals(5, placeholders.size()); assertEquals("Wrong first placeholder", "catalogue", placeholders.get(0)); assertEquals("Wrong second placeholder", "count?", placeholders.get(1)); assertEquals("Wrong third placeholder", "startPage?", placeholders.get(2)); assertEquals("Wrong fourth placeholder", "startIndex?", placeholders.get(3)); assertEquals("Wrong fifth placeholder", "searchTerms?", placeholders.get(4)); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_nullURI() { URISignatureHandler.extractPlaceholders(badURI_nullURI); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_emptyURI() { URISignatureHandler.extractPlaceholders(badURI_emptyURI); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_SingleOpeningSymbolNoClosingSymbol() { URISignatureHandler .extractPlaceholders(badURI_SingleOpeningSymbolNoClosingSymbol); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_SingleClosingSymbolNoOpeningSymbol() { URISignatureHandler .extractPlaceholders(badURI_SingleClosingSymbolNoOpeningSymbol); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_DoubleOpeningSymbolsNoClosingSymbol() { URISignatureHandler .extractPlaceholders(badURI_DoubleOpeningSymbolsNoClosingSymbol); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_DoubleOpeningSymbols() { URISignatureHandler.extractPlaceholders(badURI_DoubleOpeningSymbols); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_DoubleOpeningSymbolsSpaced() { URISignatureHandler .extractPlaceholders(badURI_DoubleOpeningSymbolsSpaced); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_DoubleClosingSymbols() { URISignatureHandler.extractPlaceholders(badURI_DoubleClosingSymbols); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_DoubleClosingSymbolsSpaced() { URISignatureHandler .extractPlaceholders(badURI_DoubleClosingSymbolsSpaced); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_NestedPlaceholders() { URISignatureHandler.extractPlaceholders(badURI_NestedPlaceholders); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_NestedPlaceholdersSpaced() { URISignatureHandler .extractPlaceholders(badURI_NestedPlaceholdersSpaced); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_DuplicatePlaceholders() { URISignatureHandler.extractPlaceholders(badURI_DuplicatePlaceholders); }
@Test(expected = URISignatureHandler.URISignatureParsingException.class) public void extractPlaceholders_badURI_DuplicatePlaceholdersWithOthers() { URISignatureHandler .extractPlaceholders(badURI_DuplicatePlaceholdersWithOthers); }