@Test public void shouldNotMatchConditionWhenTextsDoNotContainValues() { when(mockWebElementConverter.getTextsFrom(mockElements)).thenReturn(asList("b", "tsxt", "a")); TextsContainCondition condition = new TextsContainCondition(mockWebElementConverter, false, "a", "b", "text"); assertThat(condition.apply(mockElements), equalTo(false)); }
@Override public boolean apply(List<WebElement> elements) { List<String> elementsTexts = webElementConverter.getTextsFrom(elements); if (texts.length > elementsTexts.size()) return false; List<String> actualTexts = ignoreCase ? elementsTexts.stream().map(String::toLowerCase).collect(Collectors.toList()) : elementsTexts; List<String> expectedTexts = ignoreCase ? Arrays.stream(texts).map(String::toLowerCase).collect(Collectors.toList()) : Arrays.stream(texts).collect(Collectors.toList()); return CollectionUtils.intersection(expectedTexts, actualTexts).size() == expectedTexts.size(); }
TextsContainCondition extends Condition<List<WebElement>> { @Override public boolean apply(List<WebElement> elements) { List<String> elementsTexts = webElementConverter.getTextsFrom(elements); if (texts.length > elementsTexts.size()) return false; List<String> actualTexts = ignoreCase ? elementsTexts.stream().map(String::toLowerCase).collect(Collectors.toList()) : elementsTexts; List<String> expectedTexts = ignoreCase ? Arrays.stream(texts).map(String::toLowerCase).collect(Collectors.toList()) : Arrays.stream(texts).collect(Collectors.toList()); return CollectionUtils.intersection(expectedTexts, actualTexts).size() == expectedTexts.size(); } }
TextsContainCondition extends Condition<List<WebElement>> { @Override public boolean apply(List<WebElement> elements) { List<String> elementsTexts = webElementConverter.getTextsFrom(elements); if (texts.length > elementsTexts.size()) return false; List<String> actualTexts = ignoreCase ? elementsTexts.stream().map(String::toLowerCase).collect(Collectors.toList()) : elementsTexts; List<String> expectedTexts = ignoreCase ? Arrays.stream(texts).map(String::toLowerCase).collect(Collectors.toList()) : Arrays.stream(texts).collect(Collectors.toList()); return CollectionUtils.intersection(expectedTexts, actualTexts).size() == expectedTexts.size(); } TextsContainCondition(final String... texts);  TextsContainCondition(final boolean ignoreCase, final String... texts);   TextsContainCondition(final WebElementConverter webElementConverter, final boolean ignoreCase, final String... texts); }
TextsContainCondition extends Condition<List<WebElement>> { @Override public boolean apply(List<WebElement> elements) { List<String> elementsTexts = webElementConverter.getTextsFrom(elements); if (texts.length > elementsTexts.size()) return false; List<String> actualTexts = ignoreCase ? elementsTexts.stream().map(String::toLowerCase).collect(Collectors.toList()) : elementsTexts; List<String> expectedTexts = ignoreCase ? Arrays.stream(texts).map(String::toLowerCase).collect(Collectors.toList()) : Arrays.stream(texts).collect(Collectors.toList()); return CollectionUtils.intersection(expectedTexts, actualTexts).size() == expectedTexts.size(); } TextsContainCondition(final String... texts);  TextsContainCondition(final boolean ignoreCase, final String... texts);   TextsContainCondition(final WebElementConverter webElementConverter, final boolean ignoreCase, final String... texts); @Override boolean apply(List<WebElement> elements); @Override String toString(); }
TextsContainCondition extends Condition<List<WebElement>> { @Override public boolean apply(List<WebElement> elements) { List<String> elementsTexts = webElementConverter.getTextsFrom(elements); if (texts.length > elementsTexts.size()) return false; List<String> actualTexts = ignoreCase ? elementsTexts.stream().map(String::toLowerCase).collect(Collectors.toList()) : elementsTexts; List<String> expectedTexts = ignoreCase ? Arrays.stream(texts).map(String::toLowerCase).collect(Collectors.toList()) : Arrays.stream(texts).collect(Collectors.toList()); return CollectionUtils.intersection(expectedTexts, actualTexts).size() == expectedTexts.size(); } TextsContainCondition(final String... texts);  TextsContainCondition(final boolean ignoreCase, final String... texts);   TextsContainCondition(final WebElementConverter webElementConverter, final boolean ignoreCase, final String... texts); @Override boolean apply(List<WebElement> elements); @Override String toString();  }