Package org.sonar.api.batch.bootstrap

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition


  @Test
  public void shouldNotConvertLinksToPropertiesIfPropertyAlreadyDefined() throws Exception {
    MavenProject pom = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/projectWithLinksAndProperties/pom.xml", true);

    ProjectDefinition rootDef = converter.configure(Arrays.asList(pom), pom);

    Properties props = rootDef.getProperties();

    // Those properties have been fed by the POM elements <ciManagement>, <issueManagement>, ...
    assertThat(props.getProperty(CoreProperties.LINKS_CI)).isEqualTo("http://ci.com");
    assertThat(props.getProperty(CoreProperties.LINKS_ISSUE_TRACKER)).isEqualTo("http://issues.com");
    assertThat(props.getProperty(CoreProperties.LINKS_SOURCES_DEV)).isEqualTo("http://sources-dev.com");
View Full Code Here


  @Test
  public void shouldLoadSourceEncoding() throws Exception {
    MavenProject pom = loadPom("/org/sonar/batch/maven/MavenProjectConverterTest/sourceEncoding/pom.xml", true);

    ProjectDefinition rootDef = converter.configure(Arrays.asList(pom), pom);

    assertThat(rootDef.getProperties().getProperty(CoreProperties.ENCODING_PROPERTY)).isEqualTo("Shift_JIS");
  }
View Full Code Here

  }

  // SONAR-4876
  @Test
  public void shouldDefineMultiModuleProjectWithModuleKey() throws IOException {
    ProjectDefinition rootProject = loadProjectDefinition("multi-module-definitions-moduleKey");

    // CHECK ROOT
    // module properties must have been cleaned
    assertThat(rootProject.getProperties().getProperty("module1.sonar.moduleKey")).isNull();
    assertThat(rootProject.getProperties().getProperty("module2.sonar.moduleKey")).isNull();

    // CHECK MODULES
    List<ProjectDefinition> modules = rootProject.getSubProjects();
    assertThat(modules.size()).isEqualTo(2);

    // Module 2
    ProjectDefinition module2 = modules.get(1);
    assertThat(module2.getKey()).isEqualTo("com.foo.project.module2");
  }
View Full Code Here

  }

  // SONARPLUGINS-2421
  @Test
  public void shouldDefineMultiLanguageProjectWithDefinitionsAllInRootProject() throws IOException {
    ProjectDefinition rootProject = loadProjectDefinition("multi-language-definitions-all-in-root");

    // CHECK ROOT
    assertThat(rootProject.getKey()).isEqualTo("example");
    assertThat(rootProject.getName()).isEqualTo("Example");
    assertThat(rootProject.getVersion()).isEqualTo("1.0");

    // CHECK MODULES
    List<ProjectDefinition> modules = rootProject.getSubProjects();
    assertThat(modules.size()).isEqualTo(2);

    // Module 1
    ProjectDefinition module1 = modules.get(0);
    assertThat(module1.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"));
    assertThat(module1.getSourceDirs()).contains("src/main/java");
    // and module properties must have been cleaned
    assertThat(module1.getWorkDir().getCanonicalFile())
      .isEqualTo(new File(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_java-module"));

    // Module 2
    ProjectDefinition module2 = modules.get(1);
    assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"));
    assertThat(module2.getSourceDirs()).contains("src/main/groovy");
    // and module properties must have been cleaned
    assertThat(module2.getWorkDir().getCanonicalFile())
      .isEqualTo(new File(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_groovy-module"));
  }
View Full Code Here

      .isEqualTo(new File(TestUtils.getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_groovy-module"));
  }

  @Test
  public void shouldDefineMultiModuleProjectWithBaseDir() throws IOException {
    ProjectDefinition rootProject = loadProjectDefinition("multi-module-with-basedir");
    List<ProjectDefinition> modules = rootProject.getSubProjects();
    assertThat(modules.size()).isEqualTo(1);
    assertThat(modules.get(0).getKey()).isEqualTo("com.foo.project:com.foo.project.module1");
  }
View Full Code Here

    loadProjectDefinition("simple-project-with-unexisting-lib");
  }

  @Test
  public void shouldGetLibDirectory() throws IOException {
    ProjectDefinition def = loadProjectDefinition("simple-project-with-lib-dir");
    assertThat(def.getLibraries()).hasSize(1);
    File libDir = new File(def.getLibraries().get(0));
    assertThat(libDir).isDirectory().exists();
    assertThat(libDir.getName()).isEqualTo("lib");
  }
View Full Code Here

  @Test
  public void shouldFailIf2ModulesWithSameKey() {
    Properties props = new Properties();
    props.put("sonar.projectKey", "root");
    ProjectDefinition root = ProjectDefinition.create().setProperties(props);

    Properties props1 = new Properties();
    props1.put("sonar.projectKey", "mod1");
    root.addSubProject(ProjectDefinition.create().setProperties(props1));

    // Check uniqueness of a new module: OK
    Properties props2 = new Properties();
    props2.put("sonar.projectKey", "mod2");
    ProjectDefinition mod2 = ProjectDefinition.create().setProperties(props2);
    ProjectReactorBuilder.checkUniquenessOfChildKey(mod2, root);

    // Now, add it and check again
    root.addSubProject(mod2);
View Full Code Here

    assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu");
  }

  @Test
  public void shouldDefineProjectWithBuildDir() throws IOException {
    ProjectDefinition rootProject = loadProjectDefinition("simple-project-with-build-dir");
    File buildDir = rootProject.getBuildDir();
    assertThat(buildDir).isDirectory().exists();
    assertThat(new File(buildDir, "report.txt")).isFile().exists();
    assertThat(buildDir.getName()).isEqualTo("build");
  }
View Full Code Here

    MavenProject rootProject = mock(MavenProject.class);
    when(rootProject.isExecutionRoot()).thenReturn(true);
    when(session.getSortedProjects()).thenReturn(Arrays.asList(rootProject));

    MavenProjectConverter mavenProjectConverter = mock(MavenProjectConverter.class);
    ProjectDefinition projectDefinition = ProjectDefinition.create();
    when(mavenProjectConverter.configure(any(List.class), any(MavenProject.class))).thenReturn(projectDefinition);
    MavenProjectBootstrapper builder = new MavenProjectBootstrapper(session, mavenProjectConverter);

    assertThat(builder.bootstrap().getRoot()).isEqualTo(projectDefinition);
View Full Code Here

    when(module1.isExecutionRoot()).thenReturn(false);
    when(module2.isExecutionRoot()).thenReturn(false);
    when(session.getSortedProjects()).thenReturn(Arrays.asList(module1, module2, rootProject));

    MavenProjectConverter mavenProjectConverter = mock(MavenProjectConverter.class);
    ProjectDefinition projectDefinition = ProjectDefinition.create();
    when(mavenProjectConverter.configure(any(List.class), any(MavenProject.class))).thenReturn(projectDefinition);
    MavenProjectBootstrapper builder = new MavenProjectBootstrapper(session, mavenProjectConverter);

    assertThat(builder.bootstrap().getRoot()).isEqualTo(projectDefinition);
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.bootstrap.ProjectDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.