diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-19 17:10:01 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-19 17:12:09 +0200 |
commit | 3bd4ce6a6c0010e272b55656ae62cc2f0f20b9f7 (patch) | |
tree | 7385c15b6edf1f3c768ca22368b116fe6af6517a /sonar-plugin-api/src/test | |
parent | ba05cbc35820e64d70642615525377c9aa1b3069 (diff) | |
download | sonarqube-3bd4ce6a6c0010e272b55656ae62cc2f0f20b9f7.tar.gz sonarqube-3bd4ce6a6c0010e272b55656ae62cc2f0f20b9f7.zip |
SONAR-5389 Add medium tests
Diffstat (limited to 'sonar-plugin-api/src/test')
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/CheckFactoryTest.java | 18 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilderTest.java | 12 |
2 files changed, 15 insertions, 15 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/CheckFactoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/CheckFactoryTest.java index 64ce0c8c937..42f8d7f6654 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/CheckFactoryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/CheckFactoryTest.java @@ -46,7 +46,7 @@ public class CheckFactoryTest { @Test public void class_name_as_check_key() { RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithoutProperties"); - builder.activate(ruleKey); + builder.create(ruleKey).activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithoutProperties.class); @@ -60,7 +60,7 @@ public class CheckFactoryTest { @Test public void param_as_string_field() { RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithStringProperty"); - builder.activate(ruleKey).setParam("pattern", "foo"); + builder.create(ruleKey).setParam("pattern", "foo").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithStringProperty.class); @@ -77,7 +77,7 @@ public class CheckFactoryTest { thrown.expectMessage("The field 'unknown' does not exist or is not annotated with @RuleProperty in the class org.sonar.api.batch.rule.CheckWithStringProperty"); RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithStringProperty"); - builder.activate(ruleKey).setParam("unknown", "foo"); + builder.create(ruleKey).setParam("unknown", "foo").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); checkFactory.create("squid").addAnnotatedChecks(CheckWithStringProperty.class); @@ -86,7 +86,7 @@ public class CheckFactoryTest { @Test public void param_as_primitive_fields() { RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithPrimitiveProperties"); - builder.activate(ruleKey).setParam("max", "300").setParam("ignore", "true"); + builder.create(ruleKey).setParam("max", "300").setParam("ignore", "true").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithPrimitiveProperties.class); @@ -103,7 +103,7 @@ public class CheckFactoryTest { @Test public void param_as_inherited_field() { RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithPrimitiveProperties"); - builder.activate(ruleKey).setParam("max", "300"); + builder.create(ruleKey).setParam("max", "300").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithPrimitiveProperties.class); @@ -116,7 +116,7 @@ public class CheckFactoryTest { @Test public void use_engine_key() { RuleKey ruleKey = RuleKey.of("squid", "One"); - builder.activate(ruleKey).setInternalKey("S0001"); + builder.create(ruleKey).setInternalKey("S0001").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithKey.class); @@ -133,7 +133,7 @@ public class CheckFactoryTest { thrown.expect(SonarException.class); RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithUnsupportedPropertyType"); - builder.activate(ruleKey).setParam("max", "300"); + builder.create(ruleKey).setParam("max", "300").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); checkFactory.create("squid").addAnnotatedChecks(CheckWithUnsupportedPropertyType.class); @@ -142,7 +142,7 @@ public class CheckFactoryTest { @Test public void override_field_key() { RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithOverriddenPropertyKey"); - builder.activate(ruleKey).setParam("maximum", "300"); + builder.create(ruleKey).setParam("maximum", "300").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithOverriddenPropertyKey.class); @@ -158,7 +158,7 @@ public class CheckFactoryTest { @Test public void checks_as_objects() { RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithStringProperty"); - builder.activate(ruleKey).setParam("pattern", "foo"); + builder.create(ruleKey).setParam("pattern", "foo").activate(); CheckFactory checkFactory = new CheckFactory(builder.build()); CheckWithStringProperty check = new CheckWithStringProperty(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilderTest.java index d83456058fd..c308024616f 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilderTest.java @@ -39,14 +39,14 @@ public class ActiveRulesBuilderTest { @Test public void build_rules() throws Exception { ActiveRules activeRules = new ActiveRulesBuilder() - .activate(RuleKey.of("squid", "S0001")) + .create(RuleKey.of("squid", "S0001")) .setSeverity(Severity.CRITICAL) .setInternalKey("__S0001__") .setParam("min", "20") - .end() + .activate() // most simple rule - .activate(RuleKey.of("squid", "S0002")).end() - .activate(RuleKey.of("findbugs", "NPE")).setInternalKey(null).setSeverity(null).setParam("foo", null).end() + .create(RuleKey.of("squid", "S0002")).activate() + .create(RuleKey.of("findbugs", "NPE")).setInternalKey(null).setSeverity(null).setParam("foo", null).activate() .build(); assertThat(activeRules.findAll()).hasSize(3); @@ -77,9 +77,9 @@ public class ActiveRulesBuilderTest { @Test public void fail_to_add_twice_the_same_rule() throws Exception { ActiveRulesBuilder builder = new ActiveRulesBuilder(); - builder.activate(RuleKey.of("squid", "S0001")); + builder.create(RuleKey.of("squid", "S0001")).activate(); try { - builder.activate(RuleKey.of("squid", "S0001")); + builder.create(RuleKey.of("squid", "S0001")).activate(); fail(); } catch (IllegalStateException e) { assertThat(e).hasMessage("Rule 'squid:S0001' is already activated"); |