/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
package groovy.junit6.plugin

import org.apache.groovy.lang.annotation.Incubating
import org.junit.jupiter.api.extension.ExtendWith

import java.lang.annotation.Documented
import java.lang.annotation.ElementType
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target

/**
 * Enables the annotated test class or method if the Groovy closure evaluates to {@code true}.
 * <p>
 * The closure is evaluated with a delegate providing the following bindings:
 * <ul>
 *   <li>{@code systemEnvironment} &mdash; {@code System.getenv()}</li>
 *   <li>{@code systemProperties} &mdash; {@code System.getProperties()}</li>
 *   <li>{@code javaVersion} &mdash; Runtime Java feature version (e.g.&nbsp;17, 21)</li>
 *   <li>{@code junitTags} &mdash; tags assigned to the test</li>
 *   <li>{@code junitDisplayName} &mdash; display name of the test</li>
 *   <li>{@code junitUniqueId} &mdash; unique ID of the test</li>
 * </ul>
 * <p>
 * Example usage:
 * <pre>
 * &#64;Test
 * &#64;GroovyEnabledIf({ javaVersion >= 21 })
 * void needsVirtualThreads() { ... }
 *
 * &#64;Test
 * &#64;GroovyEnabledIf({ systemEnvironment['CI'] == 'true' })
 * void onlyOnCI() { ... }
 * </pre>
 *
 * @since 6.0.0
 * @see GroovyDisabledIf
 */
@Documented
@Incubating
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@ExtendWith(GroovyConditionExtension)
@interface GroovyEnabledIf {
    Class value()

    String reason() default ""
}
