本文整理了Java中io.vavr.collection.List.forAll()
方法的一些代码示例,展示了List.forAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.forAll()
方法的具体详情如下:
包路径:io.vavr.collection.List
类名称:List
方法名:forAll
暂无
代码示例来源:origin: resilience4j/resilience4j
@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();
}
代码示例来源:origin: resilience4j/resilience4j
@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();
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldRejectAttemptLessThenOne() {
// Given
final List<IntervalFunction> fns = List.of(
IntervalFunction.ofDefaults(),
IntervalFunction.ofRandomized(),
IntervalFunction.ofExponentialBackoff(),
IntervalFunction.ofExponentialRandomBackoff()
);
// When
final List<Try> tries = fns.map(fn -> Try.of(() -> fn.apply(0)));
// Then
Assertions.assertThat(tries.forAll(Try::isFailure)).isTrue();
Assertions.assertThat(tries.map(Try::getCause).forAll(t -> t instanceof IllegalArgumentException)).isTrue();
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldPassAttemptGreaterThenZero() {
// Given
final List<IntervalFunction> fns = List.of(
IntervalFunction.ofDefaults(),
IntervalFunction.ofRandomized(),
IntervalFunction.ofExponentialBackoff(),
IntervalFunction.ofExponentialRandomBackoff()
);
// When
final List<Try> tries1 = fns.map(fn -> Try.of(() -> fn.apply(1)));
final List<Try> tries2 = fns.map(fn -> Try.of(() -> fn.apply(2)));
// Then
Assertions.assertThat(tries1.forAll(Try::isFailure)).isFalse();
Assertions.assertThat(tries2.forAll(Try::isFailure)).isFalse();
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void shouldRejectNonPositiveDuration() {
// Given
final Duration negativeDuration = Duration.ofMillis(0);
final Duration zeroDuration = Duration.ofMillis(0);
final Duration smallDuration = Duration.ofMillis(9);
final long negativeInterval = -1;
final long zeroInterval = 0;
final long smallInterval = 9;
// When
List<Try> tries = List.of(
Try.of(() -> IntervalFunction.of(negativeDuration)),
Try.of(() -> IntervalFunction.of(zeroDuration)),
Try.of(() -> IntervalFunction.of(smallDuration)),
Try.of(() -> IntervalFunction.of(negativeInterval)),
Try.of(() -> IntervalFunction.of(zeroInterval)),
Try.of(() -> IntervalFunction.of(smallInterval))
);
// Then
Assertions.assertThat(tries.forAll(Try::isFailure)).isTrue();
Assertions.assertThat(tries.map(Try::getCause).forAll(t -> t instanceof IllegalArgumentException)).isTrue();
}
代码示例来源:origin: martincooper/java-datatable
/**
* Validates the passed data rows belong to the passed table.
* @param dataRows The Data Rows to check.
* @return Returns a Success or Failure.
*/
private static Try<Void> validateDataRows(DataTable table, Iterable<DataRow> dataRows) {
return List.ofAll(dataRows).forAll(row -> row.table() == table)
? Try.success(null)
: DataTableException.tryError("DataRows do not all belong to the specified table.");
}
}
内容来源于网络,如有侵权,请联系作者删除!