Search in sources :

Example 11 with NewCodePeriodDto

use of org.sonar.db.newcodeperiod.NewCodePeriodDto in project sonarqube by SonarSource.

the class ShowActionTest method show_inherited_branch_setting_from_global.

@Test
public void show_inherited_branch_setting_from_global() {
    ComponentDto project = componentDb.insertPublicProject();
    logInAsProjectAdministrator(project);
    ComponentDto branch = componentDb.insertProjectBranch(project, b -> b.setKey("branch"));
    tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.NUMBER_OF_DAYS).setValue("3"));
    ShowWSResponse response = ws.newRequest().setParam("project", project.getKey()).setParam("branch", "branch").executeProtobuf(ShowWSResponse.class);
    assertResponse(response, project.getKey(), "branch", NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS, "3", true);
}
Also used : NewCodePeriodDto(org.sonar.db.newcodeperiod.NewCodePeriodDto) ShowWSResponse(org.sonarqube.ws.NewCodePeriods.ShowWSResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 12 with NewCodePeriodDto

use of org.sonar.db.newcodeperiod.NewCodePeriodDto in project sonarqube by SonarSource.

the class ShowActionTest method show_inherited_project_setting.

@Test
public void show_inherited_project_setting() {
    ComponentDto project = componentDb.insertPublicProject();
    logInAsProjectAdministrator(project);
    tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.PREVIOUS_VERSION));
    ShowWSResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ShowWSResponse.class);
    assertResponse(response, project.getKey(), "", NewCodePeriods.NewCodePeriodType.PREVIOUS_VERSION, "", true);
}
Also used : NewCodePeriodDto(org.sonar.db.newcodeperiod.NewCodePeriodDto) ShowWSResponse(org.sonarqube.ws.NewCodePeriods.ShowWSResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 13 with NewCodePeriodDto

use of org.sonar.db.newcodeperiod.NewCodePeriodDto in project sonarqube by SonarSource.

the class ShowActionTest method show_inherited_if_project_not_found.

@Test
public void show_inherited_if_project_not_found() {
    tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.NUMBER_OF_DAYS).setValue("3"));
    ShowWSResponse response = ws.newRequest().setParam("project", "unknown").executeProtobuf(ShowWSResponse.class);
    assertResponse(response, "", "", NewCodePeriods.NewCodePeriodType.NUMBER_OF_DAYS, "3", true);
}
Also used : NewCodePeriodDto(org.sonar.db.newcodeperiod.NewCodePeriodDto) ShowWSResponse(org.sonarqube.ws.NewCodePeriods.ShowWSResponse) Test(org.junit.Test)

Example 14 with NewCodePeriodDto

use of org.sonar.db.newcodeperiod.NewCodePeriodDto 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);
}
Also used : NewCodePeriodDto(org.sonar.db.newcodeperiod.NewCodePeriodDto) ShowWSResponse(org.sonarqube.ws.NewCodePeriods.ShowWSResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 15 with NewCodePeriodDto

use of org.sonar.db.newcodeperiod.NewCodePeriodDto in project sonarqube by SonarSource.

the class SetBaselineActionTest method set_baseline_on_main_branch.

@Test
@UseDataProvider("nullOrEmpty")
public void set_baseline_on_main_branch(@Nullable String branchName) {
    ComponentDto project = tester.insertPrivateProject();
    SnapshotDto analysis = db.components().insertSnapshot(project);
    logInAsProjectAdministrator(project);
    call(project.getKey(), branchName, analysis.getUuid());
    NewCodePeriodDto loaded = dbClient.newCodePeriodDao().selectByBranch(dbSession, project.uuid(), project.uuid()).get();
    assertThat(loaded.getValue()).isEqualTo(analysis.getUuid());
    assertThat(loaded.getType()).isEqualTo(SPECIFIC_ANALYSIS);
}
Also used : NewCodePeriodDto(org.sonar.db.newcodeperiod.NewCodePeriodDto) SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

NewCodePeriodDto (org.sonar.db.newcodeperiod.NewCodePeriodDto)27 Test (org.junit.Test)20 ComponentDto (org.sonar.db.component.ComponentDto)16 SnapshotDto (org.sonar.db.component.SnapshotDto)12 ShowWSResponse (org.sonarqube.ws.NewCodePeriods.ShowWSResponse)10 DbSession (org.sonar.db.DbSession)6 BranchDto (org.sonar.db.component.BranchDto)6 ListWSResponse (org.sonarqube.ws.NewCodePeriods.ListWSResponse)6 WebService (org.sonar.api.server.ws.WebService)4 UserRole (org.sonar.api.web.UserRole)4 DbClient (org.sonar.db.DbClient)4 NewCodePeriodDao (org.sonar.db.newcodeperiod.NewCodePeriodDao)4 NewCodePeriodType (org.sonar.db.newcodeperiod.NewCodePeriodType)4 ComponentFinder (org.sonar.server.component.ComponentFinder)4 DateUtils (org.sonar.api.utils.DateUtils)3 BranchType (org.sonar.db.component.BranchType)3 NotFoundException (org.sonar.server.exceptions.NotFoundException)3 NewCodePeriods (org.sonarqube.ws.NewCodePeriods)3 ProjectDump (com.sonarsource.governance.projectdump.protobuf.ProjectDump)2 Instant (java.time.Instant)2