Combination { @SafeVarargs @SuppressWarnings("varargs") public static <T> Stream<List<T>> of(final T... items) { return CombinationUtil.of(items); } private  Combination(); @SafeVarargs @SuppressWarnings("varargs") // Creating a List from an array is safe static Stream<List<T>> of(final T... items); static Stream<List<T>> of(final Collection<T> items);  }
@Test void testOfEmpty() { final List<List<String>> actual = Combination.<String>of() .collect(toList()); assertTrue(actual.isEmpty()); }
@Test void testOfSingleton() { final List<List<String>> actual = Combination.of("a") .collect(toList()); assertEquals( singletonList( singletonList("a") ), actual ); }
@Test void testOfTwo() { final Set<List<String>> actual = Combination.of("a", "b") .collect(toSet()); final Set<List<String>> expected = new HashSet<>(asList( singletonList("a"), singletonList("b"), asList("a", "b") )); assertEquals(expected, actual); }
@Test void testOfThree() { final Set<List<String>> actual = Combination.of("a", "b", "c") .collect(toSet()); final Set<List<String>> expected = new HashSet<>(asList( singletonList("a"), singletonList("b"), singletonList("c"), asList("a", "b"), asList("a", "c"), asList("b", "c"), asList("a", "b", "c") )); assertEquals(expected, actual); }
@Test void testOfTwoList() { final Set<List<String>> actual = Combination.of(Arrays.asList("a", "b")) .collect(toSet()); final Set<List<String>> expected = new HashSet<>(asList( singletonList("a"), singletonList("b"), asList("a", "b") )); assertEquals(expected, actual); }