CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/springboot-error-handling

Error handling for Spring Boot APIs — @ControllerAdvice, structured error

84

1.76x
Quality

75%

Does it follow best practices?

Impact

99%

1.76x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

Build an Employee Directory API

Problem/Feature Description

An HR department needs a REST API to manage their employee directory. Build it using Spring Boot and Java.

Resources:

  • Department: { id, name, managerId }
  • Employee: { id, firstName, lastName, email, departmentId, jobTitle, salary, hireDate }

Endpoints:

  • GET /api/departments -- list all departments
  • POST /api/departments -- create a department (name required, must be unique)
  • GET /api/departments/{id} -- get department details including employee count
  • GET /api/departments/{id}/employees -- list employees in a department, support pagination (page, size params)
  • POST /api/employees -- create an employee (firstName, lastName, email required; email must be unique; departmentId must reference an existing department; salary must be positive)
  • GET /api/employees/{id} -- get an employee by ID
  • PUT /api/employees/{id} -- update employee details
  • DELETE /api/employees/{id} -- remove an employee (cannot delete a department manager)
  • PATCH /api/employees/{id}/transfer -- transfer an employee to a different department (body: { departmentId })

Business rules:

  • Department manager must be an employee within that department
  • An employee's email must be unique across the entire organization
  • Salary must be between 30000 and 500000
  • Cannot delete a department that has employees

Use H2 embedded database with Spring Data JPA.

Output Specification

Produce a complete Spring Boot project:

  • src/main/java/com/example/ -- controller, service, model/entity, and repository packages
  • pom.xml or build.gradle -- with dependencies
  • src/main/resources/application.properties -- configuration including H2 settings

You may create additional files as needed for a well-structured codebase.

evals

scenario-1

criteria.json

task.md

tile.json