Skip to content

mattslagle44/sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo Sample (Spring Boot)

Minimal REST API demonstrating:

  • Clean controller design
  • DTO validation (Jakarta Validation)
  • Unit tests with MockMvc

Why this project?

This repository was created as a code sample for job applications.
It shows core back-end development practices:

  • API design (REST endpoints for managing Todos)
  • Input validation and error handling
  • Automated tests to ensure reliability

Run

./mvnw spring-boot:run

Once running, the API will be available at:
http://localhost:8080/api/todos


Try it out

Once the server is running, you can interact with the API using curl, Postman, or any HTTP client.

1. List all Todos

curl http://localhost:8080/api/todos

Response:

[]

2. Create a new Todo

curl -X POST http://localhost:8080/api/todos \
  -H "Content-Type: application/json" \
  -d '{ "title": "Write cover letter", "notes": "Keep it simple", "done": false }'

Response:

{
  "id": 1,
  "title": "Write cover letter",
  "notes": "Keep it simple",
  "done": false
}

3. List again

curl http://localhost:8080/api/todos

Response:

[
  {
    "id": 1,
    "title": "Write cover letter",
    "notes": "Keep it simple",
    "done": false
  }
]

4. Validation example

Try creating a Todo with an empty title:

curl -X POST http://localhost:8080/api/todos \
  -H "Content-Type: application/json" \
  -d '{ "title": "", "notes": "missing title", "done": false }'

Response (400 Bad Request):

{
  "errors": [
    {
      "field": "title",
      "message": "must not be blank"
    }
  ]
}

Test

./mvnw test

This runs the automated unit tests (JUnit + MockMvc) that verify the API behavior.


Tech Stack

  • Java 17
  • Spring Boot 3
  • Maven (with Maven Wrapper for portability)
  • JUnit 5 + MockMvc

About

Minimal Spring Boot REST API with validation and tests (sample code project).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages