diff --git a/src/main/java/de/tum/in/test/api/jupiter/JupiterTestGuard.java b/src/main/java/de/tum/in/test/api/jupiter/JupiterTestGuard.java index 5310ea5f..543ab855 100644 --- a/src/main/java/de/tum/in/test/api/jupiter/JupiterTestGuard.java +++ b/src/main/java/de/tum/in/test/api/jupiter/JupiterTestGuard.java @@ -1,22 +1,16 @@ package de.tum.in.test.api.jupiter; import static de.tum.in.test.api.internal.ReportingUtils.doProceedAndPostProcess; -import static de.tum.in.test.api.internal.TestGuardUtils.*; -import static de.tum.in.test.api.localization.Messages.formatLocalized; -import static org.junit.platform.commons.support.AnnotationSupport.findAnnotation; +import static de.tum.in.test.api.internal.TestGuardUtils.checkForHidden; -import java.lang.reflect.Method; -import java.time.ZonedDateTime; import java.util.Optional; import org.apiguardian.api.API; import org.apiguardian.api.API.Status; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ReflectiveInvocationContext; import de.tum.in.test.api.Deadline; -import de.tum.in.test.api.internal.TestType; /** * This class' main purpose is to guard the {@link HiddenTest}s execution and @@ -25,9 +19,7 @@ * @author Christian Femers */ @API(status = Status.INTERNAL) -public final class JupiterTestGuard implements UnifiedInvocationInterceptor, DisplayNameGenerator { - - private final DisplayNameGenerator defaultNameGen = new DisplayNameGenerator.ReplaceUnderscores(); +public final class JupiterTestGuard implements UnifiedInvocationInterceptor { @Override public T interceptGenericInvocation(Invocation invocation, ExtensionContext extensionContext, @@ -36,28 +28,4 @@ public T interceptGenericInvocation(Invocation invocation, ExtensionConte checkForHidden(jupiterContext); return doProceedAndPostProcess(invocation, jupiterContext); } - - @Override - public String generateDisplayNameForClass(Class testClass) { - return defaultNameGen.generateDisplayNameForClass(testClass); - } - - @Override - public String generateDisplayNameForNestedClass(Class nestedClass) { - return defaultNameGen.generateDisplayNameForNestedClass(nestedClass); - } - - @Override - public String generateDisplayNameForMethod(Class testClass, Method testMethod) { - if (findAnnotation(testMethod, JupiterArtemisTest.class).map(JupiterArtemisTest::value) - .orElse(null) == TestType.HIDDEN) { - var deadline = extractDeadline(Optional.of(testClass), Optional.of(testMethod)); - String name = testMethod.toString(); - if (deadline.isEmpty()) - return formatLocalized("test_guard.obfuscate_hidden_test_missing_deadline", name); //$NON-NLS-1$ - if (ZonedDateTime.now().isBefore(deadline.get())) - return String.format("Hidden Test %08X", name.hashCode()); //$NON-NLS-1$ - } - return defaultNameGen.generateDisplayNameForMethod(testClass, testMethod); - } } diff --git a/src/main/java/de/tum/in/test/api/jupiter/ObfuscateMethodNamesBeforeDeadline.java b/src/main/java/de/tum/in/test/api/jupiter/ObfuscateMethodNamesBeforeDeadline.java deleted file mode 100644 index 625d7c92..00000000 --- a/src/main/java/de/tum/in/test/api/jupiter/ObfuscateMethodNamesBeforeDeadline.java +++ /dev/null @@ -1,33 +0,0 @@ -package de.tum.in.test.api.jupiter; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import org.apiguardian.api.API; -import org.apiguardian.api.API.Status; -import org.junit.jupiter.api.DisplayNameGeneration; - -import de.tum.in.test.api.Deadline; - -/** - * Obfuscates the name of {@link HiddenTest}s before the {@link Deadline}, using - * some basic hash code. - *

- * This has not been tested in conjunction with Artemis! - * - * @author Christian Femers - * @since 0.1.0 - * @version 1.0.0 - */ -@API(status = Status.EXPERIMENTAL) -@Documented -@Retention(RUNTIME) -@Target({ TYPE, ANNOTATION_TYPE }) -@DisplayNameGeneration(JupiterTestGuard.class) -public @interface ObfuscateMethodNamesBeforeDeadline { - // marker only -}