aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2012-11-29 11:18:53 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2012-11-29 11:18:53 +0100
commit9322b252de6c294af1b54377c9df3a7c737771f8 (patch)
tree0b3e9ebcf74ef49c3f32da0e41c31742ad46b815 /sonar-plugin-api
parent5f283a0a38d0d3aff9b228138b5b339ddc3362fc (diff)
downloadsonarqube-9322b252de6c294af1b54377c9df3a7c737771f8.tar.gz
sonarqube-9322b252de6c294af1b54377c9df3a7c737771f8.zip
SONAR-1352 Update export profile xml to include period alert properties
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java5
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/profiles/XMLProfileSerializerTest.java2
-rw-r--r--sonar-plugin-api/src/test/resources/org/sonar/api/profiles/XMLProfileSerializerTest/exportAlerts.xml1
3 files changed, 6 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java
index f8cc1a95522..5e93ca45c0d 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java
@@ -19,6 +19,7 @@
*/
package org.sonar.api.profiles;
+import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.ServerComponent;
@@ -115,7 +116,9 @@ public final class XMLProfileSerializer implements ServerComponent {
private void appendAlert(Alert alert, Writer writer) throws IOException {
writer.append("<alert><metric>");
StringEscapeUtils.escapeXml(writer, alert.getMetric().getKey());
- writer.append("</metric><operator>");
+ writer.append("</metric><period>");
+ StringEscapeUtils.escapeXml(writer, ObjectUtils.toString(alert.getPeriod()));
+ writer.append("</period><operator>");
StringEscapeUtils.escapeXml(writer, alert.getOperator());
writer.append("</operator><warning>");
StringEscapeUtils.escapeXml(writer, alert.getValueWarning());
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 ba2d0a36e56..f54bde9a043 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
@@ -80,7 +80,7 @@ public class XMLProfileSerializerTest {
public void exportAlerts() throws Exception {
Writer writer = new StringWriter();
RulesProfile profile = RulesProfile.create("sonar way", "java");
- Alert alert = new Alert(profile, new Metric("coverage"), Alert.OPERATOR_SMALLER, "60", "80");
+ Alert alert = new Alert(profile, new Metric("coverage"), Alert.OPERATOR_SMALLER, "60", "80", 1);
profile.getAlerts().add(alert);
new XMLProfileSerializer().write(profile, writer);
diff --git a/sonar-plugin-api/src/test/resources/org/sonar/api/profiles/XMLProfileSerializerTest/exportAlerts.xml b/sonar-plugin-api/src/test/resources/org/sonar/api/profiles/XMLProfileSerializerTest/exportAlerts.xml
index 1a1859836c8..1ae4e6eda4a 100644
--- a/sonar-plugin-api/src/test/resources/org/sonar/api/profiles/XMLProfileSerializerTest/exportAlerts.xml
+++ b/sonar-plugin-api/src/test/resources/org/sonar/api/profiles/XMLProfileSerializerTest/exportAlerts.xml
@@ -6,6 +6,7 @@
<alerts>
<alert>
<metric>coverage</metric>
+ <period>1</period>
<operator>&lt;</operator>
<error>60</error>
<warning>80</warning>