Package org.sonar.api.issue

Examples of org.sonar.api.issue.Issuable


        r = File.create(inputPath.relativePath());
      }
    } else {
      r = project;
    }
    Issuable issuable = perspectives.as(Issuable.class, r);
    if (issuable == null) {
      return;
    }
    issuable.addIssue(toDefaultIssue(project.getKey(), ComponentKeys.createEffectiveKey(project, r), issue));
  }
View Full Code Here


      );
  }

  @Override
  public void decorate(Resource resource, DecoratorContext context) {
    Issuable issuable = perspectives.as(Issuable.class, resource);
    if (issuable != null && shouldSaveNewMetrics(context)) {
      List<Issue> issues = newArrayList(issuable.issues());
      saveMeasures(context, issues);
    }
  }
View Full Code Here

    return Arrays.<Metric>asList(CoreMetrics.TECHNICAL_DEBT);
  }

  @Override
  public void decorate(Resource resource, DecoratorContext context) {
    Issuable issuable = perspectives.as(Issuable.class, resource);
    if (issuable != null && shouldSaveMeasure(context)) {
      List<Issue> issues = newArrayList(issuable.issues());
      saveMeasures(context, issues);
    }
  }
View Full Code Here

  public void shouldAddIssueOnFile() {
    InputFile file = new DefaultInputFile("foo", "src/Foo.php");

    ArgumentCaptor<Issue> argumentCaptor = ArgumentCaptor.forClass(Issue.class);

    Issuable issuable = mock(Issuable.class);
    when(resourcePerspectives.as(Issuable.class, File.create("src/Foo.php"))).thenReturn(issuable);

    when(issuable.addIssue(argumentCaptor.capture())).thenReturn(true);

    adaptor.store(new DefaultIssue()
      .onFile(file)
      .ruleKey(RuleKey.of("foo", "bar"))
      .message("Foo")
View Full Code Here

  public void shouldAddIssueOnDirectory() {
    InputDir dir = new DefaultInputDir("foo", "src");

    ArgumentCaptor<Issue> argumentCaptor = ArgumentCaptor.forClass(Issue.class);

    Issuable issuable = mock(Issuable.class);
    when(resourcePerspectives.as(Issuable.class, Directory.create("src"))).thenReturn(issuable);

    when(issuable.addIssue(argumentCaptor.capture())).thenReturn(true);

    adaptor.store(new DefaultIssue()
      .onDir(dir)
      .ruleKey(RuleKey.of("foo", "bar"))
      .message("Foo")
View Full Code Here

  @Test
  public void shouldAddIssueOnProject() {
    ArgumentCaptor<Issue> argumentCaptor = ArgumentCaptor.forClass(Issue.class);

    Issuable issuable = mock(Issuable.class);
    when(resourcePerspectives.as(Issuable.class, (Resource) project)).thenReturn(issuable);

    when(issuable.addIssue(argumentCaptor.capture())).thenReturn(true);

    adaptor.store(new DefaultIssue()
      .onProject()
      .ruleKey(RuleKey.of("foo", "bar"))
      .message("Foo")
View Full Code Here

      .setResolution(Issue.RESOLUTION_FALSE_POSITIVE).setStatus(Issue.STATUS_RESOLVED);
    DefaultIssue fixed = new DefaultIssue().setRuleKey(RuleKey.parse("squid:AvoidCycles"))
      .setResolution(Issue.RESOLUTION_FIXED).setStatus(Issue.STATUS_RESOLVED);

    File file = new File("foo.c");
    Issuable issuable = mock(Issuable.class);
    when(perspectives.as(Issuable.class, file)).thenReturn(issuable);
    when(issuable.resolvedIssues()).thenReturn(Arrays.<Issue>asList(falsePositive, fixed));

    DecoratorContext context = mock(DecoratorContext.class);
    decorator.decorate(file, context);

    verify(context).saveMeasure(CoreMetrics.FALSE_POSITIVE_ISSUES, 1.0);
View Full Code Here

  @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

  @Test
  public void project_should_be_issuable() throws Exception {
    IssuableFactory factory = new IssuableFactory(moduleIssues, cache, projectTree);
    Component component = new ResourceComponent(new Project("Foo").setEffectiveKey("foo"));
    Issuable issuable = factory.loadPerspective(Issuable.class, component);

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

TOP

Related Classes of org.sonar.api.issue.Issuable

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.