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

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


    assertThat(pattern.getAllLines()).containsOnly(10, 25, 98);
  }

  @Test
  public void shouldReadRangeOfLineIds() {
    IssuePattern pattern = decoder.decodeLine("*;*;[10-12,25,97-100]");

    assertThat(pattern.isCheckLines()).isTrue();
    assertThat(pattern.getAllLines()).containsOnly(10, 11, 12, 25, 97, 98, 99, 100);
  }
View Full Code Here


  @Test
  public void shouldNotExcludeLines() {
    // [] is different than *
    // - all violations are excluded on *
    // * no violations are excluded on []
    IssuePattern pattern = decoder.decodeLine("*;*;[]");

    assertThat(pattern.isCheckLines()).isTrue();
    assertThat(pattern.getAllLines()).isEmpty();
  }
View Full Code Here

    assertThat(pattern.getAllLines()).isEmpty();
  }

  @Test
  public void shouldReadBlockPattern() {
    IssuePattern pattern = decoder.decodeLine("SONAR-OFF;SONAR-ON");

    assertThat(pattern.getResourcePattern()).isNull();
    assertThat(pattern.getBeginBlockRegexp()).isEqualTo("SONAR-OFF");
    assertThat(pattern.getEndBlockRegexp()).isEqualTo("SONAR-ON");
  }
View Full Code Here

    assertThat(pattern.getEndBlockRegexp()).isEqualTo("SONAR-ON");
  }

  @Test
  public void shouldReadAllFilePattern() {
    IssuePattern pattern = decoder.decodeLine("SONAR-ALL-OFF");

    assertThat(pattern.getResourcePattern()).isNull();
    assertThat(pattern.getAllFileRegexp()).isEqualTo("SONAR-ALL-OFF");
  }
View Full Code Here

    decoder.decode(";ON");
  }

  @Test
  public void shouldAcceptEmptyEndBlockRegexp() {
    IssuePattern pattern = decoder.decodeLine("OFF;");

    assertThat(pattern.getResourcePattern()).isNull();
    assertThat(pattern.getBeginBlockRegexp()).isEqualTo("OFF");
    assertThat(pattern.getEndBlockRegexp()).isEmpty();
  }
View Full Code Here

    String rule = "rule";
    RuleKey ruleKey = mock(RuleKey.class);
    when(ruleKey.toString()).thenReturn(rule);
    when(issue.ruleKey()).thenReturn(ruleKey);

    IssuePattern matching = mock(IssuePattern.class);
    WildcardPattern rulePattern = mock(WildcardPattern.class);
    when(matching.getRulePattern()).thenReturn(rulePattern);
    when(rulePattern.match(rule)).thenReturn(false);
    when(exclusionPatternInitializer.getMulticriteriaPatterns()).thenReturn(ImmutableList.of(matching));

    assertThat(ignoreFilter.accept(issue, chain)).isTrue();
    verify(chain).accept(issue);
View Full Code Here

    RuleKey ruleKey = mock(RuleKey.class);
    when(ruleKey.toString()).thenReturn(rule);
    when(issue.ruleKey()).thenReturn(ruleKey);
    when(issue.componentKey()).thenReturn(componentKey);

    IssuePattern matching = mock(IssuePattern.class);
    WildcardPattern rulePattern = mock(WildcardPattern.class);
    when(matching.getRulePattern()).thenReturn(rulePattern);
    when(rulePattern.match(rule)).thenReturn(true);
    WildcardPattern pathPattern = mock(WildcardPattern.class);
    when(matching.getResourcePattern()).thenReturn(pathPattern);
    when(pathPattern.match(path)).thenReturn(true);
    when(exclusionPatternInitializer.getMulticriteriaPatterns()).thenReturn(ImmutableList.of(matching));
    when(exclusionPatternInitializer.getPathForComponent(componentKey)).thenReturn(path);

    assertThat(ignoreFilter.accept(issue, chain)).isTrue();
View Full Code Here

    RuleKey ruleKey = mock(RuleKey.class);
    when(ruleKey.toString()).thenReturn(rule);
    when(issue.ruleKey()).thenReturn(ruleKey);
    when(issue.componentKey()).thenReturn(componentKey);

    IssuePattern matching = mock(IssuePattern.class);
    WildcardPattern rulePattern = mock(WildcardPattern.class);
    when(matching.getRulePattern()).thenReturn(rulePattern);
    when(rulePattern.match(rule)).thenReturn(true);
    WildcardPattern pathPattern = mock(WildcardPattern.class);
    when(matching.getResourcePattern()).thenReturn(pathPattern);
    when(pathPattern.match(path)).thenReturn(false);
    when(exclusionPatternInitializer.getMulticriteriaPatterns()).thenReturn(ImmutableList.of(matching));
    when(exclusionPatternInitializer.getPathForComponent(componentKey)).thenReturn(path);

    assertThat(ignoreFilter.accept(issue, chain)).isFalse();
View Full Code Here

    RuleKey ruleKey = mock(RuleKey.class);
    when(ruleKey.toString()).thenReturn(rule);
    when(issue.ruleKey()).thenReturn(ruleKey);
    when(issue.componentKey()).thenReturn(componentKey);

    IssuePattern matching = mock(IssuePattern.class);
    WildcardPattern rulePattern = mock(WildcardPattern.class);
    when(matching.getRulePattern()).thenReturn(rulePattern);
    when(rulePattern.match(rule)).thenReturn(true);
    WildcardPattern pathPattern = mock(WildcardPattern.class);
    when(matching.getResourcePattern()).thenReturn(pathPattern);
    when(pathPattern.match(path)).thenReturn(false);
    when(exclusionPatternInitializer.getMulticriteriaPatterns()).thenReturn(ImmutableList.of(matching));
    when(exclusionPatternInitializer.getPathForComponent(componentKey)).thenReturn(null);

    assertThat(ignoreFilter.accept(issue, chain)).isFalse();
View Full Code Here

public class IssuePatternTest {

  @Test
  public void shouldMatchLines() {
    IssuePattern pattern = new IssuePattern("*", "*");
    pattern.addLine(12).addLine(15).addLineRange(20, 25);

    assertThat(pattern.matchLine(3)).isFalse();
    assertThat(pattern.matchLine(12)).isTrue();
    assertThat(pattern.matchLine(14)).isFalse();
    assertThat(pattern.matchLine(21)).isTrue();
    assertThat(pattern.matchLine(6599)).isFalse();
  }
View Full Code Here

TOP

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

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.