Package org.sonar.api.server.ws.internal

Examples of org.sonar.api.server.ws.internal.SimpleGetRequest


  DebtModel debtModel = mock(DebtModel.class);

  @Test
  public void toQueryOptions_load_all_fields() throws Exception {
    RuleMapping mapping = new RuleMapping(languages, macroInterpreter, debtModel);
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "1");
    request.setParam("ps", "10");
    QueryContext queryContext = mapping.newQueryOptions(SearchOptions.create(request));

    assertThat(queryContext.getFieldsToReturn()).isEmpty();
  }
View Full Code Here


  }

  @Test
  public void toQueryOptions_load_only_few_simple_fields() throws Exception {
    RuleMapping mapping = new RuleMapping(languages, macroInterpreter, debtModel);
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "1");
    request.setParam("ps", "10");
    request.setParam("f", "repo,name,lang");
    QueryContext queryContext = mapping.newQueryOptions(SearchOptions.create(request));

    assertThat(queryContext.getFieldsToReturn()).containsOnly(
      RuleNormalizer.RuleField.REPOSITORY.field(),
      RuleNormalizer.RuleField.NAME.field(),
View Full Code Here

  }

  @Test
  public void toQueryOptions_langName_requires_lang() throws Exception {
    RuleMapping mapping = new RuleMapping(languages, macroInterpreter, debtModel);
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "1");
    request.setParam("ps", "10");
    request.setParam("f", "langName");
    QueryContext queryContext = mapping.newQueryOptions(SearchOptions.create(request));

    assertThat(queryContext.getFieldsToReturn()).containsOnly(RuleNormalizer.RuleField.LANGUAGE.field());
  }
View Full Code Here

  }

  @Test
  public void toQueryOptions_debt_requires_group_of_fields() throws Exception {
    RuleMapping mapping = new RuleMapping(languages, macroInterpreter, debtModel);
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "1");
    request.setParam("ps", "10");
    request.setParam("f", "debtRemFn");
    QueryContext queryContext = mapping.newQueryOptions(SearchOptions.create(request));

    assertThat(queryContext.getFieldsToReturn()).containsOnly(
      RuleNormalizer.RuleField.DEBT_FUNCTION_COEFFICIENT.field(),
      RuleNormalizer.RuleField.DEBT_FUNCTION_OFFSET.field(),
View Full Code Here

  }

  @Test
  public void toQueryOptions_html_note_requires_markdown_note() throws Exception {
    RuleMapping mapping = new RuleMapping(languages, macroInterpreter, debtModel);
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "1");
    request.setParam("ps", "10");
    request.setParam("f", "htmlNote");
    QueryContext queryContext = mapping.newQueryOptions(SearchOptions.create(request));

    assertThat(queryContext.getFieldsToReturn()).containsOnly(RuleNormalizer.RuleField.NOTE.field());
  }
View Full Code Here

  }

  @Test
  public void toQueryOptions_debt_characteristics() throws Exception {
    RuleMapping mapping = new RuleMapping(languages, macroInterpreter, debtModel);
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "1");
    request.setParam("ps", "10");
    request.setParam("f", "debtChar");
    QueryContext queryContext = mapping.newQueryOptions(SearchOptions.create(request));

    assertThat(queryContext.getFieldsToReturn()).containsOnly(
      RuleNormalizer.RuleField.CHARACTERISTIC.field(),
      RuleNormalizer.RuleField.DEFAULT_CHARACTERISTIC.field());
View Full Code Here

public class SearchOptionsTest {

  @Test
  public void create_from_http_request() throws Exception {
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "3");
    request.setParam("ps", "10");
    request.setParam("f", "name,repo");
    request.setParam("severities", "BLOCKER");

    SearchOptions options = SearchOptions.create(request);

    assertThat(options.fields()).containsOnly("name", "repo");
    assertThat(options.page()).isEqualTo(3);
View Full Code Here

    assertThat(options.pageSize()).isEqualTo(10);
  }

  @Test
  public void hasField() throws Exception {
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "3");
    request.setParam("ps", "10");
    request.setParam("f", "name,repo");
    SearchOptions options = SearchOptions.create(request);

    assertThat(options.hasField("repo")).isTrue();
    assertThat(options.hasField("severity")).isFalse();
  }
View Full Code Here

    assertThat(options.hasField("severity")).isFalse();
  }

  @Test
  public void hasField_always_true_by_default() throws Exception {
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "3");
    request.setParam("ps", "10");
    SearchOptions options = SearchOptions.create(request);

    assertThat(options.hasField("repo")).isTrue();
  }
View Full Code Here

    assertThat(options.hasField("repo")).isTrue();
  }

  @Test
  public void hasField_no_if_empty_value() throws Exception {
    SimpleGetRequest request = new SimpleGetRequest();
    request.setParam("p", "3");
    request.setParam("ps", "10");
    request.setParam("f", "");
    SearchOptions options = SearchOptions.create(request);

    assertThat(options.hasField("repo")).isFalse();
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.server.ws.internal.SimpleGetRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.