// Path: sunshine-core/src/main/java/org/tatools/sunshine/core/RegexCondition.java
// @EqualsAndHashCode
// public class RegexCondition implements Condition {
// 
//     final Pattern regex;
// 
//     /**
//      * Use a value of "tests-regex" system property as a regex pattern. If the system property is
//      * not set, the "(.+)(Test)([\w\d]+)?" value is used.
//      */
//     public RegexCondition() {
//         this(System.getProperty("tests-regex", "(.+)(Test)([\\w\\d]+)?"));
//     }
// 
//     /**
//      * Construct the object with given regex.
//      *
//      * @param regex the value to be complied in a {@link Pattern}
//      */
//     public RegexCondition(String regex) {
//         this(Pattern.compile(regex));
//     }
// 
//     /**
//      * Construct the object with given regex.
//      *
//      * @param regex the value
//      */
//     public RegexCondition(Pattern regex) {
//         this.regex = regex;
//     }
// 
//     @Override
//     public final boolean applicable(String identity) {
//         return regex.matcher(identity).matches();
//     }
// }
// 
// Path: sunshine-core/src/main/java/org/tatools/sunshine/core/Sun.java
// public class Sun implements Star {
// 
//     private static final int SUNSHINE_ERROR = 12;
//     private final Kernel<?> core;
// 
//     /**
//      * Constructs the new instance.
//      *
//      * @param kernel the {@link Kernel}
//      */
//     public Sun(Kernel<?> kernel) {
//         this.core = kernel;
//     }
// 
//     /**
//      * Retrieves a {@link Status} of encapsulated {@link Kernel}. If there are some errors in
//      * suite's preparation, the execution will be aborted with exit code #{@value SUNSHINE_ERROR},
//      * otherwise exit code will be provided by appropriate {@link Kernel}.
//      */
//     @Override
//     public final void shine() {
//         try {
//             final Status status = this.core.status();
//             System.out.println(
//                     new StringBuilder("\n===============================================\n")
//                             .append("Total tests run: ")
//                             .append(status.runCount())
//                             .append(", Failures: ")
//                             .append(status.failureCount())
//                             .append(", Skips: ")
//                             .append(status.ignoreCount())
//                             .append("\n===============================================\n"));
//             System.exit(status.code());
//         } catch (KernelException e) {
//             e.printStackTrace(System.out);
//             System.exit(Sun.SUNSHINE_ERROR);
//         }
//     }
// }
// 
// Path: sunshine-core/src/main/java/org/tatools/sunshine/core/VerboseRegex.java
// public class VerboseRegex implements Condition {
// 
//     private final RegexCondition regexCondition;
//     private final boolean[] say = new boolean[] {true};
//     private final PrintStream printer;
// 
//     /**
//      * Construct the object.
//      *
//      * @param condition the condition
//      */
//     public VerboseRegex(RegexCondition condition) {
//         this(condition, System.out);
//     }
// 
//     /**
//      * Construct the object.
//      *
//      * @param regexCondition the condition
//      * @param printer a print stream
//      */
//     VerboseRegex(RegexCondition regexCondition, PrintStream printer) {
//         this.regexCondition = regexCondition;
//         this.printer = printer;
//     }
// 
//     @Override
//     public final boolean applicable(String identity) {
//         if (say[0]) {
//             this.printer.println(
//                     String.format(
//                             "The following pattern will be used for classes filtering: %s",
//                             this.regexCondition.regex.pattern()));
//             Arrays.fill(say, false);
//         }
//         return this.regexCondition.applicable(identity);
//     }
// }


import org.tatools.sunshine.core.RegexCondition;
import org.tatools.sunshine.core.Sun;
import org.tatools.sunshine.core.VerboseRegex;
package org.tatools.sunshine.testng;


/**
 * The {@link Sunshine} class is a main class to run TestNG tests.
 *
 * <p>If no arguments will be provided, then Sunshine will try to find TestNG tests in the
 * CLASSPATH.
 *
 * <p>If an argument will be provided, then Sunshine will run TestNG with given argument. The
 * argument is a path to TestNG configuration file (XML or YAML).
 *
 * @author Dmytro Serdiuk (dmytro.serdiuk@gmail.com)
 * @version $Id$
 * @since 0.1
 */
public final class Sunshine {

    public static void main(String[] args) {
        if (args != null && args.length > 0) {
// Path: sunshine-core/src/main/java/org/tatools/sunshine/core/RegexCondition.java
// @EqualsAndHashCode
// public class RegexCondition implements Condition {
// 
//     final Pattern regex;
// 
//     /**
//      * Use a value of "tests-regex" system property as a regex pattern. If the system property is
//      * not set, the "(.+)(Test)([\w\d]+)?" value is used.
//      */
//     public RegexCondition() {
//         this(System.getProperty("tests-regex", "(.+)(Test)([\\w\\d]+)?"));
//     }
// 
//     /**
//      * Construct the object with given regex.
//      *
//      * @param regex the value to be complied in a {@link Pattern}
//      */
//     public RegexCondition(String regex) {
//         this(Pattern.compile(regex));
//     }
// 
//     /**
//      * Construct the object with given regex.
//      *
//      * @param regex the value
//      */
//     public RegexCondition(Pattern regex) {
//         this.regex = regex;
//     }
// 
//     @Override
//     public final boolean applicable(String identity) {
//         return regex.matcher(identity).matches();
//     }
// }
// 
// Path: sunshine-core/src/main/java/org/tatools/sunshine/core/Sun.java
// public class Sun implements Star {
// 
//     private static final int SUNSHINE_ERROR = 12;
//     private final Kernel<?> core;
// 
//     /**
//      * Constructs the new instance.
//      *
//      * @param kernel the {@link Kernel}
//      */
//     public Sun(Kernel<?> kernel) {
//         this.core = kernel;
//     }
// 
//     /**
//      * Retrieves a {@link Status} of encapsulated {@link Kernel}. If there are some errors in
//      * suite's preparation, the execution will be aborted with exit code #{@value SUNSHINE_ERROR},
//      * otherwise exit code will be provided by appropriate {@link Kernel}.
//      */
//     @Override
//     public final void shine() {
//         try {
//             final Status status = this.core.status();
//             System.out.println(
//                     new StringBuilder("\n===============================================\n")
//                             .append("Total tests run: ")
//                             .append(status.runCount())
//                             .append(", Failures: ")
//                             .append(status.failureCount())
//                             .append(", Skips: ")
//                             .append(status.ignoreCount())
//                             .append("\n===============================================\n"));
//             System.exit(status.code());
//         } catch (KernelException e) {
//             e.printStackTrace(System.out);
//             System.exit(Sun.SUNSHINE_ERROR);
//         }
//     }
// }
// 
// Path: sunshine-core/src/main/java/org/tatools/sunshine/core/VerboseRegex.java
// public class VerboseRegex implements Condition {
// 
//     private final RegexCondition regexCondition;
//     private final boolean[] say = new boolean[] {true};
//     private final PrintStream printer;
// 
//     /**
//      * Construct the object.
//      *
//      * @param condition the condition
//      */
//     public VerboseRegex(RegexCondition condition) {
//         this(condition, System.out);
//     }
// 
//     /**
//      * Construct the object.
//      *
//      * @param regexCondition the condition
//      * @param printer a print stream
//      */
//     VerboseRegex(RegexCondition regexCondition, PrintStream printer) {
//         this.regexCondition = regexCondition;
//         this.printer = printer;
//     }
// 
//     @Override
//     public final boolean applicable(String identity) {
//         if (say[0]) {
//             this.printer.println(
//                     String.format(
//                             "The following pattern will be used for classes filtering: %s",
//                             this.regexCondition.regex.pattern()));
//             Arrays.fill(say, false);
//         }
//         return this.regexCondition.applicable(identity);
//     }
// }


// Path: sunshine-testng/src/main/java/org/tatools/sunshine/testng/Sunshine.java
import org.tatools.sunshine.core.RegexCondition;
import org.tatools.sunshine.core.Sun;
import org.tatools.sunshine.core.VerboseRegex;

package org.tatools.sunshine.testng;


/**
 * The {@link Sunshine} class is a main class to run TestNG tests.
 *
 * <p>If no arguments will be provided, then Sunshine will try to find TestNG tests in the
 * CLASSPATH.
 *
 * <p>If an argument will be provided, then Sunshine will run TestNG with given argument. The
 * argument is a path to TestNG configuration file (XML or YAML).
 *
 * @author Dmytro Serdiuk (dmytro.serdiuk@gmail.com)
 * @version $Id$
 * @since 0.1
 */
public final class Sunshine {

    public static void main(String[] args) {
        if (args != null && args.length > 0) {
            new Sun(new TestNGKernel(new PreparedTestNGSuite(args[0]))).shine();