
com.greenpepper.annotation.Annotations Maven / Gradle / Ivy
package com.greenpepper.annotation;
import com.greenpepper.GreenPepper;
import com.greenpepper.expectation.Expectation;
import com.greenpepper.util.log.GreenPepperLogger;
import com.greenpepper.shaded.org.slf4j.Logger;
import java.lang.reflect.InvocationTargetException;
/**
* Annotations class.
*
* @author oaouattara
* @version $Id: $Id
*/
public final class Annotations
{
public static final String GREENPEPPER_EXCEPTIONS_LOGGERNAME = "greenpepper.exceptions";
private static final Logger LOGGER = GreenPepperLogger.getLogger(GREENPEPPER_EXCEPTIONS_LOGGERNAME);
/**
* exception.
*
* @param t a {@link java.lang.Throwable} object.
* @return a {@link com.greenpepper.annotation.ExceptionAnnotation} object.
*/
public static ExceptionAnnotation exception(Throwable t)
{
if (t instanceof InvocationTargetException)
{
if (GreenPepper.isDebugEnabled()) {
LOGGER.info("Caught exception in fixture execution", t);
}
return new ExceptionAnnotation( ((InvocationTargetException) t).getTargetException() );
}
else
{
if (GreenPepper.isDebugEnabled()) {
LOGGER.info("Caught exception in fixture execution", t);
}
return new ExceptionAnnotation( t );
}
}
/**
* right.
*
* @return a {@link com.greenpepper.annotation.RightAnnotation} object.
*/
public static RightAnnotation right()
{
return new RightAnnotation();
}
/**
* wrong.
*
* @return a {@link com.greenpepper.annotation.WrongAnnotation} object.
*/
public static WrongAnnotation wrong()
{
return new WrongAnnotation();
}
/**
* wrong.
*
* @param expected a {@link com.greenpepper.expectation.Expectation} object.
* @param actual a {@link java.lang.Object} object.
* @return a {@link com.greenpepper.annotation.WrongAnnotation} object.
*/
public static WrongAnnotation wrong(Expectation expected, Object actual)
{
WrongAnnotation annotation = wrong();
annotation.giveDetails( expected, actual );
return annotation;
}
/**
* ignored.
*
* @param actual a {@link java.lang.Object} object.
* @return a {@link com.greenpepper.annotation.IgnoredAnnotation} object.
*/
public static IgnoredAnnotation ignored(Object actual)
{
return new IgnoredAnnotation( actual );
}
/**
* entered.
*
* @return a {@link com.greenpepper.annotation.EnteredAnnotation} object.
*/
public static EnteredAnnotation entered()
{
return new EnteredAnnotation();
}
/**
* notEntered.
*
* @return a {@link com.greenpepper.annotation.NotEnteredAnnotation} object.
*/
public static NotEnteredAnnotation notEntered()
{
return new NotEnteredAnnotation();
}
/**
* missing.
*
* @return a {@link com.greenpepper.annotation.Annotation} object.
*/
public static Annotation missing()
{
return new MissingAnnotation();
}
/**
* surplus.
*
* @return a {@link com.greenpepper.annotation.SurplusAnnotation} object.
*/
public static SurplusAnnotation surplus()
{
return new SurplusAnnotation();
}
/**
* skipped.
*
* @return a {@link com.greenpepper.annotation.SkippedAnnotation} object.
*/
public static SkippedAnnotation skipped()
{
return new SkippedAnnotation();
}
/**
* stopped.
*
* @return a {@link com.greenpepper.annotation.StoppedAnnotation} object.
*/
public static StoppedAnnotation stopped()
{
return new StoppedAnnotation();
}
private Annotations()
{
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy