From 5529213febfeb49dc4fad4470842675fa5f061f2 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 5 Jun 2014 17:53:11 +0200 Subject: [PATCH] SONAR-5382 Remove DuplicationClient, SourceClient and TestClient --- .../java/org/sonar/wsclient/SonarClient.java | 36 ---- .../org/sonar/wsclient/duplication/Block.java | 39 ---- .../wsclient/duplication/Duplication.java | 32 ---- .../duplication/DuplicationClient.java | 32 ---- .../wsclient/duplication/Duplications.java | 34 ---- .../org/sonar/wsclient/duplication/File.java | 39 ---- .../internal/DefaultDuplicationClient.java | 123 ------------- .../internal/DefaultDuplications.java | 61 ------- .../duplication/internal/package-info.java | 24 --- .../wsclient/duplication/package-info.java | 24 --- .../java/org/sonar/wsclient/source/Scm.java | 38 ---- .../org/sonar/wsclient/source/Source.java | 36 ---- .../sonar/wsclient/source/SourceClient.java | 36 ---- .../sonar/wsclient/source/SourceScmQuery.java | 79 -------- .../wsclient/source/SourceShowQuery.java | 69 ------- .../wsclient/source/internal/DefaultScm.java | 62 ------- .../source/internal/DefaultSource.java | 52 ------ .../source/internal/DefaultSourceClient.java | 73 -------- .../source/internal/package-info.java | 24 --- .../sonar/wsclient/source/package-info.java | 24 --- .../org/sonar/wsclient/test/Coverage.java | 45 ----- .../sonar/wsclient/test/CoverageClient.java | 34 ---- .../wsclient/test/CoverageShowQuery.java | 80 --------- .../org/sonar/wsclient/test/CoveredFile.java | 39 ---- .../org/sonar/wsclient/test/TestCase.java | 42 ----- .../org/sonar/wsclient/test/TestClient.java | 46 ----- .../wsclient/test/TestableTestCases.java | 58 ------ .../test/internal/DefaultCoverage.java | 64 ------- .../test/internal/DefaultCoverageClient.java | 58 ------ .../test/internal/DefaultTestClient.java | 168 ------------------ .../internal/DefaultTestableTestCases.java | 73 -------- .../wsclient/test/internal/package-info.java | 24 --- .../org/sonar/wsclient/test/package-info.java | 24 --- .../org/sonar/wsclient/SonarClientTest.java | 8 - .../DefaultDuplicationClientTest.java | 70 -------- .../internal/DefaultSourceClientTest.java | 70 -------- .../internal/DefaultCoverageClientTest.java | 60 ------- .../test/internal/DefaultTestClientTest.java | 99 ----------- .../show_duplications.json | 30 ---- .../DefaultSourceClientTest/return_scm.json | 7 - .../DefaultSourceClientTest/show_source.json | 10 -- .../show_coverage.json | 7 - .../DefaultTestClientTest/covered_files.json | 14 -- .../DefaultTestClientTest/show_test_case.json | 16 -- .../DefaultTestClientTest/test_cases.json | 16 -- 45 files changed, 2099 deletions(-) delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Block.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplication.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/DuplicationClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplications.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/File.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplications.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/package-info.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/package-info.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/Scm.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/Source.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceScmQuery.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceShowQuery.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultScm.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSource.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSourceClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/package-info.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/source/package-info.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/Coverage.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageShowQuery.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoveredFile.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestCase.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestableTestCases.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverage.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverageClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestClient.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestableTestCases.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/package-info.java delete mode 100644 sonar-ws-client/src/main/java/org/sonar/wsclient/test/package-info.java delete mode 100644 sonar-ws-client/src/test/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest.java delete mode 100644 sonar-ws-client/src/test/java/org/sonar/wsclient/source/internal/DefaultSourceClientTest.java delete mode 100644 sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultCoverageClientTest.java delete mode 100644 sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultTestClientTest.java delete mode 100644 sonar-ws-client/src/test/resources/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest/show_duplications.json delete mode 100644 sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/return_scm.json delete mode 100644 sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/show_source.json delete mode 100644 sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultCoverageClientTest/show_coverage.json delete mode 100644 sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/covered_files.json delete mode 100644 sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/show_test_case.json delete mode 100644 sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/test_cases.json diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java index 71a87213e74..0ab9691bb54 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java @@ -19,8 +19,6 @@ */ package org.sonar.wsclient; -import org.sonar.wsclient.duplication.DuplicationClient; -import org.sonar.wsclient.duplication.internal.DefaultDuplicationClient; import org.sonar.wsclient.internal.HttpRequestFactory; import org.sonar.wsclient.issue.ActionPlanClient; import org.sonar.wsclient.issue.IssueClient; @@ -36,14 +34,8 @@ import org.sonar.wsclient.qualitygate.QualityGateClient; import org.sonar.wsclient.qualitygate.internal.DefaultQualityGateClient; import org.sonar.wsclient.rule.RuleClient; import org.sonar.wsclient.rule.internal.DefaultRuleClient; -import org.sonar.wsclient.source.SourceClient; -import org.sonar.wsclient.source.internal.DefaultSourceClient; import org.sonar.wsclient.system.SystemClient; import org.sonar.wsclient.system.internal.DefaultSystemClient; -import org.sonar.wsclient.test.CoverageClient; -import org.sonar.wsclient.test.TestClient; -import org.sonar.wsclient.test.internal.DefaultCoverageClient; -import org.sonar.wsclient.test.internal.DefaultTestClient; import org.sonar.wsclient.user.UserClient; import org.sonar.wsclient.user.internal.DefaultUserClient; @@ -138,34 +130,6 @@ public class SonarClient { return new DefaultQProfileClient(requestFactory); } - /** - * New client to interact with web services related to source - */ - public SourceClient sourceClient() { - return new DefaultSourceClient(requestFactory); - } - - /** - * New client to interact with web services related to coverage - */ - public CoverageClient coverageClient() { - return new DefaultCoverageClient(requestFactory); - } - - /** - * New client to interact with web services related to duplication - */ - public DuplicationClient duplicationClient() { - return new DefaultDuplicationClient(requestFactory); - } - - /** - * New client to interact with web services related to test - */ - public TestClient testClient() { - return new DefaultTestClient(requestFactory); - } - public SystemClient systemClient() { return new DefaultSystemClient(requestFactory); } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Block.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Block.java deleted file mode 100644 index e72e5292cea..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Block.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.wsclient.duplication; - -import javax.annotation.CheckForNull; - -/** - * @since 4.4 - */ -public interface Block { - - @CheckForNull - File file(); - - @CheckForNull - Integer from(); - - @CheckForNull - Integer size(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplication.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplication.java deleted file mode 100644 index 9008afe835d..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplication.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.wsclient.duplication; - -import java.util.List; - -/** - * @since 4.4 - */ -public interface Duplication { - - List blocks(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/DuplicationClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/DuplicationClient.java deleted file mode 100644 index 27f624b2ff4..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/DuplicationClient.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.wsclient.duplication; - -/** - * Display duplication information - * - * @since 4.4 - */ -public interface DuplicationClient { - - Duplications show(String componentKey); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplications.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplications.java deleted file mode 100644 index 25536cae072..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/Duplications.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.wsclient.duplication; - -import java.util.List; - -/** - * @since 4.4 - */ -public interface Duplications { - - List duplications(); - - List files(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/File.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/File.java deleted file mode 100644 index 976f9a7ab90..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/File.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.wsclient.duplication; - -import javax.annotation.CheckForNull; - -/** - * @since 4.4 - */ -public interface File { - - @CheckForNull - String key(); - - @CheckForNull - String name(); - - @CheckForNull - String projectName(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClient.java deleted file mode 100644 index 814aab56dff..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClient.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.wsclient.duplication.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.duplication.*; -import org.sonar.wsclient.internal.EncodingUtils; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class DefaultDuplicationClient implements DuplicationClient { - - private final HttpRequestFactory requestFactory; - - public DefaultDuplicationClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public Duplications show(String componentKey) { - Map params = EncodingUtils.toMap("key", componentKey); - String jsonResult = requestFactory.get("/api/duplications/show", params); - - DefaultDuplications duplications = new DefaultDuplications(); - Map jRoot = (Map) JSONValue.parse(jsonResult); - parseFiles(duplications, jRoot); - parseDuplications(duplications, jRoot); - return duplications; - } - - private void parseDuplications(final DefaultDuplications duplications, Map jRoot) { - List jsonDuplications = (List) jRoot.get("duplications"); - if (jsonDuplications != null) { - for (Map jsonDuplication : jsonDuplications) { - final List blockList = new ArrayList(); - - List blocks = (List) jsonDuplication.get("blocks"); - if (blocks != null) { - for (final Map block : blocks) { - blockList.add((new Block() { - @Override - public File file() { - String ref = JsonUtils.getString(block, "_ref"); - return ref != null ? duplications.fileByRef(ref) : null; - } - - @Override - public Integer from() { - return JsonUtils.getInteger(block, "from"); - } - - @Override - public Integer size() { - return JsonUtils.getInteger(block, "size"); - } - })); - } - } - - Duplication duplication = new Duplication() { - @Override - public List blocks() { - return blockList; - } - }; - - duplications.addDuplication(duplication); - } - } - } - - private void parseFiles(DefaultDuplications duplications, Map jRoot) { - Map jsonFiles = (Map) jRoot.get("files"); - if (jsonFiles != null) { - for (Map.Entry entry : jsonFiles.entrySet()) { - String ref = entry.getKey(); - final Map file = entry.getValue(); - if (ref != null && file != null) { - - duplications.addFile(ref, new File() { - @Override - public String key() { - return JsonUtils.getString(file, "key"); - } - - @Override - public String name() { - return JsonUtils.getString(file, "name"); - } - - @Override - public String projectName() { - return JsonUtils.getString(file, "projectName"); - } - }); - - } - } - } - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplications.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplications.java deleted file mode 100644 index 4d7d7f1dabb..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/DefaultDuplications.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.wsclient.duplication.internal; - -import org.sonar.wsclient.duplication.Duplication; -import org.sonar.wsclient.duplication.Duplications; -import org.sonar.wsclient.duplication.File; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DefaultDuplications implements Duplications { - - private final List duplications = new ArrayList(); - private final Map files = new HashMap(); - - @Override - public List duplications() { - return duplications; - } - - @Override - public List files() { - return new ArrayList(files.values()); - } - - File fileByRef(String ref) { - return files.get(ref); - } - - DefaultDuplications addDuplication(Duplication duplication) { - duplications.add(duplication); - return this; - } - - DefaultDuplications addFile(String ref, File file) { - files.put(ref, file); - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/package-info.java deleted file mode 100644 index 9488f801b80..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/internal/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.wsclient.duplication.internal; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/package-info.java deleted file mode 100644 index d703cacae42..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/duplication/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.wsclient.duplication; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/Scm.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/Scm.java deleted file mode 100644 index 27a2bb6b2d8..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/Scm.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.wsclient.source; - -import javax.annotation.CheckForNull; - -import java.util.Date; - -public interface Scm { - - @CheckForNull - Integer lineIndex(); - - @CheckForNull - String author(); - - @CheckForNull - Date date(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/Source.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/Source.java deleted file mode 100644 index 2d5b807fce1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/Source.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.wsclient.source; - -import javax.annotation.CheckForNull; - -/** - * @since 4.4 - */ -public interface Source { - - @CheckForNull - Integer lineIndex(); - - @CheckForNull - String lineAsHtml(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceClient.java deleted file mode 100644 index 6f5bb490def..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceClient.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.wsclient.source; - -import java.util.List; - -/** - * Display sources information - * - * @since 4.4 - */ -public interface SourceClient { - - List show(SourceShowQuery query); - - List scm(SourceScmQuery query); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceScmQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceScmQuery.java deleted file mode 100644 index 70d5124206c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceScmQuery.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.wsclient.source; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class SourceScmQuery { - - private String key; - private String from; - private String to; - private Boolean groupCommits; - - private SourceScmQuery() { - // Nothing here - } - - public String key() { - return key; - } - - public SourceScmQuery setKey(String key) { - this.key = key; - return this; - } - - @CheckForNull - public String from() { - return from; - } - - public SourceScmQuery setFrom(@Nullable String from) { - this.from = from; - return this; - } - - @CheckForNull - public String to() { - return to; - } - - public SourceScmQuery setTo(@Nullable String to) { - this.to = to; - return this; - } - - @CheckForNull - public Boolean groupCommits() { - return groupCommits; - } - - public SourceScmQuery setGroupCommits(@Nullable Boolean groupCommits) { - this.groupCommits = groupCommits; - return this; - } - - public static SourceScmQuery create(){ - return new SourceScmQuery(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceShowQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceShowQuery.java deleted file mode 100644 index d56241ace18..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/SourceShowQuery.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.wsclient.source; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class SourceShowQuery { - - private String key; - private String from; - private String to; - - private SourceShowQuery() { - // Nothing here - } - - public String key() { - return key; - } - - public SourceShowQuery setKey(String key) { - this.key = key; - return this; - } - - @CheckForNull - public String from() { - return from; - } - - public SourceShowQuery setFrom(@Nullable String from) { - this.from = from; - return this; - } - - @CheckForNull - public String to() { - return to; - } - - public SourceShowQuery setTo(@Nullable String to) { - this.to = to; - return this; - } - - public static SourceShowQuery create(){ - return new SourceShowQuery(); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultScm.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultScm.java deleted file mode 100644 index e6cfc870a95..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultScm.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.wsclient.source.internal; - -import org.sonar.wsclient.source.Scm; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.CheckForNull; - -import java.util.Date; -import java.util.List; - -public class DefaultScm implements Scm { - - private final List json; - - public DefaultScm(List json) { - this.json = json; - } - - @Override - @CheckForNull - public Integer lineIndex() { - Object value = json.get(0); - if (value != null) { - return ((Long) value).intValue(); - } - return null; - } - - - @Override - @CheckForNull - public String author() { - return (String) json.get(1); - } - - @Override - @CheckForNull - public Date date() { - return JsonUtils.parseDate((String) json.get(2)); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSource.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSource.java deleted file mode 100644 index 37a4f7db646..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSource.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.wsclient.source.internal; - -import org.sonar.wsclient.source.Source; - -import javax.annotation.CheckForNull; - -import java.util.List; - -public class DefaultSource implements Source { - - private final List json; - - public DefaultSource(List json) { - this.json = json; - } - - @Override - @CheckForNull - public Integer lineIndex() { - Object value = json.get(0); - if (value != null) { - return ((Long) value).intValue(); - } - return null; - } - - @Override - @CheckForNull - public String lineAsHtml() { - return (String) json.get(1); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSourceClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSourceClient.java deleted file mode 100644 index db20901c1b1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/DefaultSourceClient.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.wsclient.source.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.EncodingUtils; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.source.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class DefaultSourceClient implements SourceClient { - - private final HttpRequestFactory requestFactory; - - public DefaultSourceClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public List show(SourceShowQuery query) { - Map params = EncodingUtils.toMap("key", query.key(), "from", query.from(), "to", query.to()); - String json = requestFactory.get("/api/sources/show", params); - - List sources = new ArrayList(); - Map jRoot = (Map) JSONValue.parse(json); - List jsonSources = (List) jRoot.get("sources"); - if (jsonSources != null) { - for (List jSource : jsonSources) { - sources.add(new DefaultSource(jSource)); - } - } - return sources; - } - - @Override - public List scm(SourceScmQuery query) { - Map params = EncodingUtils.toMap("key", query.key(), "from", query.from(), "to", query.to()); - params.put("group_commits", query.groupCommits()); - String json = requestFactory.get("/api/sources/scm", params); - - List result = new ArrayList(); - Map jRoot = (Map) JSONValue.parse(json); - List jsonResult = (List) jRoot.get("scm"); - if (jsonResult != null) { - for (List line : jsonResult) { - result.add(new DefaultScm(line)); - } - } - return result; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/package-info.java deleted file mode 100644 index 1a92c5c0269..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/internal/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.wsclient.source.internal; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/source/package-info.java deleted file mode 100644 index 546965bbac9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/source/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.wsclient.source; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/Coverage.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/Coverage.java deleted file mode 100644 index b18c7edcd76..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/Coverage.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.wsclient.test; - -import javax.annotation.CheckForNull; - -/** - * @since 4.4 - */ -public interface Coverage { - - @CheckForNull - Integer lineIndex(); - - @CheckForNull - Boolean isCovered(); - - @CheckForNull - Integer tests(); - - @CheckForNull - Integer branches(); - - @CheckForNull - Integer coveredBranches(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageClient.java deleted file mode 100644 index 97a28d7eb16..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageClient.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.wsclient.test; - -import java.util.List; - -/** - * Display coverage information - * - * @since 4.4 - */ -public interface CoverageClient { - - List show(CoverageShowQuery query); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageShowQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageShowQuery.java deleted file mode 100644 index 092cfd51d92..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoverageShowQuery.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.wsclient.test; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class CoverageShowQuery { - - private String key; - private String from; - private String to; - private String type; - - private CoverageShowQuery() { - // Nothing here - } - - public String key() { - return key; - } - - public CoverageShowQuery setKey(String key) { - this.key = key; - return this; - } - - @CheckForNull - public String from() { - return from; - } - - public CoverageShowQuery setFrom(@Nullable String from) { - this.from = from; - return this; - } - - @CheckForNull - public String to() { - return to; - } - - public CoverageShowQuery setTo(@Nullable String to) { - this.to = to; - return this; - } - - @CheckForNull - public String type() { - return type; - } - - public CoverageShowQuery setType(@Nullable String type) { - this.type = type; - return this; - } - - public static CoverageShowQuery create(){ - return new CoverageShowQuery(); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoveredFile.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoveredFile.java deleted file mode 100644 index 4eaadd3e603..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/CoveredFile.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.wsclient.test; - -import javax.annotation.CheckForNull; - -/** - * @since 4.4 - */ -public interface CoveredFile { - - @CheckForNull - String key(); - - @CheckForNull - String longName(); - - @CheckForNull - Integer coveredLines(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestCase.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestCase.java deleted file mode 100644 index 5dd4b8cfd3c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestCase.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.wsclient.test; - -import javax.annotation.CheckForNull; - -/** - * @since 4.4 - */ -public interface TestCase { - - @CheckForNull - String name(); - - @CheckForNull - String status(); - - @CheckForNull - Long durationInMs(); - - @CheckForNull - Integer coveredLines(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestClient.java deleted file mode 100644 index 14d575f645c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestClient.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.wsclient.test; - -import java.util.List; - -/** - * Get test information - * - * @since 4.4 - */ -public interface TestClient { - - /** - * Return list of test cases of a test plan - */ - List show(String testPlanKey); - - /** - * Return list of test cases covering a files' line - */ - TestableTestCases testCases(String fileKey, Integer line); - - /** - * Return the list of files covered by a test plan's test case - */ - List coveredFiles(String testPlanKey, String testCase); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestableTestCases.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestableTestCases.java deleted file mode 100644 index 7d4dfa8125f..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/TestableTestCases.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.wsclient.test; - -import javax.annotation.CheckForNull; - -import java.util.List; - -/** - * @since 4.4 - */ -public interface TestableTestCases { - - List files(); - - List tests(); - - @CheckForNull - File fileByTest(String testCase); - - interface TestCase { - @CheckForNull - String name(); - - @CheckForNull - String status(); - - @CheckForNull - Long durationInMs(); - } - - interface File { - @CheckForNull - String key(); - - @CheckForNull - String longName(); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverage.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverage.java deleted file mode 100644 index 4c9e73d7a42..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverage.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.wsclient.test.internal; - -import org.sonar.wsclient.test.Coverage; - -import java.util.List; - -public class DefaultCoverage implements Coverage { - - private final List json; - - public DefaultCoverage(List json) { - this.json = json; - } - - @Override - public Integer lineIndex() { - Object value = json.get(0); - return value != null ? ((Long) value).intValue() : null; - } - - @Override - public Boolean isCovered() { - Object value = json.get(1); - return value != null ? (Boolean) value : null; - } - - @Override - public Integer tests() { - Object value = json.get(2); - return value != null ? ((Long) value).intValue() : null; - } - - @Override - public Integer branches() { - Object value = json.get(3); - return value != null ? ((Long) value).intValue() : null; - } - - @Override - public Integer coveredBranches() { - Object value = json.get(4); - return value != null ? ((Long) value).intValue() : null; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverageClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverageClient.java deleted file mode 100644 index d5666045f21..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultCoverageClient.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.wsclient.test.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.EncodingUtils; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.test.Coverage; -import org.sonar.wsclient.test.CoverageClient; -import org.sonar.wsclient.test.CoverageShowQuery; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class DefaultCoverageClient implements CoverageClient { - - private final HttpRequestFactory requestFactory; - - public DefaultCoverageClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public List show(CoverageShowQuery query) { - Map params = EncodingUtils.toMap("key", query.key(), "from", query.from(), "to", query.to(), "type", query.type()); - String jsonResult = requestFactory.get("/api/coverage/show", params); - - List coverages = new ArrayList(); - Map jRoot = (Map) JSONValue.parse(jsonResult); - List jsonList = (List) jRoot.get("coverage"); - if (jsonList != null) { - for (List json : jsonList) { - coverages.add(new DefaultCoverage(json)); - } - } - return coverages; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestClient.java deleted file mode 100644 index c6c1f055462..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestClient.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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.wsclient.test.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.EncodingUtils; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.test.CoveredFile; -import org.sonar.wsclient.test.TestCase; -import org.sonar.wsclient.test.TestClient; -import org.sonar.wsclient.test.TestableTestCases; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class DefaultTestClient implements TestClient { - - private final HttpRequestFactory requestFactory; - - public DefaultTestClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public List show(String testPlanKey) { - Map params = EncodingUtils.toMap("key", testPlanKey); - String jsonResult = requestFactory.get("/api/tests/show", params); - - List testCases = new ArrayList(); - Map jRoot = (Map) JSONValue.parse(jsonResult); - List maps = (List) jRoot.get("tests"); - if (maps != null) { - for (final Map json : maps) { - testCases.add(new TestCase() { - @Override - public String name() { - return JsonUtils.getString(json, "name"); - } - - @Override - public String status() { - return JsonUtils.getString(json, "status"); - } - - @Override - public Long durationInMs() { - return JsonUtils.getLong(json, "durationInMs"); - } - - @Override - public Integer coveredLines() { - return JsonUtils.getInteger(json, "coveredLines"); - } - }); - } - } - return testCases; - } - - @Override - public List coveredFiles(String testPlanKey, String testCase) { - Map params = EncodingUtils.toMap("key", testPlanKey, "test", testCase); - String jsonResult = requestFactory.get("/api/tests/covered_files", params); - - List files = new ArrayList(); - Map jRoot = (Map) JSONValue.parse(jsonResult); - List maps = (List) jRoot.get("files"); - if (maps != null) { - for (final Map json : maps) { - files.add(new CoveredFile() { - @Override - public String key() { - return JsonUtils.getString(json, "key"); - } - - @Override - public String longName() { - return JsonUtils.getString(json, "longName"); - } - - @Override - public Integer coveredLines() { - return JsonUtils.getInteger(json, "coveredLines"); - } - }); - } - } - return files; - } - - @Override - public TestableTestCases testCases(String fileKey, Integer line) { - Map params = EncodingUtils.toMap("key", fileKey); - params.put("line", line); - String jsonResult = requestFactory.get("/api/tests/test_cases", params); - - Map jRoot = (Map) JSONValue.parse(jsonResult); - final DefaultTestableTestCases testableTestCases = new DefaultTestableTestCases(); - - Map jsonFiles = (Map) jRoot.get("files"); - if (jsonFiles != null) { - for (Map.Entry entry : jsonFiles.entrySet()) { - String ref = entry.getKey(); - final Map file = entry.getValue(); - if (ref != null && file != null) { - testableTestCases.addFile(ref, new TestableTestCases.File() { - @Override - public String key() { - return JsonUtils.getString(file, "key"); - } - - @Override - public String longName() { - return JsonUtils.getString(file, "longName"); - } - - }); - } - } - } - - List tests = (List) jRoot.get("tests"); - if (tests != null) { - for (final Map json : tests) { - final String fileRef = JsonUtils.getString(json, "_ref"); - - testableTestCases.addTest(fileRef, new TestableTestCases.TestCase() { - @Override - public String name() { - return JsonUtils.getString(json, "name"); - } - - @Override - public String status() { - return JsonUtils.getString(json, "status"); - } - - @Override - public Long durationInMs() { - return JsonUtils.getLong(json, "durationInMs"); - } - - }); - } - } - return testableTestCases; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestableTestCases.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestableTestCases.java deleted file mode 100644 index 885ab6abcf3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/DefaultTestableTestCases.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.wsclient.test.internal; - -import org.sonar.wsclient.test.TestableTestCases; - -import javax.annotation.CheckForNull; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DefaultTestableTestCases implements TestableTestCases { - - private final List tests = new ArrayList(); - private final Map filesByRef = new HashMap(); - private final Map filesByTest = new HashMap(); - - @Override - public List tests() { - return tests; - } - - @Override - @CheckForNull - public File fileByTest(String testCase) { - return filesByTest.get(testCase); - } - - @Override - public List files() { - return new ArrayList(filesByRef.values()); - } - - @CheckForNull - public File fileByRef(String ref) { - return filesByRef.get(ref); - } - - public DefaultTestableTestCases addTest(String ref, TestCase testCase) { - tests.add(testCase); - File file = fileByRef(ref); - if (file != null) { - filesByTest.put(testCase.name(), file); - } - return this; - } - - public DefaultTestableTestCases addFile(String ref, File file) { - filesByRef.put(ref, file); - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/package-info.java deleted file mode 100644 index e7ae755dea6..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/internal/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.wsclient.test.internal; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/test/package-info.java deleted file mode 100644 index 578e47ce73b..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/test/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.wsclient.test; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java index 0b04d799b51..3f3c6e53050 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java @@ -20,7 +20,6 @@ package org.sonar.wsclient; import org.junit.Test; -import org.sonar.wsclient.duplication.internal.DefaultDuplicationClient; import org.sonar.wsclient.issue.internal.DefaultActionPlanClient; import org.sonar.wsclient.issue.internal.DefaultIssueClient; import org.sonar.wsclient.permissions.internal.DefaultPermissionClient; @@ -28,10 +27,7 @@ import org.sonar.wsclient.project.internal.DefaultProjectClient; import org.sonar.wsclient.qprofile.internal.DefaultQProfileClient; import org.sonar.wsclient.qualitygate.internal.DefaultQualityGateClient; import org.sonar.wsclient.rule.internal.DefaultRuleClient; -import org.sonar.wsclient.source.internal.DefaultSourceClient; import org.sonar.wsclient.system.internal.DefaultSystemClient; -import org.sonar.wsclient.test.internal.DefaultCoverageClient; -import org.sonar.wsclient.test.internal.DefaultTestClient; import org.sonar.wsclient.user.internal.DefaultUserClient; import static org.fest.assertions.Assertions.assertThat; @@ -49,10 +45,6 @@ public class SonarClientTest { assertThat(client.ruleClient()).isNotNull().isInstanceOf(DefaultRuleClient.class); assertThat(client.qualityGateClient()).isNotNull().isInstanceOf(DefaultQualityGateClient.class); assertThat(client.qProfileClient()).isNotNull().isInstanceOf(DefaultQProfileClient.class); - assertThat(client.sourceClient()).isNotNull().isInstanceOf(DefaultSourceClient.class); - assertThat(client.coverageClient()).isNotNull().isInstanceOf(DefaultCoverageClient.class); - assertThat(client.duplicationClient()).isNotNull().isInstanceOf(DefaultDuplicationClient.class); - assertThat(client.testClient()).isNotNull().isInstanceOf(DefaultTestClient.class); assertThat(client.systemClient()).isNotNull().isInstanceOf(DefaultSystemClient.class); } diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest.java deleted file mode 100644 index d8ed99aa211..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.wsclient.duplication.internal; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.wsclient.MockHttpServerInterceptor; -import org.sonar.wsclient.duplication.*; -import org.sonar.wsclient.internal.HttpRequestFactory; - -import java.io.IOException; -import java.util.List; - -import static org.fest.assertions.Assertions.assertThat; - -public class DefaultDuplicationClientTest { - - @Rule - public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor(); - - @Test - public void show_duplications() throws IOException { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - httpServer.stubResponseBody(Resources.toString(Resources.getResource(this.getClass(), "DefaultDuplicationClientTest/show_duplications.json"), Charsets.UTF_8)); - - DuplicationClient client = new DefaultDuplicationClient(requestFactory); - Duplications result = client.show("MyFile"); - - assertThat(httpServer.requestedPath()).isEqualTo("/api/duplications/show?key=MyFile"); - - List duplications = result.duplications(); - assertThat(duplications).hasSize(1); - - Duplication duplication = duplications.get(0); - assertThat(duplication.blocks()).hasSize(2); - - Block block = duplication.blocks().get(0); - assertThat(block.from()).isEqualTo(94); - assertThat(block.size()).isEqualTo(101); - - File file = block.file(); - assertThat(file.key()).isEqualTo("org.codehaus.sonar:sonar-plugin-api:src/main/java/org/sonar/api/utils/command/CommandExecutor.java"); - assertThat(file.name()).isEqualTo("CommandExecutor"); - assertThat(file.projectName()).isEqualTo("SonarQube"); - - List files = result.files(); - assertThat(files).hasSize(2); - } - -} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/source/internal/DefaultSourceClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/source/internal/DefaultSourceClientTest.java deleted file mode 100644 index b9019f6a03c..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/source/internal/DefaultSourceClientTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.wsclient.source.internal; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.wsclient.MockHttpServerInterceptor; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.source.*; - -import java.io.IOException; -import java.util.List; - -import static org.fest.assertions.Assertions.assertThat; - -public class DefaultSourceClientTest { - - @Rule - public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor(); - - @Test - public void show_source() throws IOException { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - httpServer.stubResponseBody(Resources.toString(Resources.getResource(this.getClass(), "DefaultSourceClientTest/show_source.json"), Charsets.UTF_8)); - - SourceClient client = new DefaultSourceClient(requestFactory); - List sources = client.show(SourceShowQuery.create().setKey("MyFile").setFrom("20").setTo("25")); - - assertThat(httpServer.requestedPath()).isEqualTo("/api/sources/show?key=MyFile&from=20&to=25"); - assertThat(sources).hasSize(6); - assertThat(sources.get(0).lineIndex()).isEqualTo(20); - assertThat(sources.get(0).lineAsHtml()).isEqualTo("package org.sonar.check;"); - } - - @Test - public void return_scm() throws IOException { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - httpServer.stubResponseBody(Resources.toString(Resources.getResource(this.getClass(), "DefaultSourceClientTest/return_scm.json"), Charsets.UTF_8)); - - SourceClient client = new DefaultSourceClient(requestFactory); - List result = client.scm(SourceScmQuery.create().setKey("MyFile").setFrom("1").setTo("3").setGroupCommits(true)); - - assertThat(httpServer.requestedPath()).isEqualTo("/api/sources/scm?key=MyFile&from=1&to=3&group_commits=true"); - assertThat(result).hasSize(3); - assertThat(result.get(0).lineIndex()).isEqualTo(1); - assertThat(result.get(0).author()).isEqualTo("julien"); - assertThat(result.get(0).date().getTime()).isEqualTo(1363129200000L); - } - -} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultCoverageClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultCoverageClientTest.java deleted file mode 100644 index 3ddd1119b5d..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultCoverageClientTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.wsclient.test.internal; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.wsclient.MockHttpServerInterceptor; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.test.Coverage; -import org.sonar.wsclient.test.CoverageClient; -import org.sonar.wsclient.test.CoverageShowQuery; - -import java.io.IOException; -import java.util.List; - -import static org.fest.assertions.Assertions.assertThat; - -public class DefaultCoverageClientTest { - - @Rule - public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor(); - - @Test - public void show_coverage() throws IOException { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - httpServer.stubResponseBody(Resources.toString(Resources.getResource(this.getClass(), "DefaultCoverageClientTest/show_coverage.json"), Charsets.UTF_8)); - - CoverageClient client = new DefaultCoverageClient(requestFactory); - List coverage = client.show(CoverageShowQuery.create().setKey("MyFile").setFrom("20").setTo("25").setType("UT")); - - assertThat(httpServer.requestedPath()).isEqualTo("/api/coverage/show?key=MyFile&from=20&to=25&type=UT"); - assertThat(coverage).hasSize(3); - assertThat(coverage.get(0).lineIndex()).isEqualTo(49); - assertThat(coverage.get(0).isCovered()).isTrue(); - assertThat(coverage.get(0).tests()).isEqualTo(14); - assertThat(coverage.get(0).branches()).isEqualTo(3); - assertThat(coverage.get(0).coveredBranches()).isEqualTo(2); - } - -} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultTestClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultTestClientTest.java deleted file mode 100644 index 9c3d9178694..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/test/internal/DefaultTestClientTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.wsclient.test.internal; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.wsclient.MockHttpServerInterceptor; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.test.CoveredFile; -import org.sonar.wsclient.test.TestCase; -import org.sonar.wsclient.test.TestClient; -import org.sonar.wsclient.test.TestableTestCases; - -import java.io.IOException; -import java.util.List; - -import static org.fest.assertions.Assertions.assertThat; - -public class DefaultTestClientTest { - - @Rule - public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor(); - - @Test - public void show_test_case() throws IOException { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - httpServer.stubResponseBody(Resources.toString(Resources.getResource(this.getClass(), "DefaultTestClientTest/show_test_case.json"), Charsets.UTF_8)); - - TestClient client = new DefaultTestClient(requestFactory); - List tests = client.show("MyTestFile"); - - assertThat(httpServer.requestedPath()).isEqualTo("/api/tests/show?key=MyTestFile"); - assertThat(tests).hasSize(2); - assertThat(tests.get(0).name()).isEqualTo("find_by_params"); - assertThat(tests.get(0).status()).isEqualTo("OK"); - assertThat(tests.get(0).durationInMs()).isEqualTo(10L); - assertThat(tests.get(0).coveredLines()).isEqualTo(89); - } - - @Test - public void test_cases() throws IOException { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - httpServer.stubResponseBody(Resources.toString(Resources.getResource(this.getClass(), "DefaultTestClientTest/test_cases.json"), Charsets.UTF_8)); - - TestClient client = new DefaultTestClient(requestFactory); - TestableTestCases coveringTestCases = client.testCases("MyFile", 10); - - assertThat(httpServer.requestedPath()).isEqualTo("/api/tests/test_cases?key=MyFile&line=10"); - assertThat(coveringTestCases.tests()).hasSize(1); - assertThat(coveringTestCases.files()).hasSize(1); - - TestableTestCases.TestCase testCase = coveringTestCases.tests().get(0); - assertThat(testCase.name()).isEqualTo("find_by_params"); - assertThat(testCase.status()).isEqualTo("OK"); - assertThat(testCase.durationInMs()).isEqualTo(10L); - - TestableTestCases.File file = coveringTestCases.fileByTest("find_by_params"); - assertThat(file.key()).isEqualTo("org.codehaus.sonar:sonar-server:src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java"); - assertThat(file.longName()).isEqualTo("src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java"); - } - - @Test - public void covered_files() throws IOException { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - httpServer.stubResponseBody(Resources.toString(Resources.getResource(this.getClass(), "DefaultTestClientTest/covered_files.json"), Charsets.UTF_8)); - - TestClient client = new DefaultTestClient(requestFactory); - List files = client.coveredFiles("MyTestFile", "find_by_params"); - - assertThat(httpServer.requestedPath()).isEqualTo("/api/tests/covered_files?key=MyTestFile&test=find_by_params"); - assertThat(files).hasSize(2); - - CoveredFile file = files.get(0); - assertThat(file.key()).isEqualTo("org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/paging/PagedResult.java"); - assertThat(file.longName()).isEqualTo("src/main/java/org/sonar/server/paging/PagedResult.java"); - assertThat(file.coveredLines()).isEqualTo(5); - } - -} diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest/show_duplications.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest/show_duplications.json deleted file mode 100644 index 83b36f842ef..00000000000 --- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/duplication/internal/DefaultDuplicationClientTest/show_duplications.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "duplications": [ - { - "blocks": [ - { - "from": 94, - "size": 101, - "_ref": "1" - }, - { - "from": 83, - "size": 101, - "_ref": "2" - } - ] - } - ], - "files": { - "1": { - "key": "org.codehaus.sonar:sonar-plugin-api:src/main/java/org/sonar/api/utils/command/CommandExecutor.java", - "name": "CommandExecutor", - "projectName": "SonarQube" - }, - "2": { - "key": "com.sonarsource.orchestrator:sonar-orchestrator:src/main/java/com/sonar/orchestrator/util/CommandExecutor.java", - "name": "CommandExecutor", - "projectName": "SonarSource :: Orchestrator" - } - } -} diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/return_scm.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/return_scm.json deleted file mode 100644 index 513f3e4a17f..00000000000 --- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/return_scm.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "scm": [ - [1, "julien", "2013-03-13"], - [2, "julien", "2013-03-14"], - [3, "simon", "2014-01-01"] - ] -} diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/show_source.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/show_source.json deleted file mode 100644 index 74ef52f4510..00000000000 --- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/source/internal/DefaultSourceClientTest/show_source.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "sources": [ - [20, "package org.sonar.check;"], - [21, ""], - [22, "public enum Priority {"], - [23, " /**"], - [24, " * WARNING : DO NOT CHANGE THE ENUMERATION ORDER"], - [25, " * the enum ordinal is used for db persistence"] - ] -} diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultCoverageClientTest/show_coverage.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultCoverageClientTest/show_coverage.json deleted file mode 100644 index 8e05f85da30..00000000000 --- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultCoverageClientTest/show_coverage.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "coverage": [ - [49, true, 14, 3, 2], - [52, false, null, null, null], - [72, true, 4, 2, 1] - ] -} diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/covered_files.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/covered_files.json deleted file mode 100644 index ce75518aefa..00000000000 --- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/covered_files.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "files": [ - { - "key": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/paging/PagedResult.java", - "longName": "src/main/java/org/sonar/server/paging/PagedResult.java", - "coveredLines": 5 - }, - { - "key": "org.codehaus.sonar:sonar-server:src/main/java/org/sonar/server/rule/RuleDocumentParser.java", - "longName": "src/main/java/org/sonar/server/rule/RuleDocumentParser.java", - "coveredLines": 38 - } - ] -} diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/show_test_case.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/show_test_case.json deleted file mode 100644 index fd6076387e6..00000000000 --- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/show_test_case.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tests": [ - { - "name": "find_by_params", - "status": "OK", - "durationInMs": 10, - "coveredLines" : 89 - }, - { - "name": "find_rules_by_characteristics", - "status": "ERROR", - "durationInMs": 97, - "coveredLines" : 0 - } - ] -} diff --git a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/test_cases.json b/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/test_cases.json deleted file mode 100644 index fd00ccea046..00000000000 --- a/sonar-ws-client/src/test/resources/org/sonar/wsclient/test/internal/DefaultTestClientTest/test_cases.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tests": [ - { - "_ref": "1", - "name": "find_by_params", - "status": "OK", - "durationInMs": 10 - } - ], - "files": { - "1": { - "key": "org.codehaus.sonar:sonar-server:src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java", - "longName": "src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java" - } - } -} -- 2.39.5