Java Code Examples for org.hamcrest.Matchers#allOf()

The following examples show how to use org.hamcrest.Matchers#allOf() . 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 5 votes vote down vote up
@Test
public void textView_returnsProperMatcher() {
    //given
    final Cortado.OrAnd.Matcher matcher = Cortado.textView().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(TextView.class),
            matcher.getCortado().matchers.get(0));

    //when

    //then
    Utils.assertThat(matcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 2
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void button_returnsProperMatcher() {
    //given
    final Cortado.OrAnd.Matcher matcher = Cortado.button().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(Button.class),
            matcher.getCortado().matchers.get(0));

    //when

    //then
    Utils.assertThat(matcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 3
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void imageView_returnsProperMatcher() {
    //given
    final Cortado.OrAnd.Matcher matcher = Cortado.imageView().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(ImageView.class),
            matcher.getCortado().matchers.get(0));

    //when

    //then
    Utils.assertThat(matcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 4
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void imageButton_returnsProperMatcher() {
    //given
    final Cortado.OrAnd.Matcher matcher = Cortado.imageButton().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(ImageButton.class),
            matcher.getCortado().matchers.get(0));

    //when

    //then
    Utils.assertThat(matcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 5
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void onTextView_returnsProperViewInteraction() {
    //given
    final Cortado.OrAnd.ViewInteraction viewInteraction = Cortado.onTextView().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(TextView.class),
            viewInteraction.getCortado().matchers.get(0));

    //when
    final Matcher<View> rawMatcher = viewInteraction.getCortado().get();

    //then
    Utils.assertThat(rawMatcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 6
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void onEditText_returnsProperViewInteraction() {
    //given
    final Cortado.OrAnd.ViewInteraction viewInteraction = Cortado.onEditText().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(EditText.class),
            viewInteraction.getCortado().matchers.get(0));

    //when
    final Matcher<View> rawMatcher = viewInteraction.getCortado().get();

    //then
    Utils.assertThat(rawMatcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 7
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void onButton_returnsProperViewInteraction() {
    //given
    final Cortado.OrAnd.ViewInteraction viewInteraction = Cortado.onButton().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(Button.class),
            viewInteraction.getCortado().matchers.get(0));

    //when
    final Matcher<View> rawMatcher = viewInteraction.getCortado().get();

    //then
    Utils.assertThat(rawMatcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 8
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void onImageView_returnsProperViewInteraction() {
    //given
    final Cortado.OrAnd.ViewInteraction viewInteraction = Cortado.onImageView().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(ImageView.class),
            viewInteraction.getCortado().matchers.get(0));

    //when
    final Matcher<View> rawMatcher = viewInteraction.getCortado().get();

    //then
    Utils.assertThat(rawMatcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 9
Source Project: cortado   File: Cortado_Tests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void onImageButton_returnsProperViewInteraction() {
    //given
    final Cortado.OrAnd.ViewInteraction viewInteraction = Cortado.onImageButton().withText("test");
    final Matcher<View> expectedEspressoMatcher = Matchers.allOf(
            ViewMatchers.isAssignableFrom(ImageButton.class),
            viewInteraction.getCortado().matchers.get(0));

    //when
    final Matcher<View> rawMatcher = viewInteraction.getCortado().get();

    //then
    Utils.assertThat(rawMatcher).isEqualTo(expectedEspressoMatcher);
}
 
Example 10
private Matcher<Map<String, Object>> ruleOutputToMatchers(RuleOutput ruleOutput) {
  Matcher<Map<? extends String, ? extends Object>> targetMatcher =
      Matchers.hasEntry("target", ruleOutput.target);
  Matcher<Map<? extends String, ? extends Object>> valMatcher =
      Matchers.hasEntry("val", ruleOutput.val);

  Matcher<Object> srcs = createEndOfPathMatcher(ruleOutput.srcs);
  Matcher<Object> deps =
      (Matcher<Object>)
          (Matcher<? extends Object>)
              Matchers.containsInAnyOrder(
                  Collections2.transform(
                      ruleOutput.deps,
                      d -> (Matcher<? super Object>) (Matcher<?>) ruleOutputToMatchers(d)));
  Matcher<Object> outputs = createEndOfPathMatcher(ruleOutput.outputs);

  Matcher<Map<? extends String, ? extends Object>> srcsMatcher =
      Matchers.hasEntry(Matchers.is("srcs"), srcs);
  Matcher<Map<? extends String, ? extends Object>> depMatcher =
      Matchers.hasEntry(Matchers.is("dep"), deps);
  Matcher<Map<? extends String, ? extends Object>> outputsMatcher =
      Matchers.hasEntry(Matchers.is("outputs"), outputs);

  Matcher<? extends Map<? extends String, ? extends Object>> matcher =
      Matchers.allOf(targetMatcher, valMatcher, srcsMatcher, depMatcher, outputsMatcher);
  return (Matcher<Map<String, Object>>) matcher;
}
 
Example 11
private static Matcher<? super View> viewNameMatcher(String viewName) {
  Matcher<View> subMatchers = Matchers.allOf(ImmutableList.of(
    propertyMatcher(View::getName, "name", viewNameEqualTo(viewName))
  ));

  return Matchers.describedAs("%0", subMatchers, viewName);
}
 
Example 12
private static Matcher<? super Index> indexMatcher(Index index) {
  Matcher<Index> subMatchers = Matchers.allOf(ImmutableList.of(
    propertyMatcher(Index::getName, "name", indexNameEqualTo(index.getName())),
    propertyMatcher(Index::columnNames, "columns", contains(indexColumnNamesEqualTo(index.columnNames()))),
    propertyMatcher(Index::isUnique, "unique", equalTo(index.isUnique()))
  ));

  return Matchers.describedAs("%0", subMatchers, index.toString());
}
 
Example 13
Source Project: intellijcoder   File: TestUtil.java    License: MIT License 5 votes vote down vote up
public static <T> Matcher<T[]> hasItemsInArray(Matcher<T>... items) {
    Collection<Matcher<? super T[]>> matchers = new ArrayList<Matcher<? super T[]>>(items.length);
    for (Matcher<T> item : items) {
        matchers.add(hasItemInArray(item));
    }
    return Matchers.allOf(matchers);
}
 
Example 14
Source Project: espresso-samples   File: TestUtils.java    License: Apache License 2.0 4 votes vote down vote up
public Matcher<View> getConstraints() {
    return Matchers.allOf(new Matcher[] {
        ViewMatchers.isAssignableFrom(RecyclerView.class), ViewMatchers.isDisplayed()
    });
}
 
Example 15
Source Project: Awesome-WanAndroid   File: TestUtils.java    License: Apache License 2.0 4 votes vote down vote up
public Matcher<View> getConstraints() {
    return Matchers.allOf(new Matcher[] {
            ViewMatchers.isAssignableFrom(RecyclerView.class), ViewMatchers.isDisplayed()
    });
}
 
Example 16
Source Project: Awesome-WanAndroid   File: TestUtils.java    License: Apache License 2.0 4 votes vote down vote up
public Matcher<View> getConstraints() {
    return Matchers.allOf(new Matcher[] {
            ViewMatchers.isAssignableFrom(RecyclerView.class), ViewMatchers.isDisplayed()
    });
}
 
Example 17
Source Project: cortado   File: Linker.java    License: Apache License 2.0 4 votes vote down vote up
@Override
Matcher<? super View> link(List<Matcher<? super View>> matchers) {
    return Matchers.allOf(matchers);
}
 
Example 18
public static Matcher<Result<?>> isResult(Matcher<?> valueMatcher, Iterable<String> warnings) {
    return Matchers.allOf(
        hasProperty("value", valueMatcher),
        hasWarnings(warnings));
}
 
Example 19
public ViewGroupInteraction onChildView(Matcher<View> matcher) {
    //noinspection unchecked
    return new ViewGroupInteraction(Matchers.allOf(withParent(groupMatcher), matcher));
}
 
Example 20
Source Project: Scoops   File: TestUtils.java    License: Apache License 2.0 4 votes vote down vote up
public Matcher<View> getConstraints() {
    return Matchers.allOf(new Matcher[]{
            ViewMatchers.isAssignableFrom(RecyclerView.class), ViewMatchers.isDisplayed()
    });
}