Basic Java Spring Test: Top Score Ranking Build Restful API for a simple Note-Taking application using Spring Boot, Mysql, JPA and Gradle.
-
Java - 1.8.x
-
gradle - 6.x.x
-
Mysql - 5.x.x
1. Clone the application
git clone https://github.com/HeidariHamed/Top-Score-Ranking.git2. Create Mysql database
create database gameExmaple file are provided in: src/resources/data.sql
3. Change mysql username and password as per your installation
-
open
src/main/resources/application.properties -
change
spring.datasource.usernameandspring.datasource.passwordas per your mysql installation
4. Build and run the app using gradle
./gradlew -Pprod clean bootJar
java -jar build/libs/*.jarAlternatively, you can run the app without packaging it using -
./gradlewThe app will start running at http://localhost:8080.
The app defines following APIs.
Get score
GET /api/v1/player/{id}
Delete score
DELETE /api/v1/player/delete/{id}
Get list of score
GET /api/v1/list?name=hamed&after=2017-01-01&before=2020-01-01
Player's history
GET /api/v1/history/{player}
Add player
POST /api/v1/player
{
"player":"hamed",
"score": 100,
"time":"2021-02-20 10:10:00"
}
You can test them using postman or any other rest client.
To launch your application's tests, run:
./gradlew test integrationTest