REST API to move NASA's rover on Mars
Java >= 1.8
This project has Maven Wrapper, so it is not necessary to have Maven installed.
Building with tests:
./mvnw clean verify
Building ignoring tests:
./mvnw clean verify -DskipTests
After building, the Spring Boot Plugin will generate a fat JAR file in the target directory. To run it:
java -jar target/curiosity.jar
The HTTP server will start on port 8080.
To send commands to the rover, it is necessary to make a POST request to http://localhost:8080/rest/mars/{input}, where input can be something like:
Lto move 90° to the left;Rto move 90° to the right;Mto move 1 position forward.
After executing the movements, the rover will return the last position in this format: (x,y,d), where:
xrepresents the position X;yrepresents the position Y;drepresents the initial of cardinal direction (North,East,South andWest).
curl -s --request POST http://localhost:8080/rest/mars/MMRMMRMM
200 OK: (2,0,S)
curl -s --request POST http://localhost:8080/rest/mars/MML
200 OK: (0,2,W)
curl -s --request POST http://localhost:8080/rest/mars/AAA
400 Bad Request: 'A' is not a recognized movement. Consider just these: (L,R,M)
curl -s --request POST http://localhost:8080/rest/mars/MMMMMMMMMMMMMMMMMMMMMMMM
400 Bad Request: The (0,6,N) position is out of the bounds (0 to 5, 0 to 5)