Package org.sonar.batch.issue.ignore.pattern

Examples of org.sonar.batch.issue.ignore.pattern.LineRange


    void setEnd(int end) {
      this.end = end;
    }

    public LineRange toLineRange() {
      return new LineRange(start, end == -1 ? fileLength : end);
    }
View Full Code Here


  @Test
  public void shouldReturnExtraPatternForLinesOfResource() {
    String file = "foo";
    Set<LineRange> lineRanges = Sets.newHashSet();
    lineRanges.add(new LineRange(25, 28));
    patternMatcher.addPatternToExcludeLines(file, lineRanges);

    IssuePattern extraPattern = patternMatcher.getPatternsForComponent(file).iterator().next();
    assertThat(extraPattern.matchResource(file)).isTrue();
    assertThat(extraPattern.getAllLines()).isEqualTo(Sets.newHashSet(25, 26, 27, 28));
View Full Code Here

public class LineRangeTest {

  @Test(expected = IllegalArgumentException.class)
  public void lineRangeShouldBeOrdered() {
    new LineRange(25, 12);
  }
View Full Code Here

    new LineRange(25, 12);
  }

  @Test
  public void shouldConvertLineRangeToLines() {
    LineRange range = new LineRange(12, 15);

    assertThat(range.toLines()).containsOnly(12, 13, 14, 15);
  }
View Full Code Here

    assertThat(range.toLines()).containsOnly(12, 13, 14, 15);
  }

  @Test
  public void shouldTestInclusionInRangeOfLines() {
    LineRange range = new LineRange(12, 15);

    assertThat(range.in(3)).isFalse();
    assertThat(range.in(12)).isTrue();
    assertThat(range.in(13)).isTrue();
    assertThat(range.in(14)).isTrue();
    assertThat(range.in(15)).isTrue();
    assertThat(range.in(16)).isFalse();
  }
View Full Code Here

    assertThat(range.in(16)).isFalse();
  }

  @Test
  public void testToString() throws Exception {
    assertThat(new LineRange(12, 15).toString()).isEqualTo("[12-15]");
  }
View Full Code Here

    assertThat(new LineRange(12, 15).toString()).isEqualTo("[12-15]");
  }

  @Test
  public void testEquals() throws Exception {
    LineRange range = new LineRange(12, 15);
    assertThat(range).isEqualTo(range);
    assertThat(range).isEqualTo(new LineRange(12, 15));
    assertThat(range).isNotEqualTo(new LineRange(12, 2000));
    assertThat(range).isNotEqualTo(new LineRange(1000, 2000));
    assertThat(range).isNotEqualTo(null);
    assertThat(range).isNotEqualTo(new StringBuffer());
  }
View Full Code Here

    assertThat(range).isNotEqualTo(new StringBuffer());
  }

  @Test
  public void testHashCode() throws Exception {
    assertThat(new LineRange(12, 15).hashCode()).isEqualTo(new LineRange(12, 15).hashCode());
  }
View Full Code Here

  public void shouldAddPatternToExcludeLines() throws Exception {
    regexpScanner.scan(javaFile, new File(Resources.getResource(
      "org/sonar/batch/issue/ignore/scanner/IssueExclusionsRegexpScannerTest/file-with-double-regexp.txt").toURI()), UTF_8);

    Set<LineRange> lineRanges = Sets.newHashSet();
    lineRanges.add(new LineRange(21, 25));
    verify(patternsInitializer).getPatternMatcher();
    verify(patternMatcher, times(1)).addPatternToExcludeLines(javaFile, lineRanges);
    verifyNoMoreInteractions(patternsInitializer);
  }
View Full Code Here

  public void shouldAddPatternToExcludeLinesTillTheEnd() throws Exception {
    regexpScanner.scan(javaFile, new File(Resources.getResource(
      "org/sonar/batch/issue/ignore/scanner/IssueExclusionsRegexpScannerTest/file-with-double-regexp-unfinished.txt").toURI()), UTF_8);

    Set<LineRange> lineRanges = Sets.newHashSet();
    lineRanges.add(new LineRange(21, 34));
    verify(patternsInitializer).getPatternMatcher();
    verify(patternMatcher, times(1)).addPatternToExcludeLines(javaFile, lineRanges);
    verifyNoMoreInteractions(patternsInitializer);
  }
View Full Code Here

TOP

Related Classes of org.sonar.batch.issue.ignore.pattern.LineRange

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.