### Question:
FieldSpecGroupValueGenerator { public Stream<DataBag> generate(FieldSpecGroup group) { Field first = getFirst(group); if (group.fieldSpecs().size() == 1) { return underlyingGenerator.generate(first, group.fieldSpecs().get(first)) .map(val -> toDataBag(first, val)); } FieldSpec firstSpec = updateFirstSpecFromRelations(first, group); Stream<DataBag> firstDataBagValues = underlyingGenerator.generate(first, firstSpec) .map(value -> toDataBag(first, value)); return flatMap( firstDataBagValues, dataBag -> generateRemainingData(first, dataBag, removeSpecFromGroup(first, group))); } @Inject  FieldSpecGroupValueGenerator(FieldSpecValueGenerator underlyingGenerator, CombinationStrategyType combinationStrategy); Stream<DataBag> generate(FieldSpecGroup group);  }### Answer:
@Test public void generate_withGroupOfSingleField_returnsCorrectStream() { Map<Field, FieldSpec> specMap = new HashMap<>(); Field firstField = createField("first"); FieldSpec firstSpec = FieldSpecFactory.fromType(firstField.getType()); specMap.put(firstField, FieldSpecFactory.fromType(firstField.getType())); FieldSpecValueGenerator underlyingGenerator = mock(FieldSpecValueGenerator.class); String result = "result"; DataBagValue firstValue = new DataBagValue(result); when(underlyingGenerator.generate(any(Field.class), eq(firstSpec))).thenReturn(Stream.of(firstValue)); FieldSpecGroupValueGenerator generator = new FieldSpecGroupValueGenerator(underlyingGenerator, CombinationStrategyType.MINIMAL); FieldSpecGroup group = new FieldSpecGroup(specMap, Collections.emptyList()); Stream<DataBag> stream = generator.generate(group); Map<Field, DataBagValue> dataBag = new HashMap<>(); dataBag.put(firstField, firstValue); assertEquals(Collections.singleton(new DataBag(dataBag)), stream.collect(Collectors.toSet())); }