use of org.sonar.api.resources.Project in project sonarqube by SonarSource.
the class DefaultIndexTest method createIndex.
@Before
public void createIndex() throws IOException {
ruleFinder = mock(RuleFinder.class);
componentStore = mock(InputComponentStore.class);
componentTree = mock(InputComponentTree.class);
index = new DefaultIndex(componentStore, componentTree, mock(MeasureCache.class), mock(MetricFinder.class));
baseDir = temp.newFolder();
ProjectDefinition rootDef = ProjectDefinition.create().setKey("project").setBaseDir(baseDir);
ProjectDefinition moduleADef = ProjectDefinition.create().setKey("moduleA").setBaseDir(new java.io.File(baseDir, "moduleA"));
ProjectDefinition moduleBDef = ProjectDefinition.create().setKey("moduleB").setBaseDir(new java.io.File(baseDir, "moduleB"));
ProjectDefinition moduleB1Def = ProjectDefinition.create().setKey("moduleB1").setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1"));
rootDef.addSubProject(moduleADef);
rootDef.addSubProject(moduleBDef);
moduleBDef.addSubProject(moduleB1Def);
project = new Project(rootDef);
moduleA = new Project(moduleADef);
moduleB = new Project(moduleBDef);
moduleB1 = new Project(moduleB1Def);
RulesProfile rulesProfile = RulesProfile.create();
rule = Rule.create("repoKey", "ruleKey", "Rule");
rule.setId(1);
rulesProfile.activateRule(rule, null);
index.setCurrentStorage(mock(DefaultSensorStorage.class));
}
use of org.sonar.api.resources.Project in project sonarlint-core by SonarSource.
the class ScannerExtensionDictionnaryTest method checkProject.
@Test
public void checkProject() {
BatchExtension ok = new CheckProjectOK();
BatchExtension ko = new CheckProjectKO();
ScannerExtensionDictionnary selector = newSelector(ok, ko);
List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, new Project(ProjectDefinition.create().setKey("key")), true));
assertThat(extensions).hasSize(1);
assertThat(extensions.get(0)).isInstanceOf(CheckProjectOK.class);
}
use of org.sonar.api.resources.Project in project sonarqube by SonarSource.
the class PhasesSumUpTimeProfiler method onProjectAnalysis.
@Override
public void onProjectAnalysis(ProjectAnalysisEvent event) {
Project module = event.getProject();
if (event.isStart()) {
currentModuleProfiling = new ModuleProfiling(module, system);
} else {
currentModuleProfiling.stop();
modulesProfilings.put(module, currentModuleProfiling);
long moduleTotalTime = currentModuleProfiling.totalTime();
println("");
println(" -------- Profiling of module " + module.getName() + ": " + TimeUtils.formatDuration(moduleTotalTime) + " --------");
println("");
Properties props = new Properties();
currentModuleProfiling.dump(props);
println("");
println(" -------- End of profiling of module " + module.getName() + " --------");
println("");
String fileName = module.getKey() + "-profiler.properties";
dumpToFile(props, ScannerUtils.cleanKeyForFilename(fileName));
totalProfiling.merge(currentModuleProfiling);
if (module.getParent() == null && !module.getModules().isEmpty()) {
dumpTotalExecutionSummary();
}
}
}
use of org.sonar.api.resources.Project in project sonarqube by SonarSource.
the class InitializersExecutor method execute.
public void execute() {
Collection<Initializer> initializers = selector.select(Initializer.class, module, true, null);
eventBus.fireEvent(new InitializersPhaseEvent(Lists.newArrayList(initializers), true));
if (LOG.isDebugEnabled()) {
LOG.debug("Initializers : {}", StringUtils.join(initializers, " -> "));
}
Project project = new Project(module.definition());
for (Initializer initializer : initializers) {
eventBus.fireEvent(new InitializerExecutionEvent(initializer, true));
Profiler profiler = Profiler.create(LOG).startInfo("Initializer " + initializer);
initializer.execute(project);
profiler.stopInfo();
eventBus.fireEvent(new InitializerExecutionEvent(initializer, false));
}
eventBus.fireEvent(new InitializersPhaseEvent(Lists.newArrayList(initializers), false));
}
use of org.sonar.api.resources.Project in project sonarqube 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, null));
assertThat(extensions).hasSize(3);
assertThat(extensions.get(2)).isEqualTo(checker);
}
Aggregations