diff options
author | Godin <mandrikov@gmail.com> | 2010-12-13 21:55:49 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-13 21:55:49 +0000 |
commit | d104ca20751117924dc7e74a9cf13445926b0acc (patch) | |
tree | 4ddaaf560ff2c6d8adeb03d643d5e5b015846604 /sonar-ws-client/src/test | |
parent | d52d82788c75ca8f67270b247105d3350b22f4e8 (diff) | |
download | sonarqube-d104ca20751117924dc7e74a9cf13445926b0acc.tar.gz sonarqube-d104ca20751117924dc7e74a9cf13445926b0acc.zip |
SONAR-833: New Web Service to get history of measures (time machine)
Diffstat (limited to 'sonar-ws-client/src/test')
4 files changed, 17 insertions, 24 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineDataTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineDataTest.java index cd7fec9609f..6672a3acf5e 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineDataTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineDataTest.java @@ -2,7 +2,7 @@ package org.sonar.wsclient.services; import org.junit.Test; -import java.util.*; +import java.util.Arrays; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; @@ -12,14 +12,11 @@ public class TimeMachineDataTest { @Test public void valueAsDouble() { - Map<Date, List<String>> map = new HashMap<Date, List<String>>(); - Date date = new Date(); - map.put(date, Arrays.asList(null, "20.3", "hello")); - TimeMachineData data = new TimeMachineData().setData(map); + TimeMachineData data = new TimeMachineData().setValues(Arrays.asList(null, "20.3", "hello")); - assertThat(data.getValueAsDouble(date, 0), nullValue()); - assertThat(data.getValueAsDouble(date, 1), is(20.3)); - assertThat(data.getValueAsDouble(date, 2), nullValue()); + assertThat(data.getValueAsDouble(0), nullValue()); + assertThat(data.getValueAsDouble(1), is(20.3)); + assertThat(data.getValueAsDouble(2), nullValue()); } } 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 13a8b5c0482..908658f336b 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 @@ -6,7 +6,6 @@ import org.sonar.wsclient.services.TimeMachineData; 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; @@ -18,12 +17,10 @@ public class TimeMachineUnmarshallerTest { public void toModel() throws Exception { TimeMachineData data = new TimeMachineUnmarshaller().toModel(WSTestUtils.loadFile("/timemachine/timemachine.json")); - Map<Date, List<String>> map = data.getData(); - assertThat(map.size(), is(1)); - Date date = map.keySet().iterator().next(); + Date date = data.getDate(); 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(); + List<String> values = data.getValues(); assertThat(values.size(), is(3)); assertThat(values.get(0), is("20.0")); assertThat(values.get(1), nullValue()); @@ -32,10 +29,9 @@ public class TimeMachineUnmarshallerTest { @Test public void many() throws Exception { - TimeMachineData data = new TimeMachineUnmarshaller().toModel(WSTestUtils.loadFile("/timemachine/many.json")); + List<TimeMachineData> data = new TimeMachineUnmarshaller().toModels(WSTestUtils.loadFile("/timemachine/many.json")); - Map<Date, List<String>> map = data.getData(); - assertThat(map.size(), is(3)); + assertThat(data.size(), is(3)); } } diff --git a/sonar-ws-client/src/test/resources/timemachine/many.json b/sonar-ws-client/src/test/resources/timemachine/many.json index a65a8daa255..6ee5fa2312a 100644 --- a/sonar-ws-client/src/test/resources/timemachine/many.json +++ b/sonar-ws-client/src/test/resources/timemachine/many.json @@ -1,5 +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] -} +[ + {"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 03130cc0286..17f064aeb0b 100644 --- a/sonar-ws-client/src/test/resources/timemachine/timemachine.json +++ b/sonar-ws-client/src/test/resources/timemachine/timemachine.json @@ -1,3 +1,3 @@ -{ - "2010-12-04T15:59:23+0000": [20.0, null, 12.8] -} +[ + {"2010-12-04T15:59:23+0000": [20.0, null, 12.8]} +] |