]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14675 Community Edition should have an EditionProvider
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 13 Apr 2021 02:59:01 +0000 (21:59 -0500)
committersonartech <sonartech@sonarsource.com>
Wed, 14 Apr 2021 20:03:29 +0000 (20:03 +0000)
sonar-core/src/main/java/org/sonar/core/platform/PlatformEditionProvider.java
sonar-core/src/test/java/org/sonar/core/platform/PlatformEditionProviderTest.java

index 0e5d68a948915b1424c38726b45589831ef36d20..6ab15b1fb56415da9affb049add91ca638071c77 100644 (file)
@@ -21,27 +21,9 @@ package org.sonar.core.platform;
 
 import java.util.Optional;
 
-import static com.google.common.base.Preconditions.checkState;
-import static org.sonar.core.platform.EditionProvider.Edition.COMMUNITY;
-
 public class PlatformEditionProvider implements EditionProvider {
-  private static final EditionProvider[] NO_OTHER_PROVIDERS = new EditionProvider[0];
-  private final EditionProvider[] otherEditionProviders;
-
-  public PlatformEditionProvider() {
-    this(NO_OTHER_PROVIDERS);
-  }
-
-  public PlatformEditionProvider(EditionProvider[] otherEditionProviders) {
-    this.otherEditionProviders = otherEditionProviders;
-  }
-
   @Override
   public Optional<Edition> get() {
-    checkState(otherEditionProviders.length <= 1, "There can't be more than 1 other EditionProvider");
-    if (otherEditionProviders.length == 1) {
-      return otherEditionProviders[0].get();
-    }
-    return Optional.of(COMMUNITY);
+    return Optional.of(Edition.COMMUNITY);
   }
 }
index a6793840b81e4508742c4f1ea9b3ab5d533f8067..038ab7143e83cfa7e4b38a12fbd7a34aa748337e 100644 (file)
  */
 package org.sonar.core.platform;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
-import static java.util.Optional.of;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.core.platform.EditionProvider.Edition.COMMUNITY;
-import static org.sonar.core.platform.EditionProvider.Edition.DATACENTER;
-import static org.sonar.core.platform.EditionProvider.Edition.DEVELOPER;
 
 public class PlatformEditionProviderTest {
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  @Test
-  public void returns_COMMUNITY_when_there_is_no_other_EditionProvider() {
-    ComponentContainer container = new ComponentContainer();
-    ComponentContainer child = new ComponentContainer(container);
-    child.add(PlatformEditionProvider.class);
-
-    assertThat(container.getComponentByType(PlatformEditionProvider.class)).isNull();
-    PlatformEditionProvider platformEditionProvider = child.getComponentByType(PlatformEditionProvider.class);
-    assertThat(platformEditionProvider.get()).contains(COMMUNITY);
-  }
-
-  @Test
-  public void returns_edition_from_other_EditionProvider_in_any_container() {
-    ComponentContainer container = new ComponentContainer();
-    container.add((EditionProvider) () -> of(DATACENTER));
-    ComponentContainer child = new ComponentContainer(container);
-    child.add(PlatformEditionProvider.class);
-
-    assertThat(container.getComponentByType(PlatformEditionProvider.class)).isNull();
-    PlatformEditionProvider platformEditionProvider = child.getComponentByType(PlatformEditionProvider.class);
-    assertThat(platformEditionProvider.get()).contains(DATACENTER);
-  }
-
   @Test
-  public void get_fails_with_ISE_if_there_is_more_than_one_other_EditionProvider_in_any_container() {
-    ComponentContainer container = new ComponentContainer();
-    container.add((EditionProvider) () -> of(DATACENTER));
-    ComponentContainer child = new ComponentContainer(container);
-    child.add((EditionProvider) () -> of(DEVELOPER));
-    child.add(PlatformEditionProvider.class);
-
-    assertThat(container.getComponentByType(PlatformEditionProvider.class)).isNull();
-    PlatformEditionProvider platformEditionProvider = child.getComponentByType(PlatformEditionProvider.class);
-
-    expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage("There can't be more than 1 other EditionProvider");
-
-    platformEditionProvider.get();
+  public void returns_COMMUNITY() {
+    assertThat(new PlatformEditionProvider().get()).contains(COMMUNITY);
   }
 }