Merge automation from ECOMP's repository
[vid.git] / vid-automation / src / main / java / vid / automation / test / utils / ExtendedHamcrestMatcher.java
1 package vid.automation.test.utils;
2
3 import org.hamcrest.Matcher;
4
5 import java.util.ArrayList;
6 import java.util.Collection;
7 import java.util.List;
8
9 import static org.hamcrest.core.AllOf.allOf;
10 import static org.hamcrest.core.IsCollectionContaining.hasItem;
11
12 public class ExtendedHamcrestMatcher {
13
14
15     //this method return matcher for has items that support collection as input (Instead of ...)
16     public static <T> Matcher<Iterable<T>> hasItemsFromCollection(Collection<T> items) {
17         List<Matcher<? super Iterable<T>>> all = new ArrayList<>(items.size());
18         for (T element : items) {
19             all.add(hasItem(element));
20         }
21
22         return allOf(all);
23     }
24 }