use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class SearchAzureReposActionTest method search_repos_with_same_name_and_different_project.
@Test
public void search_repos_with_same_name_and_different_project() {
mockClient(new GsonAzureRepoList(ImmutableList.of(getGsonAzureRepo("project-1", "repoName-1"), getGsonAzureRepo("project-2", "repoName-1"))));
AlmSettingDto almSetting = insertAlmSetting();
ProjectDto projectDto1 = insertProject(almSetting, "repoName-1", "project-1");
ProjectDto projectDto2 = insertProject(almSetting, "repoName-1", "project-2");
SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchAzureReposWsResponse.class);
assertThat(response.getRepositoriesCount()).isEqualTo(2);
assertThat(response.getRepositoriesList()).extracting(AzureRepo::getName, AzureRepo::getProjectName, AzureRepo::getSqProjectKey, AzureRepo::getSqProjectName).containsExactlyInAnyOrder(tuple("repoName-1", "project-1", projectDto1.getKey(), projectDto1.getName()), tuple("repoName-1", "project-2", projectDto2.getKey(), projectDto2.getName()));
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class SearchAzureReposActionTest method search_repos_with_project_already_set_up.
@Test
public void search_repos_with_project_already_set_up() {
AlmSettingDto almSetting = insertAlmSetting();
ProjectDto projectDto2 = insertProject(almSetting, "repoName-2", "project-2");
SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchAzureReposWsResponse.class);
assertThat(response.getRepositoriesCount()).isEqualTo(2);
assertThat(response.getRepositoriesList()).extracting(AzureRepo::getName, AzureRepo::getProjectName, AzureRepo::getSqProjectKey, AzureRepo::getSqProjectName).containsExactlyInAnyOrder(tuple("repoName-1", "project-1", "", ""), tuple("repoName-2", "project-2", projectDto2.getKey(), projectDto2.getName()));
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class SearchBitbucketCloudReposActionTest method use_projectKey_to_disambiguate_when_multiple_projects_are_binded_on_one_bitbucket_repo.
@Test
public void use_projectKey_to_disambiguate_when_multiple_projects_are_binded_on_one_bitbucket_repo() {
when(bitbucketCloudRestClient.searchRepos(any(), any(), any(), any(), any())).thenReturn(getRepositoryList());
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertBitbucketCloudAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setUserUuid(user.getUuid());
});
ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("B"));
ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("A"));
db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project1, s -> s.setAlmRepo("repo-slug-2"));
db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project2, s -> s.setAlmRepo("repo-slug-2"));
SearchBitbucketcloudReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchBitbucketcloudReposWsResponse.class);
assertThat(response.getRepositoriesList()).extracting(BBCRepo::getUuid, BBCRepo::getName, BBCRepo::getSlug, BBCRepo::getProjectKey, BBCRepo::getSqProjectKey).containsExactlyInAnyOrder(tuple("REPO-UUID-ONE", "repoName1", "repo-slug-1", "projectKey1", ""), tuple("REPO-UUID-TWO", "repoName2", "repo-slug-2", "projectKey2", "A"));
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class SearchBitbucketCloudReposActionTest method list_repos.
@Test
public void list_repos() {
when(bitbucketCloudRestClient.searchRepos(any(), any(), any(), any(), any())).thenReturn(getRepositoryList());
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertBitbucketCloudAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setPersonalAccessToken("abc:xyz");
dto.setUserUuid(user.getUuid());
});
ProjectDto projectDto = db.components().insertPrivateProjectDto();
db.almSettings().insertBitbucketCloudProjectAlmSetting(almSetting, projectDto, s -> s.setAlmRepo("repo-slug-2"));
SearchBitbucketcloudReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).setParam("p", "1").setParam("ps", "100").executeProtobuf(SearchBitbucketcloudReposWsResponse.class);
assertThat(response.getIsLastPage()).isFalse();
assertThat(response.getPaging().getPageIndex()).isOne();
assertThat(response.getPaging().getPageSize()).isEqualTo(100);
assertThat(response.getRepositoriesList()).extracting(BBCRepo::getUuid, BBCRepo::getName, BBCRepo::getSlug, BBCRepo::getProjectKey, BBCRepo::getSqProjectKey, BBCRepo::getWorkspace).containsExactlyInAnyOrder(tuple("REPO-UUID-ONE", "repoName1", "repo-slug-1", "projectKey1", "", almSetting.getAppId()), tuple("REPO-UUID-TWO", "repoName2", "repo-slug-2", "projectKey2", projectDto.getKey(), almSetting.getAppId()));
}
use of org.sonar.db.project.ProjectDto in project sonarqube by SonarSource.
the class SearchBitbucketServerReposActionTest method list_repos.
@Test
public void list_repos() {
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertBitbucketAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setUserUuid(user.getUuid());
});
ProjectDto projectDto = db.components().insertPrivateProjectDto();
db.almSettings().insertBitbucketProjectAlmSetting(almSetting, projectDto, s -> s.setAlmRepo("projectKey2"), s -> s.setAlmSlug("repo-slug-2"));
AlmIntegrations.SearchBitbucketserverReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchBitbucketserverReposWsResponse.class);
assertThat(response.getIsLastPage()).isTrue();
assertThat(response.getRepositoriesList()).extracting(AlmIntegrations.BBSRepo::getId, AlmIntegrations.BBSRepo::getName, AlmIntegrations.BBSRepo::getSlug, AlmIntegrations.BBSRepo::hasSqProjectKey, AlmIntegrations.BBSRepo::getSqProjectKey, AlmIntegrations.BBSRepo::getProjectKey).containsExactlyInAnyOrder(tuple(1L, "repoName1", "repo-slug-1", false, "", "projectKey1"), tuple(3L, "repoName2", "repo-slug-2", true, projectDto.getKey(), "projectKey2"));
}
Aggregations