001    /******************************************************************************
002     * Copyright (C) MActor Developers. 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     ******************************************************************************/
020    package org.mactor.framework;
021    
022    import java.util.Calendar;
023    
024    import org.mactor.framework.spec.SpecNode;
025    import org.mactor.framework.spec.TestSpec;
026    
027    public class TestEvent {
028            public enum EventType {
029                    Start, End
030            };
031            private EventType eventType;
032            private String outputText;
033            private SpecNode node;
034            private boolean successful = true;
035            private int dataId;
036            private MactorException cause;
037            private Calendar time = Calendar.getInstance();
038            private String testInstanceId;
039            private String testRunInstanceId;
040            private TestSpec testSpec;
041            public TestEvent(String testRunInstanceId, String testInstanceId, EventType eventType, TestSpec testSpec, SpecNode node, int dataId, String outputText, boolean successful, MactorException cause) {
042                    this.testRunInstanceId = testRunInstanceId;
043                    this.testInstanceId = testInstanceId;
044                    this.eventType = eventType;
045                    this.outputText = outputText;
046                    this.testSpec = testSpec;
047                    this.node = node;
048                    this.successful = successful;
049                    this.dataId = dataId;
050                    this.cause = cause;
051            }
052            public Calendar getTime() {
053                    return time;
054            }
055            public int getDataId() {
056                    return dataId;
057            }
058            public EventType getEventType() {
059                    return eventType;
060            }
061            public boolean isStartEventType() {
062                    return EventType.Start.equals(eventType);
063            }
064            public SpecNode getNode() {
065                    return node;
066            }
067            public String getOutputText() {
068                    return outputText;
069            }
070            public boolean isSuccessful() {
071                    return successful;
072            }
073            public boolean isSuccessfulTestCompleteEvent() {
074                    return isSuccessful() && isTestCompleteEvent();
075            }
076            public boolean isFaultTestCompleteEvent() {
077                    return !isSuccessful() && isTestCompleteEvent();
078            }
079            public boolean isTestCompleteEvent() {
080                    return (node instanceof TestSpec) && EventType.End.equals(eventType);
081            }
082            public MactorException getCause() {
083                    return cause;
084            }
085            public String getTestRunInstanceId() {
086                    return testRunInstanceId;
087            }
088            public void setTestRunInstanceId(String testRunInstanceId) {
089                    this.testRunInstanceId = testRunInstanceId;
090            }
091            public TestSpec getTestSpec() {
092                    return testSpec;
093            }
094            public String getTestInstanceId() {
095                    return testInstanceId;
096            }
097    }