Code Monkey home page Code Monkey logo

grocery-list-api's Introduction

Grocery List Api

This is a simple RESTful API for the Grocery List App

SpringBoot Docker Java GitHub Workflow Status (branch)

This is a Spring Boot application that exposes the necessary REST services for the Grocery List App.

The OpenAPI Specification v3 of the services are described in the file:

open-api-specs/grocery-list-api.yaml

You can copy the content of the file and paste it in the Swagger Editor to see the description of all services in the project.

This is a screenshoot of the Swagger Editor with the specifications Screenshot 2021-11-27 211456

Build project

./gradlew build

Run tests

./gradlew test

You will find a complete report of the result os the tests in:

build/reports/test/index.html

The tests were written in Spock Framework using the language Groovy.

All test are located in:

src/test/groovy/com/rideco/grocery/controllers/ProductsControllerSpec.groovy

here is an example of one of several tests:

def "create a product with NULL name throws BAD_REQUEST response"() {
    given: "a request body with null name"
    def createProductRequestBody = [
        name       : null,
        description: '1 bottle'
    ]

    when: "create the new product"
    def response = mvc.perform(
            post("/rest/products")
                .contentType(MediaType.APPLICATION_JSON)
                .content(toJson(createProductRequestBody))
    )

    then: "the response is BAD_REQUEST"
    response.andExpect(status().isBadRequest())

    and: "the error code is VALIDATION_ERROR"
    ErrorResponse errorResponse = parseErrorResponse(response.andReturn().response.contentAsString)
    errorResponse.errorCode == ErrorResponseCode.VALIDATION_ERROR
}

grocery-list-api's People

Contributors

joanpablo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.