diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2017-01-11 10:46:55 +0100 |
---|---|---|
committer | Julien HENRY <henryju@yahoo.fr> | 2017-01-12 11:26:48 +0100 |
commit | 82852ffe4457fce2a57aa25c468f0b75645cc848 (patch) | |
tree | 07d418d27f3ffaa44922dc9ce00fb6812706338f /sonar-scanner-protocol/src | |
parent | 1a063b96deafadd4b8b81f84f81d1ee5dfb289fe (diff) | |
download | sonarqube-82852ffe4457fce2a57aa25c468f0b75645cc848.tar.gz sonarqube-82852ffe4457fce2a57aa25c468f0b75645cc848.zip |
SONAR-8584 Remove internal WS batch/global
Diffstat (limited to 'sonar-scanner-protocol/src')
7 files changed, 0 insertions, 305 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/GlobalRepositories.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/GlobalRepositories.java deleted file mode 100644 index 7bf3bdb643a..00000000000 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/GlobalRepositories.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.protocol.input; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import org.sonar.scanner.protocol.GsonHelper; - -/** - * Container for all global data going from server to batch. - * This is not an API since server and batch always share the same version. - */ -public class GlobalRepositories { - - private long timestamp; - private Collection<Metric> metrics = new ArrayList<>(); - private Map<String, String> globalSettings = new HashMap<>(); - - public Map<String, String> globalSettings() { - return globalSettings; - } - - public GlobalRepositories addGlobalSetting(String key, String value) { - globalSettings.put(key, value); - return this; - } - - public Collection<Metric> metrics() { - return metrics; - } - - public GlobalRepositories addMetric(Metric metric) { - metrics.add(metric); - return this; - } - - public long timestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String toJson() { - return GsonHelper.create().toJson(this); - } - - public static GlobalRepositories fromJson(String json) { - return GsonHelper.create().fromJson(json, GlobalRepositories.class); - } - -} diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/Metric.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/Metric.java deleted file mode 100644 index 24c68c76414..00000000000 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/input/Metric.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.protocol.input; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class Metric { - - private final int id; - - private final String key; - - private final String valueType; - - private final String description; - - private final int direction; - - private final String name; - - private final boolean qualitative; - - private final boolean userManaged; - - private final Double worstValue; - - private final Double bestValue; - - private final boolean optimizedBestValue; - - public Metric(int id, - String key, - String valueType, - @Nullable String description, - int direction, - String name, - boolean qualitative, - boolean userManaged, - @Nullable Double worstValue, - @Nullable Double bestValue, - boolean optimizedBestValue) { - this.id = id; - this.key = key; - this.valueType = valueType; - this.description = description; - this.direction = direction; - this.name = name; - this.qualitative = qualitative; - this.userManaged = userManaged; - this.worstValue = worstValue; - this.bestValue = bestValue; - this.optimizedBestValue = optimizedBestValue; - } - - public int id() { - return id; - } - - public String key() { - return key; - } - - public String valueType() { - return valueType; - } - - @CheckForNull - public String description() { - return description; - } - - public int direction() { - return direction; - } - - public String name() { - return name; - } - - public boolean isQualitative() { - return qualitative; - } - - public boolean isUserManaged() { - return userManaged; - } - - @CheckForNull - public Double worstValue() { - return worstValue; - } - - @CheckForNull - public Double bestValue() { - return bestValue; - } - - public boolean isOptimizedBestValue() { - return optimizedBestValue; - } - -} diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/GlobalRepositoriesTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/GlobalRepositoriesTest.java deleted file mode 100644 index 703e182ea8d..00000000000 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/input/GlobalRepositoriesTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.protocol.input; - -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import org.sonar.scanner.protocol.input.GlobalRepositories; -import org.sonar.scanner.protocol.input.Metric; - -import static net.javacrumbs.jsonunit.assertj.JsonAssert.assertThatJson; -import static org.assertj.core.api.Assertions.assertThat; - -public class GlobalRepositoriesTest { - - @Test - public void to_json() throws Exception { - GlobalRepositories ref = new GlobalRepositories(); - ref.addMetric(new Metric(1, "ncloc", "INT", "Description", -1, "NCLOC", true, false, 2.0, 1.0, true)); - ref.addGlobalSetting("prop", "value"); - ref.setTimestamp(10); - - assertThatJson(ref.toJson()) - .isEqualTo(IOUtils.toString(getClass().getResource("GlobalRepositoriesTest/expected.json"))); - } - - @Test - public void from_json() { - GlobalRepositories ref = GlobalRepositories - .fromJson( - "{timestamp:1," - + "metrics:[{id:1,key:ncloc,valueType:DATA,description:Description,direction:-1,name:NCLOC,qualitative:true,userManaged:false,worstValue:2.0,bestValue:1.0,optimizedBestValue:true}]," - + "globalSettings:{prop:value}}"); - - assertThat(ref.timestamp()).isEqualTo(1); - Metric metric = ref.metrics().iterator().next(); - assertThat(metric.id()).isEqualTo(1); - assertThat(metric.key()).isEqualTo("ncloc"); - assertThat(metric.valueType()).isEqualTo("DATA"); - assertThat(metric.description()).isEqualTo("Description"); - assertThat(metric.direction()).isEqualTo(-1); - assertThat(metric.name()).isEqualTo("NCLOC"); - assertThat(metric.isQualitative()).isTrue(); - assertThat(metric.isUserManaged()).isFalse(); - assertThat(metric.worstValue()).isEqualTo(2.0); - assertThat(metric.bestValue()).isEqualTo(1.0); - assertThat(metric.isOptimizedBestValue()).isTrue(); - - assertThat(ref.globalSettings()).containsEntry("prop", "value"); - } -} diff --git a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/GlobalRepositoriesTest/expected.json b/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/GlobalRepositoriesTest/expected.json deleted file mode 100644 index de38ae0cb18..00000000000 --- a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/GlobalRepositoriesTest/expected.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "timestamp": 10, - "metrics": [ - { - "id": 1, - "key": "ncloc", - "valueType": "INT", - "description": "Description", - "direction": -1, - "name": "NCLOC", - "qualitative": true, - "userManaged": false, - "worstValue": 2.0, - "bestValue": 1.0, - "optimizedBestValue": true - } - ], - "globalSettings": { - "prop": "value" - } -} diff --git a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/ProjectRepositoriesTest/testToJson.json b/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/ProjectRepositoriesTest/testToJson.json deleted file mode 100644 index ba7489143a6..00000000000 --- a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/ProjectRepositoriesTest/testToJson.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "timestamp": 10, - "settingsByModule": { - "foo": { - "prop1": "value1", - "prop2": "value2", - "prop": "value" - } - }, - "fileDataByModuleAndPath": { - "foo": { - "src/main/java/Foo.java": { - "hash": "xyz", - "needBlame": true - }, - "src/main/java/Foo2.java": { - "hash": "xyz", - "needBlame": false - } - } - }, - "lastAnalysisDate": "2014-05-18T15:50:45+0100" -} diff --git a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/RulesSearchTest/empty.json b/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/RulesSearchTest/empty.json deleted file mode 100644 index 055fe8b8d63..00000000000 --- a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/RulesSearchTest/empty.json +++ /dev/null @@ -1 +0,0 @@ -{"total":3225,"p":30,"ps":500,"rules":[]}
\ No newline at end of file diff --git a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/RulesSearchTest/expected.json b/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/RulesSearchTest/expected.json deleted file mode 100644 index 89350a7e331..00000000000 --- a/sonar-scanner-protocol/src/test/resources/org/sonar/scanner/protocol/input/RulesSearchTest/expected.json +++ /dev/null @@ -1 +0,0 @@ -{"total":290,"p":1,"ps":2,"rules":[{"key":"squid:S1194","internalKey":"S1194","repo":"squid","name":"\"java.lang.Error\" should not be extended","severity":"MAJOR","lang":"java"},{"key":"squid:ObjectFinalizeOverridenCallsSuperFinalizeCheck","internalKey":"ObjectFinalizeOverridenCallsSuperFinalizeCheck","repo":"squid","name":"super.finalize() should be called at the end of Object.finalize() implementations","severity":"BLOCKER","lang":"java"}]}
\ No newline at end of file |