Search in sources :

Example 1 with ComponentWsRequest

use of org.sonarqube.ws.client.measure.ComponentWsRequest in project sonarqube by SonarSource.

the class MeasuresWsTest method component.

@Test
public void component() {
    scanXooSample();
    ComponentWsResponse response = wsClient.measures().component(new ComponentWsRequest().setComponentKey("sample").setMetricKeys(singletonList("ncloc")).setAdditionalFields(newArrayList("metrics", "periods")));
    WsMeasures.Component component = response.getComponent();
    assertThat(component.getKey()).isEqualTo("sample");
    assertThat(component.getMeasuresList()).isNotEmpty();
    assertThat(response.getMetrics().getMetricsList()).extracting("key").containsOnly("ncloc");
}
Also used : ComponentWsResponse(org.sonarqube.ws.WsMeasures.ComponentWsResponse) WsMeasures(org.sonarqube.ws.WsMeasures) ComponentWsRequest(org.sonarqube.ws.client.measure.ComponentWsRequest) Test(org.junit.Test)

Example 2 with ComponentWsRequest

use of org.sonarqube.ws.client.measure.ComponentWsRequest in project sonarqube by SonarSource.

the class ComponentAction method toComponentWsRequest.

private static ComponentWsRequest toComponentWsRequest(Request request) {
    ComponentWsRequest componentWsRequest = new ComponentWsRequest().setComponentId(request.param(PARAM_COMPONENT_ID)).setComponentKey(request.param(PARAM_COMPONENT_KEY)).setAdditionalFields(request.paramAsStrings(PARAM_ADDITIONAL_FIELDS)).setMetricKeys(request.mandatoryParamAsStrings(PARAM_METRIC_KEYS)).setDeveloperId(request.param(PARAM_DEVELOPER_ID)).setDeveloperKey(request.param(PARAM_DEVELOPER_KEY));
    checkRequest(!componentWsRequest.getMetricKeys().isEmpty(), "At least one metric key must be provided");
    return componentWsRequest;
}
Also used : ComponentWsRequest(org.sonarqube.ws.client.measure.ComponentWsRequest)

Example 3 with ComponentWsRequest

use of org.sonarqube.ws.client.measure.ComponentWsRequest in project sonarqube by SonarSource.

the class LiteTest method call_measures_ws.

@Test
public void call_measures_ws() {
    // project measures
    WsMeasures.ComponentWsResponse component = wsClient.measures().component(new ComponentWsRequest().setComponentKey(PROJECT_KEY).setMetricKeys(asList("lines", "ncloc", "files")));
    assertThat(component.getComponent().getMeasuresCount()).isEqualTo(3);
    // file measures
    WsMeasures.ComponentTreeWsResponse tree = wsClient.measures().componentTree(new ComponentTreeWsRequest().setBaseComponentKey(PROJECT_KEY).setQualifiers(singletonList("FIL")).setMetricKeys(asList("lines", "ncloc")));
    assertThat(tree.getComponentsCount()).isEqualTo(4);
    tree.getComponentsList().forEach(c -> {
        assertThat(c.getMeasuresList()).extracting(m -> m.getMetric()).containsOnly("lines", "ncloc");
    });
}
Also used : BeforeClass(org.junit.BeforeClass) Issues(org.sonarqube.ws.Issues) ComponentWsRequest(org.sonarqube.ws.client.measure.ComponentWsRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) WsMeasures(org.sonarqube.ws.WsMeasures) Collections.singletonList(java.util.Collections.singletonList) WsClient(org.sonarqube.ws.client.WsClient) Arrays.asList(java.util.Arrays.asList) CollectionCondition(com.codeborne.selenide.CollectionCondition) ClassRule(org.junit.ClassRule) WsComponents(org.sonarqube.ws.WsComponents) Condition(com.codeborne.selenide.Condition) TreeWsRequest(org.sonarqube.ws.client.component.TreeWsRequest) Condition.hasText(com.codeborne.selenide.Condition.hasText) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) ItUtils.runProjectAnalysis(util.ItUtils.runProjectAnalysis) RulesPage(pageobjects.RulesPage) Test(org.junit.Test) ItUtils.xooPlugin(util.ItUtils.xooPlugin) Navigation(pageobjects.Navigation) RuleItem(pageobjects.RuleItem) Condition.or(com.codeborne.selenide.Condition.or) SearchWsRequest(org.sonarqube.ws.client.issue.SearchWsRequest) ItUtils(util.ItUtils) Orchestrator(com.sonar.orchestrator.Orchestrator) WsMeasures(org.sonarqube.ws.WsMeasures) ComponentTreeWsRequest(org.sonarqube.ws.client.measure.ComponentTreeWsRequest) ComponentWsRequest(org.sonarqube.ws.client.measure.ComponentWsRequest) Test(org.junit.Test)

Aggregations

ComponentWsRequest (org.sonarqube.ws.client.measure.ComponentWsRequest)3 Test (org.junit.Test)2 WsMeasures (org.sonarqube.ws.WsMeasures)2 CollectionCondition (com.codeborne.selenide.CollectionCondition)1 Condition (com.codeborne.selenide.Condition)1 Condition.hasText (com.codeborne.selenide.Condition.hasText)1 Condition.or (com.codeborne.selenide.Condition.or)1 Orchestrator (com.sonar.orchestrator.Orchestrator)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 BeforeClass (org.junit.BeforeClass)1 ClassRule (org.junit.ClassRule)1 Issues (org.sonarqube.ws.Issues)1 WsComponents (org.sonarqube.ws.WsComponents)1 ComponentWsResponse (org.sonarqube.ws.WsMeasures.ComponentWsResponse)1 WsClient (org.sonarqube.ws.client.WsClient)1 TreeWsRequest (org.sonarqube.ws.client.component.TreeWsRequest)1 SearchWsRequest (org.sonarqube.ws.client.issue.SearchWsRequest)1 ComponentTreeWsRequest (org.sonarqube.ws.client.measure.ComponentTreeWsRequest)1