https://geosura-test.herokuapp.com/
- Spring Boot - 2.2.6
- JDK - 1.8 or later
- Spring Framework - 5.2.5
- Hibernate
- JPA
- Apache Maven - 3.6
- PostgreSQL 10.2
- PostGIS 2.5
git clone https://github.com/AndresHerrera/geosura-test.git
cd geosura-test
Needed to configure postgresql connectivity into application.properties:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:postgresql://localhost:5432/geosuradb
spring.datasource.username=postgres
spring.datasource.password=postgres
CREATE DATABASE geosuradb;
CREATE TABLE IF NOT EXISTS public.vehicles(
id SERIAL NOT NULL ,
lon double precision,
lat double precision,
licence_plate VARCHAR(8)
);
ALTER TABLE public.vehicles ADD CONSTRAINT vehicles_pk PRIMARY KEY(id);
SELECT AddGeometryColumn('public','vehicles','the_geom',4326,'POINT',2);
CREATE EXTENSION IF NOT exists postgis;
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.53249,3.40570, 'AAA-000');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.50503,3.43372, 'BBB-111');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.51568,3.44997, 'CCC-222');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.49494,3.48135, 'DDD-333');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.52585,3.37757, 'EEE-444');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.53886,3.38145, 'FFF-555');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.54631,3.40942, 'GGG-666');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.51512,3.46005, 'HHH-777');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.52797,3.48456, 'III-888');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.46759,3.43351, 'OOO-089');
INSERT INTO public.vehicles(lon,lat,licence_plate) VALUES(-76.50262,3.39943, 'UUU-456');
UPDATE public.vehicles set the_geom = st_setsrid(st_makepoint(lon,lat),4326);
mvn spring-boot:run
API Name | HTTP Method | Path | Status Code | Description |
---|---|---|---|---|
GET Vehicles | GET | /api/v1/vehicles | 200 (OK) | All Vehicle resources are fetched |
POST Vehicle | POST | /api/v1/vehicles | 201 (Created) | A new Vehicle resource is fetched |
GET Vehicle | GET | /api/v1/vehicles/{id} | 200 (OK) | One vehicle resource is fetched |
PUT Vehicle | PUT | /api/v1/vehicles/{id} | 200 (OK) | Vehicle resource is updated |
DELETE Vehicle | DELETE | /api/v1/vehicles/{id} | 204 (No Content) | Vehicle resource is deleted |
https://geosura-test.herokuapp.com:8080/api/v1/
- HTTP Method: GET
- Request URL: http://localhost:8080/api/v1/vehicles
curl --location --request GET 'http://localhost:8080/api/v1/vehicles' --data-raw ''
- HTTP Method: POST
- Request URL: https://localhost:8080/api/v1/vehicles
curl --location --request POST 'http://localhost:8080/api/v1/vehicles' \
--header 'Content-Type: application/json' \
--data-raw '{
"licencePlate": "BBB-666",
"longitude": -76.50305,
"latitude": 3.43372
}'
- HTTP Method: GET
- Request URL: http://localhost:8080/api/v1/vehicles/2
curl --location --request GET 'http://localhost:8080/api/v1/vehicles/2' \
--header 'Content-Type: application/json' \
--data-raw ''
- HTTP Method: GET
- Request URL: http://localhost:8080/api/v1/vehicles/2
curl --location --request PUT 'http://localhost:8080/api/v1/vehicles/2' \
--header 'Content-Type: application/json' \
--data-raw '{"licencePlate":"MMM-999","longitude":-76.50503,"latitude":3.43372}'
- HTTP Method: DELETE
- Request URL: http://localhost:8080/api/v1/vehicles/1
curl --location --request DELETE 'http://localhost:8080/api/v1/vehicles/1' --data-raw ''