Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

RESTful API, an implementation of the "mars rover" challenge, using Java and Spring

License

Notifications You must be signed in to change notification settings

hmigl/space-probe-control-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

space-probe-control-system

Contents

-----------------------------------------------------

Overview

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

-----------------------------------------------------

Getting Started

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!

-----------------------------------------------------

Usage and Examples

API Operations

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

Request Samples

POST /api/planets
  • xAxis -> planet length
  • yAxis -> planet height
{
  "xAxis": 5,
  "yAxis": 5
}
POST /api/probes?planetId=1

?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 or WEST
{
  "spaceProbes": [
    {
      "xAxis": 1,
      "yAxis": 2,
      "pointsTo": "NORTH"
    },
    {
      "xAxis": 3,
      "yAxis": 3,
      "pointsTo": "EAST"
    }
  ]
}
PUT /api/probes?planetId=1

?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 forward
    • L -> turn left
    • R -> turn right
{
  "instructions": [
    {
      "probeId": 1,
      "command": "LMLMLMLMM"
    },
    {
      "probeId": 2,
      "command": "MMRMMRMRRML"
    }
  ]
}

-----------------------------------------------------

Licence

space-probe-control-system is licensed under the terms of the GPL License.

About

RESTful API, an implementation of the "mars rover" challenge, using Java and Spring

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published