Search in sources :

Example 6 with BuiltInQualityProfile

use of org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile in project sonarqube by SonarSource.

the class BuiltInQualityProfilesDefinitionTest method createDefaultProfile.

@Test
public void createDefaultProfile() {
    Map<String, Map<String, BuiltInQualityProfile>> profiles = define(c -> {
        c.createBuiltInQualityProfile("Foo", "xoo").setDefault(true).done();
    });
    assertThat(profiles).containsOnlyKeys("xoo");
    assertThat(profiles.get("xoo")).containsOnlyKeys("Foo");
    BuiltInQualityProfile profile = profiles.get("xoo").get("Foo");
    assertThat(profile.name()).isEqualTo("Foo");
    assertThat(profile.language()).isEqualTo("xoo");
    assertThat(profile.isDefault()).isTrue();
}
Also used : BuiltInQualityProfile(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile) NewBuiltInQualityProfile(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.NewBuiltInQualityProfile) Map(java.util.Map) Test(org.junit.Test)

Example 7 with BuiltInQualityProfile

use of org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile in project sonarqube by SonarSource.

the class BuiltInQualityProfilesDefinitionTest method sanityEqualCheck.

@Test
public void sanityEqualCheck() {
    Map<String, Map<String, BuiltInQualityProfile>> profiles = define(c -> {
        NewBuiltInQualityProfile profile1 = c.createBuiltInQualityProfile("Foo1", "xoo");
        NewBuiltInActiveRule rule = profile1.activateRule("repo", "rule");
        profile1.done();
        NewBuiltInQualityProfile profile2 = c.createBuiltInQualityProfile("Foo2", "xoo");
        profile2.done();
        NewBuiltInQualityProfile profile3 = c.createBuiltInQualityProfile("Foo1", "xoo2");
        profile3.done();
        assertThat(profile1).isNotNull();
        assertThat(profile1).isNotEqualTo(profile2);
        assertThat(profile1).isNotEqualTo(profile3);
        assertThat(profile1.hashCode()).isNotEqualTo(profile2.hashCode());
        assertThat(profile1.name()).isNotEqualTo("Foo");
        assertThat(profile1.toString()).hasToString("NewBuiltInQualityProfile{name='Foo1', language='xoo', default='false'}");
        assertThat(rule.toString()).hasToString("[repository=repo, key=rule]");
    });
    BuiltInQualityProfile profile1 = profiles.get("xoo").get("Foo1");
    BuiltInQualityProfile profile2 = profiles.get("xoo").get("Foo2");
    BuiltInQualityProfile profile3 = profiles.get("xoo2").get("Foo1");
    assertThat(profile1).isNotNull().isNotEqualTo(profile2).isNotEqualTo(profile3);
    assertThat(profile1.hashCode()).isNotEqualTo(profile2.hashCode());
    assertThat(profile1.name()).isNotEqualTo("Foo");
    assertThat(profile1.toString()).hasToString("BuiltInQualityProfile{name='Foo1', language='xoo', default='false'}");
    assertThat(profile1.rule(RuleKey.of("repo", "rule")).toString()).hasToString("[repository=repo, key=rule]");
}
Also used : BuiltInQualityProfile(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile) NewBuiltInQualityProfile(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.NewBuiltInQualityProfile) NewBuiltInActiveRule(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.NewBuiltInActiveRule) NewBuiltInQualityProfile(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.NewBuiltInQualityProfile) Map(java.util.Map) Test(org.junit.Test)

Aggregations

BuiltInQualityProfile (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile)7 Test (org.junit.Test)6 Map (java.util.Map)4 NewBuiltInQualityProfile (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.NewBuiltInQualityProfile)4 NewBuiltInActiveRule (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.NewBuiltInActiveRule)2 LinkedHashMap (java.util.LinkedHashMap)1 Consumer (java.util.function.Consumer)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 Tuple.tuple (org.assertj.core.groups.Tuple.tuple)1 ExpectedException (org.junit.rules.ExpectedException)1 RuleKey (org.sonar.api.rule.RuleKey)1 BuiltInQualityProfilesDefinition (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition)1 Context (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.Context)1