Package org.sonar.api.resources

Examples of org.sonar.api.resources.File


  }

  @Test
  public void saveZeroIfNoDuplications() {
    SumDuplicationsDecorator decorator = new SumDuplicationsDecorator();
    File file = new File("org/foo/BarTest.java");
    DecoratorContext context = mock(DecoratorContext.class);

    decorator.decorate(file, context);

    verify(context).saveMeasure(argThat(new IsMeasure(CoreMetrics.DUPLICATED_LINES, 0.0)));
View Full Code Here


  public void shouldComputeVariations() {
    TimeMachineConfiguration timeMachineConfiguration = mock(TimeMachineConfiguration.class);
    VariationDecorator decorator = new VariationDecorator(mock(PastMeasuresLoader.class), mock(MetricFinder.class), timeMachineConfiguration, mock(RuleFinder.class));

    assertThat(decorator.shouldComputeVariation(new Project("foo"))).isTrue();
    assertThat(decorator.shouldComputeVariation(new File("foo/bar.c"))).isFalse();
  }
View Full Code Here

  @Test
  public void testCopyManualMeasures() throws Exception {
    setupData("testCopyManualMeasures");

    File javaFile = new File("Foo.java");
    javaFile.setId(40);

    ManualMeasureDecorator decorator = new ManualMeasureDecorator(getSession(), new DefaultMetricFinder(getSessionFactory()));
    DecoratorContext context = mock(DecoratorContext.class);
    decorator.decorate(javaFile, context);
View Full Code Here

  }

  @Test
  public void shouldStoreDependencyInSameFolder() {

    File foo = File.create("src/Foo.java");
    File bar = File.create("src/Bar.java");
    when(sensorContext.getResource(foo)).thenReturn(foo);
    when(sensorContext.getResource(bar)).thenReturn(bar);

    adaptor.store(new DefaultDependency()
      .from(new DefaultInputFile("foo", "src/Foo.java").setType(Type.MAIN))
View Full Code Here

  }

  @Test
  public void throw_if_attempt_to_save_same_dep_twice() {

    File foo = File.create("src/Foo.java");
    File bar = File.create("src/Bar.java");
    when(sensorContext.getResource(foo)).thenReturn(foo);
    when(sensorContext.getResource(bar)).thenReturn(bar);
    when(sonarIndex.getEdge(foo, bar)).thenReturn(new Dependency(foo, bar));

    thrown.expect(IllegalStateException.class);
View Full Code Here

  }

  @Test
  public void shouldStoreDependencyInDifferentFolder() {

    File foo = File.create("src1/Foo.java");
    File bar = File.create("src2/Bar.java");
    when(sensorContext.getResource(foo)).thenReturn(foo);
    when(sensorContext.getResource(bar)).thenReturn(bar);

    adaptor.store(new DefaultDependency()
      .from(new DefaultInputFile("foo", "src1/Foo.java").setType(Type.MAIN))
View Full Code Here

  }

  @Test
  public void shouldIncrementParentWeight() {

    File foo = File.create("src1/Foo.java");
    File bar = File.create("src2/Bar.java");
    Directory src1 = Directory.create("src1");
    Directory src2 = Directory.create("src2");
    when(sensorContext.getResource(foo)).thenReturn(foo);
    when(sensorContext.getResource(bar)).thenReturn(bar);
    Dependency parentDep = new Dependency(src1, src2).setWeight(4);
View Full Code Here

    verifyZeroInteractions(context, issueCache, tracking, handlers, workflow);
  }

  @Test
  public void should_process_open_issues() throws Exception {
    Resource file = new File("Action.java").setEffectiveKey("struts:Action.java").setId(123);
    final DefaultIssue issue = new DefaultIssue();

    // INPUT : one issue, no open issues during previous scan, no filtering
    when(issueCache.byComponent("struts:Action.java")).thenReturn(Arrays.asList(issue));
    List<IssueDto> dbIssues = Collections.emptyList();
View Full Code Here

  }

  @Test
  public void should_register_unmatched_issues_as_end_of_life() throws Exception {
    // "Unmatched" issues existed in previous scan but not in current one -> they have to be closed
    Resource file = new File("Action.java").setEffectiveKey("struts:Action.java").setId(123);

    // INPUT : one issue existing during previous scan
    IssueDto unmatchedIssue = new IssueDto().setKee("ABCDE").setResolution(null).setStatus("OPEN").setRuleKey("squid", "AvoidCycle");

    IssueTrackingResult trackingResult = new IssueTrackingResult();
View Full Code Here

    assertThat(issue.isEndOfLife()).isTrue();
  }

  @Test
  public void manual_issues_should_be_moved_if_matching_line_found() throws Exception {
    Resource file = new File("Action.java").setEffectiveKey("struts:Action.java").setId(123);

    // INPUT : one issue existing during previous scan
    IssueDto unmatchedIssue = new IssueDto().setKee("ABCDE").setReporter("freddy").setLine(6).setStatus("OPEN").setRuleKey("manual", "Performance");
    when(ruleFinder.findByKey(RuleKey.of("manual", "Performance"))).thenReturn(new Rule("manual", "Performance"));
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.