### Question:
GroupsComputer { @SafeVarargs public final Groups computeGroups(Class<?>... groups) { Exceptions.raiseIf(groups == null, IllegalArgumentException::new, "null validation groups specified"); if (groups.length == 0 || (groups.length == 1 && groups[0] == Default.class)) { return DEFAULT_GROUPS; } return computeGroups(Arrays.asList(groups)); }  @SafeVarargs final Groups computeGroups(Class<?>... groups); @Deprecated final Groups computeCascadingGroups(Set<GroupConversionDescriptor> groupConversions, Class<?> group); Groups computeGroups(Collection<Class<?>> groups); Groups computeGroups(Stream<Class<?>> groups); static final Class<?>[] DEFAULT_GROUP; static final Groups DEFAULT_GROUPS; }### Answer:
@Test(expected = ValidationException.class) public void testComputeGroupsNotAnInterface() { groupsComputer.computeGroups(Collections.singleton(String.class)); }
@Test(expected = IllegalArgumentException.class) public void testGroupChainForNull() { groupsComputer.computeGroups((Class<?>[]) null); }
@Test public void testGroupChainForEmptySet() { assertEquals(Collections.singleton(Group.DEFAULT), groupsComputer.computeGroups(new HashSet<Class<?>>()).getGroups()); }
@Test(expected = GroupDefinitionException.class) public void testCyclicGroupSequences() { groupsComputer.computeGroups(Collections.singleton(CyclicGroupSequence1.class)); }
@Test(expected = GroupDefinitionException.class) public void testCyclicGroupSequence() { groupsComputer.computeGroups(Collections.singleton(CyclicGroupSequence.class)); }
@Test public void testGroupDuplicates() { Set<Class<?>> groups = new HashSet<Class<?>>(); groups.add(First.class); groups.add(Second.class); groups.add(Last.class); Groups chain = groupsComputer.computeGroups(groups); assertEquals(3, chain.getGroups().size()); groups.clear(); groups.add(First.class); groups.add(First.class); chain = groupsComputer.computeGroups(groups); assertEquals(1, chain.getGroups().size()); groups.clear(); groups.add(First.class); groups.add(Last.class); groups.add(First.class); chain = groupsComputer.computeGroups(groups); assertEquals(2, chain.getGroups().size()); }
@Test public void testSequenceResolution() { Set<Class<?>> groups = new HashSet<Class<?>>(); groups.add(Address.Complete.class); Groups chain = groupsComputer.computeGroups(groups); Iterator<Group.Sequence> sequences = chain.getSequences().iterator(); Iterator<Group> sequence = sequences.next().getGroups().iterator(); assertEquals(Default.class, sequence.next().getGroup()); assertEquals(Address.HighLevelCoherence.class, sequence.next().getGroup()); }