### Question:
MoreMapUtils { public static URI getUri(Map<?, ?> map, Object key, URI defaultValue) { Object uri = map.get(key); if (uri == null) { return defaultValue; } if (uri instanceof URI) { return (URI) uri; } if (uri instanceof String) { try { return URI.create(((String) uri).trim()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Object '" + key + "' is not a valid URI: " + uri, e); } } throw new IllegalArgumentException( "Object '" + key + "' must be a String or a URI. Got " + uri.getClass().getName()); } private  MoreMapUtils(); static List<T> getListOfEnum(
      Map<?, ?> map,
      Object key,
      List<T> defaultValue,
      final Class<T> enumClass); static Path getHadoopPath(Map<?, ?> map, Object key, Path defaultValue); static URI getUri(Map<?, ?> map, Object key, URI defaultValue);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void invalidUri() { Map<?, ?> map = newMap(KEY, "s3:"); MoreMapUtils.getUri(map, KEY, null); }
@Test public void noKeyReturnsDefaultUri() { Map<?, ?> map = newMap(KEY + "_+", "abc"); URI defaultUri = URI.create("my-uri"); assertThat(MoreMapUtils.getUri(map, KEY, defaultUri), is(defaultUri)); }
@Test public void nullUri() { Map<?, ?> map = newMap(KEY, null); assertThat(MoreMapUtils.getUri(map, KEY, null), is(nullValue())); }
@Test public void uri() { URI uri = URI.create("http: Map<?, ?> map = newMap(KEY, uri); assertThat(MoreMapUtils.getUri(map, KEY, null), is(uri)); }
@Test public void uriAsString() { Map<?, ?> map = newMap(KEY, "ftp: assertThat(MoreMapUtils.getUri(map, KEY, null), is(URI.create("ftp: }
@Test(expected = IllegalArgumentException.class) public void invalidUriType() { Map<?, ?> map = newMap(KEY, new Object()); MoreMapUtils.getUri(map, KEY, null); }