View Javadoc

1   /**
2    * Copyright 2005-2013 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 edu.samplu.common;
17  
18  import edu.samplu.admin.test.ComponentSmokeTest;
19  
20  import java.util.HashMap;
21  import java.util.Iterator;
22  import java.util.Map;
23  
24  /**
25   * Created as a way to link Rice Smoke Test failures to existing Jiras as a html link in Jenkins.  The more failures
26   * the more useful it is to not have to keep tracking down the same Jiras.  Having this feature for Integration Tests
27   * as well would be a huge help for the QA team.
28   * TODO:
29   * <ol>
30   *   <li>Integration Test integration.  ITs often fail by the 10s tracking down existing Jiras is a huge time sink.</li>
31   *   <li>Possible Extraction of jiraMatches data to property file.</li>
32   * </ol>
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  public class JiraAwareFailureUtil {
36      /**
37       * KULRICE-8823 Fix broken smoke tests in CI
38       */
39      public static final String KULRICE_8823_FIX_BROKEN_SMOKE_TESTS_IN_CI = "KULRICE-8823 Fix broken smoke tests in CI";
40  
41      /**
42       * https://jira.kuali.org/browse/
43       */
44      public static final String JIRA_BROWSE_URL = "https://jira.kuali.org/browse/";
45  
46      static Map<String, String> jiraMatches;
47  
48      static {
49          jiraMatches = new HashMap<String, String>();
50  
51          jiraMatches.put(
52                  ComponentSmokeTest.CREATE_NEW_DOCUMENT_NOT_SUBMITTED_SUCCESSFULLY_MESSAGE_TEXT + ComponentSmokeTest.FOR_TEST_MESSAGE,
53                  KULRICE_8823_FIX_BROKEN_SMOKE_TESTS_IN_CI);
54  
55          jiraMatches.put("//*[@id='u229']", KULRICE_8823_FIX_BROKEN_SMOKE_TESTS_IN_CI);
56  
57          jiraMatches.put("after clicking Expand All", "KULRICE-3833 KRAD Sampleapp (Travel) Account Inquiry Collapse all toggles all and Expand all does nothing");
58  
59          jiraMatches.put("Library Widget Suggest, CAT not suggested", "KULRICE-10365 Library Widget Suggest not suggesting"); // already in 2.4 merged back as error exists in 2.3 as well.
60  
61          jiraMatches.put("Lookupable is null", "KULRICE-10207 DemoTravelAccountMultivalueLookUpSmokeTest Lookupable is null.");
62  
63          jiraMatches.put("Account Maintenance (Edit)", "KULRICE-10216 KRAD Demo Account Maintenance (Edit) Incident Report RiceRuntimeException: Exception trying to invoke action ROUTE");
64  
65          jiraMatches.put("An exception occurred processing JSP page /kr/WEB-INF/jsp/KualiMaintenanceDocument.jsp", "KULRICE-10235 JasperException: An exception occurred processing JSP page /kr/WEB-INF/jsp/KualiMaintenanceDocument.jsp");
66  
67          jiraMatches.put("BusinessObjectMetaDataServiceImpl.getBusinessObjectRelationship(BusinessObjectMetaDataServiceImpl.java:267)", "KULRICE-10354 Identity links throws NullPointerException");
68  
69          jiraMatches.put("//table[@id='row']/tbody/tr[1]/td[1]/a", "KULRICE-10355 Investigate DocSearchWDIT testBasicDocSearch failure");
70  
71          jiraMatches.put("BusinessObjectDaoProxy called with non-legacy class: class org.kuali.rice.coreservice.impl.namespace.NamespaceBo", "KULRICE-10356 Agenda edit BusinessObjectDaoProxy called with non-legacy class: class org.kuali.rice.coreservice.impl.namespace.NamespaceBo");
72  
73          jiraMatches.put("annot get new instance of class to check for KualiCode", "KULRICE-10358 Component search Action List Incident Report Cannot get new instance of class to check for KualiCode");
74  
75          jiraMatches.put("Library Widget Suggest, CAT not suggested", "KULRICE-10365 Library Widget Suggest not suggesting");
76  
77          jiraMatches.put("WorkFlowRouteRulesBlanketApp expected:<[FINAL]>", "KULRICE-9051 WorkFlow Route Rules Blanket Approval submit status results in Enroute, not Final");
78  
79          jiraMatches.put("HTTP Status 404 - /kew/RouteLog.do", "KULRICE-10540 Demo Travel Account Maintenance Edit Route log inline 404");
80          //jiraMatches.put("", "");
81      }
82  
83      /**
84       * If the contents contents the jiraMatches key, call fail on failable passing in the jiraMatches value for the matched key.
85       * @param contents to check for containing of the jiraMatches keys.
86       * @param failable to fail with the jiraMatches value if the jiraMatches key is contained in the contents
87       */
88      public static void failOnMatchedJira(String contents, Failable failable) {
89          Iterator<String> iter = jiraMatches.keySet().iterator();
90          String key = null;
91  
92          while (iter.hasNext()) {
93              key = iter.next();
94              if (contents.contains(key)) {
95                  failable.fail(JIRA_BROWSE_URL + jiraMatches.get(key));
96              }
97          }
98      }
99  
100     /**
101      * Calls failOnMatchedJira with the contents and if no match is detected then the message.
102      * @param contents to check for containing of the jiraMatches keys.
103      * @param message to check for containing of the jiraMatches keys if contents doesn't
104      * @param failable to fail with the jiraMatches value if the contents or message is detected
105      */
106     public static void failOnMatchedJira(String contents, String message, Failable failable) {
107         failOnMatchedJira(contents, failable);
108         failOnMatchedJira(message, failable);
109     }
110 }