package org.eclipse.incquery.examples.cps.m2t.proto.distributed.tests;

import static org.junit.Assert.assertTrue;

import org.eclipse.incquery.examples.cps.m2t.proto.distributed.general.HostRunner;
import org.eclipse.incquery.examples.cps.m2t.proto.distributed.general.applications.Application;
import org.eclipse.incquery.examples.cps.m2t.proto.distributed.general.communicationlayer.CommunicationNetwork;
import org.eclipse.incquery.examples.cps.m2t.proto.distributed.generated.hosts.Host152661025;
import org.eclipse.incquery.examples.cps.m2t.proto.distributed.generated.hosts.Host152661026;
import org.eclipse.incquery.examples.cps.m2t.proto.distributed.generated.hosts.statemachines.BehaviorCameraB;
import org.eclipse.incquery.examples.cps.tests.CPSTestBase;
import org.junit.Test;

import com.google.common.collect.Iterables;

public class IntegrationTest extends CPSTestBase {
	
	@Test
	public void sendTriggerTest(){
		
		CommunicationNetwork network = new CommunicationNetwork();
		
		// Create Hosts
		Host152661025 hostStorage = new Host152661025(network);
		Host152661026 hostSenders = new Host152661026(network);
		
		// Create HostRunners
		HostRunner hostRunnerStorage = new HostRunner(hostStorage);
		HostRunner hostRunnerSenders = new HostRunner(hostSenders);
		
		// Add hosts to network
		network.addHost("152.66.102.5", hostRunnerStorage);
		network.addHost("152.66.102.6", hostRunnerSenders);
		
		assertTrue(Iterables.isEmpty(hostStorage.calculatePossibleNextStates()));
		
		Application appCamera = hostSenders.getApplications().iterator().next();
		appCamera.stepToState(BehaviorCameraB.CSent);
		
		assertTrue(!Iterables.isEmpty(hostStorage.calculatePossibleNextStates()));
		
	}
	
}

@@ -65,16 +65,61 @@
 tests;%0A%0A
+import static org.junit.Assert.assertEquals;%0A
 import s
@@ -334,16 +334,121 @@
 cation;%0A
+import org.eclipse.incquery.examples.cps.m2t.proto.distributed.general.applications.statemachines.State;%0A
 import o
@@ -1852,10 +1852,788 @@
 %09%09%0A%09%7D%0A%09%0A
+%09@Test%0A%09public void stepSenderAndNeutralStateTest()%7B%0A%09%09CommunicationNetwork network = new CommunicationNetwork();%0A%09%09Host152661026 hostSenders = new Host152661026(network);%0A%09%09%0A%09%09Application appCamera = hostSenders.getApplications().iterator().next();%0A%09%09%0A%09%09State%3C?%3E currentState = appCamera.getCurrentState();%0A%09%09%0A%09%09// SendStep%0A%09%09assertEquals(BehaviorCameraB.CInit, currentState);%0A%09%09%0A%09%09appCamera.stepToState(BehaviorCameraB.CSent);%0A%09%09%0A%09%09assertTrue(appCamera.getCurrentState() != currentState);%0A%09%09%0A%09%09assertEquals(BehaviorCameraB.CSent, appCamera.getCurrentState());%0A%09%09%0A%09%09// Neutral step%0A%09%09appCamera.stepToState(BehaviorCameraB.CInit);%0A%09%09%0A%09%09assertTrue(appCamera.getCurrentState() != BehaviorCameraB.CSent);%0A%09%09%0A%09%09assertEquals(BehaviorCameraB.CInit, appCamera.getCurrentState());%0A%09%7D%0A%09%0A
 %7D%0A

Add step state test