]> source.dussan.org Git - sonarqube.git/commitdiff
Remove dead code
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 16 May 2016 12:25:52 +0000 (14:25 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 16 May 2016 12:47:00 +0000 (14:47 +0200)
server/sonar-server/src/main/java/org/sonar/server/search/ws/BaseMapping.java
server/sonar-server/src/test/java/org/sonar/server/search/ws/SearchOptionsTest.java [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-clean.zip [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-corrupt.zip [deleted file]

index 3438f6a7f9f5a683d40ff3c4faa1cb5ddc660818..3009997005d7dccc64cb8b09b4b74df7b7d9f068 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.search.ws;
 import com.google.common.collect.LinkedHashMultimap;
 import com.google.common.collect.Multimap;
 import java.util.Arrays;
-import java.util.List;
 import java.util.Set;
 import javax.annotation.Nullable;
 import org.sonar.api.server.ServerSide;
@@ -52,18 +51,6 @@ public abstract class BaseMapping<DOC extends BaseDoc, CTX> {
     return mappers.keySet();
   }
 
-  public org.sonar.server.es.SearchOptions newQueryOptions(SearchOptions options) {
-    org.sonar.server.es.SearchOptions result = new org.sonar.server.es.SearchOptions();
-    result.setPage(options.page(), options.pageSize());
-    List<String> optionFields = options.fields();
-    if (optionFields != null) {
-      for (String optionField : optionFields) {
-        result.addFields(indexFieldsByWsFields.get(optionField));
-      }
-    }
-    return result;
-  }
-
   /**
    * Write only requested document fields
    */
@@ -89,18 +76,10 @@ public abstract class BaseMapping<DOC extends BaseDoc, CTX> {
     return map(key, new IndexStringMapper(key, indexKey));
   }
 
-  protected BaseMapping mapBoolean(String key, String indexKey) {
-    return map(key, new IndexBooleanMapper(key, indexKey));
-  }
-
   protected BaseMapping mapDateTime(String key, String indexKey) {
     return map(key, new IndexDatetimeMapper(key, indexKey));
   }
 
-  protected BaseMapping mapArray(String key, String indexKey) {
-    return map(key, new IndexArrayMapper(key, indexKey));
-  }
-
   protected BaseMapping map(String key, Mapper mapper) {
     mappers.put(key, mapper);
     if (mapper instanceof IndexMapper) {
@@ -148,38 +127,6 @@ public abstract class BaseMapping<DOC extends BaseDoc, CTX> {
     }
   }
 
-  public static class IndexBooleanMapper<DOC extends BaseDoc, CTX> extends IndexMapper<DOC, CTX> {
-    private final String key;
-
-    public IndexBooleanMapper(String key, String indexKey) {
-      super(indexKey);
-      this.key = key;
-    }
-
-    @Override
-    public void write(JsonWriter json, DOC doc, CTX context) {
-      Boolean val = doc.getNullableField(indexFields[0]);
-      json.prop(key, val != null ? val.booleanValue() : null);
-    }
-  }
-
-  public static class IndexArrayMapper<DOC extends BaseDoc, CTX> extends IndexMapper<DOC, CTX> {
-    private final String key;
-
-    public IndexArrayMapper(String key, String indexKey) {
-      super(indexKey);
-      this.key = key;
-    }
-
-    @Override
-    public void write(JsonWriter json, DOC doc, CTX context) {
-      Iterable<String> values = doc.getNullableField(indexFields[0]);
-      if (values != null) {
-        json.name(key).beginArray().values(values).endArray();
-      }
-    }
-  }
-
   public static class IndexDatetimeMapper<DOC extends BaseDoc, CTX> extends IndexMapper<DOC, CTX> {
     private final String key;
 
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/ws/SearchOptionsTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/ws/SearchOptionsTest.java
deleted file mode 100644 (file)
index 6bac7a5..0000000
+++ /dev/null
@@ -1,159 +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.server.search.ws;
-
-import com.google.common.collect.Lists;
-import java.io.StringWriter;
-import org.junit.Test;
-import org.sonar.api.server.ws.RequestHandler;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.server.ws.WebService.Param;
-import org.sonar.api.server.ws.internal.SimpleGetRequest;
-import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.server.search.QueryContext;
-import org.sonar.server.search.Result;
-import org.sonar.test.JsonAssert;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class SearchOptionsTest {
-
-  @Test
-  public void create_from_http_request() {
-    SimpleGetRequest request = new SimpleGetRequest();
-    request.setParam(Param.PAGE, "3");
-    request.setParam(Param.PAGE_SIZE, "10");
-    request.setParam(Param.FIELDS, "name,repo");
-    request.setParam("severities", "BLOCKER");
-
-    SearchOptions options = SearchOptions.create(request);
-
-    assertThat(options.fields()).containsOnly("name", "repo");
-    assertThat(options.page()).isEqualTo(3);
-    assertThat(options.pageSize()).isEqualTo(10);
-  }
-
-  @Test
-  public void hasField() {
-    SimpleGetRequest request = new SimpleGetRequest();
-    request.setParam(Param.PAGE, "3");
-    request.setParam(Param.PAGE_SIZE, "10");
-    request.setParam(Param.FIELDS, "name,repo");
-    SearchOptions options = SearchOptions.create(request);
-
-    assertThat(options.hasField("repo")).isTrue();
-    assertThat(options.hasField("severity")).isFalse();
-  }
-
-  @Test
-  public void hasField_always_true_by_default() {
-    SimpleGetRequest request = new SimpleGetRequest();
-    request.setParam(Param.PAGE, "3");
-    request.setParam(Param.PAGE_SIZE, "10");
-    SearchOptions options = SearchOptions.create(request);
-
-    assertThat(options.hasField("repo")).isTrue();
-  }
-
-  @Test
-  public void hasField_no_if_empty_value() {
-    SimpleGetRequest request = new SimpleGetRequest();
-    request.setParam(Param.PAGE, "3");
-    request.setParam(Param.PAGE_SIZE, "10");
-    request.setParam(Param.FIELDS, "");
-    SearchOptions options = SearchOptions.create(request);
-
-    assertThat(options.hasField("repo")).isFalse();
-  }
-
-  @Test
-  public void write_statistics_to_json_response() {
-    SimpleGetRequest request = new SimpleGetRequest();
-    request.setParam(Param.PAGE, "3");
-    request.setParam(Param.PAGE_SIZE, "10");
-    request.setParam(Param.FIELDS, "name,repo");
-    request.setParam("severities", "BLOCKER");
-
-    SearchOptions options = SearchOptions.create(request);
-    StringWriter json = new StringWriter();
-    JsonWriter jsonWriter = JsonWriter.of(json).beginObject();
-    Result result = mock(Result.class);
-    when(result.getTotal()).thenReturn(42L);
-    options.writeStatistics(jsonWriter, result);
-    jsonWriter.endObject().close();
-
-    JsonAssert.assertJson(json.toString()).isSimilarTo("{\"total\": 42, \"p\": 3, \"ps\": 10}");
-  }
-
-  @Test
-  public void defineFieldsParam() {
-    WebService.Context context = new WebService.Context();
-    new WebService() {
-      @Override
-      public void define(Context context) {
-        NewController newController = context.createController("api/foo");
-        NewAction action = newController
-          .createAction("search")
-          .setSince("5.3")
-          .setDescription("Search Description")
-          .setPost(true)
-          .setHandler(mock(RequestHandler.class));
-        SearchOptions.defineFieldsParam(action, Lists.newArrayList("name", "lang", "severity"));
-        newController.done();
-      }
-    }.define(context);
-
-    WebService.Action searchAction = context.controller("api/foo").action("search");
-    Param param = searchAction.param(Param.FIELDS);
-    assertThat(param).isNotNull();
-    assertThat(param.possibleValues()).containsOnly("name", "lang", "severity");
-    assertThat(param.exampleValue()).isEqualTo("name,lang");
-  }
-
-  @Test
-  public void definePageParams() {
-    WebService.Context context = new WebService.Context();
-    new WebService() {
-      @Override
-      public void define(Context context) {
-        NewController newController = context.createController("api/foo");
-        NewAction action = newController
-          .createAction("search")
-          .setSince("5.3")
-          .setDescription("Search Description")
-          .setPost(true)
-          .setHandler(mock(RequestHandler.class));
-        SearchOptions.definePageParams(action);
-        newController.done();
-      }
-    }.define(context);
-
-    WebService.Action searchAction = context.controller("api/foo").action("search");
-    Param page = searchAction.param(Param.PAGE);
-    assertThat(page).isNotNull();
-    assertThat(page.defaultValue()).isEqualTo("1");
-    Param pageSize = searchAction.param(Param.PAGE_SIZE);
-    assertThat(pageSize).isNotNull();
-    assertThat(pageSize.defaultValue()).isEqualTo("" + QueryContext.DEFAULT_LIMIT);
-
-  }
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-clean.zip b/server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-clean.zip
deleted file mode 100644 (file)
index 66aaf5e..0000000
Binary files a/server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-clean.zip and /dev/null differ
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-corrupt.zip b/server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-corrupt.zip
deleted file mode 100644 (file)
index 37abade..0000000
Binary files a/server/sonar-server/src/test/resources/org/sonar/server/search/ESNodeTest/data-es-corrupt.zip and /dev/null differ