001: /******************************************************************************
002: * Copyright (C) Lars Ivar Almli. All rights reserved. *
003: * ---------------------------------------------------------------------------*
004: * This file is part of MActor. *
005: * *
006: * MActor is free software; you can redistribute it and/or modify *
007: * it under the terms of the GNU General Public License as published by *
008: * the Free Software Foundation; either version 2 of the License, or *
009: * (at your option) any later version. *
010: * *
011: * MActor is distributed in the hope that it will be useful, *
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
014: * GNU General Public License for more details. *
015: * *
016: * You should have received a copy of the GNU General Public License *
017: * along with MActor; if not, write to the Free Software *
018: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
019: ******************************************************************************/package org.mactor.framework;
020:
021: import java.util.Calendar;
022: import org.mactor.framework.spec.SpecNode;
023: import org.mactor.framework.spec.TestSpec;
024:
025: public class TestEvent {
026: public enum EventType {
027: Start, End
028: };
029:
030: private EventType eventType;
031: private String outputText;
032: private SpecNode node;
033: private boolean successful = true;
034: private int dataIndex;
035: private MactorException cause;
036:
037: private Calendar time = Calendar.getInstance();
038:
039: public Calendar getTime() {
040: return time;
041: }
042:
043: public TestEvent(EventType eventType, SpecNode node, int dataIndex,
044: String outputText, boolean successful, MactorException cause) {
045: this .eventType = eventType;
046: this .outputText = outputText;
047: this .node = node;
048: this .successful = successful;
049: this .dataIndex = dataIndex;
050: this .cause = cause;
051:
052: }
053:
054: public TestEvent(EventType eventType, SpecNode node, int dataIndex,
055: String outputText, boolean successful) {
056: this (eventType, node, dataIndex, outputText, successful, null);
057: }
058:
059: public TestEvent(EventType eventType, SpecNode node, int dataIndex) {
060: this (eventType, node, dataIndex, null, true, null);
061: }
062:
063: public int getDataIndex() {
064: return dataIndex;
065: }
066:
067: public EventType getEventType() {
068: return eventType;
069: }
070:
071: public boolean isStartEventType() {
072: return EventType.Start.equals(eventType);
073: }
074:
075: public SpecNode getNode() {
076: return node;
077: }
078:
079: public String getOutputText() {
080: return outputText;
081: }
082:
083: public boolean isSuccessful() {
084: return successful;
085: }
086:
087: public boolean isSuccessfulTestCompleteEvent() {
088: return isSuccessful() && isTestCompleteEvent();
089: }
090:
091: public boolean isFaultTestCompleteEvent() {
092: return !isSuccessful() && isTestCompleteEvent();
093: }
094:
095: public boolean isTestCompleteEvent() {
096: return (node instanceof TestSpec)
097: && EventType.End.equals(eventType);
098: }
099:
100: public MactorException getCause() {
101: return cause;
102: }
103:
104: }
|