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");
}
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;
}
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");
});
}
Aggregations