### Question:
RepositoryUtils { public static RepositoryId getRepository(final MavenProject project, final String owner, final String name) { if (!StringUtils.isEmpty(owner, name)) return RepositoryId.create(owner, name); if (project == null) return null; RepositoryId repo = null; final Scm scm = project.getScm(); if (scm != null) { repo = RepositoryId.createFromUrl(scm.getUrl()); if (repo == null) repo = extractRepositoryFromScmUrl(scm.getConnection()); if (repo == null) repo = extractRepositoryFromScmUrl(scm.getDeveloperConnection()); } if (repo == null) repo = RepositoryId.createFromUrl(project.getUrl()); return repo; }  static RepositoryId extractRepositoryFromScmUrl(String url); static RepositoryId getRepository(final MavenProject project,
			final String owner, final String name);  }### Answer:
@Test public void extractRepositoryFromEmptyProject() { MavenProject project = Mockito.mock(MavenProject.class); RepositoryId repositoryId = RepositoryUtils.getRepository(project, null, null); assertThat(repositoryId).isNull(); }
@Test public void extractRepositoryFromEmptyProjectWithUrl() { MavenProject project = Mockito.mock(MavenProject.class); when(project.getUrl()).thenReturn("https: RepositoryId repositoryId = RepositoryUtils.getRepository(project, null, null); assertThat(repositoryId).isNotNull(); assertThat(repositoryId.getName()).isEqualTo("coffee-mill-maven-plugin"); assertThat(repositoryId.getOwner()).isEqualTo("nanoko-project"); }
@Test public void extractRepositoryFromEmptyProjectWithSCM() { Scm scm = Mockito.mock(Scm.class); when(scm.getUrl()).thenReturn("https: MavenProject project = Mockito.mock(MavenProject.class); when(project.getUrl()).thenReturn("must not be used"); when(project.getScm()).thenReturn(scm); RepositoryId repositoryId = RepositoryUtils.getRepository(project, null, null); assertThat(repositoryId).isNotNull(); assertThat(repositoryId.getName()).isEqualTo("coffee-mill-maven-plugin"); assertThat(repositoryId.getOwner()).isEqualTo("nanoko-project"); }