Kotlin test

Adrien Carteron 4ed6142526 [FEAT] add example пре 2 година
Docker f5c782b392 [FEAT] add docker stuff to embed the service and the db пре 2 година
gradle f52351d6c3 first commit пре 2 година
src 819dd57bc0 [FEAT] пре 2 година
.gitignore f52351d6c3 first commit пре 2 година
README.md 4ed6142526 [FEAT] add example пре 2 година
build.gradle.kts f52351d6c3 first commit пре 2 година
gradle.properties f52351d6c3 first commit пре 2 година
gradlew f52351d6c3 first commit пре 2 година
gradlew.bat f52351d6c3 first commit пре 2 година
settings.gradle.kts f52351d6c3 first commit пре 2 година

README.md

Implementation

Requirements

  • Gradle
  • Mongodb

Compile

gradle build

Run

unzip build/distributions/playerRank-0.0.1.zip -d <location>
/<location>/playerRank-0.0.1/bin/playerRank

starts web server with api: http://localhost:8080/

Run test

gradle test --tests "re.chasam.models.impl.TournamentImplTest"
gradle test --tests "re.chasam.models.impl.PlayerTest"

Mongo connexion

Its access follows the format:

scheme://host:port

to access to a db and use collection. Defaults parameters can be overriden using environments variables:

SCHEME
HOST
PORT
NAME
COLLECTION

Docker

cd Docker
docker compose up

API

GET /players

lists all players with name score and rank

GET /player/{id}

get a player score and its rank

POST /players {"name":"a name"}

add a new player, its score and rank are set to 0

PATCH /players/{id} {"score":42}

set the score of a player

DELETE /players

remove all players

Examples

curl -X POST -d '{"name":"Player 1","score":0}' -H "Content-Type: application/json" http://127.0.0.1:8080/players

curl -X POST -d '{"name":"Player 2","score":0}' -H "Content-Type: application/json" http://127.0.0.1:8080/players

curl -X POST -d '{"name":"Player 3","score":0}' -H "Content-Type: application/json" http://127.0.0.1:8080/players

curl -X POST -d '{"name":"Player 4","score":0}' -H "Content-Type: application/json" http://127.0.0.1:8080/players

curl -X PATCH -d '{"score":42}' -H "Content-Type: application/json" "http://127.0.0.1:8080/players/Player%201"

curl -X GET "http://127.0.0.1:8080/players/Player%201"

curl -X GET "http://127.0.0.1:8080/players/Player%202"

curl -X DELETE -H "Content-Type: application/json" http://127.0.0.1:8080/players