Package org.hamcrest

Examples of org.hamcrest.Matcher.matches()


                    actualMatcher = ((MatcherDecorator)m).getActualMatcher();
                } else {
                    actualMatcher = m;
                }
                //this is very important to only allow VarargMatchers here. If you're not sure why remove it and run all tests.
                if (!(actualMatcher instanceof VarargMatcher) || !actualMatcher.matches(rawArgs[i])) {
                    return false;
                }
            //it's not a vararg (i.e. some ordinary argument before varargs), just do the ordinary check
            } else if (!m.matches(rawArgs[i])){
                return false;
View Full Code Here


    }

    private Matcher matcher(final boolean result, Object... values) {
        Matcher mock = mock(Matcher.class);
        for (Object value : values) {
            when(mock.matches(value)).thenReturn(result);
        }
        return mock;
    }

    public static abstract class DomainObject<R> implements Validatable<R> {
View Full Code Here

                    actualMatcher = ((MatcherDecorator)m).getActualMatcher();
                } else {
                    actualMatcher = m;
                }
                //this is very important to only allow VarargMatchers here. If you're not sure why remove it and run all tests.
                if (!(actualMatcher instanceof VarargMatcher) || !actualMatcher.matches(rawArgs[i])) {
                    return false;
                }
            //it's not a vararg (i.e. some ordinary argument before varargs), just do the ordinary check
            } else if (!m.matches(rawArgs[i])){
                return false;
View Full Code Here

                    actualMatcher = ((MatcherDecorator)m).getActualMatcher();
                } else {
                    actualMatcher = m;
                }
                //this is very important to only allow VarargMatchers here. If you're not sure why remove it and run all tests.
                if (!(actualMatcher instanceof VarargMatcher) || !actualMatcher.matches(rawArgs[i])) {
                    return false;
                }
            //it's not a vararg (i.e. some ordinary argument before varargs), just do the ordinary check
            } else if (!m.matches(rawArgs[i])){
                return false;
View Full Code Here

public class RegexTextMatcherTest {

  @Test
  public void cannotNotMatchText() throws Exception {
    Matcher matcher = withRegex("Some Text");
    assertFalse(matcher.matches(new Object()));
  }

  @Test
  public void doesNotMatchNullText() throws Exception {
    Matcher matcher = withRegex("Some Text");
View Full Code Here

  }

  @Test
  public void doesNotMatchNullText() throws Exception {
    Matcher matcher = withRegex("Some Text");
    assertFalse(matcher.matches(new ObjectWithGetText(null)));
  }

  @Test
  public void doesNotMatchRegex() throws Exception {
    Matcher matcher = withRegex("Some (.*) Text");
View Full Code Here

  }

  @Test
  public void doesNotMatchRegex() throws Exception {
    Matcher matcher = withRegex("Some (.*) Text");
    assertFalse(matcher.matches(new ObjectWithGetText("Some text that should not match")));
  }

  @Test
  public void matchesRegex() throws Exception {
    Matcher matcher = withRegex("Some (.*) Text");
View Full Code Here

  }

  @Test
  public void matchesRegex() throws Exception {
    Matcher matcher = withRegex("Some (.*) Text");
    assertTrue(matcher.matches(new ObjectWithGetText("Some long string Text")));
  }

  @Test
  public void getsToString() throws Exception {
    Matcher matcher = withRegex("Some Text");
View Full Code Here

public class TextMatcherTest {

  @Test
  public void doesNotMatchObjectsWithNoGetTextMethod() throws Exception {
    Matcher matcher = withText("Some Text");
    assertFalse(matcher.matches(new Object()));
  }

  @Test
  public void doesNotMatchObjectsWithNullGetText() throws Exception {
    Matcher matcher = withText("Some Text");
View Full Code Here

  }

  @Test
  public void doesNotMatchObjectsWithNullGetText() throws Exception {
    Matcher matcher = withText("Some Text");
    assertFalse(matcher.matches(new ObjectWithGetText(null)));
  }

  @Test
  public void doesNotMatchText() throws Exception {
    Matcher matcher = withText("Some Text");
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.