A simple and easy-to-use REST API. It aims to make it possible to send landing and movement instructions to space probes.
This project uses:
- JDK 11
- Maven
- Spring Boot
- Spring Data JPA + Hibernate
- Docker
- PostgreSQL
- JUnit5, Mockito and MockMVC
After cloning this repository, run:
docker compose up -d
To execute unit tests, run:
./mvnw test
Wait a few minutes and it's done! The API will be running at http://localhost:8080/
Make sure you've got a tool like Insomnia or Postman in order to perform HTTP requests!
Warning! All resources below are located after
/api
planet operations
Resource | POST | GET | PUT | DELETE |
---|---|---|---|---|
/planets | Register new planet | Retrieve all planets |
Error | Remove all planets |
/planets/{id} | Error | Retrieve details for planet {id} |
Update details of planet {id}, if it exists |
Remove planet {id} |
space probe operations
Resource | POST | GET | PUT | DELETE |
---|---|---|---|---|
/probes | Land one or more space probes* |
Retrieve all space probes* |
Send movement instructions to one or more space probes* |
Remove all space probes |
/probes/{id} | Error | Retrieve details for space probe {id} |
Error | Remove space probe {id} |
*Requires the query string "planetId", e.g.,
POST /api/probes?planetId=1
will land the space probes at the planet whose id is 1
- xAxis -> planet length
- yAxis -> planet height
{
"xAxis": 5,
"yAxis": 5
}
?planetId=1
is a query string, probes will be landed at planet 1
- "spaceProbes" -> array; must not be empty and contains landing information
- "xAxis" -> horizontal distance from origin (planet's xAxis)
- "yAxis" -> vertical distance from origin (planet's yAxis)
- "pointsTo" -> space probe direction; can be
NORTH
,SOUTH
,EAST
orWEST
{
"spaceProbes": [
{
"xAxis": 1,
"yAxis": 2,
"pointsTo": "NORTH"
},
{
"xAxis": 3,
"yAxis": 3,
"pointsTo": "EAST"
}
]
}
?planetId=1
is a query string, certain probes at planet 1 will be moved
- "instructions" -> array; must not be empty and contains movement information
- "probeId" -> id of the space probe that is about to be moved
- "command" -> command sequence composed by chars
M
,L
,R
M
-> move forwardL
-> turn leftR
-> turn right
{
"instructions": [
{
"probeId": 1,
"command": "LMLMLMLMM"
},
{
"probeId": 2,
"command": "MMRMMRMRRML"
}
]
}
space-probe-control-system
is licensed under the terms of the GPL License.