
com.polonium.eclipserunner.core.ExceptionsRecognizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polonium-webdriver Show documentation
Show all versions of polonium-webdriver Show documentation
Polonium-Webdriver extends polonium core with paging functionality (page-object pattern),
and handles/recognizes fails made by selenium driver. This version has Polonium-Core included.
The newest version!
package com.polonium.eclipserunner.core;
import com.polonium.eclipserunner.core.annotations.MarkedGivenFail;
import com.polonium.eclipserunner.core.annotations.MarkedThenFail;
import com.polonium.eclipserunner.core.annotations.MarkedWhenFail;
import com.polonium.eclipserunner.core.exceptions.GivenException;
import com.polonium.eclipserunner.core.exceptions.ThenException;
import com.polonium.eclipserunner.core.exceptions.WhenException;
import java.util.ArrayList;
import java.util.List;
/** Class creates three static lists with defined exception types to recognized
*
* @author Marek Serwanski
*/
public class ExceptionsRecognizer {
public static List> markedWhenExceptions = new ArrayList>();
public static List> markedGivenExceptions = new ArrayList>();
public static List> markedThenExceptions = new ArrayList>();
public ExceptionsRecognizer(Class> testClass) {
addDefaultExceptions();
addProvidedExceptions(testClass);
}
private void addDefaultExceptions() {
markedWhenExceptions.add(WhenException.class);
markedGivenExceptions.add(GivenException.class);
markedThenExceptions.add(ThenException.class);
}
private void addProvidedExceptions(Class> testClass) {
if(testClass.isAnnotationPresent(MarkedGivenFail.class)){
for(Class extends Throwable> markedException : testClass.getAnnotation(MarkedGivenFail.class).value()){
markedGivenExceptions.add(markedException);
}
}
if(testClass.isAnnotationPresent(MarkedWhenFail.class)){
for(Class extends Throwable> markedException : testClass.getAnnotation(MarkedWhenFail.class).value()){
markedWhenExceptions.add(markedException);
}
}
if(testClass.isAnnotationPresent(MarkedThenFail.class)){
for(Class extends Throwable> markedException : testClass.getAnnotation(MarkedThenFail.class).value()){
markedThenExceptions.add(markedException);
}
}
//TODO: check why sometimes class returns annotations of its parent, sometimes not. And remove this shit! (oracle jdk6)
Class> parent = testClass.getSuperclass();
if(parent != null && !(parent.getName().equals("PoloniumTest"))){
addProvidedExceptions(parent);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy