Search in sources :

Example 1 with QProfileComparisonResult

use of org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult in project sonarqube by SonarSource.

the class QProfileComparisonMediumTest method compare_different_params.

@Test
public void compare_different_params() {
    ruleActivator.activate(dbSession, new RuleActivation(xooRule1.getKey()).setParameter("max", "20"), left);
    ruleActivator.activate(dbSession, new RuleActivation(xooRule1.getKey()).setParameter("min", "5"), right);
    dbSession.commit();
    QProfileComparisonResult result = comparison.compare(left.getKey(), right.getKey());
    assertThat(result.left().getKey()).isEqualTo(left.getKey());
    assertThat(result.right().getKey()).isEqualTo(right.getKey());
    assertThat(result.same()).isEmpty();
    assertThat(result.inLeft()).isEmpty();
    assertThat(result.inRight()).isEmpty();
    assertThat(result.modified()).isNotEmpty().containsOnlyKeys(xooRule1.getKey());
    assertThat(result.collectRuleKeys()).containsOnly(xooRule1.getKey());
    ActiveRuleDiff activeRuleDiff = result.modified().get(xooRule1.getKey());
    assertThat(activeRuleDiff.leftSeverity()).isEqualTo(activeRuleDiff.rightSeverity()).isEqualTo(xooRule1.getSeverityString());
    assertThat(activeRuleDiff.paramDifference().areEqual()).isFalse();
    assertThat(activeRuleDiff.paramDifference().entriesDiffering()).isEmpty();
    assertThat(activeRuleDiff.paramDifference().entriesOnlyOnLeft()).containsExactly(MapEntry.entry("max", "20"));
    assertThat(activeRuleDiff.paramDifference().entriesOnlyOnRight()).containsExactly(MapEntry.entry("min", "5"));
}
Also used : ActiveRuleDiff(org.sonar.server.qualityprofile.QProfileComparison.ActiveRuleDiff) QProfileComparisonResult(org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult) Test(org.junit.Test)

Example 2 with QProfileComparisonResult

use of org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult in project sonarqube by SonarSource.

the class QProfileComparisonMediumTest method compare_modified_param.

@Test
public void compare_modified_param() {
    ruleActivator.activate(dbSession, new RuleActivation(xooRule1.getKey()).setParameter("max", "20"), left);
    ruleActivator.activate(dbSession, new RuleActivation(xooRule1.getKey()).setParameter("max", "30"), right);
    dbSession.commit();
    QProfileComparisonResult result = comparison.compare(left.getKey(), right.getKey());
    assertThat(result.left().getKey()).isEqualTo(left.getKey());
    assertThat(result.right().getKey()).isEqualTo(right.getKey());
    assertThat(result.same()).isEmpty();
    assertThat(result.inLeft()).isEmpty();
    assertThat(result.inRight()).isEmpty();
    assertThat(result.modified()).isNotEmpty().containsOnlyKeys(xooRule1.getKey());
    assertThat(result.collectRuleKeys()).containsOnly(xooRule1.getKey());
    ActiveRuleDiff activeRuleDiff = result.modified().get(xooRule1.getKey());
    assertThat(activeRuleDiff.leftSeverity()).isEqualTo(activeRuleDiff.rightSeverity()).isEqualTo(xooRule1.getSeverityString());
    assertThat(activeRuleDiff.paramDifference().areEqual()).isFalse();
    assertThat(activeRuleDiff.paramDifference().entriesDiffering()).isNotEmpty();
    ValueDifference<String> paramDiff = activeRuleDiff.paramDifference().entriesDiffering().get("max");
    assertThat(paramDiff.leftValue()).isEqualTo("20");
    assertThat(paramDiff.rightValue()).isEqualTo("30");
}
Also used : ActiveRuleDiff(org.sonar.server.qualityprofile.QProfileComparison.ActiveRuleDiff) QProfileComparisonResult(org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult) Test(org.junit.Test)

Example 3 with QProfileComparisonResult

use of org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult in project sonarqube by SonarSource.

the class QProfileComparisonMediumTest method compare_disjoint.

@Test
public void compare_disjoint() {
    ruleActivator.activate(dbSession, new RuleActivation(xooRule1.getKey()), left);
    ruleActivator.activate(dbSession, new RuleActivation(xooRule2.getKey()), right);
    dbSession.commit();
    QProfileComparisonResult result = comparison.compare(left.getKey(), right.getKey());
    assertThat(result.left().getKey()).isEqualTo(left.getKey());
    assertThat(result.right().getKey()).isEqualTo(right.getKey());
    assertThat(result.same()).isEmpty();
    assertThat(result.inLeft()).isNotEmpty().containsOnlyKeys(xooRule1.getKey());
    assertThat(result.inRight()).isNotEmpty().containsOnlyKeys(xooRule2.getKey());
    assertThat(result.modified()).isEmpty();
    assertThat(result.collectRuleKeys()).containsOnly(xooRule1.getKey(), xooRule2.getKey());
}
Also used : QProfileComparisonResult(org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult) Test(org.junit.Test)

Example 4 with QProfileComparisonResult

use of org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult in project sonarqube by SonarSource.

the class QProfileComparisonMediumTest method compare_only_left.

@Test
public void compare_only_left() {
    ruleActivator.activate(dbSession, new RuleActivation(xooRule1.getKey()), left);
    dbSession.commit();
    QProfileComparisonResult result = comparison.compare(left.getKey(), right.getKey());
    assertThat(result.left().getKey()).isEqualTo(left.getKey());
    assertThat(result.right().getKey()).isEqualTo(right.getKey());
    assertThat(result.same()).isEmpty();
    assertThat(result.inLeft()).isNotEmpty().containsOnlyKeys(xooRule1.getKey());
    assertThat(result.inRight()).isEmpty();
    assertThat(result.modified()).isEmpty();
    assertThat(result.collectRuleKeys()).containsOnly(xooRule1.getKey());
}
Also used : QProfileComparisonResult(org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult) Test(org.junit.Test)

Example 5 with QProfileComparisonResult

use of org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult in project sonarqube by SonarSource.

the class QProfileComparisonMediumTest method compare_only_right.

@Test
public void compare_only_right() {
    ruleActivator.activate(dbSession, new RuleActivation(xooRule1.getKey()), right);
    dbSession.commit();
    QProfileComparisonResult result = comparison.compare(left.getKey(), right.getKey());
    assertThat(result.left().getKey()).isEqualTo(left.getKey());
    assertThat(result.right().getKey()).isEqualTo(right.getKey());
    assertThat(result.same()).isEmpty();
    assertThat(result.inLeft()).isEmpty();
    assertThat(result.inRight()).isNotEmpty().containsOnlyKeys(xooRule1.getKey());
    assertThat(result.modified()).isEmpty();
    assertThat(result.collectRuleKeys()).containsOnly(xooRule1.getKey());
}
Also used : QProfileComparisonResult(org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult) Test(org.junit.Test)

Aggregations

QProfileComparisonResult (org.sonar.server.qualityprofile.QProfileComparison.QProfileComparisonResult)9 Test (org.junit.Test)8 ActiveRuleDiff (org.sonar.server.qualityprofile.QProfileComparison.ActiveRuleDiff)3 RuleKey (org.sonar.api.rule.RuleKey)1 DbSession (org.sonar.db.DbSession)1 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)1 RuleDto (org.sonar.db.rule.RuleDto)1 RuleRepositoryDto (org.sonar.db.rule.RuleRepositoryDto)1