001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 * http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014
015package de.softwareforge.testing.postgres.junit5;
016
017import java.lang.annotation.ElementType;
018import java.lang.annotation.Retention;
019import java.lang.annotation.RetentionPolicy;
020import java.lang.annotation.Target;
021
022import org.junit.jupiter.api.extension.ExtendWith;
023
024/**
025 * {@code RequirePostgresVersion} signals the annotated test class or method that it only should execute if the PostgreSQL server is within a specific range. If
026 * the version is outside the range, the annotated test class or method is skipped.
027 * <p>
028 * PostgreSQL versions are interpreted as described in the <a href="https://www.postgresql.org/support/versioning/">Versioning Policy</a> and  structured as
029 * "major.minor.patch". Versions can be abbreviated, e.g. "13" is interpreted as "13.0.0".
030 * <p>
031 * Using "0.0.0" or the empty string will skip the respective boundary check.
032 * <p>
033 *
034 * @since 4.1
035 */
036@Target({ElementType.TYPE, ElementType.METHOD})
037@Retention(RetentionPolicy.RUNTIME)
038@ExtendWith({PostgresVersionCondition.class})
039public @interface RequirePostgresVersion {
040
041    /**
042     * Sets the minimum required version. This check is inclusive; the database must have at least the version specified.
043     *
044     * @return The minimum required version. Default is the empty string (ignore the check).
045     */
046    String atLeast() default "";
047
048    /**
049     * Sets the upper boundary version. The check is <b>exclusive</b>, the database version must be less than this version.
050     *
051     * @return The maximum allowed version. Default is the empty string (ignore the check).
052     */
053    String lessThan() default "";
054}