aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-core-plugin/src
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-04-25 23:12:50 +0200
committersimonbrandhof <simon.brandhof@gmail.com>2011-04-26 12:06:08 +0200
commitdbc988359bac8e7a5ca426fa42f27ae0b8c36063 (patch)
tree814a0aba8fcd5cbf039e18d8457fea11234aad5e /plugins/sonar-core-plugin/src
parente174628696636f74808f61c76a44da994edcadc7 (diff)
downloadsonarqube-dbc988359bac8e7a5ca426fa42f27ae0b8c36063.tar.gz
sonarqube-dbc988359bac8e7a5ca426fa42f27ae0b8c36063.zip
SONAR-2327 split actions for resource viewer and reviews page
Diffstat (limited to 'plugins/sonar-core-plugin/src')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java2
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewsDecorator.java)12
-rw-r--r--plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest.java (renamed from plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewsDecoratorTest.java)7
-rw-r--r--plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/fixture.xml (renamed from plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/fixture.xml)6
-rw-r--r--plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml (renamed from plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml)6
5 files changed, 16 insertions, 17 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index b0827f546f4..4634bcb01fe 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -214,7 +214,7 @@ public class CorePlugin extends SonarPlugin {
extensions.add(NoSonarFilter.class);
extensions.add(DirectoriesDecorator.class);
extensions.add(FilesDecorator.class);
- extensions.add(ReviewsDecorator.class);
+ extensions.add(CloseReviewsDecorator.class);
// time machine
extensions.add(TendencyDecorator.class);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java
index c4be5daf4f0..e037cd03877 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ReviewsDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java
@@ -36,14 +36,14 @@ import org.sonar.batch.index.ResourcePersister;
* Decorator that currently only closes a review when its corresponding violation has been fixed.
*/
@DependsUpon("ViolationPersisterDecorator")
-public class ReviewsDecorator implements Decorator {
+public class CloseReviewsDecorator implements Decorator {
- private static final Logger LOG = LoggerFactory.getLogger(ReviewsDecorator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CloseReviewsDecorator.class);
private ResourcePersister resourcePersister;
private DatabaseSession databaseSession;
- public ReviewsDecorator(ResourcePersister resourcePersister, DatabaseSession databaseSession) {
+ public CloseReviewsDecorator(ResourcePersister resourcePersister, DatabaseSession databaseSession) {
this.resourcePersister = resourcePersister;
this.databaseSession = databaseSession;
}
@@ -64,9 +64,9 @@ public class ReviewsDecorator implements Decorator {
}
}
- protected String generateSqlRequest(int resourceId, int snapshotId) {
- return "UPDATE reviews SET status='closed' " + "WHERE resource_id = " + resourceId + " AND rule_failure_permanent_id NOT IN "
- + "(SELECT permanent_id FROM rule_failures WHERE snapshot_id = " + snapshotId + ")";
+ String generateSqlRequest(int resourceId, int snapshotId) {
+ return "UPDATE reviews SET status='CLOSED' " + "WHERE resource_id = " + resourceId + " AND rule_failure_permanent_id NOT IN "
+ + "(SELECT permanent_id FROM rule_failures WHERE snapshot_id = " + snapshotId + " AND permanent_id IS NOT NULL)";
}
}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewsDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest.java
index 53c42d1b06a..493352c1147 100644
--- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ReviewsDecoratorTest.java
+++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest.java
@@ -27,16 +27,15 @@ import java.sql.Statement;
import org.junit.Test;
import org.sonar.test.persistence.DatabaseTestCase;
-public class ReviewsDecoratorTest extends DatabaseTestCase {
+public class CloseReviewsDecoratorTest extends DatabaseTestCase {
@Test
public void shouldCloseReviewWithoutCorrespondingViolation() throws Exception {
setupData("fixture");
- ReviewsDecorator reviewsDecorator = new ReviewsDecorator(null, null);
+ CloseReviewsDecorator reviewsDecorator = new CloseReviewsDecorator(null, null);
String sqlRequest = reviewsDecorator.generateSqlRequest(666, 222);
- System.out.println(sqlRequest);
-
+
Statement stmt = getConnection().createStatement();
int count = stmt.executeUpdate(sqlRequest);
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/fixture.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/fixture.xml
index d57973770cb..6142cbf4f3b 100644
--- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/fixture.xml
+++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/fixture.xml
@@ -45,17 +45,17 @@
<reviews
id="1"
- status="open"
+ status="OPEN"
rule_failure_permanent_id="1"
resource_id="555"/>
<reviews
id="2"
- status="open"
+ status="OPEN"
rule_failure_permanent_id="2"
resource_id="666"/>
<reviews
id="3"
- status="open"
+ status="OPEN"
rule_failure_permanent_id="3"
resource_id="666"/>
diff --git a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml
index 7d614f3112c..d46429ddf3d 100644
--- a/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/ReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml
+++ b/plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/sensors/CloseReviewsDecoratorTest/shouldCloseReviewWithoutCorrespondingViolation-result.xml
@@ -2,19 +2,19 @@
<reviews
id="1"
- status="open"
+ status="OPEN"
rule_failure_permanent_id="1"
resource_id="555"
created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" review_type="[null]" severity="[null]" resource_line="[null]"/>
<reviews
id="2"
- status="closed"
+ status="CLOSED"
rule_failure_permanent_id="2"
resource_id="666"
created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" review_type="[null]" severity="[null]" resource_line="[null]"/>
<reviews
id="3"
- status="open"
+ status="OPEN"
rule_failure_permanent_id="3"
resource_id="666"
created_at="[null]" updated_at="[null]" user_id="[null]" assignee_id="[null]" title="[null]" review_type="[null]" severity="[null]" resource_line="[null]"/>