// Path: issue-keeper-base/src/main/java/qa/tools/ikeeper/client/JiraClient.java
// public class JiraClient implements ITrackerClient {
// 
//     protected final JiraConnector issueConnector;
// 
//     public JiraClient(String urlDomain) {
//         issueConnector = new JiraConnector(urlDomain, null);
//     }
// 
//     public JiraClient(String urlDomain, String query) {
//         issueConnector = new JiraConnector(urlDomain, query);
//     }
// 
//     
//     @Override
//     public String getName() {
//         return "JIRA";
//     }
//     
//     @Override
//     public List<String> getDefaultActionStates() {
//         return Arrays.asList("NEW", "OPEN", "ASSIGNED", "CODING IN PROGRESS", "PULL REQUEST SENT", "REOPENED");
//     }
// 
//     @Override
//     public boolean canHandle(Annotation annotation) {
//         return annotation instanceof Jira;
//     }
// 
//     @Override
//     public List<IssueDetails> getIssues(Annotation annotation) {
//         Jira jiraAnnotation = (Jira) annotation;
// 
//         String[] ids = jiraAnnotation.value();
//         List<IssueDetails> detailsList = new ArrayList<IssueDetails>();
//         for (String id : ids) {
//             Set<IssueDetails> details = issueConnector.getIssue(id);
//             detailsList.addAll(details);
//         }
// 
//         return detailsList;
//     }
// 
//     @Override
//     public String getQuery() {
//         return issueConnector.getQuery();
//     }
// 
//     @Override
//     public void authenticate(String username, String password) {
//         issueConnector.setUsername(username);
//         issueConnector.setPassword(password);
//     }
// 
//     @Override
//     public void authenticate(String personalAccessToken) {
//         issueConnector.setPersonalAccessToken(personalAccessToken);
//     }
// 
//     @Override
//     public IssueTrackingSystemConnector getIssueConnector() {
//         return issueConnector;
//     }
// 
// }
// 
// Path: issue-keeper-base/src/main/java/qa/tools/ikeeper/interceptor/QueryInterceptor.java
// public class QueryInterceptor extends AbstractIKeeperInterceptor {
//     @Override
//     public void intercept(String testName, IAction action, List<Annotation> annotations, ITrackerClient[] clients, Map<String, String> evaluationProperties) {
//         if (!enabled) {
//             return;
//         }
//         for (Annotation annotation : annotations) {
//             for (ITrackerClient c : clients) {
//                 if (c.canHandle(annotation)) {
// 
// 
//                     List<IssueDetails> detailsList = c.getIssues(annotation);
//                     Iterator<IssueDetails> iterator = detailsList.iterator();
// 
//                     //process issue constraints
//                     while (iterator.hasNext()) {
//                         IssueDetails details = iterator.next();
//                         for (String key : evaluationProperties.keySet()) {
//                             String constraintValue = issueConstraints.get(details.getId() + "-" + key);
//                             if (constraintValue != null) {
//                                 List<String> cvs = Arrays.asList(constraintValue.split(","));
//                                 if (!cvs.contains(evaluationProperties.get(key))) {
//                                     iterator.remove();
//                                 }
//                             } else {
//                                 String regexpConstraintValue = issueConstraints.get(details.getId() + "-" + key + "~");
//                                 if (regexpConstraintValue != null) {
//                                     if (!evaluationProperties.get(key).matches(regexpConstraintValue))
//                                         iterator.remove();
//                                 }
//                             }
//                         }
// 
//                         // if there is some issue remaining in list - perform action
//                         if (!detailsList.isEmpty()) {
//                             action.perform(testName, detailsList);
//                             break;
//                         }
// 
//                     }
//                 }
//             }
//         }
//     }
// }
// 
// Path: issue-keeper-junit/src/main/java/qa/tools/ikeeper/test/IKeeperJUnitConnector.java
// public class IKeeperJUnitConnector extends IKeeperConnector implements TestRule {
// 
//     static {
//         // skip is the default action
//         action = new Skip();
//     }
// 
//     public IKeeperJUnitConnector(ITrackerClient... clients) {
//         super(clients);
//     }
// 
//     public IKeeperJUnitConnector(IKeeperInterceptor interceptor, ITrackerClient... clients){
//         super(interceptor,clients);
//     }
// 
// 
//     public IKeeperJUnitConnector(String testVersion, ITrackerClient... clients) {
//         super(testVersion, clients);
// 
//     }
// 
//     @Override
//     public Statement apply(final Statement base, final Description description) {
//         return new Statement() {
// 
//             @Override
//             public void evaluate() throws Throwable {
//                 List<Annotation> annotations = new ArrayList<Annotation>();
//                 annotations.addAll(description.getAnnotations());
//                 annotations.addAll(Arrays.asList(description.getTestClass().getAnnotations()));
// 
//                 interceptor.intercept(description.getMethodName(), action, annotations, clients, environmentProperties);
// 
//                 base.evaluate();
// 
//             }
//         };
//     }
// 
// }
// 
// Path: issue-keeper-junit/src/test/java/qa/tools/ikeeper/test/base/JiraTestBase.java
// public class JiraTestBase {
// 
//     @Rule
//     public TestRule issueKeeper;
// 
//     public JiraTestBase() {
//         issueKeeper = new IKeeperJUnitConnector(new JiraClient("https://issues.jboss.org"));
//     }
// 
// }


import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import qa.tools.ikeeper.annotation.Jira;
import qa.tools.ikeeper.client.JiraClient;
import qa.tools.ikeeper.interceptor.QueryInterceptor;
import qa.tools.ikeeper.test.IKeeperJUnitConnector;
import qa.tools.ikeeper.test.base.JiraTestBase;
import java.util.ArrayList;
import java.util.List;
package qa.tools.ikeeper.test.query;



public class JiraRegexpConstraintsTest {

    private static final List<String> executed = new ArrayList<String>();

    @Rule
    public TestRule issueKeeper;

    public JiraRegexpConstraintsTest() {
        issueKeeper = new IKeeperJUnitConnector(new QueryInterceptor(), new JiraClient("https://issues.jboss.org", "KEY=${id} AND STATUS != CLOSED AND STATUS != RESOLVED"));
    }

// Path: issue-keeper-base/src/main/java/qa/tools/ikeeper/client/JiraClient.java
// public class JiraClient implements ITrackerClient {
// 
//     protected final JiraConnector issueConnector;
// 
//     public JiraClient(String urlDomain) {
//         issueConnector = new JiraConnector(urlDomain, null);
//     }
// 
//     public JiraClient(String urlDomain, String query) {
//         issueConnector = new JiraConnector(urlDomain, query);
//     }
// 
//     
//     @Override
//     public String getName() {
//         return "JIRA";
//     }
//     
//     @Override
//     public List<String> getDefaultActionStates() {
//         return Arrays.asList("NEW", "OPEN", "ASSIGNED", "CODING IN PROGRESS", "PULL REQUEST SENT", "REOPENED");
//     }
// 
//     @Override
//     public boolean canHandle(Annotation annotation) {
//         return annotation instanceof Jira;
//     }
// 
//     @Override
//     public List<IssueDetails> getIssues(Annotation annotation) {
//         Jira jiraAnnotation = (Jira) annotation;
// 
//         String[] ids = jiraAnnotation.value();
//         List<IssueDetails> detailsList = new ArrayList<IssueDetails>();
//         for (String id : ids) {
//             Set<IssueDetails> details = issueConnector.getIssue(id);
//             detailsList.addAll(details);
//         }
// 
//         return detailsList;
//     }
// 
//     @Override
//     public String getQuery() {
//         return issueConnector.getQuery();
//     }
// 
//     @Override
//     public void authenticate(String username, String password) {
//         issueConnector.setUsername(username);
//         issueConnector.setPassword(password);
//     }
// 
//     @Override
//     public void authenticate(String personalAccessToken) {
//         issueConnector.setPersonalAccessToken(personalAccessToken);
//     }
// 
//     @Override
//     public IssueTrackingSystemConnector getIssueConnector() {
//         return issueConnector;
//     }
// 
// }
// 
// Path: issue-keeper-base/src/main/java/qa/tools/ikeeper/interceptor/QueryInterceptor.java
// public class QueryInterceptor extends AbstractIKeeperInterceptor {
//     @Override
//     public void intercept(String testName, IAction action, List<Annotation> annotations, ITrackerClient[] clients, Map<String, String> evaluationProperties) {
//         if (!enabled) {
//             return;
//         }
//         for (Annotation annotation : annotations) {
//             for (ITrackerClient c : clients) {
//                 if (c.canHandle(annotation)) {
// 
// 
//                     List<IssueDetails> detailsList = c.getIssues(annotation);
//                     Iterator<IssueDetails> iterator = detailsList.iterator();
// 
//                     //process issue constraints
//                     while (iterator.hasNext()) {
//                         IssueDetails details = iterator.next();
//                         for (String key : evaluationProperties.keySet()) {
//                             String constraintValue = issueConstraints.get(details.getId() + "-" + key);
//                             if (constraintValue != null) {
//                                 List<String> cvs = Arrays.asList(constraintValue.split(","));
//                                 if (!cvs.contains(evaluationProperties.get(key))) {
//                                     iterator.remove();
//                                 }
//                             } else {
//                                 String regexpConstraintValue = issueConstraints.get(details.getId() + "-" + key + "~");
//                                 if (regexpConstraintValue != null) {
//                                     if (!evaluationProperties.get(key).matches(regexpConstraintValue))
//                                         iterator.remove();
//                                 }
//                             }
//                         }
// 
//                         // if there is some issue remaining in list - perform action
//                         if (!detailsList.isEmpty()) {
//                             action.perform(testName, detailsList);
//                             break;
//                         }
// 
//                     }
//                 }
//             }
//         }
//     }
// }
// 
// Path: issue-keeper-junit/src/main/java/qa/tools/ikeeper/test/IKeeperJUnitConnector.java
// public class IKeeperJUnitConnector extends IKeeperConnector implements TestRule {
// 
//     static {
//         // skip is the default action
//         action = new Skip();
//     }
// 
//     public IKeeperJUnitConnector(ITrackerClient... clients) {
//         super(clients);
//     }
// 
//     public IKeeperJUnitConnector(IKeeperInterceptor interceptor, ITrackerClient... clients){
//         super(interceptor,clients);
//     }
// 
// 
//     public IKeeperJUnitConnector(String testVersion, ITrackerClient... clients) {
//         super(testVersion, clients);
// 
//     }
// 
//     @Override
//     public Statement apply(final Statement base, final Description description) {
//         return new Statement() {
// 
//             @Override
//             public void evaluate() throws Throwable {
//                 List<Annotation> annotations = new ArrayList<Annotation>();
//                 annotations.addAll(description.getAnnotations());
//                 annotations.addAll(Arrays.asList(description.getTestClass().getAnnotations()));
// 
//                 interceptor.intercept(description.getMethodName(), action, annotations, clients, environmentProperties);
// 
//                 base.evaluate();
// 
//             }
//         };
//     }
// 
// }
// 
// Path: issue-keeper-junit/src/test/java/qa/tools/ikeeper/test/base/JiraTestBase.java
// public class JiraTestBase {
// 
//     @Rule
//     public TestRule issueKeeper;
// 
//     public JiraTestBase() {
//         issueKeeper = new IKeeperJUnitConnector(new JiraClient("https://issues.jboss.org"));
//     }
// 
// }


// Path: issue-keeper-junit/src/test/java/qa/tools/ikeeper/test/query/JiraRegexpConstraintsTest.java
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import qa.tools.ikeeper.annotation.Jira;
import qa.tools.ikeeper.client.JiraClient;
import qa.tools.ikeeper.interceptor.QueryInterceptor;
import qa.tools.ikeeper.test.IKeeperJUnitConnector;
import qa.tools.ikeeper.test.base.JiraTestBase;
import java.util.ArrayList;
import java.util.List;

package qa.tools.ikeeper.test.query;



public class JiraRegexpConstraintsTest {

    private static final List<String> executed = new ArrayList<String>();

    @Rule
    public TestRule issueKeeper;

    public JiraRegexpConstraintsTest() {
        issueKeeper = new IKeeperJUnitConnector(new QueryInterceptor(), new JiraClient("https://issues.jboss.org", "KEY=${id} AND STATUS != CLOSED AND STATUS != RESOLVED"));
    }

    @AfterClass