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"));
}
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");
}
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());
}
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());
}
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());
}
Aggregations