integration + fixes

This commit is contained in:
2021-10-17 15:38:04 +02:00
parent 8b0eea1270
commit f461c5f3cb
25 changed files with 252 additions and 186 deletions

View File

@@ -1,5 +1,7 @@
package ch.unisg.executor1.executor.adapter.in.web;
import java.util.concurrent.CompletableFuture;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -25,7 +27,7 @@ public class TaskAvailableController {
if (ExecutorType.contains(taskType.toUpperCase())) {
TaskAvailableCommand command = new TaskAvailableCommand(
ExecutorType.valueOf(taskType.toUpperCase()));
taskAvailableUseCase.newTaskAvailable(command);
CompletableFuture.runAsync(() -> taskAvailableUseCase.newTaskAvailable(command));
}
// Add the content type as a response header

View File

@@ -14,7 +14,7 @@ import ch.unisg.executorBase.executor.domain.ExecutorBase;
import ch.unisg.executorBase.executor.domain.ExecutorType;
public class Executor extends ExecutorBase {
private static final Executor executor = new Executor(ExecutorType.ROBOT);
private final UserToRobotPort userToRobotPort = new UserToRobotAdapter();
private final InstructionToRobotPort instructionToRobotPort = new InstructionToRobotAdapter();
@@ -31,12 +31,24 @@ public class Executor extends ExecutorBase {
@Override
protected
String execution() {
String key = userToRobotPort.userToRobot();
try {
TimeUnit.MILLISECONDS.sleep(1500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
boolean result1 = instructionToRobotPort.instructionToRobot(key);
try {
TimeUnit.MILLISECONDS.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
deleteUserFromRobotPort.deleteUserFromRobot(key);
return Boolean.toString(result1);
}
}
}