aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch-protocol/src/test
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-17 15:08:04 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-17 16:27:11 +0200
commit51cc491410147364a9c81e870d40880189f62fd9 (patch)
treed652d1b1aa72e80153ef30874ba01aaf31d3ace4 /sonar-batch-protocol/src/test
parente5531f07ac51ace0dc6d957c9960fcec37c28783 (diff)
downloadsonarqube-51cc491410147364a9c81e870d40880189f62fd9.tar.gz
sonarqube-51cc491410147364a9c81e870d40880189f62fd9.zip
SONAR-5417 Initial version of batch protocol + refactoring of settings
Diffstat (limited to 'sonar-batch-protocol/src/test')
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
new file mode 100644
index 00000000000..037517958b4
--- /dev/null
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.batch.protocol.input;
+
+import org.json.JSONException;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+
+import java.io.StringReader;
+import java.util.HashMap;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class ProjectReferentialsTest {
+
+ @Test
+ public void testToJson() throws JSONException {
+ ProjectReferentials ref = new ProjectReferentials();
+ HashMap<String, String> projectSettings = new HashMap<String, String>();
+ projectSettings.put("sonar.foo", "bar");
+ ref.setProjectSettings("foo", projectSettings);
+
+ JSONAssert.assertEquals("{languages: [], projectSettings: {foo: {'sonar.foo': 'bar'}}, timestamp: 0}", ref.toJson(), true);
+ }
+
+ @Test
+ public void testFromJson() throws JSONException {
+ ProjectReferentials ref = ProjectReferentials.fromJson(new StringReader("{languages: [], projectSettings: {foo: {'sonar.foo': 'bar'}}, timestamp: 1}"));
+
+ assertThat(ref.timestamp()).isEqualTo(1);
+ }
+}