aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-03-25 23:10:45 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-03-25 23:10:46 +0100
commit1b8416c73a97f61899286d2e1f4e3e7685135e9a (patch)
tree2894a01e8efd50df65264f7f31328f46f0a756a0 /sonar-plugin-api/src/test
parent0abfc8ad75bb91dceba66f9e5905268312bed038 (diff)
downloadsonarqube-1b8416c73a97f61899286d2e1f4e3e7685135e9a.tar.gz
sonarqube-1b8416c73a97f61899286d2e1f4e3e7685135e9a.zip
SONAR-4908 extract RulesDefinitionAnnotationLoader
+ refactor the classes RegisterXXX used during server startup
Diffstat (limited to 'sonar-plugin-api/src/test')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoaderTest.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionFromAnnotationsTest.java)26
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java2
2 files changed, 14 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionFromAnnotationsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoaderTest.java
index 65efa9d1258..da45d7d5dea 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionFromAnnotationsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoaderTest.java
@@ -28,11 +28,13 @@ import org.sonar.check.Priority;
import static org.fest.assertions.Assertions.assertThat;
-public class RulesDefinitionFromAnnotationsTest {
+public class RulesDefinitionAnnotationLoaderTest {
@org.junit.Rule
public final ExpectedException thrown = ExpectedException.none();
+ RulesDefinitionAnnotationLoader annotationLoader = new RulesDefinitionAnnotationLoader();
+
@Test
public void rule_with_property() {
RulesDefinition.Repository repository = load(RuleWithProperty.class);
@@ -57,7 +59,7 @@ public class RulesDefinitionFromAnnotationsTest {
public void override_annotation_programmatically() {
RulesDefinition.Context context = new RulesDefinition.Context();
RulesDefinition.NewRepository newRepository = context.createRepository("squid", "java");
- NewRule newRule = newRepository.loadAnnotatedClass(RuleWithProperty.class);
+ NewRule newRule = annotationLoader.loadRule(newRepository, RuleWithProperty.class);
newRule.setName("Overriden name");
newRule.param("property").setDefaultValue("true");
newRule.param("property").setDescription("Overriden");
@@ -102,14 +104,14 @@ public class RulesDefinitionFromAnnotationsTest {
@Test
public void should_recognize_type() {
- assertThat(RuleDefinitionsFromAnnotations.guessType(Integer.class)).isEqualTo(RuleParamType.INTEGER);
- assertThat(RuleDefinitionsFromAnnotations.guessType(int.class)).isEqualTo(RuleParamType.INTEGER);
- assertThat(RuleDefinitionsFromAnnotations.guessType(Float.class)).isEqualTo(RuleParamType.FLOAT);
- assertThat(RuleDefinitionsFromAnnotations.guessType(float.class)).isEqualTo(RuleParamType.FLOAT);
- assertThat(RuleDefinitionsFromAnnotations.guessType(Boolean.class)).isEqualTo(RuleParamType.BOOLEAN);
- assertThat(RuleDefinitionsFromAnnotations.guessType(boolean.class)).isEqualTo(RuleParamType.BOOLEAN);
- assertThat(RuleDefinitionsFromAnnotations.guessType(String.class)).isEqualTo(RuleParamType.STRING);
- assertThat(RuleDefinitionsFromAnnotations.guessType(Object.class)).isEqualTo(RuleParamType.STRING);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(Integer.class)).isEqualTo(RuleParamType.INTEGER);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(int.class)).isEqualTo(RuleParamType.INTEGER);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(Float.class)).isEqualTo(RuleParamType.FLOAT);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(float.class)).isEqualTo(RuleParamType.FLOAT);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(Boolean.class)).isEqualTo(RuleParamType.BOOLEAN);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(boolean.class)).isEqualTo(RuleParamType.BOOLEAN);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(String.class)).isEqualTo(RuleParamType.STRING);
+ assertThat(RulesDefinitionAnnotationLoader.guessType(Object.class)).isEqualTo(RuleParamType.STRING);
}
@Test
@@ -143,8 +145,8 @@ public class RulesDefinitionFromAnnotationsTest {
private RulesDefinition.Repository load(Class annotatedClass) {
RulesDefinition.Context context = new RulesDefinition.Context();
- RulesDefinition.NewExtendedRepository newRepository = context.createRepository("squid", "java")
- .loadAnnotatedClasses(annotatedClass);
+ RulesDefinition.NewExtendedRepository newRepository = context.createRepository("squid", "java");
+ annotationLoader.load(newRepository, annotatedClass);
newRepository.done();
return context.repository("squid");
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java
index 3d1675168d5..ea9de6560d5 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/JsonWriterTest.java
@@ -23,8 +23,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.api.utils.text.WriterException;
import java.io.IOException;
import java.io.StringWriter;