aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-09-11 10:12:36 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-09-12 14:11:59 +0200
commit6c0b5563fbc8b0fbf9ed0aa722302a8f1e74cdf4 (patch)
treeb777f55fbb3408d696260c54a369bc0d9f3227eb /sonar-core
parentb5851d0ff8318549c2356b20df36401b879fc5a2 (diff)
downloadsonarqube-6c0b5563fbc8b0fbf9ed0aa722302a8f1e74cdf4.tar.gz
sonarqube-6c0b5563fbc8b0fbf9ed0aa722302a8f1e74cdf4.zip
SONAR-7851 add QProfileChangeDao
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/SequenceUuidFactory.java36
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/SequenceUuidFactoryTest.java37
2 files changed, 73 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/util/SequenceUuidFactory.java b/sonar-core/src/main/java/org/sonar/core/util/SequenceUuidFactory.java
new file mode 100644
index 00000000000..c35f78c71dc
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/util/SequenceUuidFactory.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.core.util;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Only for tests. This implementation of {@link UuidFactory} generates
+ * ids as a sequence of integers ("1", "2", ...). It starts with "1".
+ */
+public class SequenceUuidFactory implements UuidFactory {
+
+ private final AtomicInteger id = new AtomicInteger(1);
+
+ @Override
+ public String create() {
+ return String.valueOf(id.getAndIncrement());
+ }
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/SequenceUuidFactoryTest.java b/sonar-core/src/test/java/org/sonar/core/util/SequenceUuidFactoryTest.java
new file mode 100644
index 00000000000..2ca09ce5907
--- /dev/null
+++ b/sonar-core/src/test/java/org/sonar/core/util/SequenceUuidFactoryTest.java
@@ -0,0 +1,37 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.core.util;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+public class SequenceUuidFactoryTest {
+
+ private SequenceUuidFactory underTest = new SequenceUuidFactory();
+
+ @Test
+ public void generate_sequence_of_integer_ids() {
+ for (int i = 1; i < 10; i++) {
+ assertThat(underTest.create()).isEqualTo(String.valueOf(i));
+ }
+ }
+}