1   /*
2    * Copyright 2006 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.commons.scxml.model;
17  
18  import junit.framework.Test;
19  import junit.framework.TestCase;
20  import junit.framework.TestSuite;
21  
22  public class TransitionTest extends TestCase {
23  
24      public TransitionTest(String testName) {
25          super(testName);
26      }
27  
28      public static Test suite() {
29          return new TestSuite(TransitionTest.class);
30      }
31  
32      public static void main(String args[]) {
33          String[] testCaseName = { TransitionTest.class.getName()};
34          junit.textui.TestRunner.main(testCaseName);
35      }
36      
37      private Transition transition;
38      
39      public void setUp() {
40          transition = new Transition();
41      }
42      
43      public void testGetRuntimeTargetNullNoParent() {
44          transition.setTarget(null);
45          
46          assertNull(transition.getRuntimeTarget());
47      }
48      
49      public void testGetRuntimeTargetNullWithParent() {
50          State state = new State();
51          state.setId("1");
52          
53          transition.setTarget(null);
54          transition.setParent(state);
55          
56          assertEquals("1", transition.getRuntimeTarget().getId());
57      }
58      
59      public void testGetRuntimeTarget() {
60          State state = new State();
61          state.setId("2");
62          
63          transition.setTarget(state);
64          
65          assertEquals("2", transition.getRuntimeTarget().getId());
66      }
67      
68      public void testGetPath() {
69          assertNotNull(transition.getPath());
70      }
71  }