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