Skip to content

Commit

Permalink
#54 #57 #58 - adds ScannerSide unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tjuerge committed Oct 24, 2021
1 parent 0f5d503 commit 3c2a001
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}

0 comments on commit 3c2a001

Please sign in to comment.