ModelDiscovery { public static String getSmithyModelPathFromJarUrl(URL modelUrl) { String urlString = modelUrl.toString(); int position = urlString.indexOf(ROOT_RESOURCE_PATH); if (position == -1) { throw new IllegalArgumentException("Invalid Smithy model URL: " + modelUrl); } return urlString.substring(position + ROOT_RESOURCE_PATH.length()); } private  ModelDiscovery(); static List<URL> findModels(); static List<URL> findModels(ClassLoader loader); static List<URL> findModels(URL jarManifestUrl); static String getSmithyModelPathFromJarUrl(URL modelUrl); static URL createSmithyJarManifestUrl(String fileOrUrl);  }
@Test public void extractsOutModelNameFromJarURL() throws IOException { assertThat(ModelDiscovery.getSmithyModelPathFromJarUrl(new URL("jar:file:/a.jar!/META-INF/smithy/a/b.json")), equalTo("a/b.json")); assertThat(ModelDiscovery.getSmithyModelPathFromJarUrl(new URL("jar:file:/a.jar!/META-INF/smithy/b.json")), equalTo("b.json")); }
@Test public void requiresModelNameToBeValidWhenParsing() throws IOException { Assertions.assertThrows(IllegalArgumentException.class, () -> { ModelDiscovery.getSmithyModelPathFromJarUrl(new URL("jar:file:/a.jar!/blerg.json")); }); }