View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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.rice.testtools.common;
17  
18  import org.junit.Assert;
19  import org.junit.Test;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public class JiraAwareFailureUtilsTest implements JiraAwareFailable {
25  
26      String message;
27  
28      @Test
29      public void testJiraAwareFailureRegex() {
30          JiraAwareFailureUtils.regexJiraMatches.put("TEST.*UNIQUE.*TEST", "KULRICE-TEST");
31          JiraAwareFailureUtils.failOnMatchedJira("TEST UNIQUE data for TEST", this);
32          Assert.assertTrue(message.contains("KULRICE-TEST"));
33      }
34  
35      @Test
36      public void testJiraAwareFailureContains() {
37          JiraAwareFailureUtils.jiraMatches.put("TEST\u0020UNIQUE\u0020TEST", "KULRICE-TEST2");
38          JiraAwareFailureUtils.failOnMatchedJira("TEST UNIQUE TEST", this);
39          Assert.assertTrue(message.contains("KULRICE-TEST2"));
40      }
41  
42      @Override
43      public void fail(String message) {
44          this.message = message;
45      }
46  
47      @Override
48      public void jiraAwareFail(String message) {
49          this.message = message;
50      }
51  
52      @Override
53      public void jiraAwareFail(String contents, String message) {
54          this.message = message;
55      }
56  
57      @Override
58      public void jiraAwareFail(String contents, String message, Throwable throwable) {
59          this.message = message;
60      }
61  }