### Question:
EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } EasyRandom();  EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize);  }### Answer:
@Test void generatedBeansNumberShouldBeEqualToSpecifiedNumber() { Stream<Person> persons = easyRandom.objects(Person.class, 2); assertThat(persons).hasSize(2).hasOnlyElementsOfType(Person.class); }
@Test void whenSpecifiedNumberOfBeansToGenerateIsNegative_thenShouldThrowAnIllegalArgumentException() { assertThatThrownBy(() -> easyRandom.objects(Person.class, -2)).isInstanceOf(IllegalArgumentException.class); }