diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-06-30 09:02:14 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-07-02 19:44:28 +0200 |
commit | 1c0b9a97e3bc6d58c4697b4350b39adc81a6efc1 (patch) | |
tree | 58dc9e0251604655638d5f9f47611116e6e49cd1 /sonar-plugin-api | |
parent | 44a34aca80bb01c3a7689fe02d34f17718bf9293 (diff) | |
download | sonarqube-1c0b9a97e3bc6d58c4697b4350b39adc81a6efc1.tar.gz sonarqube-1c0b9a97e3bc6d58c4697b4350b39adc81a6efc1.zip |
SONAR-6588 move computation of debt to Compute Engine
Diffstat (limited to 'sonar-plugin-api')
17 files changed, 293 insertions, 765 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java index 0866cb8b203..9d334b6d5c6 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rule.java @@ -50,11 +50,19 @@ public interface Rule { RuleStatus status(); /** - * Remediation function : can by Linear (with a coefficient), Linear with offset (with a coefficient and an offset) or Constant per issue (with an offset) - * * @since 4.3 + * @deprecated since 5.2 as any computation of data are moved to server's Compute Engine. Calling this method throws an exception. */ @CheckForNull + @Deprecated + String debtSubCharacteristic(); + + /** + * @since 4.3 + * @deprecated since 5.2 as any computation of data are moved to server's Compute Engine. Calling this method throws an exception. + */ + @CheckForNull + @Deprecated DebtRemediationFunction debtRemediationFunction(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java index 097694e146c..cd6a738e3f1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java @@ -42,7 +42,6 @@ public class DefaultRule implements Rule { private final String description; private final String internalKey; private final RuleStatus status; - private final DebtRemediationFunction debtRemediationFunction; private final Map<String, RuleParam> params; DefaultRule(NewRule newRule) { @@ -53,7 +52,6 @@ public class DefaultRule implements Rule { this.description = newRule.description; this.internalKey = newRule.internalKey; this.status = newRule.status; - this.debtRemediationFunction = newRule.debtRemediationFunction; ImmutableMap.Builder<String, RuleParam> builder = ImmutableMap.builder(); for (NewRuleParam newRuleParam : newRule.params.values()) { @@ -98,8 +96,13 @@ public class DefaultRule implements Rule { } @Override + public String debtSubCharacteristic() { + throw new UnsupportedOperationException("Debt characteristic is not available by analyzer since version 5.2 (data computation moved to server)"); + } + + @Override public DebtRemediationFunction debtRemediationFunction() { - return debtRemediationFunction; + throw new UnsupportedOperationException("Debt remediation function is not available by analyzer since version 5.2 (data computation moved to server)"); } @Override diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java index 2e174b2b2ae..5d6e585b78f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java @@ -19,18 +19,15 @@ */ package org.sonar.api.batch.rule.internal; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.debt.DebtRemediationFunction; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; -import javax.annotation.Nullable; - -import java.util.HashMap; -import java.util.Map; - public class NewRule { private static final String DEFAULT_SEVERITY = Severity.defaultSeverity(); @@ -41,7 +38,6 @@ public class NewRule { String description; String severity = DEFAULT_SEVERITY; String internalKey; - DebtRemediationFunction debtRemediationFunction; RuleStatus status = RuleStatus.defaultStatus(); Map<String, NewRuleParam> params = new HashMap<>(); @@ -79,11 +75,6 @@ public class NewRule { return this; } - public NewRule setDebtRemediationFunction(@Nullable DebtRemediationFunction f) { - this.debtRemediationFunction = f; - return this; - } - public NewRuleParam addParam(String paramKey) { if (params.containsKey(paramKey)) { throw new IllegalStateException(String.format("Parameter '%s' already exists on rule '%s'", paramKey, key)); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/condition/HasIssuePropertyCondition.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/condition/HasIssuePropertyCondition.java index 6f623742638..cde5ae2bc09 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/condition/HasIssuePropertyCondition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/condition/HasIssuePropertyCondition.java @@ -43,6 +43,6 @@ public final class HasIssuePropertyCondition implements Condition { @Override public boolean matches(Issue issue) { - return !Strings.isNullOrEmpty(issue.attributes().get(propertyKey)); + return !Strings.isNullOrEmpty(issue.attribute(propertyKey)); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index 391cc49eb99..b5f423c257e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -20,17 +20,19 @@ package org.sonar.api.measures; import com.google.common.annotations.Beta; -import java.io.Serializable; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Date; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.math.NumberUtils; import org.sonar.api.technicaldebt.batch.Characteristic; import org.sonar.api.technicaldebt.batch.Requirement; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; + /** * A class to handle measures. * @@ -60,6 +62,8 @@ public class Measure<G extends Serializable> implements Serializable { protected Double variation4; protected Double variation5; protected String url; + protected Characteristic characteristic; + protected Requirement requirement; protected Integer personId; protected PersistenceMode persistenceMode = PersistenceMode.FULL; private boolean fromCore; @@ -627,13 +631,14 @@ public class Measure<G extends Serializable> implements Serializable { */ @CheckForNull public final Characteristic getCharacteristic() { - return null; + return characteristic; } /** * @since 4.1 */ public final Measure<G> setCharacteristic(@Nullable Characteristic characteristic) { + this.characteristic = characteristic; return this; } @@ -644,7 +649,7 @@ public class Measure<G extends Serializable> implements Serializable { @Deprecated @CheckForNull public final Requirement getRequirement() { - return null; + return requirement; } /** @@ -653,6 +658,7 @@ public class Measure<G extends Serializable> implements Serializable { */ @Deprecated public final Measure<G> setRequirement(@Nullable Requirement requirement) { + this.requirement = requirement; return this; } @@ -731,12 +737,16 @@ public class Measure<G extends Serializable> implements Serializable { if (metricKey != null ? !metricKey.equals(measure.metricKey) : (measure.metricKey != null)) { return false; } + if (characteristic != null ? !characteristic.equals(measure.characteristic) : (measure.characteristic != null)) { + return false; + } return !(personId != null ? !personId.equals(measure.personId) : (measure.personId != null)); } @Override public int hashCode() { int result = metricKey != null ? metricKey.hashCode() : 0; + result = 31 * result + (characteristic != null ? characteristic.hashCode() : 0); result = 31 * result + (personId != null ? personId.hashCode() : 0); return result; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java index e3be32a43a0..f872d322aea 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeasuresFilters.java @@ -205,7 +205,7 @@ public final class MeasuresFilters { } /** - * @deprecated since 5.2. Useless by design because of Compute Engine + * @deprecated since 5.2. The measures related to rules are computed on server side by Compute Engine. */ @Deprecated private abstract static class AbstractRuleMeasureFilter<M> extends MetricFilter<M> { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java index 7c23bc4734f..0caa78b2d5e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleKey.java @@ -23,12 +23,14 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import java.io.Serializable; +import javax.annotation.concurrent.Immutable; /** * Key of a rule. Unique among all the rule repositories. * * @since 3.6 */ +@Immutable public class RuleKey implements Serializable { public static final String MANUAL_REPOSITORY_KEY = "manual"; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java index d8f6456e9f2..73160afcab2 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtRemediationFunction.java @@ -43,7 +43,23 @@ import javax.annotation.CheckForNull; public interface DebtRemediationFunction { enum Type { - LINEAR, LINEAR_OFFSET, CONSTANT_ISSUE + LINEAR(true, false), LINEAR_OFFSET(true, true), CONSTANT_ISSUE(false, true); + + private final boolean usesCoefficient; + private final boolean usesOffset; + + Type(boolean usesCoefficient, boolean usesOffset) { + this.usesCoefficient = usesCoefficient; + this.usesOffset = usesOffset; + } + + public boolean usesCoefficient() { + return usesCoefficient; + } + + public boolean usesOffset() { + return usesOffset; + } } Type type(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java index 3c5270f6996..cceb006ae11 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/rule/internal/RulesBuilderTest.java @@ -51,7 +51,6 @@ public class RulesBuilderTest { newSquid1.setInternalKey("foo=bar"); newSquid1.setSeverity(Severity.CRITICAL); newSquid1.setStatus(RuleStatus.BETA); - newSquid1.setDebtRemediationFunction(DebtRemediationFunction.create(DebtRemediationFunction.Type.LINEAR_OFFSET, Duration.create(10), Duration.create(60))); newSquid1.addParam("min"); newSquid1.addParam("max").setDescription("Maximum"); // most simple rule @@ -73,9 +72,6 @@ public class RulesBuilderTest { assertThat(squid1.internalKey()).isEqualTo("foo=bar"); assertThat(squid1.status()).isEqualTo(RuleStatus.BETA); assertThat(squid1.severity()).isEqualTo(Severity.CRITICAL); - assertThat(squid1.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET); - assertThat(squid1.debtRemediationFunction().coefficient()).isEqualTo(Duration.create(10)); - assertThat(squid1.debtRemediationFunction().offset()).isEqualTo(Duration.create(60)); assertThat(squid1.params()).hasSize(2); assertThat(squid1.param("min").key()).isEqualTo("min"); assertThat(squid1.param("min").description()).isNull(); @@ -89,7 +85,6 @@ public class RulesBuilderTest { assertThat(squid2.internalKey()).isNull(); assertThat(squid2.status()).isEqualTo(RuleStatus.defaultStatus()); assertThat(squid2.severity()).isEqualTo(Severity.defaultSeverity()); - assertThat(squid2.debtRemediationFunction()).isNull(); assertThat(squid2.params()).isEmpty(); } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionTest.java index 3f0275401c0..3d7d40bc6b0 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/action/ActionTest.java @@ -17,97 +17,77 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -// -//package org.sonar.api.issue.action; -// -//import org.junit.Rule; -//import org.junit.Test; -//import org.junit.rules.ExpectedException; -//import org.sonar.api.issue.condition.Condition; -//import org.sonar.api.issue.internal.DefaultIssue; -// -//import static org.assertj.core.api.Assertions.assertThat; -//import static org.mockito.Mockito.mock; -//import static org.mockito.Mockito.when; -// -//public class ActionTest { -// @Rule -// public ExpectedException thrown = ExpectedException.none(); -// -// Condition condition1 = mock(Condition.class); -// Condition condition2 = mock(Condition.class); -// Function function1 = mock(Function.class); -// Function function2 = mock(Function.class); -// -// @Test -// public void test_action() throws Exception { -// Action action = new Action("link-to-jira") -// .setConditions(condition1, condition2) -// .setFunctions(function1, function2); -// -// assertThat(action.key()).isEqualTo("link-to-jira"); -// assertThat(action.conditions()).containsOnly(condition1, condition2); -// assertThat(action.functions()).containsOnly(function1, function2); -// } -// -// @Test -// public void key_should_be_set() { -// thrown.expectMessage("Action key must be set"); -// -// new Action(""); -// } -// -// @Test -// public void should_verify_conditions() { -// DefaultIssue issue = new DefaultIssue(); -// Action action = new Action("link-to-jira") -// .setConditions(condition1, condition2); -// -// when(condition1.matches(issue)).thenReturn(true); -// when(condition2.matches(issue)).thenReturn(false); -// assertThat(action.supports(issue)).isFalse(); -// -// when(condition1.matches(issue)).thenReturn(true); -// when(condition2.matches(issue)).thenReturn(true); -// assertThat(action.supports(issue)).isTrue(); -// } -// -// @Test -// public void test_equals_and_hashCode() throws Exception { -// Action t1 = new Action("link-to-jira"); -// Action t2 = new Action("link-to-jira"); -// Action t3 = new Action("comment"); -// -// assertThat(t1).isEqualTo(t1); -// assertThat(t1).isEqualTo(t2); -// assertThat(t1).isNotEqualTo(t3); -// -// assertThat(t1.hashCode()).isEqualTo(t1.hashCode()); -// } -// -// @Test -// public void test_toString() throws Exception { -// Action t1 = new Action("link-to-jira"); -// assertThat(t1.toString()).isEqualTo("link-to-jira"); -// } -// -//} +package org.sonar.api.issue.action; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.issue.Issue; +import org.sonar.api.issue.condition.Condition; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class ActionTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + + Condition condition1 = mock(Condition.class); + Condition condition2 = mock(Condition.class); + Function function1 = mock(Function.class); + Function function2 = mock(Function.class); + + @Test + public void test_action() throws Exception { + Action action = new Action("link-to-jira") + .setConditions(condition1, condition2) + .setFunctions(function1, function2); + + assertThat(action.key()).isEqualTo("link-to-jira"); + assertThat(action.conditions()).containsOnly(condition1, condition2); + assertThat(action.functions()).containsOnly(function1, function2); + } + + @Test + public void key_should_be_set() { + thrown.expectMessage("Action key must be set"); + + new Action(""); + } + + @Test + public void should_verify_conditions() { + Issue issue = mock(Issue.class); + Action action = new Action("link-to-jira") + .setConditions(condition1, condition2); + + when(condition1.matches(issue)).thenReturn(true); + when(condition2.matches(issue)).thenReturn(false); + assertThat(action.supports(issue)).isFalse(); + + when(condition1.matches(issue)).thenReturn(true); + when(condition2.matches(issue)).thenReturn(true); + assertThat(action.supports(issue)).isTrue(); + } + + @Test + public void test_equals_and_hashCode() throws Exception { + Action t1 = new Action("link-to-jira"); + Action t2 = new Action("link-to-jira"); + Action t3 = new Action("comment"); + + assertThat(t1).isEqualTo(t1); + assertThat(t1).isEqualTo(t2); + assertThat(t1).isNotEqualTo(t3); + + assertThat(t1.hashCode()).isEqualTo(t1.hashCode()); + } + + @Test + public void test_toString() throws Exception { + Action t1 = new Action("link-to-jira"); + assertThat(t1.toString()).isEqualTo("link-to-jira"); + } + +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasIssuePropertyConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasIssuePropertyConditionTest.java index 9f2d40e12cb..b9bef1f1f0e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasIssuePropertyConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasIssuePropertyConditionTest.java @@ -17,66 +17,53 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -//package org.sonar.api.issue.condition; -// -//import org.junit.Rule; -//import org.junit.Test; -//import org.junit.rules.ExpectedException; -//import org.sonar.api.issue.internal.DefaultIssue; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//public class HasIssuePropertyConditionTest { -// -// @Rule -// public ExpectedException thrown = ExpectedException.none(); -// -// DefaultIssue issue = new DefaultIssue(); -// -// @Test -// public void should_match() { -// HasIssuePropertyCondition condition = new HasIssuePropertyCondition("foo"); -// -// assertThat(condition.matches(issue)).isFalse(); -// assertThat(condition.matches(issue.setAttribute("foo", ""))).isFalse(); -// assertThat(condition.matches(issue.setAttribute("foo", "bar"))).isTrue(); -// } -// -// @Test -// public void should_get_property_key() { -// HasIssuePropertyCondition condition = new HasIssuePropertyCondition("foo"); -// assertThat(condition.getPropertyKey()).isEqualTo("foo"); -// } -// -// @Test -// public void shoul_fail_if_null_property() { -// thrown.expect(IllegalArgumentException.class); -// new HasIssuePropertyCondition(null); -// } -// -// @Test -// public void should_fail_if_empty_property() { -// thrown.expect(IllegalArgumentException.class); -// new HasIssuePropertyCondition(""); -// } -// -//} +package org.sonar.api.issue.condition; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.issue.Issue; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class HasIssuePropertyConditionTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + Issue issue = mock(Issue.class); + + @Test + public void should_match() { + HasIssuePropertyCondition condition = new HasIssuePropertyCondition("foo"); + + assertThat(condition.matches(issue)).isFalse(); + + when(issue.attribute("foo")).thenReturn(""); + assertThat(condition.matches(issue)).isFalse(); + + when(issue.attribute("foo")).thenReturn("bar"); + assertThat(condition.matches(issue)).isTrue(); + } + + @Test + public void should_get_property_key() { + HasIssuePropertyCondition condition = new HasIssuePropertyCondition("foo"); + assertThat(condition.getPropertyKey()).isEqualTo("foo"); + } + + @Test + public void shoul_fail_if_null_property() { + thrown.expect(IllegalArgumentException.class); + new HasIssuePropertyCondition(null); + } + + @Test + public void should_fail_if_empty_property() { + thrown.expect(IllegalArgumentException.class); + new HasIssuePropertyCondition(""); + } + +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasResolutionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasResolutionTest.java index 0762d06330b..4648aac3010 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasResolutionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasResolutionTest.java @@ -17,44 +17,30 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -//package org.sonar.api.issue.condition; -// -//import org.junit.Test; -//import org.sonar.api.issue.Issue; -//import org.sonar.api.issue.internal.DefaultIssue; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//public class HasResolutionTest { -// -// DefaultIssue issue = new DefaultIssue(); -// -// @Test -// public void should_match() { -// HasResolution condition = new HasResolution(Issue.RESOLUTION_FIXED, Issue.RESOLUTION_FALSE_POSITIVE); -// -// assertThat(condition.matches(issue.setResolution("FIXED"))).isTrue(); -// assertThat(condition.matches(issue.setResolution("FALSE-POSITIVE"))).isTrue(); -// -// assertThat(condition.matches(issue.setResolution("Fixed"))).isFalse(); -// } -//} +package org.sonar.api.issue.condition; + +import org.junit.Test; +import org.sonar.api.issue.Issue; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class HasResolutionTest { + + Issue issue = mock(Issue.class); + + @Test + public void should_match() { + HasResolution condition = new HasResolution(Issue.RESOLUTION_FIXED, Issue.RESOLUTION_FALSE_POSITIVE); + + when(issue.resolution()).thenReturn("FIXED"); + assertThat(condition.matches(issue)).isTrue(); + + when(issue.resolution()).thenReturn("FALSE-POSITIVE"); + assertThat(condition.matches(issue)).isTrue(); + + when(issue.resolution()).thenReturn("Fixed"); + assertThat(condition.matches(issue)).isFalse(); + } +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasStatusTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasStatusTest.java index 5d9258fa07b..68be04898ad 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasStatusTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/HasStatusTest.java @@ -17,47 +17,37 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -// -//package org.sonar.api.issue.condition; -// -//import org.junit.Test; -//import org.sonar.api.issue.internal.DefaultIssue; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//public class HasStatusTest { -// -// DefaultIssue issue = new DefaultIssue(); -// -// @Test -// public void should_match() { -// HasStatus condition = new HasStatus("OPEN", "REOPENED", "CONFIRMED"); -// -// assertThat(condition.matches(issue.setStatus("OPEN"))).isTrue(); -// assertThat(condition.matches(issue.setStatus("REOPENED"))).isTrue(); -// assertThat(condition.matches(issue.setStatus("CONFIRMED"))).isTrue(); -// -// assertThat(condition.matches(issue.setStatus("open"))).isFalse(); -// assertThat(condition.matches(issue.setStatus("CLOSED"))).isFalse(); -// } -// -//} +package org.sonar.api.issue.condition; + +import org.junit.Test; +import org.sonar.api.issue.Issue; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class HasStatusTest { + + Issue issue = mock(Issue.class); + + @Test + public void should_match() { + HasStatus condition = new HasStatus("OPEN", "REOPENED", "CONFIRMED"); + + when(issue.status()).thenReturn("OPEN"); + assertThat(condition.matches(issue)).isTrue(); + + when(issue.status()).thenReturn("REOPENED"); + assertThat(condition.matches(issue)).isTrue(); + + when(issue.status()).thenReturn("CONFIRMED"); + assertThat(condition.matches(issue)).isTrue(); + + when(issue.status()).thenReturn("open"); + assertThat(condition.matches(issue)).isFalse(); + + when(issue.status()).thenReturn("CLOSED"); + assertThat(condition.matches(issue)).isFalse(); + } + +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/IsUnResolvedTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/IsUnResolvedTest.java index 84159f3f242..65303bd2472 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/IsUnResolvedTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/IsUnResolvedTest.java @@ -17,42 +17,26 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -// -//package org.sonar.api.issue.condition; -// -//import org.junit.Test; -//import org.sonar.api.issue.internal.DefaultIssue; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//public class IsUnResolvedTest { -// -// DefaultIssue issue = new DefaultIssue(); -// -// @Test -// public void should_match() { -// IsUnResolved condition = new IsUnResolved(); -// -// assertThat(condition.matches(issue)).isTrue(); -// assertThat(condition.matches(issue.setResolution("FIXED"))).isFalse(); -// } -//} +package org.sonar.api.issue.condition; + +import org.junit.Test; +import org.sonar.api.issue.Issue; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class IsUnResolvedTest { + + Issue issue = mock(Issue.class); + + @Test + public void should_match() { + IsUnResolved condition = new IsUnResolved(); + + assertThat(condition.matches(issue)).isTrue(); + + when(issue.resolution()).thenReturn("FIXED"); + assertThat(condition.matches(issue)).isFalse(); + } +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/NotConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/NotConditionTest.java index ae2c76de370..aa646d14514 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/NotConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/condition/NotConditionTest.java @@ -17,48 +17,30 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -//package org.sonar.api.issue.condition; -// -//import org.junit.Test; -//import org.mockito.Mockito; -//import org.sonar.api.issue.Issue; -//import org.sonar.api.issue.internal.DefaultIssue; -// -//import static org.assertj.core.api.Assertions.assertThat; -//import static org.mockito.Matchers.any; -//import static org.mockito.Mockito.when; -// -//public class NotConditionTest { -// -// Condition target = Mockito.mock(Condition.class); -// -// @Test -// public void should_match_opposite() { -// NotCondition condition = new NotCondition(target); -// -// when(target.matches(any(Issue.class))).thenReturn(true); -// assertThat(condition.matches(new DefaultIssue())).isFalse(); -// -// when(target.matches(any(Issue.class))).thenReturn(false); -// assertThat(condition.matches(new DefaultIssue())).isTrue(); -// } -//} +package org.sonar.api.issue.condition; + +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.api.issue.Issue; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class NotConditionTest { + + Condition target = Mockito.mock(Condition.class); + Issue issue = mock(Issue.class); + + @Test + public void should_match_opposite() { + NotCondition condition = new NotCondition(target); + + when(target.matches(any(Issue.class))).thenReturn(true); + assertThat(condition.matches(issue)).isFalse(); + + when(target.matches(any(Issue.class))).thenReturn(false); + assertThat(condition.matches(issue)).isTrue(); + } +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java deleted file mode 100644 index 7db2fa9acb4..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -//package org.sonar.api.issue.internal; -// -//import com.google.common.collect.ImmutableMap; -//import org.apache.commons.lang.StringUtils; -//import org.junit.Test; -//import org.sonar.api.issue.Issue; -//import org.sonar.api.issue.IssueComment; -//import org.sonar.api.rule.RuleKey; -//import org.sonar.api.utils.Duration; -// -//import java.text.SimpleDateFormat; -//import java.util.List; -// -//import static org.assertj.core.api.Assertions.assertThat; -//import static org.assertj.core.api.Assertions.entry; -//import static org.junit.Assert.fail; -//import static org.mockito.Mockito.mock; -// -//public class DefaultIssueTest { -// -// DefaultIssue issue = new DefaultIssue(); -// -// @Test -// public void test_setters_and_getters() throws Exception { -// issue.setKey("ABCD") -// .setComponentKey("org.sample.Sample") -// .setProjectKey("Sample") -// .setRuleKey(RuleKey.of("squid", "S100")) -// .setLanguage("xoo") -// .setSeverity("MINOR") -// .setManualSeverity(true) -// .setMessage("a message") -// .setLine(7) -// .setEffortToFix(1.2d) -// .setDebt(Duration.create(28800L)) -// .setActionPlanKey("BCDE") -// .setStatus(Issue.STATUS_CLOSED) -// .setResolution(Issue.RESOLUTION_FIXED) -// .setReporter("simon") -// .setAssignee("julien") -// .setAuthorLogin("steph") -// .setChecksum("c7b5db46591806455cf082bb348631e8") -// .setNew(true) -// .setBeingClosed(true) -// .setOnDisabledRule(true) -// .setChanged(true) -// .setSendNotifications(true) -// .setCreationDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")) -// .setUpdateDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-20")) -// .setCloseDate(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-21")) -// .setSelectedAt(1400000000000L); -// -// assertThat(issue.key()).isEqualTo("ABCD"); -// assertThat(issue.componentKey()).isEqualTo("org.sample.Sample"); -// assertThat(issue.projectKey()).isEqualTo("Sample"); -// assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("squid", "S100")); -// assertThat(issue.language()).isEqualTo("xoo"); -// assertThat(issue.severity()).isEqualTo("MINOR"); -// assertThat(issue.manualSeverity()).isTrue(); -// assertThat(issue.message()).isEqualTo("a message"); -// assertThat(issue.line()).isEqualTo(7); -// assertThat(issue.effortToFix()).isEqualTo(1.2d); -// assertThat(issue.debt()).isEqualTo(Duration.create(28800L)); -// assertThat(issue.actionPlanKey()).isEqualTo("BCDE"); -// assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED); -// assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED); -// assertThat(issue.reporter()).isEqualTo("simon"); -// assertThat(issue.assignee()).isEqualTo("julien"); -// assertThat(issue.authorLogin()).isEqualTo("steph"); -// assertThat(issue.checksum()).isEqualTo("c7b5db46591806455cf082bb348631e8"); -// assertThat(issue.isNew()).isTrue(); -// assertThat(issue.isBeingClosed()).isTrue(); -// assertThat(issue.isOnDisabledRule()).isTrue(); -// assertThat(issue.isChanged()).isTrue(); -// assertThat(issue.mustSendNotifications()).isTrue(); -// assertThat(issue.creationDate()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-19")); -// assertThat(issue.updateDate()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-20")); -// assertThat(issue.closeDate()).isEqualTo(new SimpleDateFormat("yyyy-MM-dd").parse("2013-08-21")); -// assertThat(issue.selectedAt()).isEqualTo(1400000000000L); -// } -// -// @Test -// public void set_empty_dates() { -// issue -// .setCreationDate(null) -// .setUpdateDate(null) -// .setCloseDate(null) -// .setSelectedAt(null); -// -// assertThat(issue.creationDate()).isNull(); -// assertThat(issue.updateDate()).isNull(); -// assertThat(issue.closeDate()).isNull(); -// assertThat(issue.selectedAt()).isNull(); -// } -// -// @Test -// public void test_attributes() throws Exception { -// assertThat(issue.attribute("foo")).isNull(); -// issue.setAttribute("foo", "bar"); -// assertThat(issue.attribute("foo")).isEqualTo("bar"); -// issue.setAttribute("foo", "newbar"); -// assertThat(issue.attribute("foo")).isEqualTo("newbar"); -// issue.setAttribute("foo", null); -// assertThat(issue.attribute("foo")).isNull(); -// } -// -// @Test -// public void setAttributes_should_not_clear_existing_values() { -// issue.setAttributes(ImmutableMap.of("1", "one")); -// assertThat(issue.attribute("1")).isEqualTo("one"); -// -// issue.setAttributes(ImmutableMap.of("2", "two")); -// assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two")); -// -// issue.setAttributes(null); -// assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two")); -// } -// -// @Test -// public void fail_on_empty_status() { -// try { -// issue.setStatus(""); -// fail(); -// } catch (IllegalArgumentException e) { -// assertThat(e).hasMessage("Status must be set"); -// } -// } -// -// @Test -// public void fail_on_bad_severity() { -// try { -// issue.setSeverity("FOO"); -// fail(); -// } catch (IllegalArgumentException e) { -// assertThat(e).hasMessage("Not a valid severity: FOO"); -// } -// } -// -// @Test -// public void message_should_be_abbreviated_if_too_long() { -// issue.setMessage(StringUtils.repeat("a", 5000)); -// assertThat(issue.message()).hasSize(4000); -// } -// -// @Test -// public void message_should_be_trimmed() { -// issue.setMessage(" foo "); -// assertThat(issue.message()).isEqualTo("foo"); -// } -// -// @Test -// public void message_could_be_null() { -// issue.setMessage(null); -// assertThat(issue.message()).isNull(); -// } -// -// @Test -// public void test_nullable_fields() throws Exception { -// issue.setEffortToFix(null).setSeverity(null).setLine(null); -// assertThat(issue.effortToFix()).isNull(); -// assertThat(issue.severity()).isNull(); -// assertThat(issue.line()).isNull(); -// } -// -// @Test -// public void test_equals_and_hashCode() throws Exception { -// DefaultIssue a1 = new DefaultIssue().setKey("AAA"); -// DefaultIssue a2 = new DefaultIssue().setKey("AAA"); -// DefaultIssue b = new DefaultIssue().setKey("BBB"); -// assertThat(a1).isEqualTo(a1); -// assertThat(a1).isEqualTo(a2); -// assertThat(a1).isNotEqualTo(b); -// assertThat(a1.hashCode()).isEqualTo(a1.hashCode()); -// } -// -// @Test -// public void comments_should_not_be_modifiable() { -// DefaultIssue issue = new DefaultIssue().setKey("AAA"); -// -// List<IssueComment> comments = issue.comments(); -// assertThat(comments).isEmpty(); -// -// try { -// comments.add(new DefaultIssueComment()); -// fail(); -// } catch (UnsupportedOperationException e) { -// // ok -// } catch (Exception e) { -// fail("Unexpected exception: " + e); -// } -// } -// -// @Test -// public void all_changes_contain_current_change() { -// IssueChangeContext issueChangeContext = mock(IssueChangeContext.class); -// DefaultIssue issue = new DefaultIssue().setKey("AAA").setFieldChange(issueChangeContext, "actionPlan", "1.0", "1.1"); -// -// assertThat(issue.changes()).hasSize(1); -// } -//} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/FieldDiffsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/FieldDiffsTest.java deleted file mode 100644 index 031b3e9dcb7..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/FieldDiffsTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -///* -// * SonarQube, open source software quality management tool. -// * Copyright (C) 2008-2014 SonarSource -// * mailto:contact AT sonarsource DOT com -// * -// * SonarQube is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public -// * License as published by the Free Software Foundation; either -// * version 3 of the License, or (at your option) any later version. -// * -// * SonarQube is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// * Lesser General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License -// * along with this program; if not, write to the Free Software Foundation, -// * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// */ -//package org.sonar.api.issue.internal; -// -//import org.junit.Test; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//public class FieldDiffsTest { -// -// FieldDiffs diffs = new FieldDiffs(); -// -// @Test -// public void diffs_should_be_empty_by_default() { -// assertThat(diffs.diffs()).isEmpty(); -// } -// -// @Test -// public void test_diff() throws Exception { -// diffs.setDiff("severity", "BLOCKER", "INFO"); -// diffs.setDiff("resolution", "OPEN", "FIXED"); -// -// assertThat(diffs.diffs()).hasSize(2); -// -// FieldDiffs.Diff diff = diffs.diffs().get("severity"); -// assertThat(diff.oldValue()).isEqualTo("BLOCKER"); -// assertThat(diff.newValue()).isEqualTo("INFO"); -// -// diff = diffs.diffs().get("resolution"); -// assertThat(diff.oldValue()).isEqualTo("OPEN"); -// assertThat(diff.newValue()).isEqualTo("FIXED"); -// } -// -// @Test -// public void diff_with_long_values() { -// diffs.setDiff("technicalDebt", 50l, "100"); -// -// FieldDiffs.Diff diff = diffs.diffs().get("technicalDebt"); -// assertThat(diff.oldValueLong()).isEqualTo(50l); -// assertThat(diff.newValueLong()).isEqualTo(100l); -// } -// -// @Test -// public void diff_with_empty_long_values() { -// diffs.setDiff("technicalDebt", null, ""); -// -// FieldDiffs.Diff diff = diffs.diffs().get("technicalDebt"); -// assertThat(diff.oldValueLong()).isNull(); -// assertThat(diff.newValueLong()).isNull(); -// } -// -// @Test -// public void test_diff_by_key() throws Exception { -// diffs.setDiff("severity", "BLOCKER", "INFO"); -// diffs.setDiff("resolution", "OPEN", "FIXED"); -// -// assertThat(diffs.diffs()).hasSize(2); -// -// FieldDiffs.Diff diff = diffs.diffs().get("severity"); -// assertThat(diff.oldValue()).isEqualTo("BLOCKER"); -// assertThat(diff.newValue()).isEqualTo("INFO"); -// -// diff = diffs.diffs().get("resolution"); -// assertThat(diff.oldValue()).isEqualTo("OPEN"); -// assertThat(diff.newValue()).isEqualTo("FIXED"); -// } -// -// @Test -// public void should_keep_old_value() { -// diffs.setDiff("severity", "BLOCKER", "INFO"); -// diffs.setDiff("severity", null, "MAJOR"); -// FieldDiffs.Diff diff = diffs.diffs().get("severity"); -// assertThat(diff.oldValue()).isEqualTo("BLOCKER"); -// assertThat(diff.newValue()).isEqualTo("MAJOR"); -// } -// -// @Test -// public void test_toString() throws Exception { -// diffs.setDiff("severity", "BLOCKER", "INFO"); -// diffs.setDiff("resolution", "OPEN", "FIXED"); -// -// assertThat(diffs.toString()).isEqualTo("severity=BLOCKER|INFO,resolution=OPEN|FIXED"); -// } -// -// @Test -// public void test_toString_with_null_values() throws Exception { -// diffs.setDiff("severity", null, "INFO"); -// diffs.setDiff("assignee", "user1", null); -// -// assertThat(diffs.toString()).isEqualTo("severity=INFO,assignee="); -// } -// -// @Test -// public void test_parse() throws Exception { -// diffs = FieldDiffs.parse("severity=BLOCKER|INFO,resolution=OPEN|FIXED"); -// assertThat(diffs.diffs()).hasSize(2); -// -// FieldDiffs.Diff diff = diffs.diffs().get("severity"); -// assertThat(diff.oldValue()).isEqualTo("BLOCKER"); -// assertThat(diff.newValue()).isEqualTo("INFO"); -// -// diff = diffs.diffs().get("resolution"); -// assertThat(diff.oldValue()).isEqualTo("OPEN"); -// assertThat(diff.newValue()).isEqualTo("FIXED"); -// } -// -// @Test -// public void test_parse_empty_values() throws Exception { -// diffs = FieldDiffs.parse("severity=INFO,resolution="); -// assertThat(diffs.diffs()).hasSize(2); -// -// FieldDiffs.Diff diff = diffs.diffs().get("severity"); -// assertThat(diff.oldValue()).isEqualTo(""); -// assertThat(diff.newValue()).isEqualTo("INFO"); -// -// diff = diffs.diffs().get("resolution"); -// assertThat(diff.oldValue()).isEqualTo(""); -// assertThat(diff.newValue()).isEqualTo(""); -// } -// -// @Test -// public void test_parse_null() throws Exception { -// diffs = FieldDiffs.parse(null); -// assertThat(diffs.diffs()).isEmpty(); -// } -// -// @Test -// public void test_parse_empty() throws Exception { -// diffs = FieldDiffs.parse(""); -// assertThat(diffs.diffs()).isEmpty(); -// } -//} |