Package org.sonar.api.resources

Examples of org.sonar.api.resources.File


  }

  @Test
  public void should_not_save_violation_if_resource_not_indexed() {
    Rule rule = Rule.create("repoKey", "ruleKey", "Rule");
    File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
    Violation violation = Violation.create(rule, file);
    when(deprecatedViolations.get(anyString())).thenReturn(newArrayList(violation));

    index.addViolation(violation);
View Full Code Here


  }

  @Test
  public void should_get_filtered_violation_with_off_switch_mode() {
    Rule rule = Rule.create("repoKey", "ruleKey", "Rule");
    File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
    Violation violation = Violation.create(rule, file).setSwitchedOff(true);

    when(deprecatedViolations.get(anyString())).thenReturn(newArrayList(violation));

    index.index(file);
View Full Code Here

  }

  @Test
  public void should_get_filtered_violation_with_on_switch_mode() {
    Rule rule = Rule.create("repoKey", "ruleKey", "Rule");
    File file = File.create("src/org/foo/Bar.java", "org/foo/Bar.java", null, false);
    Violation violation = Violation.create(rule, file).setSwitchedOff(false);

    when(deprecatedViolations.get(anyString())).thenReturn(newArrayList(violation));

    index.index(file);
View Full Code Here

  ComponentDataCache cache = mock(ComponentDataCache.class);

  @Test
  public void should_load_default_perspective() throws Exception {
    Resource file = new File("foo.c").setEffectiveKey("myproject:path/to/foo.c");
    Component component = new ResourceComponent(file);

    HighlightableBuilder builder = new HighlightableBuilder(cache);
    Highlightable perspective = builder.loadPerspective(Highlightable.class, component);
View Full Code Here

    ruleBuilder.add(SQUID_RULE_KEY).setName(SQUID_RULE_NAME);
    activeRulesBuilder.create(SQUID_RULE_KEY).setSeverity(Severity.INFO).activate();
    initModuleIssues();

    org.sonar.api.rules.Rule rule = org.sonar.api.rules.Rule.create("squid", "AvoidCycle", "Avoid Cycle");
    Resource resource = new File("org/struts/Action.java").setEffectiveKey("struts:src/org/struts/Action.java");
    Violation violation = new Violation(rule, resource);
    violation.setLineId(42);
    violation.setSeverity(RulePriority.CRITICAL);
    violation.setMessage("the message");
View Full Code Here

  ProjectTree projectTree = mock(ProjectTree.class);

  @Test
  public void file_should_be_issuable() throws Exception {
    IssuableFactory factory = new IssuableFactory(moduleIssues, cache, projectTree);
    Component component = new ResourceComponent(new File("foo/bar.c").setEffectiveKey("foo/bar.c"));
    Issuable issuable = factory.loadPerspective(Issuable.class, component);

    assertThat(issuable).isNotNull();
    assertThat(issuable.component()).isSameAs(component);
    assertThat(issuable.issues()).isEmpty();
View Full Code Here

    sourcePersister = new SourcePersister(resourcePersister, new SnapshotSourceDao(getMyBatis()));
  }

  @Test
  public void shouldSaveSource() {
    sourcePersister.saveSource(new File("org/foo/Bar.java"), "this is the file content", DateUtils.parseDateTime("2014-10-31T16:44:02+0100"));
    checkTables("shouldSaveSource", "snapshot_sources");
  }
View Full Code Here

    assertThat(decorator.shouldExecuteOnProject(project)).isTrue();
  }

  @Test
  public void shouldNotDecorateIfNotRootProject() {
    decorator.decorate(new File("Foo"), context);
    verify(context, never()).createEvent(anyString(), anyString(), anyString(), (Date) isNull());
  }
View Full Code Here

    assertThat(decorator.shouldExecuteOnProject(null)).isTrue();
  }

  @Test
  public void not_execute_on_unit_test() throws Exception {
    File resource = mock(File.class);
    when(resource.getQualifier()).thenReturn(Qualifiers.UNIT_TEST_FILE);
    DecoratorContext context = mock(DecoratorContext.class);

    SqaleRatingDecorator decorator = new SqaleRatingDecorator();
    decorator.decorate(resource, context);
View Full Code Here

    DefaultResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), snapshotCache, resourceCache);
    persister.saveProject(multiModuleProject, null);
    persister.saveProject(moduleA, multiModuleProject);
    persister.saveResource(moduleA, new Directory("org/foo").setEffectiveKey("a:org/foo"));
    persister.saveResource(moduleA, new File("org/foo/MyClass.java").setEffectiveKey("a:org/foo/MyClass.java"));
    persister.clear();

    assertThat(persister.getSnapshotsByResource().size(), is(2));
    assertThat(persister.getSnapshotsByResource().get(multiModuleProject), notNullValue());
    assertThat(persister.getSnapshotsByResource().get(moduleA), notNullValue());
View Full Code Here

TOP

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

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.