// Path: src/main/java/com/github/vbauer/jconditions/core/CheckerContext.java
// public class CheckerContext<T> {
// 
//     private final Object instance;
//     private final T annotation;
// 
// 
//     public CheckerContext(final Object instance, final T annotation) {
//         this.instance = instance;
//         this.annotation = annotation;
//     }
// 
// 
//     public Object getInstance() {
//         return instance;
//     }
// 
//     public T getAnnotation() {
//         return annotation;
//     }
// 
// }
// 
// Path: src/main/java/com/github/vbauer/jconditions/core/ConditionChecker.java
// public interface ConditionChecker<T> {
// 
//     /**
//      * Checks if execution of test method should be continued or not.
//      *
//      * @param context input data for checker
//      * @return true if execution should be continued and false - otherwise
//      * @throws Exception on any error (it is the same as false in return value)
//      */
//     boolean isSatisfied(CheckerContext<T> context) throws Exception;
// 
// }
// 
// Path: src/main/java/com/github/vbauer/jconditions/core/ConditionCheckerEngine.java
// public final class ConditionCheckerEngine {
// 
//     private ConditionCheckerEngine() {
//         throw new UnsupportedOperationException();
//     }
// 
// 
//     public static ConditionChecker<?> detectFailedChecker(
//         final Object instance, final FrameworkMethod method
//     ) {
//         final Collection<Annotation> annotations = findAllAnnotations(instance, method);
//         return findCheckerByAnnotations(instance, null, annotations);
//     }
// 
// 
//     private static ConditionChecker<?> findCheckerByAnnotations(
//         final Object instance, final Annotation parent, final Collection<Annotation> annotations
//     ) {
//         for (final Annotation annotation : annotations) {
//             final ConditionChecker<?> checker =
//                 getConditionChecker(instance, parent, annotation);
// 
//             if (checker != null) {
//                 return checker;
//             }
//         }
//         return null;
//     }
// 
//     private static ConditionChecker<?> getConditionChecker(
//         final Object instance, final Annotation parent, final Annotation annotation
//     ) {
//         if (!ReflexUtils.isInJavaLangAnnotationPackage(annotation)) {
//             final Class<? extends Annotation> annotationType = annotation.annotationType();
// 
//             if (annotationType == Condition.class) {
//                 final Condition condition = (Condition) annotation;
//                 final ConditionChecker<?> checker =
//                     findCheckerByCondition(instance, parent, condition);
// 
//                 if (checker != null) {
//                     return checker;
//                 }
//             }
// 
//             final Collection<Annotation> extra =
//                 Arrays.asList(annotationType.getAnnotations());
// 
//             final ConditionChecker<?> checker =
//                 findCheckerByAnnotations(instance, annotation, extra);
// 
//             if (checker != null) {
//                 return checker;
//             }
//         }
//         return null;
//     }
// 
//     @SuppressWarnings({"unchecked", "rawtypes"})
//     private static <T> ConditionChecker<T> findCheckerByCondition(
//         final T instance, final Annotation parent, final Condition condition
//     ) {
//         final Class<? extends ConditionChecker> checkerClass = condition.value();
//         final ConditionChecker<T> checker = ReflexUtils.instantiate(instance, checkerClass);
//         final CheckerContext<T> context = new CheckerContext(instance, parent);
// 
//         if (!ConditionCheckerExecutor.isSatisfied(context, checker)) {
//             return checker;
//         }
//         return null;
//     }
// 
//     private static Collection<Annotation> findAllAnnotations(
//         final Object instance, final FrameworkMethod method
//     ) {
//         final Collection<Annotation> result = ReflexUtils.findAllAnnotations(instance.getClass());
//         result.addAll(Arrays.asList(method.getAnnotations()));
//         return result;
//     }
// 
// }
// 
// Path: src/main/java/com/github/vbauer/jconditions/core/ConditionCheckerExecutor.java
// public final class ConditionCheckerExecutor {
// 
//     private ConditionCheckerExecutor() {
//         throw new UnsupportedOperationException();
//     }
// 
// 
//     @SafeVarargs
//     @SuppressWarnings("rawtypes")
//     public static boolean isSatisfied(
//         final CheckerContext<?> context,
//         final Class<? extends ConditionChecker>... checkerClasses
//     ) {
//         for (final Class<? extends ConditionChecker> checkerClass : checkerClasses) {
//             if (!isSatisfied(context, checkerClass)) {
//                 return false;
//             }
//         }
//         return true;
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static boolean isSatisfied(
//         final CheckerContext context,
//         final Class<? extends ConditionChecker> checkerClass
//     ) {
//         final Object instance = context.getInstance();
//         final ConditionChecker checker = ReflexUtils.instantiate(instance, checkerClass);
//         return isSatisfied(context, checker);
//     }
// 
//     @SuppressWarnings({"unchecked", "rawtypes"})
//     public static boolean isSatisfied(
//             final CheckerContext context, final ConditionChecker checker
//     ) {
//         try {
//             return checker.isSatisfied(context);
//         } catch (final Throwable ex) {
//             return false;
//         }
//     }
// 
// }


import org.junit.Test;
import com.github.vbauer.jconditions.core.CheckerContext;
import com.github.vbauer.jconditions.core.ConditionChecker;
import com.github.vbauer.jconditions.core.ConditionCheckerEngine;
import com.github.vbauer.jconditions.core.ConditionCheckerExecutor;
import com.pushtorefresh.private_constructor_checker.PrivateConstructorChecker;
                InOutUtils.class,
                NetUtils.class,
                PropUtils.class,
                ReflexUtils.class,
                ScriptUtils.class,
                TextUtils.class
            )
            .expectedTypeOfException(UnsupportedOperationException.class)
            .check();
    }

    @Test(expected = RuntimeException.class)
    public void testInstantiateNegativeRuntimeException() {
        ReflexUtils.instantiate(null, null);
    }

    @Test(expected = Exception.class)
    public void testInstantiateNegativeException() {
        ReflexUtils.instantiate(new Object(), NegativeChecker.class);
    }


    private class NegativeChecker<T> implements ConditionChecker<T> {
        private final boolean value;

        private NegativeChecker(final boolean value) {
            this.value = value;
        }

        @Override
// Path: src/main/java/com/github/vbauer/jconditions/core/CheckerContext.java
// public class CheckerContext<T> {
// 
//     private final Object instance;
//     private final T annotation;
// 
// 
//     public CheckerContext(final Object instance, final T annotation) {
//         this.instance = instance;
//         this.annotation = annotation;
//     }
// 
// 
//     public Object getInstance() {
//         return instance;
//     }
// 
//     public T getAnnotation() {
//         return annotation;
//     }
// 
// }
// 
// Path: src/main/java/com/github/vbauer/jconditions/core/ConditionChecker.java
// public interface ConditionChecker<T> {
// 
//     /**
//      * Checks if execution of test method should be continued or not.
//      *
//      * @param context input data for checker
//      * @return true if execution should be continued and false - otherwise
//      * @throws Exception on any error (it is the same as false in return value)
//      */
//     boolean isSatisfied(CheckerContext<T> context) throws Exception;
// 
// }
// 
// Path: src/main/java/com/github/vbauer/jconditions/core/ConditionCheckerEngine.java
// public final class ConditionCheckerEngine {
// 
//     private ConditionCheckerEngine() {
//         throw new UnsupportedOperationException();
//     }
// 
// 
//     public static ConditionChecker<?> detectFailedChecker(
//         final Object instance, final FrameworkMethod method
//     ) {
//         final Collection<Annotation> annotations = findAllAnnotations(instance, method);
//         return findCheckerByAnnotations(instance, null, annotations);
//     }
// 
// 
//     private static ConditionChecker<?> findCheckerByAnnotations(
//         final Object instance, final Annotation parent, final Collection<Annotation> annotations
//     ) {
//         for (final Annotation annotation : annotations) {
//             final ConditionChecker<?> checker =
//                 getConditionChecker(instance, parent, annotation);
// 
//             if (checker != null) {
//                 return checker;
//             }
//         }
//         return null;
//     }
// 
//     private static ConditionChecker<?> getConditionChecker(
//         final Object instance, final Annotation parent, final Annotation annotation
//     ) {
//         if (!ReflexUtils.isInJavaLangAnnotationPackage(annotation)) {
//             final Class<? extends Annotation> annotationType = annotation.annotationType();
// 
//             if (annotationType == Condition.class) {
//                 final Condition condition = (Condition) annotation;
//                 final ConditionChecker<?> checker =
//                     findCheckerByCondition(instance, parent, condition);
// 
//                 if (checker != null) {
//                     return checker;
//                 }
//             }
// 
//             final Collection<Annotation> extra =
//                 Arrays.asList(annotationType.getAnnotations());
// 
//             final ConditionChecker<?> checker =
//                 findCheckerByAnnotations(instance, annotation, extra);
// 
//             if (checker != null) {
//                 return checker;
//             }
//         }
//         return null;
//     }
// 
//     @SuppressWarnings({"unchecked", "rawtypes"})
//     private static <T> ConditionChecker<T> findCheckerByCondition(
//         final T instance, final Annotation parent, final Condition condition
//     ) {
//         final Class<? extends ConditionChecker> checkerClass = condition.value();
//         final ConditionChecker<T> checker = ReflexUtils.instantiate(instance, checkerClass);
//         final CheckerContext<T> context = new CheckerContext(instance, parent);
// 
//         if (!ConditionCheckerExecutor.isSatisfied(context, checker)) {
//             return checker;
//         }
//         return null;
//     }
// 
//     private static Collection<Annotation> findAllAnnotations(
//         final Object instance, final FrameworkMethod method
//     ) {
//         final Collection<Annotation> result = ReflexUtils.findAllAnnotations(instance.getClass());
//         result.addAll(Arrays.asList(method.getAnnotations()));
//         return result;
//     }
// 
// }
// 
// Path: src/main/java/com/github/vbauer/jconditions/core/ConditionCheckerExecutor.java
// public final class ConditionCheckerExecutor {
// 
//     private ConditionCheckerExecutor() {
//         throw new UnsupportedOperationException();
//     }
// 
// 
//     @SafeVarargs
//     @SuppressWarnings("rawtypes")
//     public static boolean isSatisfied(
//         final CheckerContext<?> context,
//         final Class<? extends ConditionChecker>... checkerClasses
//     ) {
//         for (final Class<? extends ConditionChecker> checkerClass : checkerClasses) {
//             if (!isSatisfied(context, checkerClass)) {
//                 return false;
//             }
//         }
//         return true;
//     }
// 
//     @SuppressWarnings("rawtypes")
//     public static boolean isSatisfied(
//         final CheckerContext context,
//         final Class<? extends ConditionChecker> checkerClass
//     ) {
//         final Object instance = context.getInstance();
//         final ConditionChecker checker = ReflexUtils.instantiate(instance, checkerClass);
//         return isSatisfied(context, checker);
//     }
// 
//     @SuppressWarnings({"unchecked", "rawtypes"})
//     public static boolean isSatisfied(
//             final CheckerContext context, final ConditionChecker checker
//     ) {
//         try {
//             return checker.isSatisfied(context);
//         } catch (final Throwable ex) {
//             return false;
//         }
//     }
// 
// }


// Path: src/test/java/com/github/vbauer/jconditions/util/ConstructorContractTest.java
import org.junit.Test;
import com.github.vbauer.jconditions.core.CheckerContext;
import com.github.vbauer.jconditions.core.ConditionChecker;
import com.github.vbauer.jconditions.core.ConditionCheckerEngine;
import com.github.vbauer.jconditions.core.ConditionCheckerExecutor;
import com.pushtorefresh.private_constructor_checker.PrivateConstructorChecker;

                InOutUtils.class,
                NetUtils.class,
                PropUtils.class,
                ReflexUtils.class,
                ScriptUtils.class,
                TextUtils.class
            )
            .expectedTypeOfException(UnsupportedOperationException.class)
            .check();
    }

    @Test(expected = RuntimeException.class)
    public void testInstantiateNegativeRuntimeException() {
        ReflexUtils.instantiate(null, null);
    }

    @Test(expected = Exception.class)
    public void testInstantiateNegativeException() {
        ReflexUtils.instantiate(new Object(), NegativeChecker.class);
    }


    private class NegativeChecker<T> implements ConditionChecker<T> {
        private final boolean value;

        private NegativeChecker(final boolean value) {
            this.value = value;
        }

        @Override
        public boolean isSatisfied(final CheckerContext<T> context) {