From 41fd09d2d5873aeb0a8477abfb7d106c919b7495 Mon Sep 17 00:00:00 2001 From: Lukasz Jarocki Date: Mon, 3 Apr 2023 16:56:07 +0200 Subject: [PATCH] SONAR-18850 removing usage of mainBranchUuid from selectByKeyAndBranchOrPr --- .../step/ViewsPersistComponentsStepIT.java | 51 +++++++++---------- .../step/PersistComponentsStep.java | 3 ++ .../sonar/db/component/ComponentMapper.xml | 8 ++- .../server/batch/ProjectDataLoaderIT.java | 12 ++--- .../server/ce/ws/ActivityStatusActionIT.java | 9 ++-- .../server/component/ComponentFinderIT.java | 2 +- .../server/component/ws/TreeActionIT.java | 2 +- .../server/favorite/ws/RemoveActionIT.java | 2 +- .../permission/ws/AddGroupActionIT.java | 2 +- .../projectanalysis/ws/SearchActionIT.java | 8 +-- .../server/projectdump/ws/ExportActionIT.java | 3 +- .../setting/ws/ListDefinitionsActionIT.java | 12 ++--- .../server/setting/ws/ResetActionIT.java | 23 ++++----- 13 files changed, 66 insertions(+), 71 deletions(-) diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java index 2cdb776d0cd..9a1903361b3 100644 --- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java +++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepIT.java @@ -21,10 +21,13 @@ package org.sonar.ce.task.projectanalysis.step; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; +import java.util.Map; import java.util.Random; import java.util.stream.Stream; import javax.annotation.Nullable; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.sonar.api.resources.Qualifiers; @@ -41,15 +44,18 @@ import org.sonar.ce.task.projectanalysis.component.SubViewAttributes; import org.sonar.ce.task.projectanalysis.component.TreeRootHolderRule; import org.sonar.ce.task.projectanalysis.component.ViewAttributes; import org.sonar.ce.task.projectanalysis.component.ViewsComponent; +import org.sonar.ce.task.projectanalysis.component.VisitException; import org.sonar.ce.task.step.ComputationStep; import org.sonar.ce.task.step.TestComputationStepContext; import org.sonar.db.DbClient; import org.sonar.db.DbTester; +import org.sonar.db.RowNotFoundException; import org.sonar.db.component.ComponentDbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -114,7 +120,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(1); + assertRowsCountInTableComponents(1); ComponentDto projectDto = getComponentFromDb(VIEW_KEY); assertDtoIsView(projectDto); @@ -129,7 +135,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(1); + assertRowsCountInTableComponents(1); assertDtoNotUpdated(VIEW_KEY); } @@ -146,7 +152,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(3); + assertRowsCountInTableComponents(3); ComponentDto viewDto = getComponentFromDb(VIEW_KEY); assertDtoIsView(viewDto); @@ -155,25 +161,21 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { assertDtoIsProjectView1(pv1Dto, viewDto, viewDto, project); } + /** + * Assumption under test here is that application should always exists in the projects table. + * We should never have a state where application exists in Components table but not in Projects table + */ @Test - public void persist_application_with_projectView() { - ComponentDto project = ComponentTesting.newPrivateProjectDto(); - persistComponents(project); + public void execute_whenApplicationDoesNotExistsAndTryingToInsertItInComponentsTable_throwException() { + ComponentDto project = dbTester.components().insertPrivateProject(); treeRootHolder.setRoot( createViewBuilder(APPLICATION) .addChildren(createProjectView1Builder(project, null).build()) .build()); - underTest.execute(new TestComputationStepContext()); - - assertRowsCountInTableProjects(3); - - ComponentDto applicationDto = getComponentFromDb(VIEW_KEY); - assertDtoIsApplication(applicationDto); - - ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY); - assertDtoIsProjectView1(pv1Dto, applicationDto, applicationDto, project); + assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())) + .isInstanceOf(VisitException.class); } @Test @@ -186,7 +188,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(2); + assertRowsCountInTableComponents(2); ComponentDto viewDto = getComponentFromDb(VIEW_KEY); assertDtoIsView(viewDto); @@ -205,7 +207,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(2); + assertRowsCountInTableComponents(2); ComponentDto subView = getComponentFromDb(SUBVIEW_1_KEY); assertThat(subView.getCopyComponentUuid()).isEqualTo("ORIGINAL_UUID"); @@ -225,7 +227,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(2); + assertRowsCountInTableComponents(2); assertDtoNotUpdated(VIEW_KEY); assertDtoNotUpdated(SUBVIEW_1_KEY); @@ -243,7 +245,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(2); + assertRowsCountInTableComponents(2); assertDtoNotUpdated(VIEW_KEY); assertDtoIsSubView1(getComponentFromDb(VIEW_KEY), getComponentFromDb(SUBVIEW_1_KEY)); @@ -265,7 +267,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { underTest.execute(new TestComputationStepContext()); - assertRowsCountInTableProjects(4); + assertRowsCountInTableComponents(4); ComponentDto viewDto = getComponentFromDb(VIEW_KEY); assertDtoIsView(viewDto); @@ -288,7 +290,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), viewDto.uuid()); dbTester.commit(); - assertRowsCountInTableProjects(1); + assertRowsCountInTableComponents(1); ComponentDto newViewDto = getComponentFromDb(VIEW_KEY); assertDtoIsView(newViewDto); } @@ -303,19 +305,16 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { .setName("Old name") .setCreatedAt(now); persistComponents(projectView); - treeRootHolder.setRoot( createViewBuilder(PORTFOLIO) .addChildren(createProjectView1Builder(project, null).build()) .build()); - underTest.execute(new TestComputationStepContext()); - // commit functional transaction -> copies B-fields to A-fields dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid()); dbTester.commit(); - assertRowsCountInTableProjects(3); + assertRowsCountInTableComponents(3); ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY); assertDtoIsProjectView1(pv1Dto, view, view, project); } @@ -471,7 +470,7 @@ public class ViewsPersistComponentsStepIT extends BaseStepTest { return dbClient.componentDao().selectByKey(dbTester.getSession(), componentKey).get(); } - private void assertRowsCountInTableProjects(int rowCount) { + private void assertRowsCountInTableComponents(int rowCount) { assertThat(dbTester.countRowsOfTable("components")).isEqualTo(rowCount); } diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java index 6b16eab2068..a4d7aa99540 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistComponentsStep.java @@ -221,6 +221,9 @@ public class PersistComponentsStep implements ComputationStep { private ComponentDto persistComponent(ComponentDto componentDto) { ComponentDto existingComponent = existingComponentDtosByUuids.remove(componentDto.uuid()); if (existingComponent == null) { + if (componentDto.qualifier().equals("APP") && componentDto.scope().equals("PRJ")) { + throw new IllegalStateException("Application should already exists: " + componentDto); + } dbClient.componentDao().insert(dbSession, componentDto, analysisMetadataHolder.getBranch().isMain()); return componentDto; } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 75d06fde93e..1f8f072d7cb 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -78,10 +78,8 @@ p.private as isPrivate, p.created_at as createdAt from components p - left join projects pr on p.main_branch_project_uuid = pr.uuid - - inner join project_branches pb on pb.uuid = p.branch_uuid - + left join project_branches pb on pb.uuid = p.branch_uuid + left join projects pr on pb.project_uuid = pr.uuid where p.kee=#{key,jdbcType=VARCHAR} @@ -94,7 +92,7 @@ AND pb.branch_type = 'PULL_REQUEST' - AND p.main_branch_project_uuid is NULL + AND (pb.is_main = ${_true} OR p.qualifier IN ('VW', 'SVW') OR (p.qualifier = 'TRK' AND p.scope = 'FIL')) diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java index d173fa151e7..85aac489978 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/batch/ProjectDataLoaderIT.java @@ -51,10 +51,10 @@ public class ProjectDataLoaderIT { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private DbClient dbClient = db.getDbClient(); - private DbSession dbSession = db.getSession(); - private ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); - private ProjectDataLoader underTest = new ProjectDataLoader(dbClient, userSession, new ComponentFinder(dbClient, resourceTypes)); + private final DbClient dbClient = db.getDbClient(); + private final DbSession dbSession = db.getSession(); + private final ResourceTypesRule resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT); + private final ProjectDataLoader underTest = new ProjectDataLoader(dbClient, userSession, new ComponentFinder(dbClient, resourceTypes)); @Test public void throws_NotFoundException_when_branch_does_not_exist() { @@ -138,8 +138,8 @@ public class ProjectDataLoaderIT { ProjectDataQuery query = ProjectDataQuery.create().setProjectKey(key); assertThatThrownBy(() -> underTest.load(query)) - .isInstanceOf(BadRequestException.class) - .hasMessage("Key '" + key + "' belongs to a component which is not a Project"); + .isInstanceOf(NotFoundException.class) + .hasMessage("Component key '" + key + "' not found"); } @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java index 40926311f9b..62c53ec9b8d 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/ce/ws/ActivityStatusActionIT.java @@ -91,10 +91,8 @@ public class ActivityStatusActionIT { public void status_for_a_project_as_project_admin() { String projectKey = "project-key"; String anotherProjectKey = "another-project-key"; - ComponentDto project = newPrivateProjectDto().setKey(projectKey); - ComponentDto anotherProject = newPrivateProjectDto().setKey(anotherProjectKey); - db.components().insertComponent(project); - db.components().insertComponent(newPrivateProjectDto().setKey(anotherProjectKey)); + ComponentDto project = db.components().insertPrivateProject(c -> c.setKey(projectKey)); + ComponentDto anotherProject = db.components().insertPrivateProject(c -> c.setKey(anotherProjectKey)); userSession.logIn().addProjectPermission(UserRole.ADMIN, project); // pending tasks returned insertInQueue(CeQueueDto.Status.PENDING, project); @@ -119,8 +117,7 @@ public class ActivityStatusActionIT { @Test public void add_pending_time() { String projectKey = "project-key"; - ComponentDto project = newPrivateProjectDto().setKey(projectKey); - db.components().insertComponent(project); + ComponentDto project = db.components().insertPrivateProject(c -> c.setKey(projectKey)); userSession.logIn().addProjectPermission(UserRole.ADMIN, project); when(system2.now()).thenReturn(2000L); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentFinderIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentFinderIT.java index 2451aa92693..a1c952d48e4 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentFinderIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ComponentFinderIT.java @@ -140,7 +140,7 @@ public class ComponentFinderIT { @Test public void get_component_by_key() { - db.components().insertComponent(newPrivateProjectDto().setKey("project-key")); + db.components().insertPrivateProject(c -> c.setKey("project-key")); ComponentDto component = underTest.getByUuidOrKey(dbSession, null, "project-key", ID_AND_KEY); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java index e210a1f8a7f..74e2b271d90 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/TreeActionIT.java @@ -409,7 +409,7 @@ public class TreeActionIT { @Test public void fail_when_not_enough_privileges() { - ComponentDto project = db.components().insertComponent(newPrivateProjectDto("project-uuid")); + ComponentDto project = db.components().insertPrivateProject("project-uuid"); userSession.logIn() .addProjectPermission(UserRole.CODEVIEWER, project); db.commit(); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/RemoveActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/RemoveActionIT.java index 340fbad102d..092e78523c5 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/RemoveActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/favorite/ws/RemoveActionIT.java @@ -117,7 +117,7 @@ public class RemoveActionIT { } private ComponentDto insertProject() { - return db.components().insertComponent(newPrivateProjectDto(PROJECT_UUID).setKey(PROJECT_KEY)); + return db.components().insertPrivateProject(PROJECT_UUID, c -> c.setKey(PROJECT_KEY)); } private ComponentDto insertProjectAndPermissions() { diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java index 717bb05622d..29a3cdb96f7 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/permission/ws/AddGroupActionIT.java @@ -123,7 +123,7 @@ public class AddGroupActionIT extends BasePermissionWsIT { @Test public void add_permission_to_project_referenced_by_its_key() { GroupDto group = db.users().insertGroup("sonar-administrators"); - ComponentDto project = db.components().insertComponent(newPrivateProjectDto(A_PROJECT_UUID).setKey(A_PROJECT_KEY)); + ComponentDto project = db.components().insertPrivateProject(A_PROJECT_UUID, c -> c.setKey(A_PROJECT_KEY)); loginAsAdmin(); newRequest() diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java index c33b254a8a3..66972c2c75f 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java @@ -203,7 +203,7 @@ public class SearchActionIT { @Test public void return_only_processed_analyses() { - ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1")); + ComponentDto project = db.components().insertPrivateProject(c -> c.setKey("P1")); userSession.addProjectPermission(UserRole.USER, project); db.components().insertSnapshot(newAnalysis(project).setUuid("A1")); db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setStatus(SnapshotDto.STATUS_UNPROCESSED)); @@ -216,7 +216,7 @@ public class SearchActionIT { @Test public void return_events() { - ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1")); + ComponentDto project = db.components().insertPrivateProject(c -> c.setKey("P1")); userSession.addProjectPermission(UserRole.USER, project); SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1")); SnapshotDto a42 = db.components().insertSnapshot(newAnalysis(ComponentTesting.newPrivateProjectDto()).setUuid("A42")); @@ -452,7 +452,7 @@ public class SearchActionIT { @Test public void filter_by_category() { - ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1")); + ComponentDto project = db.components().insertPrivateProject(c -> c.setKey("P1")); userSession.addProjectPermission(UserRole.USER, project); SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1")); SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2")); @@ -473,7 +473,7 @@ public class SearchActionIT { @Test public void paginate_with_filter_on_category() { - ComponentDto project = db.components().insertComponent(ComponentTesting.newPrivateProjectDto().setKey("P1")); + ComponentDto project = db.components().insertPrivateProject(c -> c.setKey("P1")); userSession.addProjectPermission(UserRole.USER, project); SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(1_000_000L)); SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(2_000_000L)); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java index 1b3aee8eed6..87ddddc2562 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectdump/ws/ExportActionIT.java @@ -42,7 +42,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.test.JsonAssert.assertJson; public class ExportActionIT { @@ -66,7 +65,7 @@ public class ExportActionIT { @Before public void setUp() { - project = db.components().insertComponent(newPrivateProjectDto(PROJECT_ID).setKey(PROJECT_KEY).setName(PROJECT_NAME)); + project = db.components().insertPrivateProject(PROJECT_ID, p -> p.setKey(PROJECT_KEY).setName(PROJECT_NAME)); } @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java index 76119763cf6..96c564fa6e5 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ListDefinitionsActionIT.java @@ -73,17 +73,17 @@ public class ListDefinitionsActionIT { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - private DbClient dbClient = db.getDbClient(); - private ComponentDbTester componentDb = new ComponentDbTester(db); + private final DbClient dbClient = db.getDbClient(); + private final ComponentDbTester componentDb = new ComponentDbTester(db); private ComponentDto project; - private PropertyDefinitions propertyDefinitions = new PropertyDefinitions(System2.INSTANCE); - private SettingsWsSupport support = new SettingsWsSupport(userSession); - private WsActionTester ws = new WsActionTester( + private final PropertyDefinitions propertyDefinitions = new PropertyDefinitions(System2.INSTANCE); + private final SettingsWsSupport support = new SettingsWsSupport(userSession); + private final WsActionTester ws = new WsActionTester( new ListDefinitionsAction(dbClient, TestComponentFinder.from(db), userSession, propertyDefinitions, support)); @Before public void setUp() { - project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto()); + project = db.components().insertPrivateProject(); } @Test diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java index 6a0d3ac519b..fcd53146370 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/ResetActionIT.java @@ -72,22 +72,21 @@ public class ResetActionIT { @Rule public DbTester db = DbTester.create(System2.INSTANCE); - private I18nRule i18n = new I18nRule(); - private PropertyDbTester propertyDb = new PropertyDbTester(db); - private ComponentDbTester componentDb = new ComponentDbTester(db); - private DbClient dbClient = db.getDbClient(); - private DbSession dbSession = db.getSession(); - private ComponentFinder componentFinder = TestComponentFinder.from(db); - private PropertyDefinitions definitions = new PropertyDefinitions(System2.INSTANCE); - private SettingsUpdater settingsUpdater = new SettingsUpdater(dbClient, definitions); - private SettingValidations settingValidations = new SettingValidations(definitions, dbClient, i18n); + private final I18nRule i18n = new I18nRule(); + private final PropertyDbTester propertyDb = new PropertyDbTester(db); + private final DbClient dbClient = db.getDbClient(); + private final DbSession dbSession = db.getSession(); + private final ComponentFinder componentFinder = TestComponentFinder.from(db); + private final PropertyDefinitions definitions = new PropertyDefinitions(System2.INSTANCE); + private final SettingsUpdater settingsUpdater = new SettingsUpdater(dbClient, definitions); + private final SettingValidations settingValidations = new SettingValidations(definitions, dbClient, i18n); private ComponentDto project; - private ResetAction underTest = new ResetAction(dbClient, componentFinder, settingsUpdater, userSession, definitions, settingValidations); - private WsActionTester ws = new WsActionTester(underTest); + private final ResetAction underTest = new ResetAction(dbClient, componentFinder, settingsUpdater, userSession, definitions, settingValidations); + private final WsActionTester ws = new WsActionTester(underTest); @Before public void setUp() { - project = componentDb.insertComponent(ComponentTesting.newPrivateProjectDto()); + project = db.components().insertPrivateProject(); } @Test -- 2.39.5