org.hamcrest.Matchers#not ( )源码实例Demo

下面列出了org.hamcrest.Matchers#not ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cortado   文件: Cortado_Tests.java
@Test
public void addMatcher_doesNotNegateMatcher_when_negateNextMatcher_isFalse() {
    final Start.Matcher matcher = Cortado.view();
    final Cortado cortado = matcher.getCortado();
    assertThat(cortado.matchers).hasSize(0);
    assertThat(cortado.negateNextMatcher).isFalse();
    // no matchers added, negateNextMatcher is false

    org.hamcrest.Matcher<View> viewMatcher = ViewMatchers.withText("test");
    org.hamcrest.Matcher<View> negatedViewMatcher = Matchers.not(viewMatcher);

    cortado.negateNextMatcher = false;

    cortado.addMatcher(viewMatcher);
    assertThat(cortado.matchers).hasSize(1);
    // one matcher added

    assertThat(cortado.negateNextMatcher).isFalse();
    // negateNextMatcher is still false

    final Matcher<? super View> addedMatcher = cortado.matchers.get(0);
    Utils.assertThat(addedMatcher).isEqualTo(viewMatcher);
    Utils.assertThat(addedMatcher).isNotEqualTo(negatedViewMatcher);
}
 
源代码2 项目: cortado   文件: Cortado_Tests.java
@Test
public void addMatcher_negatesMatcher_when_negateNextMatcher_isTrue() {
    final Start.Matcher matcher = Cortado.view();
    final Cortado cortado = matcher.getCortado();
    assertThat(cortado.matchers).hasSize(0);
    assertThat(cortado.negateNextMatcher).isFalse();
    // no matchers added, negateNextMatcher is false

    org.hamcrest.Matcher<View> viewMatcher = ViewMatchers.withText("test");
    org.hamcrest.Matcher<View> negatedViewMatcher = Matchers.not(viewMatcher);

    cortado.negateNextMatcher = true;

    cortado.addMatcher(viewMatcher);
    assertThat(cortado.matchers).hasSize(1);
    // one matcher added

    assertThat(cortado.negateNextMatcher).isFalse();
    // negateNextMatcher is back to false

    final Matcher<? super View> addedMatcher = cortado.matchers.get(0);
    Utils.assertThat(addedMatcher).isNotEqualTo(viewMatcher);
    Utils.assertThat(addedMatcher).isEqualTo(negatedViewMatcher);
}
 
源代码3 项目: cortado   文件: Cortado.java
@VisibleForTesting
final void addMatcher(org.hamcrest.Matcher<View> matcher) {
    if (negateNextMatcher) {
        negateNextMatcher = false;
        matcher = Matchers.not(matcher);
    }
    matchers.add(matcher);
}
 
源代码4 项目: beam   文件: DisplayDataMatchers.java
/** Creates a matcher that matches if the examined {@link DisplayData} contains any items. */
public static Matcher<DisplayData> hasDisplayItem() {
  return new FeatureMatcher<DisplayData, Collection<DisplayData.Item>>(
      Matchers.not(Matchers.empty()), "DisplayData", "DisplayData") {
    @Override
    protected Collection<Item> featureValueOf(DisplayData actual) {
      return actual.items();
    }
  };
}
 
源代码5 项目: keycloak   文件: ExportImportUtil.java
private static Matcher<Iterable<? super String>> getDefaultClientScopeNameMatcher(ClientRepresentation rep) {
    switch (rep.getClientId()) {
        case "client-with-template":
            return Matchers.hasItem("Default_test_template");
        default:
            return Matchers.not(Matchers.hasItem("Default_test_template"));
    }
}
 
public static Matcher<Iterable<? super ValidationMessage>> noValidationInCollection() {
    return Matchers.not(Matchers.hasItem(new AnyValidationMessageMatcher()));
}
 
public static Matcher<Iterable<? super ValidationViolation>> noValidationInCollection() {
    return Matchers.not(Matchers.hasItem(new AnyValidationViolationMatcher()));
}
 
源代码8 项目: lambda-behave   文件: BoundExpectation.java
protected Matcher<? super T> negatedIfNeeded(final Matcher<? super T> matcher) {
    return positive ? matcher : Matchers.not(matcher);
}