]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12081 fail CE processing if branch/pr on Community Edition
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 19 Jun 2019 07:22:32 +0000 (09:22 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 28 Jun 2019 06:45:57 +0000 (08:45 +0200)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImpl.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/MutableAnalysisMetadataHolderRule.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/DefaultAssigneeTest.java

index 190364b96f26351fd78f0031320307e2e0b31829..46e2b3bf3b28de433766f9dae67e3883b6c67cb7 100644 (file)
@@ -25,6 +25,8 @@ import java.util.Optional;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.ce.task.util.InitializedProperty;
+import org.sonar.core.platform.EditionProvider;
+import org.sonar.core.platform.PlatformEditionProvider;
 import org.sonar.db.component.BranchType;
 import org.sonar.server.project.Project;
 import org.sonar.server.qualityprofile.QualityProfile;
@@ -49,6 +51,12 @@ public class AnalysisMetadataHolderImpl implements MutableAnalysisMetadataHolder
   private final InitializedProperty<Map<String, ScannerPlugin>> pluginsByKey = new InitializedProperty<>();
   private final InitializedProperty<String> scmRevision = new InitializedProperty<>();
 
+  private final PlatformEditionProvider editionProvider;
+
+  public AnalysisMetadataHolderImpl(PlatformEditionProvider editionProvider) {
+    this.editionProvider = editionProvider;
+  }
+
   @Override
   public MutableAnalysisMetadataHolder setOrganizationsEnabled(boolean isOrganizationsEnabled) {
     checkState(!this.organizationsEnabled.isInitialized(), "Organization enabled flag has already been set");
@@ -143,6 +151,10 @@ public class AnalysisMetadataHolderImpl implements MutableAnalysisMetadataHolder
   @Override
   public MutableAnalysisMetadataHolder setBranch(Branch branch) {
     checkState(!this.branch.isInitialized(), "Branch has already been set");
+    boolean isCommunityEdition = editionProvider.get().filter(t -> t == EditionProvider.Edition.COMMUNITY).isPresent();
+    checkState(
+      !isCommunityEdition || branch.isMain() || branch.isLegacyFeature(),
+      "Branches and Pull Requests are not supported in Community Edition");
     this.branch.setProperty(branch);
     return this;
   }
index 71d2f6ad6176edf7cb9f7ae5d677b90000c94d38..40b257f88f8e24a5b07ae20edcd7f74d856dcbae 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.analysis;
 
+import com.tngtech.java.junit.dataprovider.DataProvider;
+import com.tngtech.java.junit.dataprovider.DataProviderRunner;
+import com.tngtech.java.junit.dataprovider.UseDataProvider;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.stream.Stream;
+import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
 import org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl;
+import org.sonar.core.platform.PlatformEditionProvider;
 import org.sonar.db.component.BranchType;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.project.Project;
@@ -30,9 +39,11 @@ import org.sonar.server.project.Project;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.sonar.core.platform.EditionProvider.Edition;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
 
+@RunWith(DataProviderRunner.class)
 public class AnalysisMetadataHolderImplTest {
 
   private static Analysis baseProjectAnalysis = new Analysis.Builder()
@@ -45,7 +56,8 @@ public class AnalysisMetadataHolderImplTest {
   @Rule
   public ExpectedException expectedException = ExpectedException.none();
 
-  private AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+  private PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
+  private AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
   @Test
   public void getOrganization_throws_ISE_if_organization_is_not_set() {
@@ -113,12 +125,12 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Analysis date has not been set");
 
-    new AnalysisMetadataHolderImpl().getAnalysisDate();
+    new AnalysisMetadataHolderImpl(editionProvider).getAnalysisDate();
   }
 
   @Test
   public void setAnalysisDate_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setAnalysisDate(SOME_DATE);
 
     expectedException.expect(IllegalStateException.class);
@@ -129,19 +141,19 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void hasAnalysisDateBeenSet_returns_false_when_holder_is_not_initialized() {
-    assertThat(new AnalysisMetadataHolderImpl().hasAnalysisDateBeenSet()).isFalse();
+    assertThat(new AnalysisMetadataHolderImpl(editionProvider).hasAnalysisDateBeenSet()).isFalse();
   }
 
   @Test
   public void hasAnalysisDateBeenSet_returns_true_when_holder_date_is_set() {
-    AnalysisMetadataHolderImpl holder = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl holder = new AnalysisMetadataHolderImpl(editionProvider);
     holder.setAnalysisDate(46532);
     assertThat(holder.hasAnalysisDateBeenSet()).isTrue();
   }
 
   @Test
   public void isFirstAnalysis_return_true() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     underTest.setBaseAnalysis(null);
     assertThat(underTest.isFirstAnalysis()).isTrue();
@@ -149,7 +161,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void isFirstAnalysis_return_false() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     underTest.setBaseAnalysis(baseProjectAnalysis);
     assertThat(underTest.isFirstAnalysis()).isFalse();
@@ -160,7 +172,7 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Base project snapshot has not been set");
 
-    new AnalysisMetadataHolderImpl().isFirstAnalysis();
+    new AnalysisMetadataHolderImpl(editionProvider).isFirstAnalysis();
   }
 
   @Test
@@ -168,12 +180,12 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Base project snapshot has not been set");
 
-    new AnalysisMetadataHolderImpl().getBaseAnalysis();
+    new AnalysisMetadataHolderImpl(editionProvider).getBaseAnalysis();
   }
 
   @Test
   public void setBaseProjectSnapshot_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setBaseAnalysis(baseProjectAnalysis);
 
     expectedException.expect(IllegalStateException.class);
@@ -183,7 +195,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void isCrossProjectDuplicationEnabled_return_true() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     underTest.setCrossProjectDuplicationEnabled(true);
 
@@ -192,7 +204,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void isCrossProjectDuplicationEnabled_return_false() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     underTest.setCrossProjectDuplicationEnabled(false);
 
@@ -204,12 +216,12 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Cross project duplication flag has not been set");
 
-    new AnalysisMetadataHolderImpl().isCrossProjectDuplicationEnabled();
+    new AnalysisMetadataHolderImpl(editionProvider).isCrossProjectDuplicationEnabled();
   }
 
   @Test
   public void setIsCrossProjectDuplicationEnabled_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setCrossProjectDuplicationEnabled(true);
 
     expectedException.expect(IllegalStateException.class);
@@ -219,7 +231,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void set_branch() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     underTest.setBranch(new DefaultBranchImpl("master"));
 
@@ -231,12 +243,12 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Branch has not been set");
 
-    new AnalysisMetadataHolderImpl().getBranch();
+    new AnalysisMetadataHolderImpl(editionProvider).getBranch();
   }
 
   @Test
   public void setBranch_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setBranch(new DefaultBranchImpl("master"));
 
     expectedException.expect(IllegalStateException.class);
@@ -244,9 +256,83 @@ public class AnalysisMetadataHolderImplTest {
     underTest.setBranch(new DefaultBranchImpl("master"));
   }
 
+  @Test
+  @UseDataProvider("anyEditionIncludingNone")
+  public void setBranch_does_not_fail_if_main_branch_on_any_edition(@Nullable Edition edition) {
+    when(editionProvider.get()).thenReturn(Optional.ofNullable(edition));
+    Branch branch = mock(Branch.class);
+    when(branch.isMain()).thenReturn(true);
+    when(branch.isLegacyFeature()).thenReturn(false);
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
+
+    underTest.setBranch(branch);
+
+    assertThat(underTest.getBranch()).isSameAs(branch);
+  }
+
+  @Test
+  @UseDataProvider("anyEditionIncludingNone")
+  public void setBranch_does_not_fail_if_legacy_branch_on_any_edition(@Nullable Edition edition) {
+    when(editionProvider.get()).thenReturn(Optional.ofNullable(edition));
+    Branch branch = mock(Branch.class);
+    when(branch.isMain()).thenReturn(false);
+    when(branch.isLegacyFeature()).thenReturn(true);
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
+
+    underTest.setBranch(branch);
+
+    assertThat(underTest.getBranch()).isSameAs(branch);
+  }
+
+  @Test
+  @UseDataProvider("anyEditionIncludingNoneButCommunity")
+  public void setBranch_does_not_fail_if_non_main_non_legacy_branch_on_any_edition_but_Community(@Nullable Edition edition) {
+    when(editionProvider.get()).thenReturn(Optional.ofNullable(edition));
+    Branch branch = mock(Branch.class);
+    when(branch.isMain()).thenReturn(false);
+    when(branch.isLegacyFeature()).thenReturn(false);
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
+
+    underTest.setBranch(branch);
+
+    assertThat(underTest.getBranch()).isSameAs(branch);
+  }
+
+  @Test
+  public void setBranch_fails_if_non_main_non_legacy_branch_on_Community_edition() {
+    when(editionProvider.get()).thenReturn(Optional.of(Edition.COMMUNITY));
+    Branch branch = mock(Branch.class);
+    when(branch.isMain()).thenReturn(false);
+    when(branch.isLegacyFeature()).thenReturn(false);
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
+
+    expectedException.expect(IllegalStateException.class);
+    expectedException.expectMessage("Branches and Pull Requests are not supported in Community Edition");
+
+    underTest.setBranch(branch);
+  }
+
+  @DataProvider
+  public static Object[][] anyEditionIncludingNone() {
+    return Stream.concat(
+      Stream.of((Edition) null),
+      Arrays.stream(Edition.values()))
+      .map(t -> new Object[] {t})
+      .toArray(Object[][]::new);
+  }
+
+  @DataProvider
+  public static Object[][] anyEditionIncludingNoneButCommunity() {
+    return Stream.concat(
+      Stream.of((Edition) null),
+      Arrays.stream(Edition.values())).filter(t -> t != Edition.COMMUNITY)
+      .map(t -> new Object[] {t})
+      .toArray(Object[][]::new);
+  }
+
   @Test
   public void setPullRequestId() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     String pullRequestId = "pr-123";
     underTest.setPullRequestKey(pullRequestId);
@@ -259,12 +345,12 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Pull request key has not been set");
 
-    new AnalysisMetadataHolderImpl().getPullRequestKey();
+    new AnalysisMetadataHolderImpl(editionProvider).getPullRequestKey();
   }
 
   @Test
   public void setPullRequestId_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setPullRequestKey("pr-123");
 
     expectedException.expect(IllegalStateException.class);
@@ -274,7 +360,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void set_and_get_project() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     Project project = Project.from(newPrivateProjectDto(newOrganizationDto()));
     underTest.setProject(project);
@@ -287,12 +373,12 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Project has not been set");
 
-    new AnalysisMetadataHolderImpl().getProject();
+    new AnalysisMetadataHolderImpl(editionProvider).getProject();
   }
 
   @Test
   public void setProject_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setProject(Project.from(newPrivateProjectDto(newOrganizationDto())));
 
     expectedException.expect(IllegalStateException.class);
@@ -303,7 +389,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void getRootComponentRef() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     underTest.setRootComponentRef(10);
 
@@ -315,12 +401,12 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Root component ref has not been set");
 
-    new AnalysisMetadataHolderImpl().getRootComponentRef();
+    new AnalysisMetadataHolderImpl(editionProvider).getRootComponentRef();
   }
 
   @Test
   public void setRootComponentRef_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setRootComponentRef(10);
 
     expectedException.expect(IllegalStateException.class);
@@ -333,7 +419,7 @@ public class AnalysisMetadataHolderImplTest {
     expectedException.expect(IllegalStateException.class);
     expectedException.expectMessage("Branch has not been set");
 
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.isShortLivingBranch();
   }
 
@@ -342,7 +428,7 @@ public class AnalysisMetadataHolderImplTest {
     Branch branch = mock(Branch.class);
     when(branch.getType()).thenReturn(BranchType.SHORT);
 
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setBranch(branch);
 
     assertThat(underTest.isShortLivingBranch()).isTrue();
@@ -353,7 +439,7 @@ public class AnalysisMetadataHolderImplTest {
     Branch branch = mock(Branch.class);
     when(branch.getType()).thenReturn(BranchType.SHORT);
 
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setBranch(branch);
 
     assertThat(underTest.isSLBorPR()).isTrue();
@@ -364,7 +450,7 @@ public class AnalysisMetadataHolderImplTest {
     Branch branch = mock(Branch.class);
     when(branch.getType()).thenReturn(BranchType.LONG);
 
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setBranch(branch);
 
     assertThat(underTest.isSLBorPR()).isFalse();
@@ -375,7 +461,7 @@ public class AnalysisMetadataHolderImplTest {
     Branch branch = mock(Branch.class);
     when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
 
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setBranch(branch);
 
     assertThat(underTest.isPullRequest()).isTrue();
@@ -383,7 +469,7 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void setScmRevision_throws_ISE_when_called_twice() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setScmRevision("bd56dab");
 
     expectedException.expect(IllegalStateException.class);
@@ -393,28 +479,28 @@ public class AnalysisMetadataHolderImplTest {
 
   @Test
   public void getScmRevision_returns_empty_if_scmRevision_is_not_initialized() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
     assertThat(underTest.getScmRevision()).isNotPresent();
   }
 
   @Test
   public void getScmRevision_returns_scmRevision_if_scmRevision_is_initialized() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setScmRevision("bd56dab");
     assertThat(underTest.getScmRevision()).hasValue("bd56dab");
   }
 
   @Test
   public void getScmRevision_does_not_return_empty_string() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setScmRevision("");
     assertThat(underTest.getScmRevision()).isEmpty();
   }
 
   @Test
   public void getScmRevision_does_not_return_blank_string() {
-    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+    AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
     underTest.setScmRevision("    ");
     assertThat(underTest.getScmRevision()).isEmpty();
   }
index d59bc7df7e7aa832a1053077a299b9a7a6e077bf..a622ff7cdb56e7001739caadea10c3fb9ced1c01 100644 (file)
@@ -24,16 +24,20 @@ import java.util.Optional;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.junit.rules.ExternalResource;
+import org.sonar.core.platform.PlatformEditionProvider;
 import org.sonar.server.project.Project;
 import org.sonar.server.qualityprofile.QualityProfile;
 
+import static org.mockito.Mockito.mock;
+
 public class MutableAnalysisMetadataHolderRule extends ExternalResource implements MutableAnalysisMetadataHolder {
 
-  private AnalysisMetadataHolderImpl delegate = new AnalysisMetadataHolderImpl();
+  private PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
+  private AnalysisMetadataHolderImpl delegate = new AnalysisMetadataHolderImpl(editionProvider);
 
   @Override
   protected void after() {
-    delegate = new AnalysisMetadataHolderImpl();
+    delegate = new AnalysisMetadataHolderImpl(editionProvider);
   }
 
   @Override
index 750aeace8a05cd9ba750a83c5e6ff935a627d26d..934a2546730d74536324b9a28d06374fba264ac0 100644 (file)
@@ -28,11 +28,13 @@ import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderImpl;
 import org.sonar.ce.task.projectanalysis.analysis.Organization;
 import org.sonar.ce.task.projectanalysis.component.ConfigurationRepository;
 import org.sonar.ce.task.projectanalysis.component.TestSettingsRepository;
+import org.sonar.core.platform.PlatformEditionProvider;
 import org.sonar.db.DbTester;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.db.user.UserDto;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
 
 public class DefaultAssigneeTest {
 
@@ -45,7 +47,7 @@ public class DefaultAssigneeTest {
 
   private MapSettings settings = new MapSettings();
   private ConfigurationRepository settingsRepository = new TestSettingsRepository(settings.asConfig());
-  private AnalysisMetadataHolderImpl analysisMetadataHolder = new AnalysisMetadataHolderImpl();
+  private AnalysisMetadataHolderImpl analysisMetadataHolder = new AnalysisMetadataHolderImpl(mock(PlatformEditionProvider.class));
   private OrganizationDto organizationDto;
 
   private DefaultAssignee underTest = new DefaultAssignee(db.getDbClient(), settingsRepository, analysisMetadataHolder);