### Question:
ProductFlavorCombo { @NonNull public static <S extends DimensionAware & Named> List<ProductFlavorCombo<S>> createCombinations( @Nullable List<String> flavorDimensions, @NonNull Iterable<S> productFlavors) { List <ProductFlavorCombo<S>> result = Lists.newArrayList(); if (flavorDimensions == null || flavorDimensions.isEmpty()) { for (S flavor : productFlavors) { result.add(new ProductFlavorCombo<>(ImmutableList.of(flavor))); } } else { ArrayListMultimap<String, S> map = ArrayListMultimap.create(); for (S flavor : productFlavors) { String flavorDimension = flavor.getDimension(); if (flavorDimension == null) { throw new RuntimeException(String.format( "Flavor '%1$s' has no flavor dimension.", flavor.getName())); } if (!flavorDimensions.contains(flavorDimension)) { throw new RuntimeException(String.format( "Flavor '%1$s' has unknown dimension '%2$s'.", flavor.getName(), flavor.getDimension())); } map.put(flavorDimension, flavor); } createProductFlavorCombinations(result, Lists.<S>newArrayListWithCapacity(flavorDimensions.size()), 0, flavorDimensions, map); } return result; } ProductFlavorCombo(@NonNull T... flavors);  ProductFlavorCombo(@NonNull Iterable<T> flavors); @NonNull String getName(); @NonNull List<T> getFlavorList(); @NonNull static List<ProductFlavorCombo<S>> createCombinations(
            @Nullable List<String> flavorDimensions,
            @NonNull Iterable<S> productFlavors);  }### Answer:
@Test public void createGroupListEmpty() throws Exception { assertEqualGroupList( ImmutableList.<ProductFlavorCombo<CoreProductFlavor>>of(), ProductFlavorCombo.createCombinations( Collections.<String>emptyList(), Collections.<CoreProductFlavor>emptyList())); }
@Test public void createGroupListNullDimension() throws Exception { assertEqualGroupList( ImmutableList.of( new ProductFlavorCombo<>(f1) ), ProductFlavorCombo.createCombinations( null, ImmutableList.of(f1))); }
@Test public void createGroupListEmptyDimension() throws Exception { assertEqualGroupList( ImmutableList.of( new ProductFlavorCombo<>(f1), new ProductFlavorCombo<>(f2) ), ProductFlavorCombo.createCombinations( ImmutableList.<String>of(), ImmutableList.of(f1, f2))); }
@Test public void createGroupListSingleDimension() throws Exception { assertEqualGroupList( ImmutableList.of(new ProductFlavorCombo<>(f1d1)), ProductFlavorCombo.createCombinations( ImmutableList.of(DIMENSION1), ImmutableList.of(f1d1))); }
@Test public void createGroupListMultiDimensions() throws Exception { assertEqualGroupList( ImmutableList.of( new ProductFlavorCombo<>(f1d1, f1d2), new ProductFlavorCombo<>(f1d1, f2d2), new ProductFlavorCombo<>(f2d1, f1d2), new ProductFlavorCombo<>(f2d1, f2d2)), ProductFlavorCombo.createCombinations( ImmutableList.of(DIMENSION1, DIMENSION2), ImmutableList.of(f1d1, f1d2, f2d1, f2d2))); }
@Test public void createGroupListMissingDimension() throws Exception { try { ProductFlavorCombo.createCombinations( ImmutableList.of(DIMENSION1), ImmutableList.of(f1)); fail("Expected to throw"); } catch (RuntimeException ignore) { } }
@Test public void createGroupListInvalidDimension() throws Exception { try { ProductFlavorCombo.createCombinations( ImmutableList.of(DIMENSION1), ImmutableList.of(f1d2)); fail("Expected to throw"); } catch (RuntimeException ignore) { } }
@Test public void createGroupListDimensionWithoutFlavor() throws Exception { try { ProductFlavorCombo.createCombinations( ImmutableList.of(DIMENSION1, DIMENSION2), ImmutableList.of(f1d1)); fail("Expected to throw"); } catch (RuntimeException ignore) { } }