use of org.sonar.alm.client.bitbucketserver.Project in project sonarqube by SonarSource.
the class SearchBitbucketServerReposActionTest method getGsonBBSRepo2.
private Repository getGsonBBSRepo2() {
Repository gsonBBSRepo = new Repository();
gsonBBSRepo.setId(3L);
gsonBBSRepo.setName("repoName2");
Project project = new Project();
project.setName("projectName2");
project.setKey("projectKey2");
project.setId(4L);
gsonBBSRepo.setProject(project);
gsonBBSRepo.setSlug("repo-slug-2");
return gsonBBSRepo;
}
use of org.sonar.alm.client.bitbucketserver.Project in project sonarqube by SonarSource.
the class ImportBitbucketServerProjectActionTest method handle_givenNoDefaultBranchFound_doNotUpdateDefaultBranchName.
@Test
public void handle_givenNoDefaultBranchFound_doNotUpdateDefaultBranchName() {
BranchesList branchesList = new BranchesList();
Branch branch = new Branch("not_a_master", false);
branchesList.addBranch(branch);
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertGitHubAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setUserUuid(user.getUuid());
});
Project project = getGsonBBSProject();
Repository repo = getGsonBBSRepo(project);
when(bitbucketServerRestClient.getRepo(any(), any(), any(), any())).thenReturn(repo);
when(bitbucketServerRestClient.getBranches(any(), any(), any(), any())).thenReturn(branchesList);
Projects.CreateWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).setParam("projectKey", "projectKey").setParam("repositorySlug", "repo-slug").executeProtobuf(Projects.CreateWsResponse.class);
Projects.CreateWsResponse.Project result = response.getProject();
Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
Collection<BranchDto> branchDtos = db.getDbClient().branchDao().selectByProject(db.getSession(), projectDto.get());
List<BranchDto> collect = branchDtos.stream().filter(BranchDto::isMain).collect(Collectors.toList());
String mainBranchName = collect.iterator().next().getKey();
assertThat(mainBranchName).isEqualTo("master");
}
use of org.sonar.alm.client.bitbucketserver.Project in project sonarqube by SonarSource.
the class ImportBitbucketServerProjectActionTest method import_project.
@Test
public void import_project() {
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertGitHubAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setUserUuid(user.getUuid());
});
Project project = getGsonBBSProject();
Repository repo = getGsonBBSRepo(project);
when(bitbucketServerRestClient.getRepo(any(), any(), any(), any())).thenReturn(repo);
when(bitbucketServerRestClient.getBranches(any(), any(), any(), any())).thenReturn(defaultBranchesList);
Projects.CreateWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).setParam("projectKey", "projectKey").setParam("repositorySlug", "repo-slug").executeProtobuf(Projects.CreateWsResponse.class);
Projects.CreateWsResponse.Project result = response.getProject();
assertThat(result.getKey()).isEqualTo(project.getKey() + "_" + repo.getSlug());
assertThat(result.getName()).isEqualTo(repo.getName());
Optional<ProjectDto> projectDto = db.getDbClient().projectDao().selectProjectByKey(db.getSession(), result.getKey());
assertThat(projectDto).isPresent();
assertThat(db.getDbClient().projectAlmSettingDao().selectByProject(db.getSession(), projectDto.get())).isPresent();
}
Aggregations