bump product version to 4.1.6.2
[LibreOffice.git] / qadevOOo / runner / lib / Status.java
blob0dc6f9e8bd6469b117dc1380e0f4140c7a01d9ef
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package lib;
21 /**
22 * Status represents a result of a testing activity performed. The result is
23 * described in two ways: state and runtime state. The state describes if the
24 * activity was successful (OK state) or not (FAILED state). The runtime state
25 * describes what happened during the activity: the test can be:
26 * - PASSED - the activity completed normally (although it can complete with
27 * FAILED state)
28 * - SKIPPED - the activity was not performed because of a reason (it also can
29 * has OK or FAILED state)
30 * - EXCEPTION - the activity was abnormally terminated because of an
31 * unexpected exception. It always has a FAILED state.
32 * - EXCLUDED - the activity is expected to fail. The state represents how
33 * the state really completed: OK or FAILED.
34 * - other variants are not formalized now and can be represented by
35 * Status.failed() method. They always have a FAILED state.
37 public class Status extends SimpleStatus {
39 /**
40 * Construct a status: use runState and state
41 * @param runState either PASSED, SKIPPED, etc.
42 * @param state OK or FAILED.
44 public Status(int runState, boolean state ) {
45 super(runState, state);
48 /**
49 * Construct a status: use own message and state.
50 * @param message An own message for the status.
51 * @param state OK or FAILED.
53 public Status(String message, boolean state) {
54 super( message, state );
57 /**
58 * This is a factory method for creating a Status representing normal
59 * actibity termination.
61 * @param state describes a test state (OK if state == true, FAILED
62 * otherwise).
64 public static Status passed( boolean state ) {
65 return new Status(PASSED, state );
68 /**
69 * This is a factory method for creating a Status representing an exception
70 * activity termination. The Status always has FAILED state.
72 * @param t the exception with that the activity completed.
74 public static Status exception( Throwable t ) {
75 return new ExceptionStatus( t );
78 /**
79 * This is a factory method for creating a Status representing a skipped
80 * activity.
82 * @param state describes a test state (OK if state == true, FAILED
83 * otherwise).
85 public static Status skipped( boolean state ) {
86 return new Status( SKIPPED, state );
89 /**
90 * This is a factory method for creating a Status representing that the
91 * result of the activity was excluded. It alwas has FAILED state.
93 public static Status excluded() {
94 return new Status( EXCLUDED, false );
97 /**
98 * Creates a Status representing an activity failed for an arbitrary reason.
99 * It always has FAILED state.
101 * @param reason describes why the activity failed
103 public static Status failed(final String reason) {
104 return new Status(reason, FAILED);
108 * The method returns a human-readable description of the status.
109 * The Status implementation of the method returns the status state
110 * description and appends to it it the reason, for example:
111 * "FAILED.The getLabel works wrong", "PASSED.OK".
113 public String toString() {
114 String str = getRunStateString() + "." + getStateString();
116 return str;
120 * Checks whether the status runstate is passed.
122 public boolean isPassed() {
123 return getRunState() == PASSED;
127 * Checks whether the status runstate is skipped.
129 public boolean isSkipped() {
130 return getRunState() == SKIPPED;
134 * Checks whether the status runstate is excluded.
136 public boolean isExcluded() {
137 return getRunState() == EXCLUDED;
141 * Checks whether the status runstate is exception.
143 public boolean isException() {
144 return getRunState() == EXCEPTION;
148 * Checks whether the status state is failed.
150 public boolean isFailed() {
151 return !getState();
155 * Checks whether the status state is ok.
157 public boolean isOK() {
158 return getState();
161 public String getDescription () {
162 return getRunStateString();