Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.uchagani</groupId>
<artifactId>junit-playwright</artifactId>
<version>2.1</version>
<version>2.2.1</version>

<name>junit-playwright</name>
<description>junit-playwright allows you to easily run Playwright-Java tests in parallel</description>
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/io/github/uchagani/jp/AnnotationUtils.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.uchagani.jp;

import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;

import java.lang.annotation.Annotation;

Expand All @@ -10,18 +9,4 @@ static boolean isAnnotationPresentOnClassOrMethod(ExtensionContext extensionCont
return extensionContext.getRequiredTestClass().isAnnotationPresent(annotation) ||
extensionContext.getRequiredTestMethod().isAnnotationPresent(annotation);
}

static void ensureAnnotationIsPresentOnClassOrMethod(ExtensionContext extensionContext, Class<? extends Annotation> annotation) {
if (!isAnnotationPresentOnClassOrMethod(extensionContext, annotation)) {
String message = String.format("Class or Method is not annotated with %s", annotation.getName());
throw new RuntimeException(message);
}
}

static void ensureAnnotationIsPresentOnClassOrMethodOrParameter(ParameterContext parameterContext, ExtensionContext extensionContext, Class<? extends Annotation> annotation) {
if (!isAnnotationPresentOnClassOrMethod(extensionContext, annotation) && !parameterContext.isAnnotated(annotation)) {
String message = String.format("Class or Method or Parameter is not annotated with %s", annotation.getName());
throw new RuntimeException(message);
}
}
}
11 changes: 2 additions & 9 deletions src/main/java/io/github/uchagani/jp/ExtensionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

import java.lang.reflect.InvocationTargetException;

import static io.github.uchagani.jp.AnnotationUtils.ensureAnnotationIsPresentOnClassOrMethod;
import static io.github.uchagani.jp.AnnotationUtils.ensureAnnotationIsPresentOnClassOrMethodOrParameter;

public class ExtensionUtils {
static final ExtensionContext.Namespace namespace = ExtensionContext.Namespace.create(JunitPlaywright.class);

Expand All @@ -19,8 +16,7 @@ static <T> T getObjectFromStore(ExtensionContext extensionContext, String id, Cl
return extensionContext.getStore(namespace).get(extensionContext.getUniqueId() + id, objectType);
}

static RestConfig getRestConfig(ParameterContext parameterContext, ExtensionContext extensionContext) {
ensureAnnotationIsPresentOnClassOrMethodOrParameter(parameterContext, extensionContext, UseRestConfig.class);
public static RestConfig getRestConfig(ParameterContext parameterContext, ExtensionContext extensionContext) {
Class<? extends PlaywrightRestConfig> configClass;

try {
Expand All @@ -35,8 +31,7 @@ static RestConfig getRestConfig(ParameterContext parameterContext, ExtensionCont
return createInstanceOfConfig(configClass).getRestConfig();
}

static BrowserConfig getBrowserConfig(ExtensionContext extensionContext) {
ensureAnnotationIsPresentOnClassOrMethod(extensionContext, UseBrowserConfig.class);
public static BrowserConfig getBrowserConfig(ExtensionContext extensionContext) {
Class<? extends PlaywrightBrowserConfig> configClass;

try {
Expand All @@ -56,6 +51,4 @@ private static <T> T createInstanceOfConfig(Class<T> configClass) {
throw new RuntimeException(message, ex);
}
}


}