1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package stats; 24 25 import java.util.Vector; 26 import share.DescEntry; 27 28 /** 29 * 30 * this class summs up the results of the subentries of a given DescEntry<br> 31 * and fills the subentries in cases of SKIPPED states 32 */ 33 public class Summarizer 34 { 35 36 /** 37 * 38 * gets the state for a SuperEntry according to its subentries 39 * @param entry 40 */ summarizeUp(DescEntry entry)41 public void summarizeUp(DescEntry entry) 42 { 43 if ((entry.State != null) && !entry.State.equals("UNKNOWN")) 44 { 45 return; 46 } 47 int count = entry.SubEntryCount; 48 int knownIssues = 0; 49 Vector failures = new Vector(); 50 Vector states = new Vector(); 51 for (int i = 0; i < count; i++) 52 { 53 if (entry.SubEntries[i].State == null) 54 { 55 entry.SubEntries[i].State = "PASSED.FAILED"; 56 } 57 if (entry.SubEntries[i].State.equals("known issue")) 58 { 59 entry.SubEntries[i].State = "PASSED.OK"; 60 knownIssues++; 61 } 62 if (!entry.SubEntries[i].State.endsWith("OK")) 63 { 64 String sFailure = "[" + entry.SubEntries[i].longName + "]" + " is testcode: [" + entry.SubEntries[i].entryName + "]"; 65 failures.add(sFailure); 66 states.add(entry.SubEntries[i].State); 67 } 68 } 69 if (failures.size() > 0) 70 { 71 String errMsg = ""; 72 String state = "PASSED.FAILED"; 73 for (int j = 0; j < failures.size(); j++) 74 { 75 if (states.elementAt(j).equals("not part of the job")) 76 { 77 state = "PASSED(some interfaces/services not tested).OK"; 78 } 79 else 80 { 81 errMsg += 82 failures.elementAt(j) + " - " + states.elementAt(j) + "\r\n"; 83 } 84 } 85 entry.hasErrorMsg = true; 86 entry.ErrorMsg = errMsg; 87 entry.State = state; 88 } 89 else if (entry.EntryType.equals("component") && knownIssues > 0) 90 { 91 entry.State = "PASSED(with known issues).OK"; 92 } 93 else 94 { 95 entry.State = "PASSED.OK"; 96 } 97 } 98 summarizeDown(DescEntry entry, String state)99 public static void summarizeDown(DescEntry entry, String state) 100 { 101 if ((entry.State == null) || entry.State.equals("UNKNOWN")) 102 { 103 entry.State = state; 104 } 105 for (int i = 0; i < entry.SubEntryCount; i++) 106 { 107 summarizeDown(entry.SubEntries[i], entry.State); 108 } 109 } 110 } 111