diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2018-10-18 14:42:35 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-10-19 20:20:53 +0200 |
commit | 0ef3791c0f945ff5e2d9f3befac08871088a0e17 (patch) | |
tree | a153cbdc1cc9a9ff7d1af76845b81d8ef0fe36e5 | |
parent | b6f6490b60112e843ea49231cada884f2fdc1447 (diff) | |
download | sonarqube-0ef3791c0f945ff5e2d9f3befac08871088a0e17.tar.gz sonarqube-0ef3791c0f945ff5e2d9f3befac08871088a0e17.zip |
SONAR-11310 support main branch analysis submitted as a long branch
6 files changed, 135 insertions, 59 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDbTester.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDbTester.java index 425a1b6360e..0e9962ff7ae 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDbTester.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDbTester.java @@ -255,8 +255,12 @@ public class ComponentDbTester { @SafeVarargs public final ComponentDto insertMainBranch(OrganizationDto organization, Consumer<ComponentDto>... dtoPopulators) { ComponentDto project = newPrivateProjectDto(organization); - BranchDto branchDto = newBranchDto(project, LONG); Arrays.stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(project)); + return insertMainBranch(project); + } + + public final ComponentDto insertMainBranch(ComponentDto project) { + BranchDto branchDto = newBranchDto(project, LONG); insertComponent(project); dbClient.branchDao().insert(dbSession, branchDto); db.commit(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupport.java b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupport.java index 647f3e43a91..d7e8f7736bb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupport.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupport.java @@ -24,14 +24,18 @@ import java.util.Objects; import java.util.Optional; import javax.annotation.CheckForNull; import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; import org.sonar.api.server.ServerSide; import org.sonar.core.component.ComponentKeys; import org.sonar.db.DbSession; +import org.sonar.db.component.BranchDto; +import org.sonar.db.component.BranchType; import org.sonar.db.component.ComponentDto; import org.sonar.db.organization.OrganizationDto; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; /** * Branch code for {@link ReportSubmitter}. @@ -66,36 +70,83 @@ public class BranchSupport { return delegate.createComponentKey(projectKey, characteristics); } - ComponentDto createBranchComponent(DbSession dbSession, ComponentKey componentKey, OrganizationDto organization, ComponentDto mainComponentDto) { + ComponentDto createBranchComponent(DbSession dbSession, ComponentKey componentKey, OrganizationDto organization, + ComponentDto mainComponentDto, BranchDto mainComponentBranchDto) { checkState(delegate != null, "Current edition does not support branch feature"); - return delegate.createBranchComponent(dbSession, componentKey, organization, mainComponentDto); + return delegate.createBranchComponent(dbSession, componentKey, organization, mainComponentDto, mainComponentBranchDto); } - public interface ComponentKey { - String getKey(); + public abstract static class ComponentKey { + public abstract String getKey(); - String getDbKey(); + public abstract String getDbKey(); - Optional<String> getDeprecatedBranchName(); + public abstract Optional<String> getDeprecatedBranchName(); - Optional<String> getBranchName(); + public abstract Optional<Branch> getBranch(); - Optional<String> getPullRequestKey(); + public abstract Optional<String> getPullRequestKey(); - boolean isMainBranch(); + public final boolean isDeprecatedBranch() { + return getDeprecatedBranchName().isPresent(); + } - boolean isDeprecatedBranch(); + public final boolean isMainBranch() { + return !getBranch().isPresent() && !getPullRequestKey().isPresent(); + } /** * @return the {@link ComponentKey} of the main branch for this component. - * If this component is the main branch (ie. {@link #isMainBranch()} returns true), this method returns - * {@code this}. */ - ComponentKey getMainBranchComponentKey(); + public abstract ComponentKey getMainBranchComponentKey(); } - private static final class ComponentKeyImpl implements ComponentKey { + @Immutable + public static final class Branch { + private final String name; + private final BranchType type; + + public Branch(String name, BranchType type) { + this.name = requireNonNull(name, "name can't be null"); + this.type = requireNonNull(type, "type can't be null"); + } + + public String getName() { + return name; + } + + public BranchType getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Branch branch = (Branch) o; + return name.equals(branch.name) && type == branch.type; + } + + @Override + public int hashCode() { + return Objects.hash(name, type); + } + + @Override + public String toString() { + return "Branch{" + + "name='" + name + '\'' + + ", type=" + type + + '}'; + } + } + + private static final class ComponentKeyImpl extends ComponentKey { private final String key; private final String dbKey; @CheckForNull @@ -123,7 +174,7 @@ public class BranchSupport { } @Override - public Optional<String> getBranchName() { + public Optional<Branch> getBranch() { return Optional.empty(); } @@ -133,16 +184,6 @@ public class BranchSupport { } @Override - public boolean isMainBranch() { - return key.equals(dbKey); - } - - @Override - public boolean isDeprecatedBranch() { - return deprecatedBranchName != null; - } - - @Override public ComponentKey getMainBranchComponentKey() { return this; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupportDelegate.java b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupportDelegate.java index e2a68de7daf..934372c7416 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupportDelegate.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/BranchSupportDelegate.java @@ -23,6 +23,7 @@ import java.util.Map; import org.sonar.api.server.ServerSide; import org.sonar.db.DbSession; import org.sonar.db.ce.CeTaskCharacteristicDto; +import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.organization.OrganizationDto; import org.sonar.server.ce.queue.BranchSupport.ComponentKey; @@ -51,5 +52,5 @@ public interface BranchSupportDelegate { * key as {@code componentKey.getKey()}, ...) */ ComponentDto createBranchComponent(DbSession dbSession, ComponentKey componentKey, - OrganizationDto organization, ComponentDto mainComponentDto); + OrganizationDto organization, ComponentDto mainComponentDto, BranchDto mainComponentBranchDto); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java index 0c3716e860a..382c0e85183 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java @@ -34,6 +34,7 @@ import org.sonar.ce.task.CeTask; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.ce.CeTaskTypes; +import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.organization.OrganizationDto; import org.sonar.db.permission.OrganizationPermission; @@ -146,7 +147,9 @@ public class ReportSubmitter { Optional<ComponentDto> existingMainComponent = dbClient.componentDao().selectByKey(dbSession, componentKey.getKey()); ComponentDto mainComponentDto = existingMainComponent .orElseGet(() -> createProject(dbSession, organization, componentKey.getMainBranchComponentKey(), projectName)); - ComponentDto branchComponent = branchSupport.createBranchComponent(dbSession, componentKey, organization, mainComponentDto); + BranchDto mainComponentBranchDto = dbClient.branchDao().selectByUuid(dbSession, mainComponentDto.uuid()) + .orElseThrow(() -> new IllegalStateException("Branch of main component does not exist")); + ComponentDto branchComponent = branchSupport.createBranchComponent(dbSession, componentKey, organization, mainComponentDto, mainComponentBranchDto); if (existingMainComponent.isPresent()) { dbSession.commit(); } else { diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java index 07f1d616ad0..7c2023f427d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java @@ -25,20 +25,22 @@ import com.tngtech.java.junit.dataprovider.DataProviderRunner; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Map; +import java.util.Optional; import java.util.Random; import java.util.function.BiConsumer; import java.util.stream.IntStream; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.RandomStringUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.mockito.stubbing.Answer; import org.sonar.api.resources.Qualifiers; import org.sonar.api.utils.System2; import org.sonar.ce.queue.CeQueue; import org.sonar.ce.queue.CeQueueImpl; import org.sonar.ce.queue.CeTaskSubmit; +import org.sonar.core.component.ComponentKeys; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.ce.CeTaskTypes; @@ -55,6 +57,7 @@ import org.sonar.server.permission.PermissionTemplateService; import org.sonar.server.tester.UserSessionRule; import static java.util.Collections.emptyMap; +import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; @@ -101,7 +104,7 @@ public class BranchReportSubmitterTest { @Test public void submit_does_not_use_delegate_if_characteristics_are_empty() { OrganizationDto organization = db.organizations().insert(); - ComponentDto project = db.components().insertPrivateProject(organization); + ComponentDto project = db.components().insertMainBranch(organization); UserDto user = db.users().insertUser(); userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, project); mockSuccessfulPrepareSubmitCall(); @@ -115,7 +118,7 @@ public class BranchReportSubmitterTest { @Test public void submit_a_report_on_existing_branch() { OrganizationDto organization = db.organizations().insert(); - ComponentDto project = db.components().insertPrivateProject(organization); + ComponentDto project = db.components().insertMainBranch(organization); ComponentDto branch = db.components().insertProjectBranch(project); UserDto user = db.users().insertUser(); userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, project); @@ -130,39 +133,61 @@ public class BranchReportSubmitterTest { verifyZeroInteractions(permissionTemplateService); verifyZeroInteractions(favoriteUpdater); - verify(branchSupport, times(0)).createBranchComponent(any(), any(), any(), any()); + verify(branchSupport, times(0)).createBranchComponent(any(), any(), any(), any(), any()); verify(branchSupportDelegate).createComponentKey(project.getDbKey(), randomCharacteristics); - verify(branchSupportDelegate, times(0)).createBranchComponent(any(), any(), any(), any()); + verify(branchSupportDelegate, times(0)).createBranchComponent(any(), any(), any(), any(), any()); verifyNoMoreInteractions(branchSupportDelegate); verifyQueueSubmit(project, branch, user, randomCharacteristics, taskUuid); } @Test + public void submit_a_report_on_existing_deprecated_branch() { + OrganizationDto organization = db.organizations().insert(); + String projectKey = randomAlphabetic(10); + String deprecatedBranchName = randomAlphabetic(11); + ComponentDto deprecatedBranch = db.components().insertMainBranch(organization, cpt -> cpt.setDbKey(ComponentKeys.createKey(projectKey, deprecatedBranchName))); + UserDto user = db.users().insertUser(); + userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, deprecatedBranch); + Map<String, String> noCharacteristics = emptyMap(); + InputStream reportInput = IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8); + String taskUuid = mockSuccessfulPrepareSubmitCall(); + + underTest.submit(organization.getKey(), deprecatedBranch.getDbKey(), null, deprecatedBranch.name(), noCharacteristics, reportInput); + + verifyZeroInteractions(permissionTemplateService); + verifyZeroInteractions(favoriteUpdater); + verify(branchSupport, times(0)).createBranchComponent(any(), any(), any(), any(), any()); + verifyZeroInteractions(branchSupportDelegate); + verifyQueueSubmit(deprecatedBranch, deprecatedBranch, user, noCharacteristics, taskUuid); + } + + @Test public void submit_a_report_on_missing_branch_but_existing_project() { OrganizationDto organization = db.organizations().insert(); - ComponentDto nonExistingProject = db.components().insertPrivateProject(organization); + ComponentDto existingProject = db.components().insertMainBranch(organization); + BranchDto exitingProjectMainBranch = db.getDbClient().branchDao().selectByUuid(db.getSession(), existingProject.uuid()).get(); UserDto user = db.users().insertUser(); - userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, nonExistingProject); + userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, existingProject); Map<String, String> randomCharacteristics = randomNonEmptyMap(); - ComponentDto createdBranch = createButDoNotInsertBranch(nonExistingProject); + ComponentDto createdBranch = createButDoNotInsertBranch(existingProject); BranchSupport.ComponentKey componentKey = createComponentKeyOfBranch(createdBranch); - when(branchSupportDelegate.createComponentKey(nonExistingProject.getDbKey(), randomCharacteristics)) + when(branchSupportDelegate.createComponentKey(existingProject.getDbKey(), randomCharacteristics)) .thenReturn(componentKey); - when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject))) + when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(existingProject), eq(exitingProjectMainBranch))) .thenReturn(createdBranch); InputStream reportInput = IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8); String taskUuid = mockSuccessfulPrepareSubmitCall(); - underTest.submit(organization.getKey(), nonExistingProject.getDbKey(), null, nonExistingProject.name(), randomCharacteristics, reportInput); + underTest.submit(organization.getKey(), existingProject.getDbKey(), null, existingProject.name(), randomCharacteristics, reportInput); verifyZeroInteractions(permissionTemplateService); verifyZeroInteractions(favoriteUpdater); - verify(branchSupport).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject)); - verify(branchSupportDelegate).createComponentKey(nonExistingProject.getDbKey(), randomCharacteristics); - verify(branchSupportDelegate).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject)); + verify(branchSupport).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(existingProject), eq(exitingProjectMainBranch)); + verify(branchSupportDelegate).createComponentKey(existingProject.getDbKey(), randomCharacteristics); + verify(branchSupportDelegate).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(existingProject), eq(exitingProjectMainBranch)); verifyNoMoreInteractions(branchSupportDelegate); verify(componentUpdater, times(0)).commitAndIndex(any(), any()); - verifyQueueSubmit(nonExistingProject, createdBranch, user, randomCharacteristics, taskUuid); + verifyQueueSubmit(existingProject, createdBranch, user, randomCharacteristics, taskUuid); } @Test @@ -179,8 +204,9 @@ public class BranchReportSubmitterTest { BranchSupport.ComponentKey componentKey = createComponentKeyOfBranch(createdBranch); when(branchSupportDelegate.createComponentKey(nonExistingProject.getDbKey(), randomCharacteristics)) .thenReturn(componentKey); - when(componentUpdater.createWithoutCommit(any(), any(), eq(user.getId()))).thenReturn(nonExistingProject); - when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject))) + when(componentUpdater.createWithoutCommit(any(), any(), eq(user.getId()))) + .thenAnswer((Answer<ComponentDto>) invocation -> db.components().insertMainBranch(nonExistingProject)); + when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject), any())) .thenReturn(createdBranch); when(permissionTemplateService.wouldUserHaveScanPermissionWithDefaultTemplate(any(), eq(organization.getUuid()), any(), eq(nonExistingProject.getKey()), eq(Qualifiers.PROJECT))) @@ -190,9 +216,10 @@ public class BranchReportSubmitterTest { underTest.submit(organization.getKey(), nonExistingProject.getDbKey(), null, nonExistingProject.name(), randomCharacteristics, reportInput); - verify(branchSupport).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject)); + BranchDto exitingProjectMainBranch = db.getDbClient().branchDao().selectByUuid(db.getSession(), nonExistingProject.uuid()).get(); + verify(branchSupport).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject), eq(exitingProjectMainBranch)); verify(branchSupportDelegate).createComponentKey(nonExistingProject.getDbKey(), randomCharacteristics); - verify(branchSupportDelegate).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject)); + verify(branchSupportDelegate).createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject), eq(exitingProjectMainBranch)); verifyNoMoreInteractions(branchSupportDelegate); verifyQueueSubmit(nonExistingProject, createdBranch, user, randomCharacteristics, taskUuid); verify(componentUpdater).commitAndIndex(any(DbSession.class), eq(nonExistingProject)); @@ -201,7 +228,7 @@ public class BranchReportSubmitterTest { @Test public void submit_fails_if_branch_support_delegate_createComponentKey_throws_an_exception() { OrganizationDto organization = db.organizations().insert(); - ComponentDto project = db.components().insertPrivateProject(organization); + ComponentDto project = db.components().insertMainBranch(organization); UserDto user = db.users().insertUser(); userSession.logIn(user).addProjectPermission(SCAN_EXECUTION, project); Map<String, String> randomCharacteristics = randomNonEmptyMap(); @@ -243,7 +270,7 @@ public class BranchReportSubmitterTest { BranchSupport.ComponentKey componentKey = createComponentKeyOfBranch(createdBranch); when(branchSupportDelegate.createComponentKey(nonExistingProject.getDbKey(), randomCharacteristics)) .thenReturn(componentKey); - when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject))) + when(branchSupportDelegate.createBranchComponent(any(DbSession.class), same(componentKey), eq(organization), eq(nonExistingProject), any())) .thenReturn(createdBranch); InputStream reportInput = IOUtils.toInputStream("{binary}", StandardCharsets.UTF_8); @@ -260,7 +287,7 @@ public class BranchReportSubmitterTest { } private String mockSuccessfulPrepareSubmitCall() { - String taskUuid = RandomStringUtils.randomAlphabetic(12); + String taskUuid = randomAlphabetic(12); when(queue.prepareSubmit()).thenReturn(new CeTaskSubmit.Builder(taskUuid)); return taskUuid; } @@ -278,6 +305,7 @@ public class BranchReportSubmitterTest { when(mainComponentKey.getMainBranchComponentKey()).thenReturn(mainComponentKey); BranchSupport.ComponentKey componentKey = mockComponentKey(branch.getKey(), branch.getDbKey()); + when(componentKey.getBranch()).thenReturn(Optional.ofNullable(branch).map(b -> new BranchSupport.Branch(b.name(), BranchType.LONG))); when(componentKey.getMainBranchComponentKey()).thenReturn(mainComponentKey); return componentKey; @@ -285,8 +313,6 @@ public class BranchReportSubmitterTest { private static BranchSupport.ComponentKey mockComponentKey(String key, String dbKey) { BranchSupport.ComponentKey componentKey = mock(BranchSupport.ComponentKey.class); - when(componentKey.isDeprecatedBranch()).thenReturn(false); - when(componentKey.isMainBranch()).thenReturn(key.equals(dbKey)); when(componentKey.getKey()).thenReturn(key); when(componentKey.getDbKey()).thenReturn(dbKey); return componentKey; diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchSupportTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchSupportTest.java index 6c941f6571d..21b33edd507 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchSupportTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ce/queue/BranchSupportTest.java @@ -31,6 +31,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.sonar.db.DbSession; +import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.organization.OrganizationDto; import org.sonar.server.ce.queue.BranchSupport.ComponentKey; @@ -63,10 +64,9 @@ public class BranchSupportTest { .isEqualTo(underTestWithBranch.createComponentKey(projectKey, null, NO_CHARACTERISTICS)); assertThat(componentKey.getKey()).isEqualTo(projectKey); assertThat(componentKey.getDbKey()).isEqualTo(projectKey); - assertThat(componentKey.isMainBranch()).isTrue(); assertThat(componentKey.isDeprecatedBranch()).isFalse(); assertThat(componentKey.getMainBranchComponentKey()).isSameAs(componentKey); - assertThat(componentKey.getBranchName()).isEmpty(); + assertThat(componentKey.getBranch()).isEmpty(); assertThat(componentKey.getPullRequestKey()).isEmpty(); } @@ -81,10 +81,9 @@ public class BranchSupportTest { .isEqualTo(underTestWithBranch.createComponentKey(projectKey, deprecatedBranchName, NO_CHARACTERISTICS)); assertThat(componentKey.getKey()).isEqualTo(projectKey); assertThat(componentKey.getDbKey()).isEqualTo(projectKey + ":" + deprecatedBranchName); - assertThat(componentKey.isMainBranch()).isFalse(); assertThat(componentKey.isDeprecatedBranch()).isTrue(); assertThat(componentKey.getMainBranchComponentKey()).isSameAs(componentKey); - assertThat(componentKey.getBranchName()).isEmpty(); + assertThat(componentKey.getBranch()).isEmpty(); assertThat(componentKey.getPullRequestKey()).isEmpty(); } @@ -130,11 +129,12 @@ public class BranchSupportTest { ComponentKey componentKey = mock(ComponentKey.class); OrganizationDto organization = new OrganizationDto(); ComponentDto mainComponentDto = new ComponentDto(); + BranchDto mainComponentBranchDto = new BranchDto(); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Current edition does not support branch feature"); - underTestNoBranch.createBranchComponent(dbSession, componentKey, organization, mainComponentDto); + underTestNoBranch.createBranchComponent(dbSession, componentKey, organization, mainComponentDto, mainComponentBranchDto); } @Test @@ -144,10 +144,11 @@ public class BranchSupportTest { OrganizationDto organization = new OrganizationDto(); ComponentDto mainComponentDto = new ComponentDto(); ComponentDto expected = new ComponentDto(); - when(branchSupportDelegate.createBranchComponent(dbSession, componentKey, organization, mainComponentDto)) + BranchDto mainComponentBranchDto = new BranchDto(); + when(branchSupportDelegate.createBranchComponent(dbSession, componentKey, organization, mainComponentDto, mainComponentBranchDto)) .thenReturn(expected); - ComponentDto dto = underTestWithBranch.createBranchComponent(dbSession, componentKey, organization, mainComponentDto); + ComponentDto dto = underTestWithBranch.createBranchComponent(dbSession, componentKey, organization, mainComponentDto, mainComponentBranchDto); assertThat(dto).isSameAs(expected); } |