Search in sources :

Example 1 with SonarPublisher

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

the class SonarPublisherBranchSlicerTest method changeJobAdditionalProperties.

@Test
public void changeJobAdditionalProperties() throws IOException {
    final MavenModuleSet project = j.jenkins.createProject(MavenModuleSet.class, "random-name");
    project.getPublishersList().add(new SonarPublisher("MySonar", null, null, null, null, null, null, null, null, null, false));
    final SonarPublisherBranchSlicer.SonarPublisherBranchSlicerSpec branchSpec = new SonarPublisherBranchSlicer.SonarPublisherBranchSlicerSpec();
    final List<String> values = branchSpec.getValues(project);
    assertThat(values.get(0)).isEqualTo("(Empty)");
    final List<String> newValues = new ArrayList<String>();
    newValues.add("branchName");
    branchSpec.setValues(project, newValues);
    final SonarPublisher publisher = project.getPublishersList().get(SonarPublisher.class);
    assertThat(publisher.getBranch()).isEqualTo("branchName");
}
Also used : SonarPublisher(hudson.plugins.sonar.SonarPublisher) ArrayList(java.util.ArrayList) MavenModuleSet(hudson.maven.MavenModuleSet) Test(org.junit.Test)

Example 2 with SonarPublisher

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

the class SonarPublisherJdkSlicerTest 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, "1.7", null, null, false);
    project.getPublishersList().add(mySonar);
    final SonarPublisherJdkSlicer.SonarPublisherJdkSlicerSpec spec = new SonarPublisherJdkSlicer.SonarPublisherJdkSlicerSpec();
    final List<String> values = spec.getValues(project);
    assertThat(values.get(0)).isEqualTo("1.7");
    final List<String> newValues = new ArrayList<String>();
    newValues.add("1.7");
    spec.setValues(project, newValues);
    assertThat(mySonar.getJdkName()).isEqualTo("1.7");
}
Also used : SonarPublisher(hudson.plugins.sonar.SonarPublisher) ArrayList(java.util.ArrayList) MavenModuleSet(hudson.maven.MavenModuleSet) Test(org.junit.Test)

Example 3 with SonarPublisher

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

the class SonarPublisherAdditionalPropertiesSlicerTest method availableMavenProjectsWithSonarPublisher.

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

Example 4 with SonarPublisher

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

the class SonarPublisherAdditionalPropertiesSlicerTest method changeJobAdditionalProperties.

@Test
public void changeJobAdditionalProperties() throws IOException {
    final MavenModuleSet project = j.jenkins.createProject(MavenModuleSet.class, "random-name");
    project.getPublishersList().add(new SonarPublisher("MySonar", null, null, "-Dsonar.verbose", null, null, null, null, null, null, false));
    final SonarPublisherAdditionalPropertiesSlicer.SonarPublisherAdditionalPropertiesSlicerSpec propertiesSpec = new SonarPublisherAdditionalPropertiesSlicer.SonarPublisherAdditionalPropertiesSlicerSpec();
    final List<String> values = propertiesSpec.getValues(project);
    assertThat(values.get(0)).isEqualTo("-Dsonar.verbose");
    final List<String> newValues = new ArrayList<String>();
    newValues.add("-Dsonar.showSql");
    propertiesSpec.setValues(project, newValues);
    final SonarPublisher publisher = project.getPublishersList().get(SonarPublisher.class);
    assertThat(publisher.getJobAdditionalProperties()).isEqualTo("-Dsonar.showSql");
}
Also used : SonarPublisher(hudson.plugins.sonar.SonarPublisher) ArrayList(java.util.ArrayList) MavenModuleSet(hudson.maven.MavenModuleSet) Test(org.junit.Test)

Example 5 with SonarPublisher

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

the class SonarPublisherBranchSlicerTest method availableMavenProjectsWithSonarPublisher.

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