### Question:
PropertyUtil { public static Map<String, String> parseQuery(URI uri) throws Exception { if (uri == null) { return Collections.emptyMap(); } return parseQuery(uri.getRawQuery()); }  static URI replaceQuery(URI originalURI, Map<String, String> properties); static URI replaceQuery(URI uri, String query); static URI eraseQuery(URI uri); static String createQueryString(Map<String, ? extends Object> options); static Map<String, String> parseQuery(URI uri); static Map<String, String> parseQuery(String queryString); static Map<String, String> filterProperties(Map<String, String> properties, String optionPrefix); static Map<String, String> setProperties(Object target, Map<String, String> properties); static Map<String, Object> setProperties(Object target, Properties properties); static Map<String, String> getProperties(Object object); static Object getProperty(Object object, String name); static boolean setProperty(Object target, String name, Object value); static String stripPrefix(String value, String prefix); static String stripUpto(String value, char c); static String stripBefore(String value, char c);  }### Answer:
@Test public void testParseQueryFromURI() throws Exception { URI original = new URI("http: Map<String, String> result = PropertyUtil.parseQuery(original); assertEquals(2, result.size()); assertTrue(result.containsKey("option")); assertTrue(result.containsKey("another")); assertEquals("true", result.get("option")); assertEquals("false", result.get("another")); }
@Test public void testParseQueryFromURIWithNoQuery() throws Exception { URI original = new URI("http: Map<String, String> result = PropertyUtil.parseQuery(original); assertNotNull(result); assertTrue(result.isEmpty()); }
@Test public void testParseQueryFromNullURI() throws Exception { Map<String, String> result = PropertyUtil.parseQuery((URI) null); assertNotNull(result); assertTrue(result.isEmpty()); }
@Test public void testParseQueryFromString() throws Exception { Map<String, String> result = PropertyUtil.parseQuery("option=true&another=false"); assertTrue(result.size() == 2); assertTrue(result.containsKey("option")); assertTrue(result.containsKey("another")); assertEquals("true", result.get("option")); assertEquals("false", result.get("another")); }
@Test public void testParseQueryFromStringWithNoValues() throws Exception { Map<String, String> result = PropertyUtil.parseQuery("option=&another="); assertTrue(result.size() == 2); assertTrue(result.containsKey("option")); assertTrue(result.containsKey("another")); assertEquals("", result.get("option")); assertEquals("", result.get("another")); }
@Test public void testParseQueryFromNullURIString() throws Exception { Map<String, String> result = PropertyUtil.parseQuery((String) null); assertNotNull(result); assertTrue(result.isEmpty()); }
@Test public void testParseQueryWithSingletonProperty() throws Exception { Map<String, String> result = PropertyUtil.parseQuery("option=true&another=false&notAssigned"); assertTrue(result.size() == 3); assertTrue(result.containsKey("option")); assertTrue(result.containsKey("another")); assertTrue(result.containsKey("notAssigned")); assertEquals("true", result.get("option")); assertEquals("false", result.get("another")); assertEquals(null, result.get("notAssigned")); }
@Test public void testParseQueryEmptryString() throws Exception { Map<String, String> result = PropertyUtil.parseQuery(""); assertNotNull(result); assertTrue(result.isEmpty()); }
@Test public void testParseQueryNullString() throws Exception { Map<String, String> result = PropertyUtil.parseQuery((String) null); assertNotNull(result); assertTrue(result.isEmpty()); }
@Test public void testParseQueryDecodesParameters() throws Exception { URI original = new URI("http: final String decodedKey = "user+name"; final String decodedValue = "%Ca+Hn/av"; Map<String, String> result = PropertyUtil.parseQuery(original); assertEquals(1, result.size()); assertTrue(result.containsKey(decodedKey)); assertEquals(decodedValue, result.get(decodedKey)); }