01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.test.suite;
17:
18: import java.lang.annotation.ElementType;
19: import java.lang.annotation.Retention;
20: import java.lang.annotation.RetentionPolicy;
21: import java.lang.annotation.Target;
22: import java.util.regex.Matcher;
23: import java.util.regex.Pattern;
24:
25: import org.kuali.core.util.AssertionUtils;
26:
27: /**
28: * This annotation marks test classes or methods which have failed for reasons relating to certain JIRA issues. Ideally these issues
29: * would be about bugs in production code or database tasks, but they could be about test code too.
30: * <p>
31: * One purpose of this annotation is to remove the related tests from the Anthill results while their issues are in progress. This
32: * prevents them from obscuring new test failures that need attention, by allowing the Anthill results to be maintained at 100%
33: * success.
34: * <p>
35: * Another purpose of this annotation is for KualiTestBase to wrap any test errors or failures with a notice that the annotated JIRA
36: * issues are related. If the {@value #SKIP_OPEN_OR_IN_PROGRESS_OR_REOPENED_JIRA_ISSUES} system property is set, then the test will
37: * pass (without running its contents) any test that {@link RelatesTo} a JIRA issue that is currently open or in-progress or
38: * reopened. This is an alternative to {@link org.kuali.test.suite.OpenOrInProgressOrReopenedSuite} for Anthill to retain the same
39: * format of its test report while not revealing any failures of such tests. When using this system property, keep in mind that it
40: * takes well over a minute to get the list of open issues from JIRA. The list is cached statically, so it's insignificant to add a
41: * minute or two to the time it takes for the whole Anthill build. But, developers will probably not want to add this system
42: * property to their own environments, because of this delay and so that they can still work on those tests.
43: *
44: * @see org.kuali.test.suite.InProgressSuite.Not
45: * @see org.kuali.test.KualiTestBase
46: */
47: @Retention(RetentionPolicy.RUNTIME)
48: @Target({ElementType.TYPE,ElementType.METHOD})
49: public @interface RelatesTo {
50:
51: public JiraIssue[] value();
52:
53: /**
54: * JIRA issues which have been thought to relate to certain test failures. Using this enumeration makes it easy for the IDE to
55: * show which tests relate to which issues.
56: */
57: public enum JiraIssue {
58: NONE;
59:
60: private final static Pattern PATTERN = Pattern
61: .compile("(\\p{Alpha}+)(\\p{Digit}+)");
62:
63: /**
64: * @return the JIRA issue name, which is not a legal Java identifier.
65: */
66: @Override
67: public String toString() {
68: Matcher m = PATTERN.matcher(name());
69: final boolean matched = m.matches();
70: AssertionUtils.assertThat(matched);
71: return m.group(1) + "-" + m.group(2);
72: }
73: }
74: }
|