Browse Source

Generated StatechartActive test cases for java generator.

Axel Terfloth 10 years ago
parent
commit
4cb8061df8

+ 24 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/model.sgen

@@ -1158,6 +1158,30 @@ GeneratorModel for yakindu::java {
 		}
 	}	
 	
+	statechart StatechartActive {
+		feature Outlet {
+			targetProject = "org.yakindu.sct.generator.java.test"
+			targetFolder = "src-gen"
+		}
+
+		feature GeneralFeatures {
+			TimerService = true
+			RuntimeService = true
+		}		
+			
+		feature FunctionInlining {
+			inlineReactions = false
+			inlineEntryActions = false
+			inlineExitActions = false
+			inlineEnterSequences = false
+			inlineExitSequences = false
+			inlineChoices = false
+			inlineEnterRegion = false
+			inlineExitRegion = false
+			inlineEntries = false
+		}
+	}
+	
 	statechart StateIsActive {
 		feature Outlet {
 			targetProject = "org.yakindu.sct.generator.java.test"

+ 8 - 0
test-plugins/org.yakindu.sct.generator.java.test/model/test.sgen

@@ -363,6 +363,14 @@ GeneratorModel for sctunit::java {
 		}			
 	}
 	
+	test StatechartActive {
+		
+		feature Outlet{ 
+			targetProject = "org.yakindu.sct.generator.java.test" 
+			targetFolder = "test-gen"			
+		}			
+	}
+	
 	test StateIsActive{
 		
 		feature Outlet{ 

+ 5 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/statechartactive/IStatechartActiveStatemachine.java

@@ -0,0 +1,5 @@
+package org.yakindu.scr.statechartactive;
+import org.yakindu.scr.IStatemachine;
+
+public interface IStatechartActiveStatemachine extends IStatemachine {
+}

+ 148 - 0
test-plugins/org.yakindu.sct.generator.java.test/src-gen/org/yakindu/scr/statechartactive/StatechartActiveStatemachine.java

@@ -0,0 +1,148 @@
+package org.yakindu.scr.statechartactive;
+
+public class StatechartActiveStatemachine
+		implements
+			IStatechartActiveStatemachine {
+
+	public enum State {
+		r_A, $NullState$
+	};
+
+	private final State[] stateVector = new State[1];
+
+	private int nextStateIndex;
+
+	public StatechartActiveStatemachine() {
+
+	}
+
+	public void init() {
+		for (int i = 0; i < 1; i++) {
+			stateVector[i] = State.$NullState$;
+		}
+
+		clearEvents();
+		clearOutEvents();
+
+	}
+
+	public void enter() {
+		entryAction();
+
+		enterSequence_r_default();
+	}
+
+	public void exit() {
+		exitSequence_r();
+
+		exitAction();
+	}
+
+	/**
+	 * @see IStatemachine#isActive()
+	 */
+	@Override
+	public boolean isActive() {
+
+		return stateVector[0] != State.$NullState$;
+	}
+
+	/** 
+	 * Always returns 'false' since this state machine can never become final.
+	 *
+	 * @see IStatemachine#isFinal() 
+	 */
+	@Override
+	public boolean isFinal() {
+		return false;
+	}
+
+	/**
+	 * This method resets the incoming events (time events included).
+	 */
+	protected void clearEvents() {
+
+	}
+
+	/**
+	 * This method resets the outgoing events.
+	 */
+	protected void clearOutEvents() {
+	}
+
+	/**
+	 * Returns true if the given state is currently active otherwise false.
+	 */
+	public boolean isStateActive(State state) {
+		switch (state) {
+			case r_A :
+				return stateVector[0] == State.r_A;
+			default :
+				return false;
+		}
+	}
+
+	/* Entry action for statechart 'StatechartActive'. */
+	private void entryAction() {
+	}
+
+	/* Exit action for state 'StatechartActive'. */
+	private void exitAction() {
+	}
+
+	/* 'default' enter sequence for state A */
+	private void enterSequence_r_A_default() {
+		nextStateIndex = 0;
+		stateVector[0] = State.r_A;
+	}
+
+	/* 'default' enter sequence for region r */
+	private void enterSequence_r_default() {
+		react_r__entry_Default();
+	}
+
+	/* Default exit sequence for state A */
+	private void exitSequence_r_A() {
+		nextStateIndex = 0;
+		stateVector[0] = State.$NullState$;
+	}
+
+	/* Default exit sequence for region r */
+	private void exitSequence_r() {
+		switch (stateVector[0]) {
+			case r_A :
+				exitSequence_r_A();
+				break;
+
+			default :
+				break;
+		}
+	}
+
+	/* The reactions of state A. */
+	private void react_r_A() {
+	}
+
+	/* Default react sequence for initial entry  */
+	private void react_r__entry_Default() {
+		enterSequence_r_A_default();
+	}
+
+	public void runCycle() {
+
+		clearOutEvents();
+
+		for (nextStateIndex = 0; nextStateIndex < stateVector.length; nextStateIndex++) {
+
+			switch (stateVector[nextStateIndex]) {
+				case r_A :
+					react_r_A();
+					break;
+				default :
+					// $NullState$
+			}
+		}
+
+		clearEvents();
+	}
+}

+ 4 - 4
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/AllTestsTest.java

@@ -32,10 +32,10 @@ import org.junit.runners.Suite.SuiteClasses;
 		ParenthesisTest.class, PriorityValuesTest.class, RaiseEventTest.class,
 		SameNameDifferentRegionTest.class, ShallowHistoryTest.class,
 		ShallowHistoryWithDeepEntryTest.class, SimpleEventTest.class,
-		StatechartLocalReactionsTest.class, SimpleHierachyTest.class,
-		StateIsActiveTest.class, StaticChoiceTest.class,
-		STextKeywordsInStatesAndRegionsTest.class, StringExpressionsTest.class,
-		SyncForkTest.class, SyncJoinTest.class,
+		SimpleHierachyTest.class, StatechartActiveTest.class,
+		StatechartLocalReactionsTest.class, StateIsActiveTest.class,
+		StaticChoiceTest.class, STextKeywordsInStatesAndRegionsTest.class,
+		StringExpressionsTest.class, SyncForkTest.class, SyncJoinTest.class,
 		TransitionWithoutConditionTest.class,
 		TriggerGuardExpressionsTest.class, ValuedEventsTest.class})
 public class AllTestsTest {

+ 61 - 0
test-plugins/org.yakindu.sct.generator.java.test/test-gen/org/yakindu/sct/generator/java/test/StatechartActiveTest.java

@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2015 committers of YAKINDU and others.
+ * 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:
+ *     committers of YAKINDU - initial API and implementation
+ */
+
+package org.yakindu.sct.generator.java.test;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.yakindu.scr.statechartactive.StatechartActiveStatemachine;
+import org.yakindu.scr.statechartactive.StatechartActiveStatemachine.State;
+/**
+ *  Unit TestCase for StatechartActive
+ */
+@SuppressWarnings("all")
+public class StatechartActiveTest {
+
+	private StatechartActiveStatemachine statemachine;
+
+	@Before
+	public void setUp() {
+		statemachine = new StatechartActiveStatemachine();
+		statemachine.init();
+	}
+
+	@After
+	public void tearDown() {
+		statemachine = null;
+	}
+
+	@Test
+	public void testinactiveBeforeEnter() {
+		assertTrue(false);
+	}
+	@Test
+	public void testactiveAfterEnter() {
+		statemachine.enter();
+		assertTrue(false);
+	}
+	@Test
+	public void testinactiveAfterExit() {
+		statemachine.enter();
+		statemachine.exit();
+		assertTrue(false);
+	}
+	@Test
+	public void testactiveAfterReenter() {
+		statemachine.enter();
+		statemachine.exit();
+		statemachine.enter();
+		assertTrue(false);
+	}
+}