Skip to content

Commit

Permalink
Remove useless experimental method display name obfuscation.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaisiKoleni committed Jan 17, 2022
1 parent 792afcb commit d081f82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 67 deletions.
36 changes: 2 additions & 34 deletions src/main/java/de/tum/in/test/api/jupiter/JupiterTestGuard.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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> T interceptGenericInvocation(Invocation<T> invocation, ExtensionContext extensionContext,
Expand All @@ -36,28 +28,4 @@ public <T> T interceptGenericInvocation(Invocation<T> 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);
}
}

This file was deleted.

0 comments on commit d081f82

Please sign in to comment.