Search in sources :

Example 6 with SonarPublisher

use of hudson.plugins.sonar.SonarPublisher in project sonar-scanner-jenkins by SonarSource.

the class SonarPublisherJdkSlicerTest method availableMavenProjectsWithSonarPublisher.

@Test
public void availableMavenProjectsWithSonarPublisher() throws IOException {
    final MavenModuleSet project = j.jenkins.createProject(MavenModuleSet.class, "random-name");
    assertThat(new SonarPublisherJdkSlicer().getWorkDomain().size()).isZero();
    project.getPublishersList().add(new SonarPublisher("MySonar", null, null, null, null, null, null, null, null, null, false));
    assertThat(new SonarPublisherJdkSlicer().getWorkDomain().size()).isEqualTo(1);
}
Also used : SonarPublisher(hudson.plugins.sonar.SonarPublisher) MavenModuleSet(hudson.maven.MavenModuleSet) Test(org.junit.Test)

Example 7 with SonarPublisher

use of hudson.plugins.sonar.SonarPublisher in project sonar-scanner-jenkins by SonarSource.

the class SonarPublisherSQServerSlicerTest method availableMavenProjectsWithSonarPublisher.

@Test
public void availableMavenProjectsWithSonarPublisher() throws IOException {
    final MavenModuleSet project = j.jenkins.createProject(MavenModuleSet.class, "random-name");
    assertThat(new SonarPublisherSQServerSlicer().getWorkDomain().size()).isZero();
    project.getPublishersList().add(new SonarPublisher("MySonar", null, null, null, null, null, null, null, null, null, false));
    assertThat(new SonarPublisherSQServerSlicer().getWorkDomain().size()).isEqualTo(1);
}
Also used : SonarPublisher(hudson.plugins.sonar.SonarPublisher) MavenModuleSet(hudson.maven.MavenModuleSet) Test(org.junit.Test)

Example 8 with SonarPublisher

use of hudson.plugins.sonar.SonarPublisher in project sonar-scanner-jenkins by SonarSource.

the class SonarPublisherSQServerSlicerTest method changeJobAdditionalProperties.

@Test
public void changeJobAdditionalProperties() throws Exception {
    final MavenModuleSet project = j.jenkins.createProject(MavenModuleSet.class, "random-name");
    final SonarPublisher mySonar = new SonarPublisher("MySonar", null, null, null, null, null, null, null, null, null, false);
    project.getPublishersList().add(mySonar);
    final SonarPublisherSQServerSlicer.SonarPublisherSQInstallSlicerSpec spec = new SonarPublisherSQServerSlicer.SonarPublisherSQInstallSlicerSpec();
    final List<String> values = spec.getValues(project);
    assertThat(values.get(0)).isEqualTo("MySonar");
    final List<String> newValues = new ArrayList<String>();
    newValues.add("MySonar 2");
    spec.setValues(project, newValues);
    assertThat(mySonar.getInstallationName()).isEqualTo("MySonar 2");
}
Also used : SonarPublisher(hudson.plugins.sonar.SonarPublisher) ArrayList(java.util.ArrayList) MavenModuleSet(hudson.maven.MavenModuleSet) Test(org.junit.Test)

Example 9 with SonarPublisher

use of hudson.plugins.sonar.SonarPublisher in project sonar-scanner-jenkins by SonarSource.

the class SonarMavenTest method shouldWrapUpArguments.

@Test
public void shouldWrapUpArguments() throws Exception {
    SonarPublisher publisher = mock(SonarPublisher.class);
    SonarInstallation installation = mock(SonarInstallation.class);
    when(installation.getServerUrl()).thenReturn("hostUrl");
    when(installation.getServerAuthenticationToken()).thenReturn("xyz");
    when(publisher.getInstallation()).thenReturn(installation);
    when(publisher.getBranch()).thenReturn("branch");
    ArgumentListBuilder args = new ArgumentListBuilder();
    SonarMaven sonarMaven = new SonarMaven("-Dprop=value", "Default Maven", "pom.xml", "", new DefaultLocalRepositoryLocator(), publisher, mock(BuildListener.class), null, null, null);
    sonarMaven.wrapUpArguments(args, "sonar:sonar", mock(AbstractBuild.class), mock(Launcher.class), mock(BuildListener.class));
    List<String> result = args.toList();
    assertThat(result).contains("-Dprop=value");
    assertThat(result).contains("-Dsonar.host.url=hostUrl");
    assertThat(result).contains("-Dsonar.branch=branch");
    assertThat(result).contains("-Dsonar.login=xyz");
}
Also used : BuildListener(hudson.model.BuildListener) AbstractBuild(hudson.model.AbstractBuild) SonarPublisher(hudson.plugins.sonar.SonarPublisher) SonarInstallation(hudson.plugins.sonar.SonarInstallation) Launcher(hudson.Launcher) ArgumentListBuilder(hudson.util.ArgumentListBuilder) DefaultLocalRepositoryLocator(hudson.maven.local_repo.DefaultLocalRepositoryLocator) Test(org.junit.Test)

Aggregations

SonarPublisher (hudson.plugins.sonar.SonarPublisher)9 Test (org.junit.Test)9 MavenModuleSet (hudson.maven.MavenModuleSet)8 ArrayList (java.util.ArrayList)4 Launcher (hudson.Launcher)1 DefaultLocalRepositoryLocator (hudson.maven.local_repo.DefaultLocalRepositoryLocator)1 AbstractBuild (hudson.model.AbstractBuild)1 BuildListener (hudson.model.BuildListener)1 SonarInstallation (hudson.plugins.sonar.SonarInstallation)1 ArgumentListBuilder (hudson.util.ArgumentListBuilder)1