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 .
21 import java
.util
.HashMap
;
24 * The class supports interface tests development and Status calculation.
26 public class TestResult
{
28 * Contains methods having been tested and their results.
30 private HashMap
<String
, Status
> testedMethods
= new HashMap
<String
, Status
>();
33 * The method makes method tested with the result, i.e. it adds to its
34 * state OK (if result == true) or FAILED (if result == false) status
35 * and makes the state of the method completed. It's equal to
36 * tested(method, Status(result)) call.
38 * @param method refers to the method which was tested
39 * @param result the result of testing the method
41 * @return the result value
43 * @throw java.lang.IllegalArgumentException if the method is not
44 * available in the interface.
46 * @see #tested(String, Status)
48 public boolean tested( String method
, boolean result
) {
49 System
.out
.println("Method "+method
+" finished with state "+(result?
"OK":"FAILED"));
50 return tested( method
, Status
.passed( result
) );
54 * The method makes the method tested with the status, i.e. it adds the
55 * status to its state and makes it completed.
57 * @param method refers to the method which was tested
58 * @param status describes the result of testing the method
59 * @return <tt>true</tt> if status is OK, <tt>false</tt> otherwise.
61 * @throw java.lang.IllegalArgumentException if the method is not
62 * available in the interface.
64 public boolean tested( String method
, Status status
) {
65 testedMethods
.put(method
,status
);
70 * @return <tt>true</tt> if the method belongs to the interface tested,
71 * <tt>false</tt> otherwise.
73 public boolean hasMethod( String method
) {
74 return testedMethods
.containsKey( method
);
78 * @return status of testing the method, if it is available (was set by
79 * the tested or assert method), <tt>null</tt> otherwise.
81 * @see #tested(String, boolean)
82 * @see #tested(String, Status)
84 public Status
getStatusFor( String method
) {
85 return testedMethods
.get( method
);