Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: faa88e2b6ea393ebe73aaba1dfa0af2b7dc480b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*******************************************************************************
 * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * CONTRIBUTORS:
 * 		Henrik Rentz-Reichert (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.core.genmodel.fsm.tests

import org.eclipse.etrice.core.fsm.fSM.RefinedState
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
import org.junit.Before
import org.junit.Test

import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse

import static extension org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions.*
import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker
import org.eclipse.etrice.generator.base.logging.NullLogger

class TestFlatInheritedFSM extends FsmGenTestBase {
	
	GraphContainer gc
	
	@Before
	def void SetUp() {
		gc = getGraphContainer("FlatInheritedFSMExample.room", "TestActor")
		assertNotNull("graph context was created", gc)
		val logger = new NullLogger
		FsmGenChecker.check(gc, logger)
		assertFalse("logger has no errors", logger.hasErrors)
	}
	
	@Test
	def void testFlatInheritedFSMItemCounts() {
		assertEquals("number of nodes", 6, gc.graph.nodes.size)
		assertEquals("number of links", 6, gc.graph.links.size)
		assertEquals("number of states", 6, gc.graph.stateNodes.size)
		assertEquals("number of tr points", 0, gc.graph.trPointNodes.size)
		assertEquals("number of choice points", 0, gc.graph.choicePointNodes.size)
	}
	
	@Test
	def void testFlatInheritedFSMState0Connections() {
		val s = gc.graph.stateNodes.filter[name.equals("state0")].head
		assertNotNull("state found", s)
		
		assertEquals("incoming links", 1, s.incoming.size)
		assertEquals("outgoing links", 1, s.outgoing.size)
	}
	
	@Test
	def void testHierFSMPointersIntoOriginalFSM() {
		val n = gc.graph.stateNodes.filter[name.equals("state1")].head
		val s = actor.stateMachine.states.filter[name.equals("state1")].head
		
		assertNotNull("node found", n)
		assertNotNull("state found", s)
		assertTrue("RefinedState expected", n.stateGraphNode instanceof RefinedState)
		assertEquals("correct target", s, n.stateGraphNode)
	}
}

Back to the top