Search in sources :

Example 1 with BulkUpdateKeyWsResponse

use of org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse in project sonarqube by SonarSource.

the class BulkUpdateKeyActionTest method dry_run_by_key.

@Test
public void dry_run_by_key() {
    insertMyProject();
    BulkUpdateKeyWsResponse result = callDryRunByKey(MY_PROJECT_KEY, FROM, TO);
    assertThat(result.getKeysCount()).isEqualTo(1);
    assertThat(result.getKeys(0).getNewKey()).isEqualTo("your_project");
}
Also used : BulkUpdateKeyWsResponse(org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse) Test(org.junit.Test)

Example 2 with BulkUpdateKeyWsResponse

use of org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse 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 BulkUpdateKeyWsResponse

use of org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse in project sonarqube by SonarSource.

the class BulkUpdateKeyActionTest method bulk_update_project_key.

@Test
public void bulk_update_project_key() {
    ComponentDto project = insertMyProject();
    ComponentDto module = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:module"));
    ComponentDto inactiveModule = componentDb.insertComponent(newModuleDto(project).setKey("my_project:root:inactive_module").setEnabled(false));
    ComponentDto file = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/File.xoo"));
    ComponentDto inactiveFile = componentDb.insertComponent(newFileDto(module, null).setKey("my_project:root:module:src/InactiveFile.xoo").setEnabled(false));
    BulkUpdateKeyWsResponse result = callByUuid(project.uuid(), FROM, TO);
    assertThat(result.getKeysCount()).isEqualTo(2);
    assertThat(result.getKeysList()).extracting(Key::getKey, Key::getNewKey, Key::getDuplicate).containsExactly(tuple(project.key(), "your_project", false), tuple(module.key(), "your_project:root:module", false));
    verify(componentService).bulkUpdateKey(any(DbSession.class), eq(project.uuid()), eq(FROM), eq(TO));
}
Also used : DbSession(org.sonar.db.DbSession) ComponentDto(org.sonar.db.component.ComponentDto) BulkUpdateKeyWsResponse(org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 BulkUpdateKeyWsResponse (org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse)3 DbSession (org.sonar.db.DbSession)1 ComponentDto (org.sonar.db.component.ComponentDto)1 WsComponents (org.sonarqube.ws.WsComponents)1 ShowWsRequest (org.sonarqube.ws.client.component.ShowWsRequest)1