This API REST has been developed following the following requirements: Enunciado
- Who has developed it?
- API First
- Running the application
- Testing the application
- API Documentation
- H2 In memory database
This application has been fully designed and developed by Victor Martin Gil
Check more details about me in my website:
This API REST has been designed and developed using the API First methodology.
The API has been designed and documented before any code has been written, as you can check in the
api.yaml file.
Please note that to run this application you will need at least Java 17 version installed in your machine.
To check which java version you have installed in your machine, type the following command in your terminal or command
prompt:
java -version
You can find the prices-service.jar file ready to be executed in the following path:
/package
Open your terminal in the path where you have downloaded it in your computer and run the application with the following command:
java -jar prices-service.jar
The application is running by default in port 8080. If you need to change the port, use this command:
java -jar prices-service.jar --server.port=8085
-
Clone this repository into your local machine.
-
Use mvn clean install to generate sources specified in the following file: api.yaml
mvn clean install
This mavend command also will generate the required Mappers with Mapstruct
No you can run the application with your IDE, which will be able by default in the port 8080.
You need to run the application before testing it. Check 3.Running the application.
Be sure the application is running in port 8080, otherwise, update the port in the query in Postman Collection.
There are 5 end-to-end tests readies. You can use one of the following options to run them:
- You can run them with Cucumber using this file: get_price.feature
- Also, you can download and import the following Postman Collection and run all the folder " test".
You can use the same Postman Collection and you will find a query ready to be executed in the folder "api".
The API has been documented through this api.yaml file.
To see this documentation in an appropriate User Interface, while your application is running, you can go to
the Swagger UI.
Also, you can use online Swagger Editor and paste the content of
the api.yaml file there.
This application works with H2 in-memory database.
Please note two different databases have been defined, one for test, other for dev environments.
To access h2 console, while the application is running, you can go to the following link: http://localhost:8080/h2-console
To log into the database, set the following parameters and credentials to access dev environment database (you can also see them in application.yml file):
- Driver Class: org.h2.Driver
- JDBC URL: jdbc:h2:mem:prices-db
- User Name: sa
- Password: sa