/** * Checks if the given test class has a deployment * * @param testClass to be checked * @return whether the given test class has a deployment */ public static boolean hasDeployment(TestClass testClass) { return testClass.getMethods(Deployment.class).length != 0; }
public Method getMethod(Class<? extends Annotation> annotation) { Method[] methods = getMethods(annotation); if (methods.length > 0) { return methods[0]; } return null; }
public Method getMethod(Class<? extends Annotation> annotation) { Method[] methods = getMethods(annotation); if (methods.length > 0) { return methods[0]; } return null; }
private boolean hasDeployment(TestClass testClass) { return testClass.getMethods(Deployment.class).length != 0; } }
private boolean hasDeployment(TestClass testClass) { return testClass.getMethods(Deployment.class).length != 0; } }
private Map<Method, T> fetch(Class<T> annotation) { final Map<Method, T> map = new HashMap<Method, T>(); for (Method testMethod : testClass.getMethods(annotation)) { map.put(testMethod, testMethod.getAnnotation(annotation)); } return map; } }
private Map<Method, T> fetch(Class<T> annotation) { final Map<Method, T> map = new HashMap<Method, T>(); for (Method testMethod : testClass.getMethods(annotation)) { map.put(testMethod, testMethod.getAnnotation(annotation)); } return map; } }
private Map<Method, T> fetch(Class<T> annotation) { final Map<Method, T> map = new HashMap<Method, T>(); for (Method testMethod : testClass.getMethods(annotation)) { map.put(testMethod, testMethod.getAnnotation(annotation)); } return map; } }
protected void validateState(final TestClass testClass, final List<Throwable> errors) { Arrays.stream(testClass.getMethods(State.class)).forEach(method -> { validatePublicVoidMethods(method, errors); }); }
protected List<DeploymentConfiguration> generateDeploymentContent(TestClass testClass) { List<DeploymentConfiguration> deployments = new ArrayList<DeploymentConfiguration>(); Method[] deploymentMethods = testClass.getMethods(Deployment.class); for (Method deploymentMethod : deploymentMethods) { validate(deploymentMethod); deployments.add(generateDeploymentContent(deploymentMethod)); } return deployments; }
protected List<DeploymentConfiguration> generateDeploymentContent(TestClass testClass) { List<DeploymentConfiguration> deployments = new ArrayList<DeploymentConfiguration>(); Method[] deploymentMethods = testClass.getMethods(Deployment.class); for (Method deploymentMethod : deploymentMethods) { validate(deploymentMethod); deployments.add(generateDeploymentContent(deploymentMethod)); } return deployments; }
/** * Returns all resources defined for this test class * including those defined on the test method level. */ public Collection<T> getDescriptors(TestClass testClass) { final List<T> descriptors = new ArrayList<T>(); for (Method testMethod : testClass.getMethods(resourceAnnotation)) { descriptors.addAll(getDescriptorsDefinedFor(testMethod)); } descriptors.addAll(obtainClassLevelDescriptor(testClass.getAnnotation(resourceAnnotation))); return descriptors; }
@Override public List<DeploymentDescription> generate(TestClass testClass) { List<DeploymentDescription> deployments = new ArrayList<DeploymentDescription>(); Method[] deploymentMethods = testClass.getMethods(Deployment.class); for (Method deploymentMethod : deploymentMethods) { validate(deploymentMethod); if (deploymentMethod.isAnnotationPresent(Dependencies.class)) deployments.addAll(generateDependencyDeployments(deploymentMethod)); deployments.add(generateDeployment(deploymentMethod)); } return deployments; }
protected Archive manipulateArchive(TestClass testClass, String deploymentName, Archive archive) { final Method[] beforeDeploymentMethods = testClass.getMethods(BeforeDeployment.class); for (Method beforeDeploymentMethod : beforeDeploymentMethods) { final BeforeDeployment beforeDeploymentMethodAnnotation = beforeDeploymentMethod.getAnnotation(BeforeDeployment.class); if (beforeDeploymentMethodAnnotation.name().equals(deploymentName)) { validate(beforeDeploymentMethod); archive = invoke(Archive.class, beforeDeploymentMethod, archive); break; } } return archive; }
protected Archive manipulateArchive(TestClass testClass, String deploymentName, Archive archive) { final Method[] beforeDeploymentMethods = testClass.getMethods(BeforeDeployment.class); for (Method beforeDeploymentMethod : beforeDeploymentMethods) { final BeforeDeployment beforeDeploymentMethodAnnotation = beforeDeploymentMethod.getAnnotation(BeforeDeployment.class); if (beforeDeploymentMethodAnnotation.name().equals(deploymentName)) { validate(beforeDeploymentMethod); archive = invoke(Archive.class, beforeDeploymentMethod, archive); break; } } return archive; }
/** * Execution method delegating the anotated method for "AfterDeploy" * * @param event * The observed event * @param testClass * The testclass with the annotation */ public final void executeAfterDeploy(@Observes AfterDeploy event, TestClass testClass) { execute(testClass.getMethods(AfterDeployment.class)); }
/** * Execution method delegating the annotated method for "BeforeDeploy" * * @param event * The observed event * @param testClass * The testclass with the annotation */ public final void executeBeforeDeploy(@Observes BeforeDeploy event, TestClass testClass) { execute(testClass.getMethods(BeforeDeployment.class)); }
/** * Execution method delegating the anotated method for "BeforeUnDeploy" * * @param event * The observed event * @param testClass * The testclass with the annotation */ public final void executeBeforeUnDeploy(@Observes BeforeUnDeploy event, TestClass testClass) { execute(testClass.getMethods(BeforeUnDeployment.class)); }
/** * Execution method delegating the anotated method for "AfterUnDeploy" * * @param event * The observed event * @param testClass * The testclass with the annotation */ public final void executeAfterUnDeploy(@Observes AfterUnDeploy event, TestClass testClass) { execute(testClass.getMethods(AfterUnDeployment.class)); }
public synchronized void removeTargertServerGroups(@Observes AfterClass event) { final TestClass testClass = event.getTestClass(); final Method[] methods = testClass.getMethods(Deployment.class); for (Method method : methods) { final Deployment deployment = method.getAnnotation(Deployment.class); serverGroupTargets.remove(deployment.name()); } }