From 8d461d4fe75f7b2f48c92d82b921bf7df06ff6e3 Mon Sep 17 00:00:00 2001 From: Paul Horn Date: Thu, 18 Jul 2024 15:03:41 +0200 Subject: [PATCH] Remove EnableForNeo4jVersion annotation --- .../annotation/EnableForNeo4jVersion.java | 41 ------------- .../EnableForNeo4jVersionCondition.java | 57 ------------------- 2 files changed, 98 deletions(-) delete mode 100644 test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersion.java delete mode 100644 test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersionCondition.java diff --git a/test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersion.java b/test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersion.java deleted file mode 100644 index 165803f592..0000000000 --- a/test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersion.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) "Neo4j" - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.gds.junit.annotation; - -import org.junit.jupiter.api.extension.ExtendWith; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -@Target({ METHOD, TYPE, ANNOTATION_TYPE }) -@Retention(RUNTIME) -@ExtendWith(EnableForNeo4jVersionCondition.class) -public @interface EnableForNeo4jVersion { - - Neo4jVersion value(); - - String message() default ""; - -} diff --git a/test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersionCondition.java b/test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersionCondition.java deleted file mode 100644 index c7d4cc84b6..0000000000 --- a/test-utils/src/main/java/org/neo4j/gds/junit/annotation/EnableForNeo4jVersionCondition.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) "Neo4j" - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.gds.junit.annotation; - -import org.junit.jupiter.api.extension.ConditionEvaluationResult; -import org.junit.jupiter.api.extension.ExecutionCondition; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.neo4j.gds.compat.GraphDatabaseApiProxy; - -import java.lang.reflect.AnnotatedElement; - -import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled; -import static org.junit.jupiter.params.shadow.com.univocity.parsers.annotations.helpers.AnnotationHelper.findAnnotation; -import static org.neo4j.gds.utils.StringFormatting.formatWithLocale; - -public class EnableForNeo4jVersionCondition implements ExecutionCondition { - - private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = - ConditionEvaluationResult.enabled("@EnableForNeo4jVersion is not present"); - - @Override - public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { - AnnotatedElement element = context - .getElement() - .orElseThrow(IllegalStateException::new); - - var runningNeo4jVersion = GraphDatabaseApiProxy.neo4jVersion(); - - var single = findAnnotation(element, EnableForNeo4jVersion.class); - if (single != null && single.value().matches(runningNeo4jVersion)) { - return disabled(formatWithLocale( - "Not enabled for %s, only for Neo4j version %s", - runningNeo4jVersion, - single.value() - )); - } - - return ENABLED_BY_DEFAULT; - } -}