This project is a Spring Boot application that provides a RESTful API for controlling a robot on a 5x5 grid. The API processes commands to move the robot and returns its updated position and direction.
- RESTful API for controlling the robot
- Validation of commands
- Exception handling and meaningful error messages
- Java 11 or higher
- Maven
- Clone the repository:
git clone <repository-url> cd PilotAPI
- Install the dependencies:
mvn install
mvn spring-boot:run
The application will start on http://localhost:8080.
POST /api/robot/move
: Processes the script to move the robot.
POST /api/robot/move
Content-Type: application/json
{
"script": "POSITION 1 3 EAST\nFORWARD 3\nWAIT\nTURNAROUND\nFORWARD 1\nRIGHT\nFORWARD 2"
}
{
"x": 2,
"y": 3,
"direction": "EAST"
}
src/main/java/com/robot/pilot
: Contains the main application code.controller
: Contains the REST controllers.service
: Contains the service logic.model
: Contains the data models.config
: Contains the application configuration.exception
: Contains the custom exceptions.
The application uses @ControllerAdvice
to handle exceptions and return meaningful error messages to the client.
Run the tests using Maven:
mvn test