### Question:
NodeLayoutGenerator { Set<Set<String>> findValidServiceSets(Set<String> services) { Set<Set<String>> validServiceSets = Sets.newHashSet(); if (!services.isEmpty()) { LayoutConstraint layoutConstraint = clusterTemplate.getConstraints().getLayoutConstraint(); int[] maxCounts = new int[services.size()]; for (int i = 0; i < maxCounts.length; i++) { maxCounts[i] = 1; } List<String> serviceList = Lists.newArrayList(services); for (int i = 1; i <= services.size(); i++) { Iterator<int[]> serviceIter = new SlottedCombinationIterator(services.size(), i, maxCounts); while (serviceIter.hasNext()) { int[] serviceCounts = serviceIter.next(); Set<String> candidateSet = Sets.newHashSet(); for (int j = 0; j < serviceCounts.length; j++) { if (serviceCounts[j] == 1) { candidateSet.add(serviceList.get(j)); } } if (isValidServiceSet(candidateSet, layoutConstraint, clusterServices)) { validServiceSets.add(candidateSet); } } } } return validServiceSets; } NodeLayoutGenerator(ClusterTemplate clusterTemplate, Set<String> clusterServices,
                             Set<String> allowedHardwareTypes, Set<String> allowedImageTypes); List<NodeLayout> generateNodeLayoutPreferences();  }### Answer:
@Test public void testGetValidServiceSets() { Set<Set<String>> expected = ImmutableSet.<Set<String>>of( ImmutableSet.of("datanode", "regionserver", "nodemanager"), ImmutableSet.of("namenode", "resourcemanager", "hbasemaster"), ImmutableSet.of("reactor", "zookeeper"), ImmutableSet.of("zookeeper"), ImmutableSet.of("reactor")); Set<String> services = ImmutableSet.of("datanode", "regionserver", "nodemanager", "namenode", "resourcemanager", "hbasemaster", "reactor", "zookeeper"); NodeLayoutGenerator nodeLayoutGenerator = new NodeLayoutGenerator(reactorTemplate, services, ImmutableSet.<String>of(), ImmutableSet.<String>of()); Assert.assertEquals( expected, nodeLayoutGenerator.findValidServiceSets(reactorTemplate.getClusterDefaults().getServices())); }