Examples of WildCardPattern


Examples of org.lilyproject.indexer.model.indexerconf.WildcardPattern

import static org.junit.Assert.assertTrue;

public class WildcardPatternTest {
    @Test
    public void testStartsWith() throws Exception {
        WildcardPattern pattern = new WildcardPattern("foo*");
        Pair<Boolean, String> result = pattern.match("foobar");
        assertTrue(result.getV1());
        assertEquals("bar", result.getV2());

        result = pattern.match("fobar");
        assertFalse(result.getV1());
        assertNull(result.getV2());

        result = pattern.match("foo");
        assertTrue(result.getV1());
        assertEquals("", result.getV2());
    }
View Full Code Here

Examples of org.lilyproject.indexer.model.indexerconf.WildcardPattern

        assertEquals("", result.getV2());
    }

    @Test
    public void testEndsWith() throws Exception {
        WildcardPattern pattern = new WildcardPattern("*bar");
        Pair<Boolean, String> result = pattern.match("foobar");
        assertTrue(result.getV1());
        assertEquals("foo", result.getV2());

        result = pattern.match("fooba");
        assertFalse(result.getV1());
        assertNull(result.getV2());

        result = pattern.match("bar");
        assertTrue(result.getV1());
        assertEquals("", result.getV2());
    }
View Full Code Here

Examples of org.lilyproject.indexer.model.indexerconf.WildcardPattern

        assertEquals("", result.getV2());
    }

    @Test
    public void testEquals() throws Exception {
        WildcardPattern pattern = new WildcardPattern("foobar");
        Pair<Boolean, String> result = pattern.match("foobar");
        assertTrue(result.getV1());
        assertNull(result.getV2());

        // A star at any other position than end or start is not recognized as a wildcard
        pattern = new WildcardPattern("foo*bar");
        result = pattern.match("foo*bar");
        assertTrue(result.getV1());
        assertNull(result.getV2());

        result = pattern.match("foo1bar");
        assertFalse(result.getV1());
    }
View Full Code Here

Examples of org.lilyproject.indexer.model.indexerconf.WildcardPattern

    }

    @Test
    public void testSpecial() throws Exception {
        // A star by itself is not a wildcard
        WildcardPattern pattern = new WildcardPattern("*");
        Pair<Boolean, String> result = pattern.match("foo");
        assertTrue(result.getV1());
        assertEquals("foo", result.getV2());

        result = pattern.match("");
        assertTrue(result.getV1());
        assertEquals("", result.getV2());

        // first occurrence of star takes precedence
        pattern = new WildcardPattern("*foo*");
        result = pattern.match("barfoo*");
        assertTrue(result.getV1());
        assertEquals("bar", result.getV2());

        result = pattern.match("barfoobar");
        assertFalse(result.getV1());
        assertNull(result.getV2());
    }
View Full Code Here

Examples of org.sonar.api.utils.WildcardPattern

   *
   * @see Resource#matchFilePattern(String)
   */
  @Override
  public boolean matchFilePattern(String antPattern) {
    WildcardPattern matcher = WildcardPattern.create(antPattern, Directory.SEPARATOR);
    return matcher.match(getKey());
  }
View Full Code Here

Examples of org.sonar.api.utils.WildcardPattern

    return null;
  }

  @Override
  public boolean matchFilePattern(String antPattern) {
    WildcardPattern matcher = WildcardPattern.create(antPattern, "/");
    return matcher.match(getKey());
  }
View Full Code Here

Examples of org.sonar.api.utils.WildcardPattern

    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

Examples of org.sonar.api.utils.WildcardPattern

    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();
    verifyZeroInteractions(chain);
View Full Code Here

Examples of org.sonar.api.utils.WildcardPattern

    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();
    verifyZeroInteractions(chain);
View Full Code Here

Examples of org.sonar.api.utils.WildcardPattern

    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();
    verifyZeroInteractions(chain);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.