]> source.dussan.org Git - sonarqube.git/commitdiff
Drop no longer used ProjectAlmBindingsDao.bindingExists
authorJanos Gyerik <janos.gyerik@sonarsource.com>
Mon, 6 Aug 2018 13:05:10 +0000 (15:05 +0200)
committerSonarTech <sonartech@sonarsource.com>
Fri, 10 Aug 2018 18:21:31 +0000 (20:21 +0200)
server/sonar-db-dao/src/main/java/org/sonar/db/alm/ProjectAlmBindingsDao.java
server/sonar-db-dao/src/test/java/org/sonar/db/alm/ProjectAlmBindingsDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java

index 45fbecb66e0a253dce519d2ff304c6bd5fefad9a..61b9bc5d56e219645539774b74dadcb346a456bf 100644 (file)
@@ -57,13 +57,6 @@ public class ProjectAlmBindingsDao implements Dao {
     }
   }
 
-  public boolean bindingExists(DbSession dbSession, ALM alm, String repoId) {
-    checkAlm(alm);
-    checkRepoId(repoId);
-
-    return getMapper(dbSession).bindingCount(alm.getId(), repoId) == 1;
-  }
-
   public Optional<ProjectAlmBindingDto> selectByProjectUuid(DbSession session, String projectUuid) {
     return Optional.ofNullable(getMapper(session).selectByProjectUuid(projectUuid));
   }
index fd279815dc7872fffa04c8ca15b3d4a869b8f03f..f7705701a0875a833f702e2e7694de5f416871b5 100644 (file)
@@ -177,40 +177,6 @@ public class ProjectAlmBindingsDaoTest {
       .hasUpdatedAt(DATE);
   }
 
-  @Test
-  public void mappingExists_throws_NPE_when_alm_is_null() {
-    expectAlmNPE();
-
-    underTest.bindingExists(dbSession, null, A_REPO);
-  }
-
-  @Test
-  public void mappingExists_throws_IAE_when_repo_id_is_null() {
-    expectRepoIdNullOrEmptyIAE();
-
-    underTest.bindingExists(dbSession, GITHUB, null);
-  }
-
-  @Test
-  public void mappingExists_throws_IAE_when_repo_id_is_empty() {
-    expectRepoIdNullOrEmptyIAE();
-
-    underTest.bindingExists(dbSession, GITHUB, EMPTY_STRING);
-  }
-
-  @Test
-  public void mappingExists_returns_false_when_entry_does_not_exist_in_DB() {
-    assertThat(underTest.bindingExists(dbSession, GITHUB, A_REPO)).isFalse();
-  }
-
-  @Test
-  public void mappingExists_returns_true_when_entry_exists() {
-    when(uuidFactory.create()).thenReturn("uuid1");
-    underTest.insertOrUpdate(dbSession, GITHUB, A_REPO, A_UUID, A_GITHUB_SLUG, A_URL);
-
-    assertThat(underTest.bindingExists(dbSession, GITHUB, A_REPO)).isTrue();
-  }
-
   @Test
   public void select_by_repo_id() {
     when(system2.now()).thenReturn(DATE);
index 73579845adae017cdf25009c942adea0f4222860..afa7636baf60900ad325f952d4f48eda14f058bc 100644 (file)
@@ -628,13 +628,14 @@ public class PurgeDaoTest {
     String otherRepoId = repoId + "-foo";
 
     ComponentDto project = dbTester.components().insertPublicProject();
+    ComponentDto otherProject = dbTester.components().insertPublicProject();
     dbClient.projectAlmBindingsDao().insertOrUpdate(dbSession, alm, repoId, project.uuid(), null, "foo");
-    dbClient.projectAlmBindingsDao().insertOrUpdate(dbSession, alm, otherRepoId, "D2", null, "bar");
+    dbClient.projectAlmBindingsDao().insertOrUpdate(dbSession, alm, otherRepoId, otherProject.uuid(), null, "bar");
 
     underTest.deleteProject(dbSession, project.uuid());
 
-    assertThat(dbClient.projectAlmBindingsDao().bindingExists(dbSession, alm, repoId)).isFalse();
-    assertThat(dbClient.projectAlmBindingsDao().bindingExists(dbSession, alm, otherRepoId)).isTrue();
+    assertThat(dbClient.projectAlmBindingsDao().findProjectKey(dbSession, alm, repoId)).isEmpty();
+    assertThat(dbClient.projectAlmBindingsDao().findProjectKey(dbSession, alm, otherRepoId)).isNotEmpty();
   }
 
   @Test