Log inBook a Demo
BuildMidBackendAuto-graded

Add order search and stop half-saved orders

Build a search endpoint with filters, paging and a stable sort, and make sure a failed order leaves nothing behind.A small orders service built on Spring Boot and Spring Data JPA needs two things before its next release. First, the support team needs GET /api/orders to find orders by customer and status, one page at a time, newest first. Second, placing an order has a bug: when one line of an order fails, the customer gets an error, but part of the order is saved anyway. Build the search to the rules in the brief and make placing an order all or nothing.
40 min
java, spring-boot, maven

You're done when

  • GET /api/orders with no parameters returns all orders in the database, newest first, with the default page and size.
  • Orders with the same creation time always come in the same order, on every page.
  • The customer and status filters work alone and together.
  • The total count covers every matching order, not only the current page.
  • page and size return the right slice, and a page after the last one is empty, not an error.
  • A bad page, size or status gets a 400.
  • The response has exactly the fields the brief lists.
  • When an order fails for lack of stock, no stock changes, and the next valid order still goes through.
  • When an order fails for lack of stock, no order is saved.
  • When an order names a product that does not exist, nothing is saved and no stock changes.

What it measures

Spring Data JPATurning optional filters, paging and a stable sort into one correct query.
TransactionsMaking a change that touches several rows succeed or fail as one unit.
API designReturning exactly the response and status codes a written contract asks for.

Your environment

Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish

Start this lab

40 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo