Package org.sonar.api.resources

Examples of org.sonar.api.resources.Project


  public Project build() {
    when(pom.getGroupId()).thenReturn("mygroup");
    when(pom.getArtifactId()).thenReturn("myartifact");
    when(pom.isExecutionRoot()).thenReturn(true);
    return new Project("mygroup:myartifact").setPom(pom);
  }
View Full Code Here


    db.prepareDbUnit(getClass(), "last_snapshot.xml");
    ServerClient server = mock(ServerClient.class);

    LastSnapshots lastSnapshots = new LastSnapshots(mode, new SnapshotSourceDao(db.myBatis()), server);

    String source = lastSnapshots.getSource(new Project("my-project"));
    assertThat(source).isEqualTo("");
  }
View Full Code Here

  @Test
  public void always_save_technical_debt_for_positive_values() throws Exception {
    // for a project
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getResource()).thenReturn(new Project("foo"));
    decorator.saveCharacteristicMeasure(context, (Characteristic) null, 12.0, false);
    verify(context, times(1)).saveMeasure(new Measure(CoreMetrics.TECHNICAL_DEBT));

    // or for a file
    context = mock(DecoratorContext.class);
View Full Code Here

  }

  @Test
  public void always_save_technical_debt_for_project_if_top_characteristic() throws Exception {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getResource()).thenReturn(new Project("foo"));

    // this is a top characteristic
    DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic().setKey("root");

    decorator.saveCharacteristicMeasure(context, rootCharacteristic, 0.0, true);
View Full Code Here

   * SQALE-147
   */
  @Test
  public void never_save_technical_debt_for_project_if_not_top_characteristic() throws Exception {
    DecoratorContext context = mock(DecoratorContext.class);
    when(context.getResource()).thenReturn(new Project("foo"));

    DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic().setKey("EFFICIENCY");
    DefaultCharacteristic characteristic = new DefaultCharacteristic().setKey("MEMORY_EFFICIENCY").setParent(rootCharacteristic);

    decorator.saveCharacteristicMeasure(context, characteristic, 0.0, true);
View Full Code Here

public class InitializerTest {

  @Test
  public void shouldBeExecutedByDefault() {
    Project project = mock(Project.class);
    assertThat(new FakeInitializer().shouldExecuteOnProject(project)).isTrue();
  }
View Full Code Here

    ProjectTree projectTree = mock(ProjectTree.class);
    index = new DefaultIndex(mock(PersistenceManager.class), projectTree, metricFinder, mock(ScanGraph.class), deprecatedViolations, mock(ResourceKeyMigration.class),
      mock(MeasureCache.class));

    java.io.File baseDir = temp.newFolder();
    project = new Project("project");
    when(projectTree.getProjectDefinition(project)).thenReturn(ProjectDefinition.create().setBaseDir(baseDir));
    moduleA = new Project("moduleA").setParent(project);
    when(projectTree.getProjectDefinition(moduleA)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleA")));
    moduleB = new Project("moduleB").setParent(project);
    when(projectTree.getProjectDefinition(moduleB)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB")));
    moduleB1 = new Project("moduleB1").setParent(moduleB);
    when(projectTree.getProjectDefinition(moduleB1)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1")));

    RulesProfile rulesProfile = RulesProfile.create();
    rule = Rule.create("repoKey", "ruleKey", "Rule");
    rule.setId(1);
View Full Code Here

    assertThat(perspective.component()).isSameAs(component);
  }

  @Test
  public void project_should_not_be_highlightable() {
    Component component = new ResourceComponent(new Project("struts").setEffectiveKey("org.struts"));

    HighlightableBuilder builder = new HighlightableBuilder(cache);
    Highlightable perspective = builder.loadPerspective(Highlightable.class, component);

    assertThat(perspective).isNull();
View Full Code Here

    this.system = system;
  }

  @Override
  public void onProjectAnalysis(ProjectAnalysisEvent event) {
    Project module = event.getProject();
    if (event.isStart()) {
      decoratorsProfiler = new DecoratorsProfiler();
      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, fileName);
      totalProfiling.merge(currentModuleProfiling);
      if (module.isRoot() && !module.getModules().isEmpty()) {
        dumpTotalExecutionSummary();
      }
    }
  }
View Full Code Here

  private Metric withFormula2 = new Metric("metric2").setFormula(new FakeFormula());
  private Metric withoutFormula3 = new Metric("metric3");

  @Test
  public void selectAndSortFormulas() {
    Project project = new Project("key");
    BatchExtensionDictionnary batchExtDictionnary = newBatchDictionnary(withFormula1, withoutFormula3, withFormula2);

    Collection<Decorator> decorators = new DecoratorsSelector(batchExtDictionnary).select(project);
    assertThat(decorators).hasSize(2);
    assertThat(decorators).contains(new FormulaDecorator(withFormula1));
View Full Code Here

TOP

Related Classes of org.sonar.api.resources.Project

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.