### Question:
RepositoryUtils { public static RepositoryId extractRepositoryFromScmUrl(String url) { if (StringUtils.isEmpty(url)) return null; int ghIndex = url.indexOf(HOST_DEFAULT); if (ghIndex == -1 || ghIndex + 1 >= url.length()) return null; if (!url.endsWith(SUFFIX_GIT)) return null; url = url.substring(ghIndex + HOST_DEFAULT.length() + 1, url.length() - SUFFIX_GIT.length()); return RepositoryId.createFromId(url); }  static RepositoryId extractRepositoryFromScmUrl(String url); static RepositoryId getRepository(final MavenProject project,
			final String owner, final String name);  }### Answer:
@Test public void extractFromAnonymousUrl() { RepositoryId repo = RepositoryUtils .extractRepositoryFromScmUrl("scm:git:git: assertNotNull(repo); assertEquals("owner", repo.getOwner()); assertEquals("project", repo.getName()); assertEquals("owner/project", repo.generateId()); }
@Test public void extractFromMalformedUrls() { assertNull(RepositoryUtils .extractRepositoryFromScmUrl("scm:git:git: assertNull(RepositoryUtils .extractRepositoryFromScmUrl("scm:git:git: assertNull(RepositoryUtils .extractRepositoryFromScmUrl("scm:git:git@github.com")); assertNull(RepositoryUtils .extractRepositoryFromScmUrl("scm:git:git@github.com:")); assertNull(RepositoryUtils.extractRepositoryFromScmUrl(null)); assertNull(RepositoryUtils.extractRepositoryFromScmUrl("")); assertNull(RepositoryUtils.extractRepositoryFromScmUrl(" ")); }
@Test public void extractFromSshUrl() { RepositoryId repo = RepositoryUtils .extractRepositoryFromScmUrl("scm:git:git@github.com:owner/project.git"); assertNotNull(repo); assertEquals("owner", repo.getOwner()); assertEquals("project", repo.getName()); assertEquals("owner/project", repo.generateId()); }