]> source.dussan.org Git - sonarqube.git/commitdiff
OrganizationDao#selectByUuids does not fail with single unknown uuid
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 10 May 2017 11:52:14 +0000 (13:52 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 12 May 2017 10:37:19 +0000 (12:37 +0200)
server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
server/sonar-db-dao/src/test/java/org/sonar/db/organization/OrganizationDaoTest.java

index 4ddc575bd86772797394bbe0ecbcd3bbecca60f1..1a43599dd1a21f1b9fbbbb3afe39e130b5e2ea97 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.db.organization;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
@@ -69,9 +68,6 @@ public class OrganizationDao implements Dao {
   }
 
   public List<OrganizationDto> selectByUuids(DbSession dbSession, Set<String> organizationUuids) {
-    if (organizationUuids.size() == 1) {
-      return Collections.singletonList(getMapper(dbSession).selectByUuid(organizationUuids.iterator().next()));
-    }
     return executeLargeInputs(organizationUuids, getMapper(dbSession)::selectByUuids);
   }
 
index 7e37027d520e5fa6b627035e9638af6d51b96361..9912aede16c6462b6d015bb9dadf243abca4b3f6 100644 (file)
@@ -283,6 +283,15 @@ public class OrganizationDaoTest {
       .isEmpty();
   }
 
+  @Test
+  public void selectByUuids_returns_empty_when_no_single_uuid_exist() {
+    insertOrganization(ORGANIZATION_DTO_1);
+    insertOrganization(ORGANIZATION_DTO_2);
+
+    assertThat(underTest.selectByUuids(dbSession, of("foo uuid")))
+      .isEmpty();
+  }
+
   @Test
   public void selectByUuids_ignores_non_existing_uuids() {
     insertOrganization(ORGANIZATION_DTO_1);