| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
package org.junit.jupiter.api.condition; |
| 12 |
|
| 13 |
import static org.junit.jupiter.api.condition.EnabledOnJreCondition.DISABLED_ON_CURRENT_JRE; |
| 14 |
import static org.junit.jupiter.api.condition.EnabledOnJreCondition.ENABLED_ON_CURRENT_JRE; |
| 15 |
|
| 16 |
import java.util.Arrays; |
| 17 |
|
| 18 |
import org.junit.jupiter.api.extension.ExecutionCondition; |
| 19 |
import org.junit.platform.commons.util.Preconditions; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class DisabledOnJreCondition extends BooleanExecutionCondition<DisabledOnJre> { |
| 28 |
|
| 29 |
DisabledOnJreCondition() { |
| 30 |
super(DisabledOnJre.class, ENABLED_ON_CURRENT_JRE, DISABLED_ON_CURRENT_JRE, DisabledOnJre::disabledReason); |
| 31 |
} |
| 32 |
|
| 33 |
@Override |
| 34 |
boolean isEnabled(DisabledOnJre annotation) { |
| 35 |
JRE[] versions = annotation.value(); |
| 36 |
Preconditions.condition(versions.length > 0, "You must declare at least one JRE in @DisabledOnJre"); |
| 37 |
return Arrays.stream(versions).noneMatch(JRE::isCurrentVersion); |
| 38 |
} |
| 39 |
|
| 40 |
} |