private static String toStringOf(Collection<?> c) { return Collections.format(c); }
/** * Returns all the non-{@code null} elements in the given {@link Collection}. * * @param <T> the type of elements of the {@code Collection}. * @param c the given {@code Collection}. * @return all the non-{@code null} elements in the given {@code Collection}. An empty list is returned if the * given {@code Collection} is {@code null}. * @since 1.1.3 */ public static <T> List<T> nonNullElementsIn(Collection<T> c) { if (isNullOrEmpty(c)) { return emptyList(); } List<T> nonNull = new ArrayList<T>(); for (T element : c) { if (element != null) { nonNull.add(element); } } return nonNull; }
protected void checkCreatedSreenshots(String location, List<String> expectedNames) { List<String> actualNames = Collections.list(new File(SCREEN_DIR + location).list()); for (String expectedName : expectedNames) { assertTrue(actualNames.contains(expectedName)); } }
@After public void checkScreenAfter() { List<String> actualNames = Collections.list( new File(SCREEN_DIR + TEST_NAME + "/screenshooter_conf_should_be_used").list()); actualNames.contains("after.png"); }
@Test public void screenshooter_conf_should_be_used(@InitialPage PageObject po) { assertEquals(po.getFragment().getInnerElement().getText(), "pseudo root"); make4WebDriverActions(); List<String> actualNames = Collections.list( new File(SCREEN_DIR + TEST_NAME + "/screenshooter_conf_should_be_used").list()); actualNames.contains("before.png"); }
/** * Returns any duplicate elements from the given {@code Collection}. * * @param <T> the generic type of the given {@code Collection}. * @param c the given {@code Collection} that might have duplicate elements. * @return a {@code Collection} containing the duplicate elements of the given one. If no duplicates are found, an * empty {@code Collection} is returned. */ public static <T> Collection<T> duplicatesFrom(Collection<T> c) { Set<T> duplicates = new LinkedHashSet<T>(); if (isNullOrEmpty(c)) { return duplicates; } Set<T> noDuplicates = new HashSet<T>(); for (T e : c) { if (noDuplicates.contains(e)) { duplicates.add(e); continue; } noDuplicates.add(e); } return duplicates; }