/algaworks-testes-mockmvc

Unit Testing Controllers with Spring MockMVC

Primary LanguageJava

Unit Testing Controllers with Spring MockMVC

Tutorial by AlgaWorks.

Table of Contents

Description

From the YouTube description:

"In this video we will teach you how to unit test Controllers using Spring.

For that, we will use Rest Assured and Spring MockMVC tools together with JUnit5."

Project Summary

  • Project: Maven
  • Java: 11
  • Spring Boot: 2.4.5
  • Dependencies
    • Spring Web
    • Spring Boot DevTools
    • Lombok
    • Spring Boot Starter Test
    • Spring MockMVC
    • Spring Security
    • Bucket4j Spring Boot Starter
    • Spring Cache Abstraction
    • Ehcache
  • Plugins
    • Spring Boot Maven Plugin
    • Heroku Maven Plugin

API Documentation

Get Movie

Retrieves a movie.

Request

GET /filmes/:id
  • id must be between 0 and 100
  • the response is the same, regardless of id

Sample Response (200 OK)

{
    "codigo": 1,
    "titulo": "movie-title",
    "descricao": "movie-description"
}

Errors

Condition Error
id < 0 400 BAD REQUEST
id > 100 404 NOT FOUND

Deployment

App deployed on Heroku