diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2020-12-17 10:22:36 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-12-22 20:09:38 +0000 |
commit | e42e2b18cdef809b793fe6f3b2d30f32dfb66674 (patch) | |
tree | eba459bbe1c05313177de99b32ddcbd3c46f24b4 /server/sonar-ce-common | |
parent | 82ed20a6d9aec68faf5bc99e78a25aba42c9fedb (diff) | |
download | sonarqube-e42e2b18cdef809b793fe6f3b2d30f32dfb66674.tar.gz sonarqube-e42e2b18cdef809b793fe6f3b2d30f32dfb66674.zip |
SONAR-13999 drop organization from CE steps
Diffstat (limited to 'server/sonar-ce-common')
-rw-r--r-- | server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java | 11 | ||||
-rw-r--r-- | server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java | 20 |
2 files changed, 6 insertions, 25 deletions
diff --git a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java index 8fe59104537..e0bd75db085 100644 --- a/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java +++ b/server/sonar-ce-common/src/main/java/org/sonar/ce/queue/CeQueueImpl.java @@ -49,7 +49,6 @@ import org.sonar.db.ce.CeTaskCharacteristicDto; import org.sonar.db.ce.DeleteIf; import org.sonar.db.component.ComponentDto; import org.sonar.db.user.UserDto; -import org.sonar.server.organization.DefaultOrganizationProvider; import org.sonar.server.property.InternalProperties; import static com.google.common.base.Preconditions.checkState; @@ -69,13 +68,11 @@ public class CeQueueImpl implements CeQueue { private final System2 system2; private final DbClient dbClient; private final UuidFactory uuidFactory; - private final DefaultOrganizationProvider defaultOrganizationProvider; - public CeQueueImpl(System2 system2, DbClient dbClient, UuidFactory uuidFactory, DefaultOrganizationProvider defaultOrganizationProvider) { + public CeQueueImpl(System2 system2, DbClient dbClient, UuidFactory uuidFactory) { this.system2 = system2; this.dbClient = dbClient; this.uuidFactory = uuidFactory; - this.defaultOrganizationProvider = defaultOrganizationProvider; } @Override @@ -356,7 +353,6 @@ public class CeQueueImpl implements CeQueue { String componentUuid = taskDto.getComponentUuid(); if (component != null) { builder.setComponent(new CeTask.Component(component.uuid(), component.getDbKey(), component.name())); - builder.setOrganizationUuid(component.getOrganizationUuid()); } else if (componentUuid != null) { builder.setComponent(new CeTask.Component(componentUuid, null, null)); } @@ -368,11 +364,6 @@ public class CeQueueImpl implements CeQueue { builder.setMainComponent(new CeTask.Component(mainComponentUuid, null, null)); } - // FIXME this should be set from the CeQueueDto - if (!builder.hasOrganizationUuid()) { - builder.setOrganizationUuid(defaultOrganizationProvider.get().getUuid()); - } - return builder.build(); } diff --git a/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java b/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java index b2bdccb22a1..03970bd6ca8 100644 --- a/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java +++ b/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java @@ -44,8 +44,6 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTesting; -import org.sonar.server.organization.DefaultOrganizationProvider; -import org.sonar.server.organization.TestDefaultOrganizationProvider; import static com.google.common.collect.ImmutableList.of; import static java.util.Arrays.asList; @@ -72,9 +70,8 @@ public class CeQueueImplTest { private DbSession session = db.getSession(); private UuidFactory uuidFactory = new SequenceUuidFactory(); - private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); - private CeQueue underTest = new CeQueueImpl(system2, db.getDbClient(), uuidFactory, defaultOrganizationProvider); + private CeQueue underTest = new CeQueueImpl(system2, db.getDbClient(), uuidFactory); @Test public void submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row() { @@ -91,7 +88,7 @@ public class CeQueueImplTest { @Test public void submit_populates_component_name_and_key_of_CeTask_if_component_exists() { - ComponentDto componentDto = insertComponent(ComponentTesting.newPrivateProjectDto(db.organizations().insert(), "PROJECT_1")); + ComponentDto componentDto = insertComponent(ComponentTesting.newPrivateProjectDto("PROJECT_1")); CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, Component.fromDto(componentDto), null); CeTask task = underTest.submit(taskSubmit); @@ -226,7 +223,7 @@ public class CeQueueImplTest { @Test public void massSubmit_populates_component_name_and_key_of_CeTask_if_project_exists() { - ComponentDto componentDto1 = insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), "PROJECT_1")); + ComponentDto componentDto1 = insertComponent(ComponentTesting.newPrivateProjectDto("PROJECT_1")); CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, Component.fromDto(componentDto1), null); CeTaskSubmit taskSubmit2 = createTaskSubmit("something", newComponent(randomAlphabetic(12)), null); @@ -239,7 +236,7 @@ public class CeQueueImplTest { @Test public void massSubmit_populates_component_name_and_key_of_CeTask_if_project_and_branch_exists() { - ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization(), "PROJECT_1")); + ComponentDto project = insertComponent(ComponentTesting.newPrivateProjectDto("PROJECT_1")); ComponentDto branch1 = db.components().insertProjectBranch(project); ComponentDto branch2 = db.components().insertProjectBranch(project); CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, Component.fromDto(branch1), null); @@ -510,11 +507,6 @@ public class CeQueueImplTest { } private void verifyCeTask(CeTaskSubmit taskSubmit, CeTask task, @Nullable ComponentDto componentDto, @Nullable ComponentDto mainComponentDto, @Nullable UserDto userDto) { - if (componentDto == null) { - assertThat(task.getOrganizationUuid()).isEqualTo(defaultOrganizationProvider.get().getUuid()); - } else { - assertThat(task.getOrganizationUuid()).isEqualTo(componentDto.getOrganizationUuid()); - } assertThat(task.getUuid()).isEqualTo(taskSubmit.getUuid()); if (componentDto != null) { CeTask.Component component = task.getComponent().get(); @@ -582,9 +574,7 @@ public class CeQueueImplTest { } private ComponentDto insertComponent(ComponentDto componentDto) { - db.getDbClient().componentDao().insert(session, componentDto); - session.commit(); - return componentDto; + return db.components().insertComponent(componentDto); } private UserDto insertUser(UserDto userDto) { |