]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10147 Drop usage of global 'sonar.qualitygate' property in CE
authorEric Hartmann <hartmann.eric@gmail.com>
Fri, 8 Dec 2017 15:28:41 +0000 (16:28 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 14 Dec 2017 16:03:35 +0000 (17:03 +0100)
14 files changed:
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/analysis/Organization.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateService.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImpl.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadQualityGateStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/analysis/OrganizationTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/DefaultAssigneeTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/RuleRepositoryImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/qualitygate/QualityGateServiceImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadQualityGateStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistIssuesStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ViewsPersistComponentsStepTest.java

index c53ec627eb8df5d3abc81f41166c8de17a486f66..f2de3e7a4231bcc68d6ab08db8a80a23b7895ca8 100644 (file)
@@ -29,11 +29,13 @@ public class Organization {
   private final String uuid;
   private final String key;
   private final String name;
+  private final String defaultQualityGateUuid;
 
-  private Organization(String uuid, String key, String name) {
+  private Organization(String uuid, String key, String name, String defaultQualityGateUuid) {
     this.uuid = requireNonNull(uuid, "uuid can't be null");
     this.key = requireNonNull(key, "key can't be null");
     this.name = requireNonNull(name, "name can't be null");
+    this.defaultQualityGateUuid = requireNonNull(defaultQualityGateUuid, "defaultQualityGateUuid can't be null");
   }
 
   public String getUuid() {
@@ -48,6 +50,10 @@ public class Organization {
     return name;
   }
 
+  public String getDefaultQualityGateUuid() {
+    return defaultQualityGateUuid;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {
@@ -71,11 +77,20 @@ public class Organization {
       "uuid='" + uuid + '\'' +
       ", key='" + key + '\'' +
       ", name='" + name + '\'' +
+      ", defaultQualityGateUuid='" + defaultQualityGateUuid + '\'' +
       '}';
   }
 
+  public OrganizationDto toDto() {
+    return new OrganizationDto()
+      .setName(name)
+      .setKey(key)
+      .setUuid(uuid)
+      .setDefaultQualityGateUuid(defaultQualityGateUuid);
+  }
+
   public static Organization from(OrganizationDto organizationDto) {
-    return new Organization(organizationDto.getUuid(), organizationDto.getKey(), organizationDto.getName());
+    return new Organization(organizationDto.getUuid(), organizationDto.getKey(), organizationDto.getName(), organizationDto.getDefaultQualityGateUuid());
   }
 
 }
index 2a457118b2fb315a787babec0420b9630003f935..4eb9d15898670d7c34b5b3248d9453809c586176 100644 (file)
  */
 package org.sonar.server.computation.task.projectanalysis.qualitygate;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
+import org.sonar.server.computation.task.projectanalysis.analysis.Organization;
 
 public interface QualityGateService {
 
   /**
-   * Retrieve the {@link QualityGate} from the database with the specified id, it it exists.
+   * Retrieve the {@link QualityGate} from the database with the specified id, if it exists.
    */
   Optional<QualityGate> findById(long id);
+
+  /**
+   * Retrieve the {@link QualityGate} from the database with the specified uuid, if it exists.
+   */
+  Optional<QualityGate> findDefaultQualityGate(Organization organizationDto);
+
 }
index f01810b5eab37e18efe902b110296552ecc78f8d..f12eb5e300479b29b26b19f2d436fb0644b400b8 100644 (file)
  */
 package org.sonar.server.computation.task.projectanalysis.qualitygate;
 
-import com.google.common.base.Optional;
 import java.util.Collection;
 import java.util.Objects;
+import java.util.Optional;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.qualitygate.QualityGateConditionDto;
 import org.sonar.db.qualitygate.QualityGateDto;
+import org.sonar.server.computation.task.projectanalysis.analysis.Organization;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepository;
 import org.sonar.server.qualitygate.ShortLivingBranchQualityGate;
 
@@ -49,7 +50,18 @@ public class QualityGateServiceImpl implements QualityGateService {
     try (DbSession dbSession = dbClient.openSession(false)) {
       QualityGateDto qualityGateDto = dbClient.qualityGateDao().selectById(dbSession, id);
       if (qualityGateDto == null) {
-        return Optional.absent();
+        return Optional.empty();
+      }
+      return Optional.of(toQualityGate(dbSession, qualityGateDto));
+    }
+  }
+
+  @Override
+  public Optional<QualityGate> findDefaultQualityGate(Organization organization) {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      QualityGateDto qualityGateDto = dbClient.qualityGateDao().selectByOrganizationAndUuid(dbSession, organization.toDto(), organization.getDefaultQualityGateUuid());
+      if (qualityGateDto == null) {
+        return Optional.empty();
       }
       return Optional.of(toQualityGate(dbSession, qualityGateDto));
     }
index 68abc8c8b62d46ea85b5f6c08821a7d216339d2a..dcb01bd4695f7119433d3cbd1f9e234e255fa321 100644 (file)
  */
 package org.sonar.server.computation.task.projectanalysis.step;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.sonar.api.config.Configuration;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
 import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder;
 import org.sonar.server.computation.task.projectanalysis.component.ConfigurationRepository;
 import org.sonar.server.computation.task.projectanalysis.qualitygate.MutableQualityGateHolder;
@@ -38,9 +36,7 @@ import static org.apache.commons.lang.StringUtils.isBlank;
  * {@link MutableQualityGateHolder}.
  */
 public class LoadQualityGateStep implements ComputationStep {
-  private static final Logger LOGGER = Loggers.get(LoadQualityGateStep.class);
-
-  private static final String PROPERTY_QUALITY_GATE = "sonar.qualitygate";
+  private static final String PROPERTY_PROJECT_QUALITY_GATE = "sonar.qualitygate";
 
   private final ConfigurationRepository configRepository;
   private final QualityGateService qualityGateService;
@@ -57,39 +53,57 @@ public class LoadQualityGateStep implements ComputationStep {
 
   @Override
   public void execute() {
+    Optional<QualityGate> qualityGate = getShortLivingBranchQualityGate();
+    if (!qualityGate.isPresent()) {
+      // Not on a short living branch, let's retrieve the QG of the project
+      qualityGate = getProjectQualityGate();
+      if (!qualityGate.isPresent()) {
+        // No QG defined for the project, let's retrieve the QG on the organization
+        qualityGate = getOrganizationDefaultQualityGate();
+      }
+    }
+
+    if (qualityGate.isPresent()) {
+      qualityGateHolder.setQualityGate(qualityGate.get());
+    } else {
+      qualityGateHolder.setNoQualityGate();
+    }
+  }
+
+  private Optional<QualityGate> getShortLivingBranchQualityGate() {
     if (analysisMetadataHolder.isShortLivingBranch()) {
       Optional<QualityGate> qualityGate = qualityGateService.findById(ShortLivingBranchQualityGate.ID);
       if (qualityGate.isPresent()) {
-        qualityGateHolder.setQualityGate(qualityGate.get());
+        return qualityGate;
       } else {
         throw new IllegalStateException("Failed to retrieve hardcoded short living branch Quality Gate");
       }
-      return;
+    } else {
+      return Optional.empty();
     }
+  }
+
+  private Optional<QualityGate> getProjectQualityGate() {
     Configuration config = configRepository.getConfiguration();
-    String qualityGateSetting = config.get(PROPERTY_QUALITY_GATE).orElse(null);
+    String qualityGateSetting = config.get(PROPERTY_PROJECT_QUALITY_GATE).orElse(null);
 
     if (isBlank(qualityGateSetting)) {
-      LOGGER.debug("No quality gate is configured");
-      qualityGateHolder.setNoQualityGate();
-      return;
+      return Optional.empty();
     }
 
     try {
       long qualityGateId = Long.parseLong(qualityGateSetting);
-      Optional<QualityGate> qualityGate = qualityGateService.findById(qualityGateId);
-      if (qualityGate.isPresent()) {
-        qualityGateHolder.setQualityGate(qualityGate.get());
-      } else {
-        qualityGateHolder.setNoQualityGate();
-      }
+      return qualityGateService.findById(qualityGateId);
     } catch (NumberFormatException e) {
       throw new IllegalStateException(
-        String.format("Unsupported value (%s) in property %s", qualityGateSetting, PROPERTY_QUALITY_GATE),
-        e);
+        String.format("Unsupported value (%s) in property %s", qualityGateSetting, PROPERTY_PROJECT_QUALITY_GATE), e);
     }
   }
 
+  private Optional<QualityGate> getOrganizationDefaultQualityGate() {
+    return qualityGateService.findDefaultQualityGate(analysisMetadataHolder.getOrganization());
+  }
+
   @Override
   public String getDescription() {
     return "Load Quality gate";
index ec05e37eba387ad0a69004492578b751f0d11bd3..513fa54b3a5dfd7796ea4b3d8a388e3f865d89c4 100644 (file)
@@ -62,7 +62,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void setOrganization_throws_ISE_if_called_twice() {
-    Organization organization = Organization.from(new OrganizationDto().setUuid("uuid").setKey("key").setName("name"));
+    Organization organization = Organization.from(new OrganizationDto().setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("anyuuidr"));
     underTest.setOrganization(organization);
 
     expectedException.expect(IllegalStateException.class);
index f1fb6e2a42c212b1f871ba96cd5891b71118bbf4..1be5bbb5db0d1323e987640f2f81fa565c8044e3 100644 (file)
@@ -62,9 +62,9 @@ public class AnalysisMetadataHolderRule extends ExternalResource implements Muta
     return this;
   }
 
-  public AnalysisMetadataHolderRule setOrganizationUuid(String uuid) {
+  public AnalysisMetadataHolderRule setOrganizationUuid(String uuid, String defaultQualityGateUuid) {
     requireNonNull(uuid, "organization uuid can't be null");
-    this.organization.setProperty(Organization.from(new OrganizationDto().setUuid(uuid).setKey("key_" + uuid).setName("name_" + uuid)));
+    this.organization.setProperty(Organization.from(new OrganizationDto().setUuid(uuid).setKey("key_" + uuid).setName("name_" + uuid).setDefaultQualityGateUuid(defaultQualityGateUuid)));
     return this;
   }
 
index aedf90d7266f8a03a93785bf23b58cfc116ce4a6..75c251936a8b07f6cca33e346d57f319ba42118e 100644 (file)
@@ -57,6 +57,16 @@ public class OrganizationTest {
     Organization.from(underTest);
   }
 
+  @Test
+  public void build_throws_NPE_if_defaultQualityGateUuid_is_null() {
+    underTest.setUuid("uuid").setKey("key").setName("name");
+
+    expectedException.expect(NullPointerException.class);
+    expectedException.expectMessage("defaultQualityGateUuid can't be null");
+
+    Organization.from(underTest);
+  }
+
   @Test
   public void build_throws_NPE_if_name_is_null() {
     underTest.setUuid("uuid").setKey("key");
@@ -69,35 +79,37 @@ public class OrganizationTest {
 
   @Test
   public void verify_getters() {
-    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name"));
+    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1"));
 
     assertThat(organization.getUuid()).isEqualTo("uuid");
     assertThat(organization.getKey()).isEqualTo("key");
     assertThat(organization.getName()).isEqualTo("name");
+    assertThat(organization.getDefaultQualityGateUuid()).isEqualTo("uuid1");
   }
 
   @Test
   public void verify_toString() {
-    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name"));
+    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1"));
 
-    assertThat(organization.toString()).isEqualTo("Organization{uuid='uuid', key='key', name='name'}");
+    assertThat(organization.toString()).isEqualTo("Organization{uuid='uuid', key='key', name='name', defaultQualityGateUuid='uuid1'}");
   }
 
   @Test
   public void equals_is_based_on_uuid_only() {
-    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name"));
+    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1"));
 
-    assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("name")));
-    assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("other key").setName("name")));
-    assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("other name")));
-    assertThat(organization).isNotEqualTo(Organization.from(underTest.setUuid("other uuid").setKey("key").setName("name")));
+    assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1")));
+    assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("other key").setName("name").setDefaultQualityGateUuid("uuid1")));
+    assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("other name").setDefaultQualityGateUuid("uuid1")));
+    assertThat(organization).isEqualTo(Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("other uuid")));
+    assertThat(organization).isNotEqualTo(Organization.from(underTest.setUuid("other uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1")));
     assertThat(organization).isNotEqualTo(null);
     assertThat(organization).isNotEqualTo("toto");
   }
 
   @Test
   public void hashcode_is_based_on_uuid_only() {
-    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name"));
+    Organization organization = Organization.from(underTest.setUuid("uuid").setKey("key").setName("name").setDefaultQualityGateUuid("uuid1"));
 
     assertThat(organization.hashCode()).isEqualTo("uuid".hashCode());
   }
index aa29f66174e51cf10db2bb5f6b410dd05cc3f07e..39eab252ffe7bd0ee3084324c74d511975fe4400 100644 (file)
@@ -38,6 +38,7 @@ public class DefaultAssigneeTest {
 
   public static final String PROJECT_KEY = "PROJECT_KEY";
   public static final String ORGANIZATION_UUID = "ORGANIZATION_UUID";
+  public static final String QUALITY_GATE_UUID = "QUALITY_GATE_UUID";
 
   @Rule
   public DbTester db = DbTester.create();
@@ -52,7 +53,8 @@ public class DefaultAssigneeTest {
   @Before
   public void setUp() throws Exception {
     organizationDto = db.organizations().insertForUuid(ORGANIZATION_UUID);
-    analysisMetadataHolder.setOrganization(Organization.from(new OrganizationDto().setUuid(ORGANIZATION_UUID).setKey("Organization key").setName("Organization name")));
+    analysisMetadataHolder.setOrganization(Organization.from(
+      new OrganizationDto().setUuid(ORGANIZATION_UUID).setKey("Organization key").setName("Organization name").setDefaultQualityGateUuid(QUALITY_GATE_UUID)));
   }
 
   @Test
index eff1c5397fb87542917032b9a9d69ea3574d94f4..476851e8d3e318c2ec8d968e668c7530fe72baca 100644 (file)
@@ -51,12 +51,13 @@ public class RuleRepositoryImplTest {
   private static final RuleKey AC_RULE_KEY = RuleKey.of("a", "c");
   private static final int AC_RULE_ID = 684;
   private static final String ORGANIZATION_UUID = "org-1";
+  public static final String QUALITY_GATE_UUID = "QUALITY_GATE_UUID";
 
   @org.junit.Rule
   public ExpectedException expectedException = ExpectedException.none();
   @org.junit.Rule
   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
-      .setOrganizationUuid(ORGANIZATION_UUID);
+      .setOrganizationUuid(ORGANIZATION_UUID, QUALITY_GATE_UUID);
 
   private DbClient dbClient = mock(DbClient.class);
   private DbSession dbSession = mock(DbSession.class);
index 8ca8e9504da4b3f44d18937b14bd83e842cd7568..04a14603abf2518e2aaf274252471c450e80e45d 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.server.computation.task.projectanalysis.qualitygate;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 import java.util.Collections;
+import java.util.Optional;
 import java.util.Random;
 import org.apache.commons.lang.RandomStringUtils;
 import org.junit.Before;
@@ -40,7 +40,6 @@ import org.sonar.server.qualitygate.ShortLivingBranchQualityGate;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
-import static org.assertj.guava.api.Assertions.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
@@ -73,7 +72,7 @@ public class QualityGateServiceImplTest {
 
   @Test
   public void findById_returns_absent_when_QualityGateDto_does_not_exist() {
-    assertThat(underTest.findById(SOME_ID)).isAbsent();
+    assertThat(underTest.findById(SOME_ID)).isNotPresent();
   }
 
   @Test
@@ -94,8 +93,8 @@ public class QualityGateServiceImplTest {
     when(qualityGateDao.selectById(any(DbSession.class), eq(SOME_ID))).thenReturn(QUALITY_GATE_DTO);
     when(qualityGateConditionDao.selectForQualityGate(any(DbSession.class), eq(SOME_ID))).thenReturn(ImmutableList.of(CONDITION_1, CONDITION_2));
     // metrics are always supposed to be there
-    when(metricRepository.getOptionalById(METRIC_ID_1)).thenReturn(java.util.Optional.of(METRIC_1));
-    when(metricRepository.getOptionalById(METRIC_ID_2)).thenReturn(java.util.Optional.of(METRIC_2));
+    when(metricRepository.getOptionalById(METRIC_ID_1)).thenReturn(Optional.of(METRIC_1));
+    when(metricRepository.getOptionalById(METRIC_ID_2)).thenReturn(Optional.of(METRIC_2));
 
     Optional<QualityGate> res = underTest.findById(SOME_ID);
 
@@ -112,8 +111,8 @@ public class QualityGateServiceImplTest {
     when(qualityGateDao.selectById(any(DbSession.class), eq(SOME_ID))).thenReturn(QUALITY_GATE_DTO);
     when(qualityGateConditionDao.selectForQualityGate(any(DbSession.class), eq(SOME_ID))).thenReturn(ImmutableList.of(CONDITION_1, CONDITION_2));
     // metrics are always supposed to be there
-    when(metricRepository.getOptionalById(METRIC_ID_1)).thenReturn(java.util.Optional.empty());
-    when(metricRepository.getOptionalById(METRIC_ID_2)).thenReturn(java.util.Optional.of(METRIC_2));
+    when(metricRepository.getOptionalById(METRIC_ID_1)).thenReturn(Optional.empty());
+    when(metricRepository.getOptionalById(METRIC_ID_2)).thenReturn(Optional.of(METRIC_2));
 
     Optional<QualityGate> res = underTest.findById(SOME_ID);
 
index 6abfb9f5b44218e7faa8feb621cdf015ce629cca..1b47999f75ee27c1fa3e7bfa0cc443fd01408251 100644 (file)
@@ -19,8 +19,8 @@
  */
 package org.sonar.server.computation.task.projectanalysis.step;
 
-import com.google.common.base.Optional;
 import java.util.Collections;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -36,9 +36,8 @@ import org.sonar.server.qualitygate.ShortLivingBranchQualityGate;
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.guava.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 public class LoadQualityGateStepTest {
@@ -73,14 +72,12 @@ public class LoadQualityGateStepTest {
   @Test
   public void execute_sets_default_QualityGate_when_project_has_no_settings() {
     when(settingsRepository.getConfiguration()).thenReturn(new MapSettings().asConfig());
+    QualityGate qualityGate = mock(QualityGate.class);
+    when(qualityGateService.findDefaultQualityGate(any())).thenReturn(Optional.of(qualityGate));
 
     underTest.execute();
 
-    verifyNoQualityGate();
-
-    // verify only project is processed
-    verify(settingsRepository).getConfiguration();
-    verifyNoMoreInteractions(settingsRepository);
+    assertThat(mutableQualityGateHolder.getQualityGate().get()).isSameAs(qualityGate);
   }
 
   @Test
@@ -94,9 +91,9 @@ public class LoadQualityGateStepTest {
   }
 
   @Test
-  public void execute_sets_default_QualityGate_if_it_can_not_be_found_by_service() {
-    when(settingsRepository.getConfiguration()).thenReturn(new MapSettings().setProperty("sonar.qualitygate", 10).asConfig());
-    when(qualityGateService.findById(10)).thenReturn(Optional.absent());
+  public void execute_sets_default_QualityGate_if_no_default_quality_gate_on_organization() {
+    when(settingsRepository.getConfiguration()).thenReturn(new MapSettings().asConfig());
+    when(qualityGateService.findDefaultQualityGate(any())).thenReturn(Optional.empty());
 
     underTest.execute();
 
@@ -105,7 +102,7 @@ public class LoadQualityGateStepTest {
 
   @Test
   public void execute_sets_QualityGate_if_it_can_be_found_by_service() {
-    QualityGate qualityGate = new QualityGate(465, "name", Collections.emptyList());
+    QualityGate qualityGate = new QualityGate(10, "name", Collections.emptyList());
 
     when(settingsRepository.getConfiguration()).thenReturn(new MapSettings().setProperty("sonar.qualitygate", 10).asConfig());
     when(qualityGateService.findById(10)).thenReturn(Optional.of(qualityGate));
index c970bb0409d1ff7f9a7d214a167d5f0a9e36cdc5..ff021d9710db9995c080a703dfab628023d8f48f 100644 (file)
@@ -74,7 +74,7 @@ public class PersistIssuesStepTest extends BaseStepTest {
   public BatchReportReaderRule reportReader = new BatchReportReaderRule();
   @Rule
   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
-    .setOrganizationUuid("org-1");
+    .setOrganizationUuid("org-1","qg-uuid-1");
 
   private DbSession session = db.getSession();
   private DbClient dbClient = db.getDbClient();
index 09c708162a488afb10d7c1764ee71ac5ac7e7c74..cf347a6be5c74cc7a242e8249458db26711b9bc8 100644 (file)
@@ -72,6 +72,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   private static final String PROJECT_KEY = "PROJECT_KEY";
   private static final String MODULE_KEY = "MODULE_KEY";
   private static final String ORGANIZATION_UUID = "org1";
+  private static final String QUALITY_GATE_UUID = "gg1";
 
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
@@ -81,7 +82,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
   public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.create(treeRootHolder);
   @Rule
   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
-    .setOrganizationUuid(ORGANIZATION_UUID);
+    .setOrganizationUuid(ORGANIZATION_UUID, QUALITY_GATE_UUID);
 
   private System2 system2 = mock(System2.class);
   private DbClient dbClient = db.getDbClient();
index 62dd7f293cbd08dff160417a9658edd13a742061..e352478534f2d1dcdb16cad7c5bada020683917d 100644 (file)
@@ -78,6 +78,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   private static final String PROJECT_VIEW_1_NAME = "PV1_NAME";
   private static final String PROJECT_VIEW_1_UUID = "PV1_UUID";
   private static final String ORGANIZATION_UUID = "org1";
+  private static final String QUALITY_GATE_UUID = "qg1";
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
@@ -87,7 +88,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
   public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.create(treeRootHolder);
   @Rule
   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
-    .setOrganizationUuid(ORGANIZATION_UUID);
+    .setOrganizationUuid(ORGANIZATION_UUID, QUALITY_GATE_UUID);
 
   private System2 system2 = mock(System2.class);
   private DbClient dbClient = dbTester.getDbClient();