Jarosław Michalik
08/11/2020, 7:16 AMStephan Schroeder
08/11/2020, 8:47 AM@Static
Example:
class ProductPredicateTest {
private val product: Product = mockk()
@BeforeEach
fun setup() {
clearMocks(product)
}
@ParameterizedTest
@MethodSource("getOrPredicateProvider")
fun `getOrPredicate should return an at-least-one-combination of all the predicates`(
alwaysOrNeverTruePredicates: List<Boolean>,
expectedOrCombinationResult: Boolean
) {
val orPredicate: ProductPredicate = getOrPredicate(
alwaysOrNeverTruePredicates.map { if(it) alwaysTruePredicate else neverTruePredicate }
)
assertThat(orPredicate(product)).isEqualTo(expectedOrCombinationResult)
}
companion object {
@JvmStatic
private fun getOrPredicateProvider(): List<Arguments?> = listOf(
Arguments.of(
listOf(false, false, false),
false),
Arguments.of(
listOf(false, true, false),
true),
Arguments.of(
listOf(true, true, true),
true)
)
}
}
cedric
08/12/2020, 3:34 AMStephan Schroeder
08/12/2020, 7:08 AM