public void fooAllOf() { Espresso.onView(AllOf.allOf(ViewMatchers.withId(R.id.some_id), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Espresso.onView(AllOf.allOf(ViewMatchers.withText(R.string.some_text), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Espresso.onView(AllOf.allOf(ViewMatchers.withText("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Espresso.onView(AllOf.allOf(RistrettoViewMatchers.with("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(ViewMatchers.withId(R.id.some_id), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(ViewMatchers.withText(R.string.some_text), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(ViewMatchers.withText("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(RistrettoViewMatchers.with("some text"), ViewMatchers.isDisplayed())).perform(ViewAction.click()); Espresso.onView(AllOf.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withId(R.id.some_id))).perform(ViewAction.click()); Espresso.onView(AllOf.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText(R.string.some_text))).perform(ViewAction.click()); Espresso.onView(AllOf.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText("some text"))).perform(ViewAction.click()); Espresso.onView(AllOf.allOf(ViewMatchers.isDisplayed(), RistrettoViewMatchers.with("some text"))).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withId(R.id.some_id))).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText(R.string.some_text))).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(ViewMatchers.isDisplayed(), ViewMatchers.withText("some text"))).perform(ViewAction.click()); Ristretto.withView(AllOf.allOf(ViewMatchers.isDisplayed(), RistrettoViewMatchers.with("some text"))).perform(ViewAction.click()); }
@Test public void sendStreamMessage() { //Wait to make sure the messages are loaded sleep(2000); onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHolderAndClick(MessageType.STREAM_MESSAGE, R.id.contentView))); sleep(1000); //Fill message EditText ViewInteraction messageInteraction = onView(allOf(withId(R.id.message_et), isDisplayed())); messageInteraction.perform(replaceText(testMessageStream)); //Click Send Button ViewInteraction imageView = onView(allOf(withId(R.id.send_btn), isDisplayed())); imageView.perform(click()); sleep(2000); //Scroll And check the new sent message onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHolder(testMessageStream, R.id.contentView))); onView(AllOf.allOf(withId(R.id.contentView), withText(testMessageStream))).check(matches(isDisplayed())); checkIfMessagesMatchTheHeaderParent(); checkOrderOfMessagesCurrentList(); }
@Test public void sendPrivateMessage() { //Wait to make sure the messages are loaded sleep(2000); onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHolderAndClick(MessageType.PRIVATE_MESSAGE, R.id.contentView))); sleep(1000); //Fill message EditText ViewInteraction messageInteraction = onView(allOf(withId(R.id.message_et), isDisplayed())); messageInteraction.perform(replaceText(testMessagePrivate)); //Click Send Button ViewInteraction imageView = onView(allOf(withId(R.id.send_btn), isDisplayed())); imageView.perform(click()); sleep(2000); //Scroll And check the new sent message onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollToHolder(withMessageHolder(testMessagePrivate, R.id.contentView))); onView(AllOf.allOf(withId(R.id.contentView), withText(testMessagePrivate))).check(matches(isDisplayed())); checkIfMessagesMatchTheHeaderParent(); checkOrderOfMessagesCurrentList(); }
@Test public void and_returns_instanceOf_AllOf() { //given List<Matcher<? super View>> matchers = new ArrayList<>(); Matcher<View> matcher = new SimpleWrappingViewMatcher<>(null); matchers.add(matcher); //when Matcher<? super View> link = AND.link(matchers); //then assertThat(link).isInstanceOf(AllOf.class); }
private void expectMessageContaining(String... parts) { List<Matcher<? super String>> matchers = new ArrayList<>(); for (String part : parts) { matchers.add(StringContains.containsString(format(part))); } delegate.expectMessage(AllOf.allOf(matchers)); }
@Factory public static <T> Matcher<MuleMessage> hasSameExternalValuesThan(MuleMessage message) { List<Matcher<? super MuleMessage>> allScopeMatchers = new ArrayList<Matcher<? super MuleMessage>>(3); Object payload = message != null ? message.getPayload() : null; allScopeMatchers.add(SamePropertiesMatcher.hasSamePropertiesThan(message)); allScopeMatchers.add(SameAttachmentsMatcher.hasSameAttachmentsThan(message)); allScopeMatchers.add(PayloadMatcher.hasPayload(payload)); return new AllOf<MuleMessage>(allScopeMatchers); }
@Factory public static <T> Matcher<MuleMessage> hasSamePropertiesThan(MuleMessage message) { List<Matcher<? super MuleMessage>> allScopeMatchers = new ArrayList<Matcher<? super MuleMessage>>(4); allScopeMatchers.add(new SamePropertiesMatcher(PropertyScope.INBOUND, message)); allScopeMatchers.add(new SamePropertiesMatcher(PropertyScope.OUTBOUND, message)); allScopeMatchers.add(new SamePropertiesMatcher(PropertyScope.INVOCATION, message)); allScopeMatchers.add(new SamePropertiesMatcher(PropertyScope.SESSION, message)); return new AllOf<MuleMessage>(allScopeMatchers); }
@Factory public static <T> Matcher<MuleMessage> hasSameAttachmentsThan(MuleMessage message) { List<Matcher<? super MuleMessage>> allScopeMatchers = new ArrayList<Matcher<? super MuleMessage>>(2); allScopeMatchers.add(new SameAttachmentsMatcher(AttachmentScope.INBOUND, message)); allScopeMatchers.add(new SameAttachmentsMatcher(AttachmentScope.OUTBOUND, message)); return new AllOf<MuleMessage>(allScopeMatchers); }
private Matcher<XCScheme.BuildActionEntry> withNameAndBuildingFor( String name, Matcher<? super EnumSet<XCScheme.BuildActionEntry.BuildFor>> buildFor) { return AllOf.allOf( buildActionEntryWithName(name), new FeatureMatcher<XCScheme.BuildActionEntry, EnumSet<XCScheme.BuildActionEntry.BuildFor>>( buildFor, "Building for", "BuildFor") { @Override protected EnumSet<XCScheme.BuildActionEntry.BuildFor> featureValueOf( XCScheme.BuildActionEntry entry) { return entry.getBuildFor(); } }); }
public static Matcher<Session> sameSessionDataAs(Session data) { List<Matcher<? super Session>> matchers = new ArrayList<>(); matchers.add(sessionWithId(data.id())); matchers.add(sessionCreatedAt(data.createdAt())); matchers.add(sessionUpdatedAt(data.updatedAt())); matchers.add(sessionWithMaxAge(data.maxAge())); matchers.addAll(data.keys().stream().map(key -> sessionWithSameAttributeAs(data, key)).collect(Collectors.toList())); return new AllOf<>(matchers); }
/** * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers. */ @SafeVarargs public static <T> OutputMatcher<T> allOf(OutputMatcher<T>... matchers) { return OutputMatcherFactory.create(AllOf.allOf(matchers)); }
public static Matcher<List<Warning>> hasWarnings(Matcher<List<Warning>>... matchers) { return new AllOf<>(Arrays.asList(matchers)); }
@SuppressWarnings("unchecked") private static <T> T reportAnd(Object matchValuesArray, Class<T> clazz) { List<Matcher> matchers = MatcherSyntax.matcherListFragment(clazz, matchValuesArray); return (T) argThat(clazz, new AllOf(matchers)); }
/** * * Matches a non-primitive array containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(Object[]) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public <T> T[] arrayWithAll(T... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(Object.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return (T[]) argThat(Object[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>boolean</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(boolean...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public boolean[] booleanArrayWithAll(boolean... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(boolean.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(boolean[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>byte</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(byte...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public byte[] byteArrayWithAll(byte... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(byte.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(byte[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>char</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(char...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public char[] charArrayWithAll(char... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(char.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(char[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>short</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(short...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public short[] shortArrayWithAll(short... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(short.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(short[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>int</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(int...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public int[] intArrayWithAll(int... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(int.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(int[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>long</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(long...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public long[] longArrayWithAll(long... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(long.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(long[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>float</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(float...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public float[] floatArrayWithAll(float... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(float.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(float[].class, new AllOf(arrayMatchers)); }
/** * * Matches an array of <code>double</code> containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * Note that the order in which the values to be matched are specified is not significant; the array merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#array(double...) array()}. * <p> * * @return <code>null</code> */ @SuppressWarnings("unchecked") static public double[] doubleArrayWithAll(double... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(double.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(IsArrayContaining.hasItemInArray(itemMatcher)); } return argThat(double[].class, new AllOf(arrayMatchers)); }
/** * * Matches a {@link java.util.Collection Collection} containing elements matching the given parameters (which may be {@link MoxieMatchers} invocations). * <p> * * The class argument to this method is not matched against the value passed to the mocked method; it is provided * as a convenient way of specifying the type parameter for those who wish to statically import this method. * <p> * * Note that the order in which the values to be matched are specified is not significant; the collection merely needs to * contain a match for each given parameter in any order. For a matcher where ordering is significant, use {@link MoxieMatchers#collection(Object...) collection()}. * <p> * * @param collectionClass Type of the collection to be matched * @param items Items to be found in the collection (raw values or {@link MoxieMatchers} invocations) * @return <code>null</code> */ @SuppressWarnings("unchecked") static public <T extends Iterable> T collectionWithAll(Class<T> collectionClass, Object... items) { List<Matcher> itemMatchers = MatcherSyntax.matcherListFragment(Object.class, items); List<Matcher> arrayMatchers = new ArrayList<Matcher>(); for (Matcher itemMatcher : itemMatchers) { arrayMatchers.add(Matchers.hasItem(itemMatcher)); } return (T) argThat(collectionClass, (Matcher) new AllOf(arrayMatchers)); }
/** * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers. * <p></p> * For example: * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre> */ public static <T> Matcher<T> allOf(Matcher<? super T>... matchers) { return AllOf.allOf(Arrays.asList(matchers)); }
/** * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers. * <p></p> * For example: * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre> */ public static <T> Matcher<T> allOf(Matcher<? super T> first, Matcher<? super T> second) { return AllOf.allOf(first, second); }
/** * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers. * <p></p> * For example: * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre> */ public static <T> Matcher<T> allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third) { return AllOf.allOf(first, second, third); }
/** * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers. * <p></p> * For example: * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre> */ public static <T> Matcher<T> allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth) { return AllOf.allOf(first, second, third, fourth); }
/** * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers. * <p></p> * For example: * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre> */ public static <T> Matcher<T> allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth) { return AllOf.allOf(first, second, third, fourth, fifth); }
/** * Creates a matcher that matches if the examined object matches <b>ALL</b> of the specified matchers. * <p></p> * For example: * <pre>assertThat("myValue", allOf(startsWith("my"), containsString("Val")))</pre> */ public static <T> Matcher<T> allOf(Matcher<? super T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth) { return AllOf.allOf(first, second, third, fourth, fifth, sixth); }