Java Code Examples for org.hamcrest.Matchers#not()
The following examples show how to use
org.hamcrest.Matchers#not() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: cortado File: Cortado_Tests.java License: Apache License 2.0 | 6 votes |
@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); }
Example 2
Source Project: cortado File: Cortado_Tests.java License: Apache License 2.0 | 6 votes |
@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); }
Example 3
Source Project: cortado File: Cortado.java License: Apache License 2.0 | 5 votes |
@VisibleForTesting final void addMatcher(org.hamcrest.Matcher<View> matcher) { if (negateNextMatcher) { negateNextMatcher = false; matcher = Matchers.not(matcher); } matchers.add(matcher); }
Example 4
Source Project: beam File: DisplayDataMatchers.java License: Apache License 2.0 | 5 votes |
/** 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(); } }; }
Example 5
Source Project: keycloak File: ExportImportUtil.java License: Apache License 2.0 | 5 votes |
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")); } }
Example 6
Source Project: jackrabbit-filevault File: AnyValidationMessageMatcher.java License: Apache License 2.0 | 4 votes |
public static Matcher<Iterable<? super ValidationMessage>> noValidationInCollection() { return Matchers.not(Matchers.hasItem(new AnyValidationMessageMatcher())); }
Example 7
Source Project: jackrabbit-filevault File: AnyValidationViolationMatcher.java License: Apache License 2.0 | 4 votes |
public static Matcher<Iterable<? super ValidationViolation>> noValidationInCollection() { return Matchers.not(Matchers.hasItem(new AnyValidationViolationMatcher())); }
Example 8
Source Project: lambda-behave File: BoundExpectation.java License: MIT License | 4 votes |
protected Matcher<? super T> negatedIfNeeded(final Matcher<? super T> matcher) { return positive ? matcher : Matchers.not(matcher); }