use of org.sonarqube.ws.NewCodePeriods.ShowWSResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_branch_setting.
@Test
public void show_branch_setting() {
ComponentDto project = componentDb.insertPublicProject();
logInAsProjectAdministrator(project);
ComponentDto branch = componentDb.insertProjectBranch(project, b -> b.setKey("branch"));
tester.insert(new NewCodePeriodDto().setProjectUuid(project.uuid()).setBranchUuid(branch.uuid()).setType(NewCodePeriodType.NUMBER_OF_DAYS).setValue("1"));
ShowWSResponse response = ws.newRequest().setParam("project", project.getKey()).setParam("branch", "branch").executeProtobuf(ShowWSResponse.class);
assertResponse(response, project.getKey(), "branch", NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS, "1", false);
}
use of org.sonarqube.ws.NewCodePeriods.ShowWSResponse in project sonarqube by SonarSource.
the class ListActionTest method list_branch_and_inherited_global_settings.
@Test
public void list_branch_and_inherited_global_settings() {
ComponentDto project = componentDb.insertPublicProject();
ComponentDto branchWithOwnSettings = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("OWN_SETTINGS"));
componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("GLOBAL_SETTINGS"));
tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("global_uuid"));
tester.insert(new NewCodePeriodDto().setProjectUuid(project.uuid()).setBranchUuid(branchWithOwnSettings.uuid()).setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("branch_uuid"));
logInAsProjectAdministrator(project);
ListWSResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWSResponse.class);
assertThat(response).isNotNull();
assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey).contains("master", "OWN_SETTINGS", "GLOBAL_SETTINGS");
Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream().filter(s -> !s.getInherited()).findFirst();
assertThat(ownSettings).isNotNull();
assertThat(ownSettings).isNotEmpty();
assertThat(ownSettings.get().getProjectKey()).isEqualTo(project.getKey());
assertThat(ownSettings.get().getBranchKey()).isEqualTo("OWN_SETTINGS");
assertThat(ownSettings.get().getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
assertThat(ownSettings.get().getValue()).isEqualTo("branch_uuid");
assertThat(ownSettings.get().getInherited()).isFalse();
// check if global default is set
assertThat(response.getNewCodePeriodsList()).filteredOn(ShowWSResponse::getInherited).extracting(ShowWSResponse::getType).contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
assertThat(response.getNewCodePeriodsList()).filteredOn(ShowWSResponse::getInherited).extracting(ShowWSResponse::getValue).contains("global_uuid");
}
use of org.sonarqube.ws.NewCodePeriods.ShowWSResponse in project sonarqube by SonarSource.
the class ListActionTest method list_branch_and_inherited_project_settings.
@Test
public void list_branch_and_inherited_project_settings() {
ComponentDto project = componentDb.insertPublicProject();
ComponentDto branchWithOwnSettings = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("OWN_SETTINGS"));
componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("PROJECT_SETTINGS"));
tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("global_uuid"));
tester.insert(new NewCodePeriodDto().setProjectUuid(project.uuid()).setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("project_uuid"));
tester.insert(new NewCodePeriodDto().setProjectUuid(project.uuid()).setBranchUuid(branchWithOwnSettings.uuid()).setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("branch_uuid"));
logInAsProjectAdministrator(project);
ListWSResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWSResponse.class);
assertThat(response).isNotNull();
assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey).contains("master", "OWN_SETTINGS", "PROJECT_SETTINGS");
Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream().filter(s -> !s.getInherited()).findFirst();
assertThat(ownSettings).isNotNull();
assertThat(ownSettings).isNotEmpty();
assertThat(ownSettings.get().getProjectKey()).isEqualTo(project.getKey());
assertThat(ownSettings.get().getBranchKey()).isEqualTo("OWN_SETTINGS");
assertThat(ownSettings.get().getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
assertThat(ownSettings.get().getValue()).isEqualTo("branch_uuid");
assertThat(ownSettings.get().getInherited()).isFalse();
// check if global default is set
assertThat(response.getNewCodePeriodsList()).filteredOn(ShowWSResponse::getInherited).extracting(ShowWSResponse::getType).contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
assertThat(response.getNewCodePeriodsList()).filteredOn(ShowWSResponse::getInherited).extracting(ShowWSResponse::getValue).contains("project_uuid");
}
use of org.sonarqube.ws.NewCodePeriods.ShowWSResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_project_setting.
@Test
public void show_project_setting() {
ComponentDto project = componentDb.insertPublicProject();
logInAsProjectAdministrator(project);
tester.insert(new NewCodePeriodDto().setProjectUuid(project.uuid()).setType(NewCodePeriodType.NUMBER_OF_DAYS).setValue("4"));
ShowWSResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ShowWSResponse.class);
assertResponse(response, project.getKey(), "", NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS, "4", false);
}
use of org.sonarqube.ws.NewCodePeriods.ShowWSResponse in project sonarqube by SonarSource.
the class ShowActionTest method show_inherited_branch_setting_from_project.
@Test
public void show_inherited_branch_setting_from_project() {
ComponentDto project = componentDb.insertPublicProject();
logInAsProjectAdministrator(project);
ComponentDto branch = componentDb.insertProjectBranch(project, b -> b.setKey("branch"));
tester.insert(new NewCodePeriodDto().setProjectUuid(project.uuid()).setType(NewCodePeriodType.NUMBER_OF_DAYS).setValue("1"));
ShowWSResponse response = ws.newRequest().setParam("project", project.getKey()).setParam("branch", "branch").executeProtobuf(ShowWSResponse.class);
assertResponse(response, project.getKey(), "branch", NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS, "1", true);
}
Aggregations