use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class Validation method mustHaveSourceWithAtLeast.
private void mustHaveSourceWithAtLeast(String path, int minLines) {
for (String filePath : toFiles(path)) {
WsResponse response = newAdminWsClient(orchestrator).wsConnector().call(new GetRequest("api/sources/lines").setParam("key", filePathToKey(filePath)));
errorCollector.checkThat("Source is set on file " + filePath, response.isSuccessful(), is(true));
Sources source = Sources.parse(response.content());
if (source != null) {
errorCollector.checkThat("Source is empty on file " + filePath, source.getSources().size(), Matchers.greaterThanOrEqualTo(minLines));
}
}
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class DeprecatedPropertiesWsTest method getProperty.
@CheckForNull
private static Properties.Property getProperty(WsClient wsClient, String key, @Nullable String componentKey, boolean useIdParameter) throws UnsupportedEncodingException {
GetRequest getRequest = useIdParameter ? new GetRequest("api/properties").setParam("id", encode(key, "UTF-8")).setParam("resource", componentKey) : new GetRequest("api/properties/" + encode(key, "UTF-8")).setParam("resource", componentKey);
WsResponse response = wsClient.wsConnector().call(getRequest).failIfNotSuccessful();
Properties.Property[] properties = Properties.parse(response.content());
return Arrays.stream(properties).findFirst().orElseGet(() -> null);
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class UiTest method footer_contains_version.
@Test
public void footer_contains_version() {
WsResponse status = ItUtils.newAdminWsClient(ORCHESTRATOR).wsConnector().call(new GetRequest("api/navigation/global"));
Map<String, Object> statusMap = ItUtils.jsonToMap(status.content());
nav.getFooter().should(hasText((String) statusMap.get("version")));
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class ForceAuthenticationTest method verifyPathDoesNotRequiresAuthentication.
private void verifyPathDoesNotRequiresAuthentication(String path, WsRequest.Method method) {
WsResponse wsResponse = call(anonymousClient, path, method);
assertThat(wsResponse.isSuccessful()).as("code is %s on path %s", wsResponse.code(), path).isTrue();
wsResponse = call(adminWsClient, path, method);
assertThat(wsResponse.isSuccessful()).as("code is %s on path %s", wsResponse.code(), path).isTrue();
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class ServerSystemRestartingOrchestrator method support_install_dir_with_whitespaces.
@Test
public void support_install_dir_with_whitespaces() throws Exception {
String dirName = "target/has space";
FileUtils.deleteDirectory(new File(dirName));
orchestrator = Orchestrator.builderEnv().setOrchestratorProperty("orchestrator.workspaceDir", dirName).build();
orchestrator.start();
WsResponse statusResponse = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/system/status"));
Map<String, Object> json = ItUtils.jsonToMap(statusResponse.content());
assertThat(json.get("status")).isEqualTo("UP");
}
Aggregations