@Test void shouldFailIfSetterInvocationFails() { EasyRandom easyRandom = new EasyRandom(); Throwable thrown = catchThrowable(() -> easyRandom.nextObject(Salary.class)); assertThat(thrown).isInstanceOf(ObjectCreationException.class) .hasMessageContaining("Unable to create a random instance of type class org.jeasy.random.beans.Salary"); Throwable cause = thrown.getCause(); assertThat(cause).isInstanceOf(ObjectCreationException.class) .hasMessageContaining("Unable to invoke setter for field amount of class org.jeasy.random.beans.Salary"); Throwable rootCause = cause.getCause(); assertThat(rootCause).isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Amount must be positive"); }
public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); }
EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } }
EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom();  EasyRandom(final EasyRandomParameters easyRandomParameters); }
EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom();  EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize); }
EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom();  EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize);  }