merged tag ooo/DEV300_m102
[LibreOffice.git] / qadevOOo / runner / lib / Status.java
blob7cd65c380425a871ba71487a688a0932953e7b0a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 package lib;
30 /**
31 * Status represents a result of a testing activity performed. The result is
32 * described in two ways: state and runtime state. The state describes if the
33 * activity was successful (OK state) or not (FAILED state). The runtime state
34 * describes what happend during the activity: the test can be:
35 * - PASSED - the activity completed normally (although it can complete with
36 * FAILED state)
37 * - SKIPPED - the activity was not performed because of a reason (it also can
38 * has OK or FAILED state)
39 * - EXCEPTION - the activity was abnormally terminated because of an
40 * unexpected exception. It always has a FAILED state.
41 * - EXCLUDED - the activity is expected to fail. The state represents how
42 * the state really completed: OK or FAILED.
43 * - other variants are not formalized now and can be represented by
44 * Status.failed() method. They always have a FAILED state.
46 public class Status extends SimpleStatus {
48 /**
49 * Construct a status: use runState and state
50 * @param runState: either PASSED, SKIPPED, etc.
51 * @param state: OK or FAILED.
53 public Status(int runState, boolean state ) {
54 super(runState, state);
57 /**
58 * Construct a status: use own message and state.
59 * @parame messaeg An own message for the status.
60 * @param state: OK or FAILED.
62 public Status(String message, boolean state) {
63 super( message, state );
66 /**
67 * This is a factory method for creating a Status representing normal
68 * actibity termination.
70 * @param state describes a test state (OK if state == true, FAILED
71 * otherwise).
73 public static Status passed( boolean state ) {
74 return new Status(PASSED, state );
77 /**
78 * This is a factory method for creating a Status representing an exception
79 * activity termination. The Status alway has FAILED state.
81 * @param t the exception with that the activity completed.
83 public static Status exception( Throwable t ) {
84 return new ExceptionStatus( t );
87 /**
88 * This is a factory method for creating a Status representing a skipped
89 * activity.
91 * @param state describes a test state (OK if state == true, FAILED
92 * otherwise).
94 public static Status skipped( boolean state ) {
95 return new Status( SKIPPED, state );
98 /**
99 * This is a factory method for creating a Status representing that the
100 * result of the activity was excluded. It alwas has FAILED state.
102 public static Status excluded() {
103 return new Status( EXCLUDED, false );
107 * Creates a Status representing an activity failed for an arbitrary reason.
108 * It always has FAILED state.
110 * @param reason describes why the activity failed
112 public static Status failed(final String reason) {
113 return new Status(reason, FAILED);
117 * The method returns a human-readable description of the status.
118 * The Status implementation of the method returns the status state
119 * description and appends to it it the reason, for example:
120 * "FAILED.The getLabel works wrong", "PASSED.OK".
122 public String toString() {
123 String str = getRunStateString() + "." + getStateString();;
125 return str;
129 * Checks whether the status runstate is passed.
131 public boolean isPassed() {
132 return getRunState() == PASSED;
136 * Checks whether the status runstate is skipped.
138 public boolean isSkipped() {
139 return getRunState() == SKIPPED;
143 * Checks whether the status runstate is excluded.
145 public boolean isExcluded() {
146 return getRunState() == EXCLUDED;
150 * Checks whether the status runstate is exception.
152 public boolean isException() {
153 return getRunState() == EXCEPTION;
157 * Checks whether the status state is failed.
159 public boolean isFailed() {
160 return !getState();
164 * Checks whether the status state is ok.
166 public boolean isOK() {
167 return getState();
170 public String getDescription () {
171 return getRunStateString();