Search in sources :

Example 11 with Project

use of org.sonar.api.resources.Project in project sonarqube by SonarSource.

the class PhasesSumUpTimeProfilerTest method testSimpleProject.

@Test
public void testSimpleProject() throws InterruptedException {
    final Project project = mockProject("my:project", true);
    fakeAnalysis(profiler, project);
    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(7L);
    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(10L);
    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.POSTJOB).getProfilingPerItem(new FakePostJob()).totalTime()).isEqualTo(30L);
    assertThat(profiler.currentModuleProfiling.getProfilingPerBatchStep("Free memory").totalTime()).isEqualTo(9L);
}
Also used : Project(org.sonar.api.resources.Project) Test(org.junit.Test)

Example 12 with Project

use of org.sonar.api.resources.Project in project sonarqube by SonarSource.

the class PhasesSumUpTimeProfilerTest method testMultimoduleProject.

@Test
public void testMultimoduleProject() throws InterruptedException {
    final Project project = mockProject("project root", true);
    final Project moduleA = mockProject("moduleA", false);
    final Project moduleB = mockProject("moduleB", false);
    project.definition().addSubProject(moduleA.definition());
    project.definition().addSubProject(moduleA.definition());
    fakeAnalysis(profiler, moduleA);
    fakeAnalysis(profiler, moduleB);
    fakeAnalysis(profiler, project);
    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(7L);
    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(10L);
    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.POSTJOB).getProfilingPerItem(new FakePostJob()).totalTime()).isEqualTo(30L);
    assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(21L);
    assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(30L);
    assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.POSTJOB).getProfilingPerItem(new FakePostJob()).totalTime()).isEqualTo(90L);
}
Also used : Project(org.sonar.api.resources.Project) Test(org.junit.Test)

Example 13 with Project

use of org.sonar.api.resources.Project in project sonarlint-core by SonarSource.

the class ScannerExtensionDictionnaryTest method buildStatusCheckersAreExecutedAfterOtherPostJobs.

@Test
public void buildStatusCheckersAreExecutedAfterOtherPostJobs() {
    BuildBreaker checker = new BuildBreaker() {

        public void executeOn(Project project, SensorContext context) {
        }
    };
    ScannerExtensionDictionnary selector = newSelector(new FakePostJob(), checker, new FakePostJob());
    List extensions = Lists.newArrayList(selector.select(PostJob.class, null, true));
    assertThat(extensions).hasSize(3);
    assertThat(extensions.get(2)).isEqualTo(checker);
}
Also used : SensorContext(org.sonar.api.batch.SensorContext) CheckProject(org.sonar.api.batch.CheckProject) Project(org.sonar.api.resources.Project) BuildBreaker(org.sonar.api.batch.BuildBreaker) List(java.util.List) PostJob(org.sonar.api.batch.PostJob) Test(org.junit.Test)

Aggregations

Project (org.sonar.api.resources.Project)13 Test (org.junit.Test)7 CheckProject (org.sonar.api.batch.CheckProject)3 PostJob (org.sonar.api.batch.PostJob)3 List (java.util.List)2 BuildBreaker (org.sonar.api.batch.BuildBreaker)2 SensorContext (org.sonar.api.batch.SensorContext)2 Properties (java.util.Properties)1 Before (org.junit.Before)1 BatchExtension (org.sonar.api.BatchExtension)1 CoreProperties (org.sonar.api.CoreProperties)1 AnalysisMode (org.sonar.api.batch.AnalysisMode)1 Initializer (org.sonar.api.batch.Initializer)1 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)1 InputFile (org.sonar.api.batch.fs.InputFile)1 InputComponentTree (org.sonar.api.batch.fs.internal.InputComponentTree)1 RulesProfile (org.sonar.api.profiles.RulesProfile)1 Directory (org.sonar.api.resources.Directory)1 RuleFinder (org.sonar.api.rules.RuleFinder)1 Profiler (org.sonar.api.utils.log.Profiler)1