001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package edu.samplu.common; 017 018 import edu.samplu.admin.test.ComponentSmokeTest; 019 020 import java.util.HashMap; 021 import java.util.Iterator; 022 import java.util.Map; 023 024 /** 025 * Created as a way to link Rice Smoke Test failures to existing Jiras as a html link in Jenkins. The more failures 026 * the more useful it is to not have to keep tracking down the same Jiras. Having this feature for Integration Tests 027 * as well would be a huge help for the QA team. 028 * TODO: 029 * <ol> 030 * <li>Integration Test integration. ITs often fail by the 10s tracking down existing Jiras is a huge time sink.</li> 031 * <li>Possible Extraction of jiraMatches data to property file.</li> 032 * </ol> 033 * @author Kuali Rice Team (rice.collab@kuali.org) 034 */ 035 public class JiraAwareFailureUtil { 036 /** 037 * KULRICE-8823 Fix broken smoke tests in CI 038 */ 039 public static final String KULRICE_8823_FIX_BROKEN_SMOKE_TESTS_IN_CI = "KULRICE-8823 Fix broken smoke tests in CI"; 040 041 /** 042 * https://jira.kuali.org/browse/ 043 */ 044 public static final String JIRA_BROWSE_URL = "https://jira.kuali.org/browse/"; 045 046 static Map<String, String> jiraMatches; 047 048 static { 049 jiraMatches = new HashMap<String, String>(); 050 051 jiraMatches.put( 052 ComponentSmokeTest.CREATE_NEW_DOCUMENT_NOT_SUBMITTED_SUCCESSFULLY_MESSAGE_TEXT + ComponentSmokeTest.FOR_TEST_MESSAGE, 053 KULRICE_8823_FIX_BROKEN_SMOKE_TESTS_IN_CI); 054 055 jiraMatches.put("//*[@id='u229']", KULRICE_8823_FIX_BROKEN_SMOKE_TESTS_IN_CI); 056 057 jiraMatches.put("after clicking Expand All", "KULRICE-3833 KRAD Sampleapp (Travel) Account Inquiry Collapse all toggles all and Expand all does nothing"); 058 059 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. 060 061 jiraMatches.put("Lookupable is null", "KULRICE-10207 DemoTravelAccountMultivalueLookUpSmokeTest Lookupable is null."); 062 063 jiraMatches.put("Account Maintenance (Edit)", "KULRICE-10216 KRAD Demo Account Maintenance (Edit) Incident Report RiceRuntimeException: Exception trying to invoke action ROUTE"); 064 065 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"); 066 067 jiraMatches.put("BusinessObjectMetaDataServiceImpl.getBusinessObjectRelationship(BusinessObjectMetaDataServiceImpl.java:267)", "KULRICE-10354 Identity links throws NullPointerException"); 068 069 jiraMatches.put("//table[@id='row']/tbody/tr[1]/td[1]/a", "KULRICE-10355 Investigate DocSearchWDIT testBasicDocSearch failure"); 070 071 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"); 072 073 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"); 074 075 jiraMatches.put("Library Widget Suggest, CAT not suggested", "KULRICE-10365 Library Widget Suggest not suggesting"); 076 077 jiraMatches.put("WorkFlowRouteRulesBlanketApp expected:<[FINAL]>", "KULRICE-9051 WorkFlow Route Rules Blanket Approval submit status results in Enroute, not Final"); 078 079 jiraMatches.put("HTTP Status 404 - /kew/RouteLog.do", "KULRICE-10540 Demo Travel Account Maintenance Edit Route log inline 404"); 080 //jiraMatches.put("", ""); 081 } 082 083 /** 084 * If the contents contents the jiraMatches key, call fail on failable passing in the jiraMatches value for the matched key. 085 * @param contents to check for containing of the jiraMatches keys. 086 * @param failable to fail with the jiraMatches value if the jiraMatches key is contained in the contents 087 */ 088 public static void failOnMatchedJira(String contents, Failable failable) { 089 Iterator<String> iter = jiraMatches.keySet().iterator(); 090 String key = null; 091 092 while (iter.hasNext()) { 093 key = iter.next(); 094 if (contents.contains(key)) { 095 failable.fail(JIRA_BROWSE_URL + jiraMatches.get(key)); 096 } 097 } 098 } 099 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 }