tdf#160371: sc_subsequent_filters_test2: Add unittest
[LibreOffice.git] / qadevOOo / runner / lib / Status.java
blobae7f97ecfdfc7ca73e3d7794e8c91161d474de7e
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 * - COMPLETED - 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 COMPLETED, SKIPPED, etc.
42 * @param bSuccessful OK or FAILED.
44 public Status(RunState runState, boolean bSuccessful ) {
45 super(runState, bSuccessful);
48 /**
49 * Construct a status: use own message and state.
50 * @param message An own message for the status.
51 * @param bSuccessful 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 * activity termination.
61 * @param bSuccessful describes a test state (OK if state == true, FAILED
62 * otherwise).
64 public static Status passed( boolean bSuccessful ) {
65 return new Status(RunState.COMPLETED, bSuccessful );
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 bSuccessful ) {
86 return new Status( RunState.SKIPPED, bSuccessful );
91 /**
92 * Creates a Status representing an activity failed for an arbitrary reason.
93 * It always has FAILED state.
95 * @param reason describes why the activity failed
97 public static Status failed(final String reason) {
98 return new Status(reason, false/*bSuccessful*/);
102 * The method returns a human-readable description of the status.
103 * The Status implementation of the method returns the status state
104 * description and appends to it the reason, for example:
105 * "FAILED.The getLabel works wrong", "COMPLETED.OK".
107 @Override
108 public String toString() {
109 String str = getRunStateString() + "." + getStateString();
111 return str;
115 * Checks whether the status runstate is completed.
117 public boolean isCompleted() {
118 return getRunState() == RunState.COMPLETED;
122 * Checks whether the status state is failed.
124 public boolean isFailed() {
125 return !isSuccessful();