aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/test
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-12-13 09:45:39 +0000
committerGodin <mandrikov@gmail.com>2010-12-13 09:45:39 +0000
commit53fc4e95247f3fda3becde6bd5b4279a66255c97 (patch)
tree15e0753fa7ea4183ace82629fed56d701b28f24f /sonar-ws-client/src/test
parentab1f321e58cea13e35fd9986de416512c6e51c59 (diff)
downloadsonarqube-53fc4e95247f3fda3becde6bd5b4279a66255c97.tar.gz
sonarqube-53fc4e95247f3fda3becde6bd5b4279a66255c97.zip
SONAR-833: New Web Service to get history of measures (time machine)
Diffstat (limited to 'sonar-ws-client/src/test')
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java26
-rw-r--r--sonar-ws-client/src/test/resources/timemachine/many.json5
-rw-r--r--sonar-ws-client/src/test/resources/timemachine/timemachine.json3
3 files changed, 30 insertions, 4 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java
index e722c1120ad..a05319884a2 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java
@@ -5,17 +5,39 @@ import org.junit.Test;
import org.sonar.wsclient.services.TimeMachineData;
import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
public class TimeMachineUnmarshallerTest {
@Test
- public void toModel() throws IOException {
+ public void toModel() throws Exception {
TimeMachineData data = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/timemachine.json"));
- assertThat(data.getData().size(), is(2));
+ Map<Date, List<String>> map = data.getData();
+ assertThat(map.size(), is(1));
+ Date date = map.keySet().iterator().next();
+ final Date expectedDate = new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:ssZZZZ").parse("2010-12-04T15:59:23+0000");
+ assertThat(date, is(expectedDate));
+ List<String> values = map.values().iterator().next();
+ assertThat(values.size(), is(3));
+ assertThat(values.get(0), is("20.0"));
+ assertThat(values.get(1), nullValue());
+ assertThat(values.get(2), is("12.8"));
+ }
+
+ @Test
+ public void many() throws Exception {
+ TimeMachineData data = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/many.json"));
+
+ Map<Date, List<String>> map = data.getData();
+ assertThat(map.size(), is(3));
}
private static String loadFile(String path) throws IOException {
diff --git a/sonar-ws-client/src/test/resources/timemachine/many.json b/sonar-ws-client/src/test/resources/timemachine/many.json
new file mode 100644
index 00000000000..a65a8daa255
--- /dev/null
+++ b/sonar-ws-client/src/test/resources/timemachine/many.json
@@ -0,0 +1,5 @@
+{
+ "2010-10-10T00:00:00+0000": [25.0, null, 14.6],
+ "2010-11-15T00:00:00+0000": [23.0, null, 10.3],
+ "2010-12-04T00:00:00+0000": [20.0, null, 12.8]
+}
diff --git a/sonar-ws-client/src/test/resources/timemachine/timemachine.json b/sonar-ws-client/src/test/resources/timemachine/timemachine.json
index e4777958df8..03130cc0286 100644
--- a/sonar-ws-client/src/test/resources/timemachine/timemachine.json
+++ b/sonar-ws-client/src/test/resources/timemachine/timemachine.json
@@ -1,4 +1,3 @@
{
- "2010-10-04T00:00:00+0000": ["18.0", null, "13.1"],
- "2010-12-04T00:00:00+0000": ["20.0", null, "12.8"]
+ "2010-12-04T15:59:23+0000": [20.0, null, 12.8]
}