From 3c2a001805c160dc7aeb6b9377f52593a355151c Mon Sep 17 00:00:00 2001 From: Torsten Juergeleit Date: Sun, 24 Oct 2021 18:26:01 +0200 Subject: [PATCH] #54 #57 #58 - adds ScannerSide unit test --- .../auth/oidc/AuthOidcPluginTest.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/vaulttec/sonarqube/auth/oidc/AuthOidcPluginTest.java b/src/test/java/org/vaulttec/sonarqube/auth/oidc/AuthOidcPluginTest.java index 3903411..9ecdb2c 100644 --- a/src/test/java/org/vaulttec/sonarqube/auth/oidc/AuthOidcPluginTest.java +++ b/src/test/java/org/vaulttec/sonarqube/auth/oidc/AuthOidcPluginTest.java @@ -22,27 +22,33 @@ import org.junit.Test; import org.sonar.api.Plugin; import org.sonar.api.SonarQubeSide; +import org.sonar.api.SonarRuntime; +import org.sonar.api.internal.PluginContextImpl; import org.sonar.api.internal.SonarRuntimeImpl; import org.sonar.api.utils.Version; public class AuthOidcPluginTest { - MockContext context = new MockContext(); - AuthOidcPlugin underTest = new AuthOidcPlugin(); @Test @SuppressWarnings("unchecked") - public void test_extensions() throws Exception { + public void test_server_side_extensions() throws Exception { + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(7, 6), SonarQubeSide.SERVER); + Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build(); underTest.define(context); assertThat(context.getExtensions()).hasSize(20); } - private static class MockContext extends Plugin.Context { - MockContext() { - super(SonarRuntimeImpl.forSonarQube(Version.create(7, 6), SonarQubeSide.SERVER)); - } + @Test + @SuppressWarnings("unchecked") + public void test_scnner_side_extensions() throws Exception { + SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(7, 6), SonarQubeSide.SCANNER); + Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build(); + underTest.define(context); + + assertThat(context.getExtensions()).isEmpty(); } }