### Question:
Apriori { static <T> Set<Set<T>> aprioriGen(Set<Set<T>> itemsets) { Set<Set<T>> candidates = new HashSet<>(); for (Set<T> s1 : itemsets) { for (Set<T> s2 : itemsets) { Set<T> union = new HashSet<>(s1); union.addAll(s2); if (union.size() == s1.size() + 1) { candidates.add(union); } } } Iterator<Set<T>> iterator = candidates.iterator(); while (iterator.hasNext()) { Set<T> candidate = iterator.next(); for (Set<T> subset : kMinusOneSubsets(candidate)) { if (!itemsets.contains(subset)) { iterator.remove(); break; } } } return candidates; } private  Apriori(); static Map<Set<T>, Double> extractItemsets(Collection<Set<T>> data, double minSupport); static Ruleset<T> buildRules(Collection<Set<T>> data, double minSupport, double minConfidence);  }### Answer:
@Test public void testAprioriGen() { Set<Integer> s1 = newHashSet(1, 2, 3); Set<Integer> s2 = newHashSet(1, 2, 4); Set<Integer> s3 = newHashSet(1, 2, 5); Set<Integer> s4 = newHashSet(1, 3, 4); Set<Integer> s5 = newHashSet(1, 3, 5); Set<Integer> s6 = newHashSet(2, 3, 4); Set<Set<Integer>> l_3 = newHashSet(s1, s2, s3, s4, s5, s6); Set<Set<Integer>> c_4 = Apriori.aprioriGen(l_3); assertEquals(1, c_4.size()); assertTrue(c_4.contains(newHashSet(1, 2, 3, 4))); }