use of io.vavr.control.Try in project resilience4j by resilience4j.
the class IntervalFunctionTest method shouldRejectOutOfBoundsMultiplier.
@Test
public void shouldRejectOutOfBoundsMultiplier() {
// Given
final Duration duration = Duration.ofMillis(100);
final float lessThenOneMultiplier = 0.9999f;
// When
final List<Try> tries = List.of(Try.of(() -> IntervalFunction.ofExponentialBackoff(duration, lessThenOneMultiplier)), Try.of(() -> IntervalFunction.ofExponentialRandomBackoff(duration, lessThenOneMultiplier)));
// Then
Assertions.assertThat(tries.forAll(Try::isFailure)).isTrue();
Assertions.assertThat(tries.map(Try::getCause).forAll(t -> t instanceof IllegalArgumentException)).isTrue();
}
use of io.vavr.control.Try in project resilience4j by resilience4j.
the class IntervalFunctionTest method shouldRejectOutOfBoundsRandomizationFactor.
@Test
public void shouldRejectOutOfBoundsRandomizationFactor() {
// Given
final Duration duration = Duration.ofMillis(100);
final float negativeFactor = -0.0001f;
final float greaterThanOneFactor = 1.0001f;
// When
final List<Try> tries = List.of(Try.of(() -> IntervalFunction.ofRandomized(duration, negativeFactor)), Try.of(() -> IntervalFunction.ofRandomized(duration, greaterThanOneFactor)));
// Then
Assertions.assertThat(tries.forAll(Try::isFailure)).isTrue();
Assertions.assertThat(tries.map(Try::getCause).forAll(t -> t instanceof IllegalArgumentException)).isTrue();
}
Aggregations