julianespinel / movies-java

A repository to show how to build a basic microservice using Dropwizard.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

movies-java Build Status

This is a Java implementation of the movies exercise.

movies-java was created with educational purposes, to be used as a resource for this meetup: How to build, test and deploy a microservice?

Installation

To install the movies microservice just follow these 4 simple steps:

  1. git clone git@github.com:julianespinel/movies.git
  2. cd movies-java/scripts
  3. sh build.sh
  4. sh start-develop.sh
  5. sh create-movies.sh

Testing

Unit tests

  1. cd movies-java/scripts
  2. sh build.sh

Checking code coverage

  1. cd movies-java/target/sites/jacoco/
  2. Open file index.html

Usage

To check if the the microservice is up and running go to http://localhost:9001/movies/admin/ping. If you receive pong as response then it is running.

With the movies microservice you are able to execute the following acitons:

  1. Create a movie
  2. Find a specific movie
  3. Find a set of movies
  4. Update a movie
  5. Delete a movie

Each API call is specified below:

1. Check microservice is alive

Request

Method: GET
URL: http://localhost:9001/movies/admin/ping

Response

pong

2. Create a movie

Request

Method: POST
URL: http://localhost:9001/movies/api/movies
Body:

{
    "imdbId": "tt0133093",
    "title": "The Matrix",
    "runtimeInMinutes": 136,
    "releaseDate": "1999-03-31T00:00",
    "filmRating": "R",
    "genre": "Action, Sci-Fi",
    "director": "The Wachowski brothers",
    "plot": "A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.",
    "metascore": 73,
    "imdbRating": 8.7,
    "imdbVotes": 1023621
}

Response

{
  "imdbId": "tt0133093"
}

3. Find a specific movie

Request

Method: GET
URL: http://localhost:9001/movies/api/movies/tt0133093

Response

{
  "imdbId": "tt0133093",
  "title": "The Matrix",
  "runtimeInMinutes": 136,
  "releaseDate": "1999-03-31T00:00",
  "filmRating": "R",
  "genre": "Action, Sci-Fi",
  "director": "The Wachowski brothers",
  "plot": "A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.",
  "metascore": 73,
  "imdbRating": 8.7,
  "imdbVotes": 1023621
}

4. Find a set of movies

Request

Method: GET
URL: http://localhost:9001/movies/api/movies?title=Matrix&runtimeInMinutes=130&metascore=6&imdbRating=7.2&imdbVotes=1000

Response

[
  {
    "imdbId": "tt0133093",
    "title": "The Matrix",
    "runtimeInMinutes": 136,
    "releaseDate": "1999-03-31T00:00",
    "filmRating": "R",
    "genre": "Action, Sci-Fi",
    "director": "The Wachowski brothers",
    "plot": "A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.",
    "metascore": 73,
    "imdbRating": 8.7,
    "imdbVotes": 1023621
  }
]

5. Update a movie

Request

Method: PUT
URL: http://localhost:9001/movies/api/movies/tt0133093
Body:

{
    "imdbId": "tt0133093",
    "title": "The Matrix2",
    "runtimeInMinutes": 136,
    "releaseDate": "1999-03-31T00:00",
    "filmRating": "R",
    "genre": "Action, Sci-Fi",
    "director": "The Wachowski brothers and some others",
    "plot": "A computer hacker meets agent Smith.",
    "metascore": 83,
    "imdbRating": 8.7,
    "imdbVotes": 1023621
}

We changed the title, director, plot and the metascore.

Response

{
  "imdbId": "tt0133093",
  "title": "The Matrix2",
  "runtimeInMinutes": 136,
  "releaseDate": "1999-03-31T00:00",
  "filmRating": "R",
  "genre": "Action, Sci-Fi",
  "director": "The Wachowski brothers and some others",
  "plot": "A computer hacker meets agent Smith.",
  "metascore": 83,
  "imdbRating": 8.7,
  "imdbVotes": 1023621
}

6. Delete a movie

Request

Method: DELETE
URL: http://localhost:9001/movies/api/movies/tt0133093

Response

{
  "The movie was deleted?": true
}

License

This project is under the MIT License. See the LICENSE file for the full license text.

About

A repository to show how to build a basic microservice using Dropwizard.

License:MIT License


Languages

Language:Java 96.4%Language:Shell 3.6%