Debian Codegraph @

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/DisabledOnJreCondition.java

raw symbols SCIP
1 /*
2 * Copyright 2015-2024 the original author or authors.
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v2.0 which
6 * accompanies this distribution and is available at
7 *
8 * https://www.eclipse.org/legal/epl-v20.html
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 * {@link ExecutionCondition} for {@link DisabledOnJre @DisabledOnJre}.
23 *
24 * @since 5.1
25 * @see DisabledOnJre
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 }