}
}
- 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));
}
.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);
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