]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA remove redundant quality gate UUID creation
authorZipeng WU <zipeng.wu@sonarsource.com>
Fri, 3 May 2024 09:43:09 +0000 (11:43 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 8 May 2024 20:02:44 +0000 (20:02 +0000)
server/sonar-db-dao/src/it/java/org/sonar/db/qualitygate/QualityGateDaoIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/QualityGateUpdaterIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/CopyActionIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/ws/CreateActionIT.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/QualityGateUpdater.java

index 174a1e17a0aeb60796a82bc1ea1a639f5ee65cd4..7d588c0d1e85cb72e9575ce8c1a3b3f2584558d4 100644 (file)
@@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.utils.System2;
-import org.sonar.core.util.Uuids;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.BranchDto;
@@ -53,7 +52,6 @@ class QualityGateDaoIT {
   @Test
   void insert() {
     QualityGateDto newQgate = new QualityGateDto()
-      .setUuid(Uuids.createFast())
       .setName("My Quality Gate")
       .setBuiltIn(false)
       .setUpdatedAt(new Date());
@@ -71,7 +69,7 @@ class QualityGateDaoIT {
 
   @Test
   void insert_built_in() {
-    underTest.insert(db.getSession(), new QualityGateDto().setName("test").setBuiltIn(true).setUuid(Uuids.createFast()));
+    underTest.insert(db.getSession(), new QualityGateDto().setName("test").setBuiltIn(true));
 
     QualityGateDto reloaded = underTest.selectByName(db.getSession(), "test");
 
index edac704a9fab113eb163419bc0481869d37411a2..c3ef0fe02b1875690623fff867fd7c21243829c2 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.qualitygate;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
@@ -39,7 +38,7 @@ public class QualityGateUpdaterIT {
 
   private final DbClient dbClient = db.getDbClient();
   private final DbSession dbSession = db.getSession();
-  private final QualityGateUpdater underTest = new QualityGateUpdater(dbClient, UuidFactoryFast.getInstance());
+  private final QualityGateUpdater underTest = new QualityGateUpdater(dbClient);
 
   @Test
   public void create_quality_gate() {
index 99e86f49b6c4313d854cd848419ee709e2af2c0d..f13c66479471f77d8c12bce99d990c80e5d017ef 100644 (file)
@@ -27,7 +27,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.sonar.api.server.ws.WebService;
-import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
@@ -63,7 +62,7 @@ public class CopyActionIT {
 
   private final DbClient dbClient = db.getDbClient();
   private final DbSession dbSession = db.getSession();
-  private final QualityGateUpdater qualityGateUpdater = new QualityGateUpdater(dbClient, UuidFactoryFast.getInstance());
+  private final QualityGateUpdater qualityGateUpdater = new QualityGateUpdater(dbClient);
   private final QualityGatesWsSupport wsSupport = new QualityGatesWsSupport(dbClient, userSession, TestComponentFinder.from(db));
 
   private final CopyAction underTest = new CopyAction(dbClient, userSession, qualityGateUpdater, wsSupport);
index 6c13b0673efa0a116ac2ea623aef7c5a5001000c..7f3e80da5ee35a4adb423edcbac1b0680e94de2c 100644 (file)
@@ -29,10 +29,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.server.ws.WebService;
-import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
@@ -65,8 +63,7 @@ public class CreateActionIT {
 
   private final DbClient dbClient = db.getDbClient();
   private final DbSession dbSession = db.getSession();
-  private final CreateAction underTest = new CreateAction(dbClient, userSession, new QualityGateUpdater(dbClient,
-    UuidFactoryFast.getInstance()),
+  private final CreateAction underTest = new CreateAction(dbClient, userSession, new QualityGateUpdater(dbClient),
     new QualityGateConditionsUpdater(dbClient));
   private final WsActionTester ws = new WsActionTester(underTest);
 
index e26266d1fd1976bf545772fcf2bf105948bd2a8e..868182d1cc7f756810905efe7f49eac12767d9e7 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.qualitygate;
 
-import org.sonar.core.util.UuidFactory;
 import org.sonar.core.util.Uuids;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
@@ -32,19 +31,16 @@ import static org.sonar.server.util.Validation.IS_ALREADY_USED_MESSAGE;
 public class QualityGateUpdater {
 
   private final DbClient dbClient;
-  private final UuidFactory uuidFactory;
 
-  public QualityGateUpdater(DbClient dbClient, UuidFactory uuidFactory) {
+  public QualityGateUpdater(DbClient dbClient) {
     this.dbClient = dbClient;
-    this.uuidFactory = uuidFactory;
   }
 
   public QualityGateDto create(DbSession dbSession, String name) {
     validateQualityGate(dbSession, name);
     QualityGateDto newQualityGate = new QualityGateDto()
       .setName(name)
-      .setBuiltIn(false)
-      .setUuid(uuidFactory.create());
+      .setBuiltIn(false);
     dbClient.qualityGateDao().insert(dbSession, newQualityGate);
     return newQualityGate;
   }