Search in sources :

Example 1 with ShowWsRequest

use of org.sonarqube.ws.client.component.ShowWsRequest in project sonarqube by SonarSource.

the class ProjectsWsTest method update_key.

@Test
public void update_key() {
    String newProjectKey = "another_project_key";
    WsComponents.Component project = wsClient.components().show(new ShowWsRequest().setKey(PROJECT_KEY)).getComponent();
    assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
    wsClient.projects().updateKey(UpdateKeyWsRequest.builder().setKey(PROJECT_KEY).setNewKey(newProjectKey).build());
    assertThat(wsClient.components().show(new ShowWsRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
}
Also used : WsComponents(org.sonarqube.ws.WsComponents) ShowWsRequest(org.sonarqube.ws.client.component.ShowWsRequest) Test(org.junit.Test)

Example 2 with ShowWsRequest

use of org.sonarqube.ws.client.component.ShowWsRequest in project sonarqube by SonarSource.

the class ProjectsWsTest method bulk_update_key.

@Test
public void bulk_update_key() {
    String newProjectKey = "another_project_key";
    WsComponents.Component project = wsClient.components().show(new ShowWsRequest().setKey(PROJECT_KEY)).getComponent();
    assertThat(project.getKey()).isEqualTo(PROJECT_KEY);
    BulkUpdateKeyWsResponse result = wsClient.projects().bulkUpdateKey(BulkUpdateKeyWsRequest.builder().setKey(PROJECT_KEY).setFrom(PROJECT_KEY).setTo(newProjectKey).build());
    assertThat(wsClient.components().show(new ShowWsRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey);
    assertThat(result.getKeysCount()).isEqualTo(1);
    assertThat(result.getKeys(0)).extracting(Key::getKey, Key::getNewKey, Key::getDuplicate).containsOnlyOnce(PROJECT_KEY, newProjectKey, false);
}
Also used : WsComponents(org.sonarqube.ws.WsComponents) ShowWsRequest(org.sonarqube.ws.client.component.ShowWsRequest) BulkUpdateKeyWsResponse(org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse) Test(org.junit.Test)

Example 3 with ShowWsRequest

use of org.sonarqube.ws.client.component.ShowWsRequest in project sonarqube by SonarSource.

the class ShowAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    ShowWsRequest showWsRequest = toShowWsRequest(request);
    ShowWsResponse showWsResponse = doHandle(showWsRequest);
    writeProtobuf(showWsResponse, request, response);
}
Also used : ShowWsRequest(org.sonarqube.ws.client.component.ShowWsRequest) ShowWsResponse(org.sonarqube.ws.WsComponents.ShowWsResponse)

Aggregations

ShowWsRequest (org.sonarqube.ws.client.component.ShowWsRequest)3 Test (org.junit.Test)2 WsComponents (org.sonarqube.ws.WsComponents)2 ShowWsResponse (org.sonarqube.ws.WsComponents.ShowWsResponse)1 BulkUpdateKeyWsResponse (org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse)1