summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-12-08 21:30:14 +0000
committerGodin <mandrikov@gmail.com>2010-12-08 21:30:14 +0000
commit8ea838b32e45f4fb08d1ac3aa8d480a2e0cef7af (patch)
treea363634e6c11e1602261efa14bf9499fa1adc55c /sonar-plugin-api
parent85ad745aaee19225e0abbb11abd167e39a8b1e95 (diff)
downloadsonarqube-8ea838b32e45f4fb08d1ac3aa8d480a2e0cef7af.tar.gz
sonarqube-8ea838b32e45f4fb08d1ac3aa8d480a2e0cef7af.zip
* SONAR-1809: MetricFinder should be available on server side
* Fix javadocs
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java6
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java11
3 files changed, 9 insertions, 13 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
index d05609c607a..0083d62b17e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
@@ -20,16 +20,15 @@
package org.sonar.api.measures;
import org.sonar.api.BatchComponent;
+import org.sonar.api.ServerComponent;
import java.util.Collection;
import java.util.List;
/**
- * This component is currently available only on batch-side
- *
* @since 2.5
*/
-public interface MetricFinder extends BatchComponent {
+public interface MetricFinder extends BatchComponent, ServerComponent {
Metric findById(int id);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
index 3ecff6e74fb..84cc6c0ea79 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
@@ -209,11 +209,7 @@ public final class XMLProfileParser implements ServerComponent {
if (metric == null) {
messages.addWarningText("Metric '" + metricKey + "' does not exist");
} else {
- Alert alert = new Alert();
- alert.setMetric(metric);
- alert.setOperator(operator);
- alert.setValueError(valueError);
- alert.setValueWarning(valueWarning);
+ Alert alert = new Alert(profile, metric, operator, valueError, valueWarning);
profile.getAlerts().add(alert);
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java
index e63801dea3b..bc7a9aa35d9 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java
@@ -45,7 +45,7 @@ public class XMLProfileSerializerTest {
RulesProfile profile = RulesProfile.create("sonar way", "java");
new XMLProfileSerializer().write(profile, writer);
- assertSimilarXml("/org/sonar/api/profiles/XMLProfileSerializerTest/exportEmptyProfile.xml", writer.toString());
+ assertSimilarXml("exportEmptyProfile.xml", writer.toString());
}
@Test
@@ -55,7 +55,7 @@ public class XMLProfileSerializerTest {
profile.activateRule(Rule.create("checkstyle", "IllegalRegexp", "illegal regexp"), RulePriority.BLOCKER);
new XMLProfileSerializer().write(profile, writer);
- assertSimilarXml("/org/sonar/api/profiles/XMLProfileSerializerTest/exportProfile.xml", writer.toString());
+ assertSimilarXml("exportProfile.xml", writer.toString());
}
@Test
@@ -73,7 +73,7 @@ public class XMLProfileSerializerTest {
// the tokens parameter is not set
new XMLProfileSerializer().write(profile, writer);
- assertSimilarXml("/org/sonar/api/profiles/XMLProfileSerializerTest/exportRuleParameters.xml", writer.toString());
+ assertSimilarXml("exportRuleParameters.xml", writer.toString());
}
@Test
@@ -88,10 +88,11 @@ public class XMLProfileSerializerTest {
profile.getAlerts().add(alert);
new XMLProfileSerializer().write(profile, writer);
- assertSimilarXml("/org/sonar/api/profiles/XMLProfileSerializerTest/exportAlerts.xml", writer.toString());
+ assertSimilarXml("exportAlerts.xml", writer.toString());
}
- public static void assertSimilarXml(String pathToExpectedXml, String xml) throws IOException, SAXException {
+ public static void assertSimilarXml(String fileWithExpectedXml, String xml) throws IOException, SAXException {
+ String pathToExpectedXml = "/org/sonar/api/profiles/XMLProfileSerializerTest/" + fileWithExpectedXml;
InputStream stream = XMLProfileSerializerTest.class.getResourceAsStream(pathToExpectedXml);
try {
Diff diff = isSimilarXml(IOUtils.toString(stream), xml);