]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22649 remove usage of id generator that are incompatible with a large volume...
authorSteve Marion <steve.marion@sonarsource.com>
Wed, 31 Jul 2024 09:02:18 +0000 (11:02 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 12 Aug 2024 20:02:45 +0000 (20:02 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoWithPersisterTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/DbTester.java

index 342d6b64e61e92f50f61f36590a8ab666976865e..89221a2434dd18c9b9f91002acc3b0727a5ebef2 100644 (file)
@@ -58,7 +58,7 @@ public class IssueTesting {
     checkArgument(file.branchUuid().equals(projectUuid), "The file doesn't belong to the project");
 
     return new IssueDto()
-      .setKee("uuid_" + randomAlphabetic(5))
+      .setKee(UuidFactoryFast.getInstance().create())
       .setRule(rule)
       .setType(RuleType.values()[nextInt(RuleType.values().length)])
       .setProjectUuid(projectUuid)
index ac11529d44f4a3f525d052e663a4dbbce4cb8a46..e5d99902d9c701447da9278bfaef3233df8113af 100644 (file)
@@ -71,7 +71,7 @@ public class AlmSettingDaoWithPersisterTest {
       .extracting("devOpsPlatformSettingUuid", "key")
       .containsExactly(almSettingDto.getUuid(), almSettingDto.getKey());
     assertThat(newValue)
-      .hasToString("{\"devOpsPlatformSettingUuid\": \"1\", \"key\": \"key\", \"devOpsPlatformName\": \"id1\", \"url\": \"url\", \"appId\": \"id1\", \"clientId\": \"cid1\" }");
+      .hasToString("{\"devOpsPlatformSettingUuid\": \""+almSettingDto.getUuid()+"\", \"key\": \""+almSettingDto.getKey()+"\", \"devOpsPlatformName\": \"id1\", \"url\": \"url\", \"appId\": \"id1\", \"clientId\": \"cid1\" }");
 
     almSettingDto.setPrivateKey("updated private key");
     almSettingDto.setAppId("updated app id");
@@ -90,8 +90,9 @@ public class AlmSettingDaoWithPersisterTest {
     assertThat(newValue)
       .extracting("devOpsPlatformSettingUuid", "key", "appId", "devOpsPlatformName", "url", "clientId")
       .containsExactly(almSettingDto.getUuid(), almSettingDto.getKey(), almSettingDto.getAppId(), almSettingDto.getAppId(), almSettingDto.getUrl(), almSettingDto.getClientId());
-    assertThat(newValue).hasToString("{\"devOpsPlatformSettingUuid\": \"1\", \"key\": \"updated key\", \"devOpsPlatformName\": \"updated app id\", "
-      + "\"url\": \"updated url\", \"appId\": \"updated app id\", \"clientId\": \"cid1\" }");
+    assertThat(newValue).hasToString("{\"devOpsPlatformSettingUuid\": \""+almSettingDto.getUuid()+"\", \"key\": \""+almSettingDto.getKey()
+      +"\", \"devOpsPlatformName\": \""+almSettingDto.getAppId()+"\", "
+      + "\"url\": \""+almSettingDto.getUrl()+"\", \"appId\": \""+almSettingDto.getAppId()+"\", \"clientId\": \""+almSettingDto.getClientId()+"\" }");
   }
 
   @Test
index 17206cf18087eb25dd9a6f9c67638d295159e150..07bd20d7fe1013b579f9dd38b66357192c773e25 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.db.notification;
 
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
 import java.util.Arrays;
 import java.util.List;
 import java.util.stream.IntStream;
@@ -100,8 +102,10 @@ public class NotificationQueueDaoTest {
     db.commit();
 
     assertThat(dao.selectOldest(3))
-      .extracting(NotificationQueueDto::getUuid)
-      .containsExactlyElementsOf(Arrays.asList("1", "2", "3"));
+      .extracting(NotificationQueueDto::getData)
+      .map(bytes -> new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject())
+      .extracting("type")
+      .containsExactlyElementsOf(List.of("foo_0", "foo_1", "foo_2"));
   }
 
   private List<String> selectAllUuid() {
index 3108082c4cf8ee101da5f4413db6fa0fb6afc11d..c9e8783b46e05da1f4bddc98496a5929ee6b5583 100644 (file)
@@ -29,8 +29,8 @@ import java.util.Map;
 import java.util.stream.Stream;
 import javax.annotation.Nullable;
 import org.sonar.api.utils.System2;
-import org.sonar.core.util.SequenceUuidFactory;
 import org.sonar.core.util.UuidFactory;
+import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.alm.integration.pat.AlmPatsDbTester;
 import org.sonar.db.almsettings.AlmSettingsDbTester;
 import org.sonar.db.audit.AuditDbTester;
@@ -62,7 +62,7 @@ import org.sonar.db.webhook.WebhookDeliveryDbTester;
  */
 public class DbTester extends AbstractDbTester<TestDbImpl> {
 
-  private final UuidFactory uuidFactory = new SequenceUuidFactory();
+  private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();
   private final System2 system2;
   private final AuditPersister auditPersister;
   private DbClient client;