Search in sources :

Example 26 with NewCodePeriodDto

use of org.sonar.db.newcodeperiod.NewCodePeriodDto 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);
}
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 27 with NewCodePeriodDto

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

the class SetBaselineActionTest method set_baseline_on_non_main_branch.

@Test
public void set_baseline_on_non_main_branch() {
    ComponentDto project = tester.insertPrivateProject();
    ComponentDto branchComponent = tester.insertProjectBranch(project);
    SnapshotDto analysis = db.components().insertSnapshot(branchComponent);
    BranchDto branch = branchDao.selectByUuid(dbSession, branchComponent.uuid()).get();
    logInAsProjectAdministrator(project);
    call(project.getKey(), branch.getKey(), analysis.getUuid());
    NewCodePeriodDto loaded = dbClient.newCodePeriodDao().selectByBranch(dbSession, project.uuid(), branch.getUuid()).get();
    assertThat(loaded.getValue()).isEqualTo(analysis.getUuid());
    assertThat(loaded.getType()).isEqualTo(SPECIFIC_ANALYSIS);
}
Also used : BranchDto(org.sonar.db.component.BranchDto) NewCodePeriodDto(org.sonar.db.newcodeperiod.NewCodePeriodDto) SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

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