aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-04 14:14:21 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-04 14:14:21 +0200
commit41c86d81b9c4ae4f045da26a631e38c201521077 (patch)
treee03b543d56fdd8bf4bb72fc4da953b40572308e5 /sonar-plugin-api/src/test
parent79ebf35daa3acad4ec270ab193e1506d57f9afed (diff)
downloadsonarqube-41c86d81b9c4ae4f045da26a631e38c201521077.tar.gz
sonarqube-41c86d81b9c4ae4f045da26a631e38c201521077.zip
Fix quality flaws
Diffstat (limited to 'sonar-plugin-api/src/test')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java81
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java5
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristicTest.java81
3 files changed, 167 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java
new file mode 100644
index 00000000000..2a09fe5bef9
--- /dev/null
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtCharacteristicTest.java
@@ -0,0 +1,81 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.api.batch.debt.internal;
+
+import org.junit.Test;
+
+import java.util.Date;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DefaultDebtCharacteristicTest {
+
+ @Test
+ public void setter_and_getter_on_characteristic() throws Exception {
+ DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
+ .setId(1)
+ .setKey("PORTABILITY")
+ .setName("Portability")
+ .setOrder(1)
+ .setCreatedAt(new Date())
+ .setUpdatedAt(new Date());
+
+ assertThat(debtCharacteristic.id()).isEqualTo(1);
+ assertThat(debtCharacteristic.key()).isEqualTo("PORTABILITY");
+ assertThat(debtCharacteristic.name()).isEqualTo("Portability");
+ assertThat(debtCharacteristic.order()).isEqualTo(1);
+ assertThat(debtCharacteristic.parentId()).isNull();
+ assertThat(debtCharacteristic.isSub()).isFalse();
+ assertThat(debtCharacteristic.createdAt()).isNotNull();
+ assertThat(debtCharacteristic.updatedAt()).isNotNull();
+ }
+
+ @Test
+ public void setter_and_getter_on_sub_characteristic() throws Exception {
+ DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
+ .setId(1)
+ .setKey("COMPILER")
+ .setName("Compiler")
+ .setParentId(2)
+ .setCreatedAt(new Date())
+ .setUpdatedAt(new Date());
+
+ assertThat(debtCharacteristic.id()).isEqualTo(1);
+ assertThat(debtCharacteristic.key()).isEqualTo("COMPILER");
+ assertThat(debtCharacteristic.name()).isEqualTo("Compiler");
+ assertThat(debtCharacteristic.order()).isNull();
+ assertThat(debtCharacteristic.parentId()).isEqualTo(2);
+ assertThat(debtCharacteristic.isSub()).isTrue();
+ assertThat(debtCharacteristic.createdAt()).isNotNull();
+ assertThat(debtCharacteristic.updatedAt()).isNotNull();
+ }
+
+ @Test
+ public void to_string() throws Exception {
+ assertThat(new DefaultDebtCharacteristic()
+ .setId(1)
+ .setKey("PORTABILITY")
+ .setName("Portability")
+ .setOrder(1)
+ .setCreatedAt(new Date())
+ .setUpdatedAt(new Date())).isNotNull();
+ }
+}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java
index 561cb5ed3ae..a5dfe422bf2 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/debt/internal/DefaultDebtModelTest.java
@@ -72,6 +72,9 @@ public class DefaultDebtModelTest {
assertThat(debtCharacteristic.order()).isEqualTo(1);
assertThat(debtCharacteristic.parentId()).isNull();
assertThat(debtCharacteristic.isSub()).isFalse();
+
+
+ assertThat(debtModel.characteristicById(555)).isNull();
}
@Test
@@ -84,5 +87,7 @@ public class DefaultDebtModelTest {
assertThat(debtCharacteristic.order()).isNull();
assertThat(debtCharacteristic.parentId()).isEqualTo(1);
assertThat(debtCharacteristic.isSub()).isTrue();
+
+ assertThat(debtModel.characteristicByKey("UNKNOWN")).isNull();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristicTest.java
new file mode 100644
index 00000000000..f7d84cef57e
--- /dev/null
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristicTest.java
@@ -0,0 +1,81 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.api.server.debt.internal;
+
+import org.junit.Test;
+
+import java.util.Date;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DefaultDebtCharacteristicTest {
+
+ @Test
+ public void setter_and_getter_on_characteristic() throws Exception {
+ DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
+ .setId(1)
+ .setKey("PORTABILITY")
+ .setName("Portability")
+ .setOrder(1)
+ .setCreatedAt(new Date())
+ .setUpdatedAt(new Date());
+
+ assertThat(debtCharacteristic.id()).isEqualTo(1);
+ assertThat(debtCharacteristic.key()).isEqualTo("PORTABILITY");
+ assertThat(debtCharacteristic.name()).isEqualTo("Portability");
+ assertThat(debtCharacteristic.order()).isEqualTo(1);
+ assertThat(debtCharacteristic.parentId()).isNull();
+ assertThat(debtCharacteristic.isSub()).isFalse();
+ assertThat(debtCharacteristic.createdAt()).isNotNull();
+ assertThat(debtCharacteristic.updatedAt()).isNotNull();
+ }
+
+ @Test
+ public void setter_and_getter_on_sub_characteristic() throws Exception {
+ DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
+ .setId(1)
+ .setKey("COMPILER")
+ .setName("Compiler")
+ .setParentId(2)
+ .setCreatedAt(new Date())
+ .setUpdatedAt(new Date());
+
+ assertThat(debtCharacteristic.id()).isEqualTo(1);
+ assertThat(debtCharacteristic.key()).isEqualTo("COMPILER");
+ assertThat(debtCharacteristic.name()).isEqualTo("Compiler");
+ assertThat(debtCharacteristic.order()).isNull();
+ assertThat(debtCharacteristic.parentId()).isEqualTo(2);
+ assertThat(debtCharacteristic.isSub()).isTrue();
+ assertThat(debtCharacteristic.createdAt()).isNotNull();
+ assertThat(debtCharacteristic.updatedAt()).isNotNull();
+ }
+
+ @Test
+ public void to_string() throws Exception {
+ assertThat(new DefaultDebtCharacteristic()
+ .setId(1)
+ .setKey("PORTABILITY")
+ .setName("Portability")
+ .setOrder(1)
+ .setCreatedAt(new Date())
+ .setUpdatedAt(new Date())).isNotNull();
+ }
+}