1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.scxml;
18  
19  import junit.framework.Test;
20  import junit.framework.TestCase;
21  import junit.framework.TestSuite;
22  
23  import org.apache.commons.scxml.model.State;
24  
25  public class StatusTest extends TestCase {
26  
27      public StatusTest(String name) {
28          super(name);
29      }
30  
31      public static Test suite() {
32          TestSuite suite = new TestSuite(StatusTest.class);
33          suite.setName("TestStatus");
34          return suite;
35      }
36  
37      public static void main(String args[]) {
38          String[] testCaseName = { StatusTest.class.getName()};
39          junit.textui.TestRunner.main(testCaseName);
40      }
41  
42      private Status status;
43      
44      public void setUp() {
45          status = new Status();
46      }
47      
48      public void testIsFinalStateFalse() {
49          State state = new State();
50          state.setIsFinal(false);
51          
52          status.getStates().add(state);
53          
54          assertFalse(status.isFinal());
55      }
56      
57      public void testIsFinalStateHasParent() {
58          State state = new State();
59          state.setIsFinal(true);
60          state.setParent(new State());
61          
62          status.getStates().add(state);
63  
64          assertFalse(status.isFinal());
65      }
66      
67      public void testIsFinalStateHasEvent() {
68          State state = new State();
69          state.setIsFinal(true);
70          
71          status.getStates().add(state);
72          status.getEvents().add(new TriggerEvent("name", TriggerEvent.CALL_EVENT));
73          
74          assertFalse(status.isFinal());
75      }
76      
77      public void testIsFinalState() {
78          State state = new State();
79          state.setIsFinal(true);
80          
81          status.getStates().add(state);
82          
83          assertTrue(status.isFinal());
84      }
85      
86  }