1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 package stats; 28 29 import java.util.Vector; 30 import share.DescEntry; 31 32 /** 33 * 34 * this class summs up the results of the subentries of a given DescEntry<br> 35 * and fills the subentries in cases of SKIPPED states 36 */ 37 public class Summarizer 38 { 39 40 /** 41 * 42 * gets the state for a SuperEntry according to its subentries 43 * @param entry 44 */ 45 public void summarizeUp(DescEntry entry) 46 { 47 if ((entry.State != null) && !entry.State.equals("UNKNOWN")) 48 { 49 return; 50 } 51 int count = entry.SubEntryCount; 52 int knownIssues = 0; 53 Vector failures = new Vector(); 54 Vector states = new Vector(); 55 for (int i = 0; i < count; i++) 56 { 57 if (entry.SubEntries[i].State == null) 58 { 59 entry.SubEntries[i].State = "PASSED.FAILED"; 60 } 61 if (entry.SubEntries[i].State.equals("known issue")) 62 { 63 entry.SubEntries[i].State = "PASSED.OK"; 64 knownIssues++; 65 } 66 if (!entry.SubEntries[i].State.endsWith("OK")) 67 { 68 String sFailure = "[" + entry.SubEntries[i].longName + "]" + " is testcode: [" + entry.SubEntries[i].entryName + "]"; 69 failures.add(sFailure); 70 states.add(entry.SubEntries[i].State); 71 } 72 } 73 if (failures.size() > 0) 74 { 75 String errMsg = ""; 76 String state = "PASSED.FAILED"; 77 for (int j = 0; j < failures.size(); j++) 78 { 79 if (states.elementAt(j).equals("not part of the job")) 80 { 81 state = "PASSED(some interfaces/services not tested).OK"; 82 } 83 else 84 { 85 errMsg += 86 failures.elementAt(j) + " - " + states.elementAt(j) + "\r\n"; 87 } 88 } 89 entry.hasErrorMsg = true; 90 entry.ErrorMsg = errMsg; 91 entry.State = state; 92 } 93 else if (entry.EntryType.equals("component") && knownIssues > 0) 94 { 95 entry.State = "PASSED(with known issues).OK"; 96 } 97 else 98 { 99 entry.State = "PASSED.OK"; 100 } 101 } 102 103 public static void summarizeDown(DescEntry entry, String state) 104 { 105 if ((entry.State == null) || entry.State.equals("UNKNOWN")) 106 { 107 entry.State = state; 108 } 109 for (int i = 0; i < entry.SubEntryCount; i++) 110 { 111 summarizeDown(entry.SubEntries[i], entry.State); 112 } 113 } 114 } 115