Commit 7d62b3af authored by Christina's avatar Christina
Browse files

add simthreadstate to commandhandlertest

parent 8f00d2a9
Pipeline #527719 passed with stages
in 137 minutes and 57 seconds
......@@ -53,10 +53,13 @@ public class RemoteScenarioRun extends ScenarioRun implements RemoteRunListener
return true;
}
synchronized public SimThreadState getCurrentSimThreadState(){
synchronized public SimThreadState getCurrentSimThreadState(){
if (simulation == null){
return SimThreadState.INIT;
}
else if (simulation.getThreadState() == null){
return SimThreadState.INIT;
}
return simulation.getThreadState();
}
......
......@@ -57,7 +57,7 @@ public class ControlCommandHandler extends CommandHandler<ControlVar> {
TraCICloseCommand cmd = (TraCICloseCommand) rawCmd;
remoteManager.setClientCloseCommandReceived(true);
if (remoteManager.getCurrentSimThreadState().equals(SimThreadState.MAIN_LOOP)) {
logger.info("Current simulation run in main loop. Stop simulation.");
......
......@@ -17,6 +17,7 @@ import org.vadere.manager.traci.response.TraCIGetVersionResponse;
import org.vadere.manager.traci.response.TraCIResponse;
import org.vadere.manager.traci.response.TraCISimTimeResponse;
import org.vadere.manager.traci.response.TraCIStatusResponse;
import org.vadere.simulator.control.simulation.SimThreadState;
import java.util.HashMap;
......@@ -31,8 +32,7 @@ public class ControlCommandHandlerTest extends CommandHandlerTest {
private ControlCommandHandler ctrCmdHandler = ControlCommandHandler.instance;
@Test
public void process_close() {
private void process_close_(SimThreadState simThreadState) {
TraCICmd traciCmd = TraCICmd.CLOSE;
CmdType cmdType = traciCmd.type;
......@@ -40,6 +40,7 @@ public class ControlCommandHandlerTest extends CommandHandlerTest {
TraCICloseCommand rawCmd = (TraCICloseCommand) getFirstCommand(TraCICloseCommand.build());
RemoteManager rm = mock(RemoteManager.class, Mockito.RETURNS_DEEP_STUBS);
doNothing().when(rm).setClientCloseCommandReceived(true);
when(rm.getCurrentSimThreadState()).thenReturn(simThreadState);
TraCICommand cmd = ctrCmdHandler.process_close(rawCmd, rm);
testTraCICommand(cmd, traciCmd, cmdType);
......@@ -50,6 +51,23 @@ public class ControlCommandHandlerTest extends CommandHandlerTest {
TraCIResponse res = closeCommand.getResponse();
}
@Test
public void process_close(){
process_close_(SimThreadState.INIT);
}
@Test
public void process_close_mainLoop(){
process_close_(SimThreadState.MAIN_LOOP);
}
@Test
public void process_close_postLoop(){
process_close_(SimThreadState.POST_LOOP);
}
@Test
public void process_simStep() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment