diff options
4 files changed, 7 insertions, 18 deletions
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java index adc79ccc582..562e986c70e 100644 --- a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java +++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java @@ -31,6 +31,7 @@ public class TimeMachineUnmarshaller extends AbstractUnmarshaller<TimeMachine> { for (int i = 0; i < size; i++) { JSONObject cellJson = JsonUtils.getArray(cells, i); JSONArray valuesJson = cellJson.get("v").isArray(); + Object[] resultValues = new Object[JsonUtils.getArraySize(valuesJson)]; for (int indexValue = 0; indexValue < JsonUtils.getArraySize(valuesJson); indexValue++) { Object value = valuesJson.get(indexValue); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java index bdf87e27ac0..8a7092741a7 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java @@ -103,15 +103,4 @@ public final class JsonUtils { return null; } - /** - * @since 2.5 - */ - public static Date parseDateTime(String dateTime) { - try { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); - return dateFormat.parse(dateTime); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java index 72203450dfc..b59a364bc31 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java @@ -37,8 +37,8 @@ public class TimeMachineUnmarshaller extends AbstractUnmarshaller<TimeMachine> { int size = cols.size(); TimeMachineColumn[] result = new TimeMachineColumn[size]; for (int index = 0; index < size; index++) { - JSONObject colJson = (JSONObject)cols.get(index); - result[index]=new TimeMachineColumn(index, JsonUtils.getString(colJson, "metric"), null, null); + JSONObject colJson = (JSONObject) cols.get(index); + result[index] = new TimeMachineColumn(index, JsonUtils.getString(colJson, "metric"), null, null); } return result; } @@ -47,15 +47,15 @@ public class TimeMachineUnmarshaller extends AbstractUnmarshaller<TimeMachine> { int size = cells.size(); TimeMachineCell[] result = new TimeMachineCell[size]; for (int i = 0; i < size; i++) { - JSONObject cellJson = (JSONObject)cells.get(i); + JSONObject cellJson = (JSONObject) cells.get(i); JSONArray valuesJson = JsonUtils.getArray(cellJson, "v"); Object[] resultValues = new Object[valuesJson.size()]; for (int indexValue = 0; indexValue < valuesJson.size(); indexValue++) { Object value = valuesJson.get(indexValue); - resultValues[indexValue]=value; + resultValues[indexValue] = value; } - result[i]=new TimeMachineCell(JsonUtils.getDateTime(cellJson, "d"), resultValues); + result[i] = new TimeMachineCell(JsonUtils.getDateTime(cellJson, "d"), resultValues); } return result; } 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 774dd1bfd81..731d58e24f7 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 @@ -67,8 +67,7 @@ public class TimeMachineUnmarshallerTest { TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(WSTestUtils.loadFile("/timemachine/typed-values.json")); assertThat(timeMachine.getCells()[0].getValues().length, is(2)); - assertThat((String)timeMachine.getCells()[0].getValues()[0], is("Sonar way")); + assertThat((String) timeMachine.getCells()[0].getValues()[0], is("Sonar way")); assertThat((Double) timeMachine.getCells()[0].getValues()[1], is(80.0)); - } } |