aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/test
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-04-30 11:08:36 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-04-30 11:08:49 +0200
commit7a1500500fcc6de7c743cf0d4cdbbb1a391e957b (patch)
tree5296cf56bd50beb3d914380883ac62fb726833c0 /sonar-core/src/test
parentf11fdee785dac6f660c9ee581606969056d275c7 (diff)
downloadsonarqube-7a1500500fcc6de7c743cf0d4cdbbb1a391e957b.tar.gz
sonarqube-7a1500500fcc6de7c743cf0d4cdbbb1a391e957b.zip
SONAR-3755 keep state changes
Diffstat (limited to 'sonar-core/src/test')
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java3
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java14
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/workflow/SetResolutionTest.java47
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/workflow/TransitionTest.java17
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/workflow/UnsetClosedAtTest.java38
6 files changed, 12 insertions, 111 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java
index 4a0834f8fad..e625470bedc 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java
@@ -42,7 +42,7 @@ public class DefaultIssueBuilderTest {
.build();
assertThat(issue).isNotNull();
- assertThat(issue.key()).isNull();
+ assertThat(issue.key()).isNotNull();
assertThat(issue.cost()).isEqualTo(10000.0);
assertThat(issue.componentKey()).isEqualTo(componentKey);
assertThat(issue.description()).isEqualTo("the desc");
@@ -50,7 +50,7 @@ public class DefaultIssueBuilderTest {
assertThat(issue.ruleKey().repository()).isEqualTo("squid");
assertThat(issue.ruleKey().rule()).isEqualTo("NullDereference");
assertThat(issue.severity()).isEqualTo(Severity.CRITICAL);
- assertThat(issue.updatedAt()).isNull();
+ assertThat(issue.updatedAt()).isNotNull();
assertThat(issue.closedAt()).isNull();
assertThat(issue.assignee()).isNull();
assertThat(issue.isNew()).isTrue();
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java
index 8600e27ba99..89aeb4fbd5a 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java
@@ -25,7 +25,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.issue.Issue;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.issue.db.IssueDto;
import java.util.Date;
@@ -86,7 +85,7 @@ public class IssueDtoTest {
assertThat(issue.line()).isEqualTo(6);
assertThat(issue.severity()).isEqualTo("BLOCKER");
assertThat(issue.description()).isEqualTo("message");
- assertThat(issue.isManualSeverity()).isTrue();
+ assertThat(issue.manualSeverity()).isTrue();
assertThat(issue.manual()).isTrue();
assertThat(issue.userLogin()).isEqualTo("arthur");
assertThat(issue.assignee()).isEqualTo("perceval");
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java b/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java
index 77abe017209..19d07e6c213 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/workflow/IssueWorkflowTest.java
@@ -24,15 +24,19 @@ import com.google.common.collect.Collections2;
import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.core.issue.DefaultIssue;
+import org.sonar.core.issue.IssueChangeContext;
+import org.sonar.core.issue.IssueUpdater;
import javax.annotation.Nullable;
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
public class IssueWorkflowTest {
- IssueWorkflow workflow = new IssueWorkflow();
+ IssueWorkflow workflow = new IssueWorkflow(new FunctionExecutor(new IssueUpdater()));
@Test
public void should_init_state_machine() throws Exception {
@@ -51,9 +55,9 @@ public class IssueWorkflowTest {
workflow.start();
DefaultIssue issue = new DefaultIssue().setStatus(Issue.STATUS_OPEN);
- List<Transition> transitions = workflow.outManualTransitions(issue);
- assertThat(transitions).hasSize(3);
- assertThat(keys(transitions)).containsOnly("close", "falsepositive", "resolve");
+ List<Transition> transitions = workflow.outTransitions(issue);
+ assertThat(transitions).hasSize(2);
+ assertThat(keys(transitions)).containsOnly("falsepositive", "resolve");
}
@Test
@@ -65,7 +69,7 @@ public class IssueWorkflowTest {
.setStatus(Issue.STATUS_RESOLVED)
.setNew(false)
.setAlive(false);
- workflow.doAutomaticTransition(issue);
+ workflow.doAutomaticTransition(issue, IssueChangeContext.createScan(new Date()));
assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED);
assertThat(issue.closedAt()).isNotNull();
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/workflow/SetResolutionTest.java b/sonar-core/src/test/java/org/sonar/core/issue/workflow/SetResolutionTest.java
deleted file mode 100644
index 2ab06515ada..00000000000
--- a/sonar-core/src/test/java/org/sonar/core/issue/workflow/SetResolutionTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.issue.workflow;
-
-import org.junit.Test;
-import org.sonar.api.issue.Issue;
-import org.sonar.core.issue.DefaultIssue;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class SetResolutionTest {
- @Test
- public void should_set_resolution() throws Exception {
- DefaultIssue issue = new DefaultIssue();
- SetResolution function = new SetResolution(Issue.RESOLUTION_FIXED);
- function.execute(issue);
- assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
- }
-
- @Test
- public void resolution_should_not_be_empty() throws Exception {
- try {
- new SetResolution("");
- fail();
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessage("Resolution must be set");
- }
- }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/workflow/TransitionTest.java b/sonar-core/src/test/java/org/sonar/core/issue/workflow/TransitionTest.java
index 4f068afe6cc..caf383720f4 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/workflow/TransitionTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/workflow/TransitionTest.java
@@ -25,7 +25,6 @@ import org.sonar.core.issue.DefaultIssue;
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class TransitionTest {
@@ -102,22 +101,6 @@ public class TransitionTest {
}
@Test
- public void should_execute_functions() throws Exception {
- DefaultIssue issue = new DefaultIssue();
- Transition transition = Transition.builder("close")
- .from("OPEN").to("CLOSED")
- .conditions(condition1, condition2)
- .functions(function1, function2)
- .build();
- transition.execute(issue);
-
- assertThat(issue.status()).isEqualTo("CLOSED");
- assertThat(issue.updatedAt()).isNotNull();
- verify(function1).execute(issue);
- verify(function2).execute(issue);
- }
-
- @Test
public void should_verify_conditions() throws Exception {
DefaultIssue issue = new DefaultIssue();
Transition transition = Transition.builder("close")
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/workflow/UnsetClosedAtTest.java b/sonar-core/src/test/java/org/sonar/core/issue/workflow/UnsetClosedAtTest.java
deleted file mode 100644
index e74f78b9a1d..00000000000
--- a/sonar-core/src/test/java/org/sonar/core/issue/workflow/UnsetClosedAtTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.issue.workflow;
-
-import org.junit.Test;
-import org.sonar.core.issue.DefaultIssue;
-
-import java.util.Date;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class UnsetClosedAtTest {
- @Test
- public void should_remove_date() throws Exception {
- UnsetClosedAt function = new UnsetClosedAt();
- DefaultIssue issue = new DefaultIssue().setCreatedAt(new Date()).setCreatedAt(new Date());
- function.execute(issue);
- assertThat(issue.closedAt()).isNull();
- assertThat(issue.createdAt()).isNotNull();
- }
-}