Spring Boot API: Insurance Quote Application
Spring Boot API: Insurance Quote Application
Build APIs That Work—Clearly, Confidently, and With Purpose
About the Book
Looking for a Spring Boot API book that goes beyond boilerplate code? Spring Boot API: Insurance Quote Application is a hands‑on guide for developers who want to build real, production‑ready applications. Whether you’re new to Spring Boot or refining your Agile skills, this book walks you through the full development lifecycle—from user stories and Gherkin scenarios to Test‑Driven Development, layered architecture, microservices integration, and API testing with Postman, Swagger, and mocking frameworks.
Software architecture isn’t just about layers, endpoints, and data flow—it’s about people. Behind every controller is a user story. Behind every test case is a team striving to build with confidence. This book invites you to see Spring Boot development not just as a technical craft, but as a human one. Through clear diagrams, real‑world APIs, and thoroughly commented code, you’ll explore how thoughtful design can shape better software.
Inside, you will build three APIs in the form of microservices that power a dynamic insurance platform. You’ll explore:
- Agile development with real‑life scenarios
- Test‑Driven Development using JUnit
- Testing with Mockito
- Spring Boot layering: controllers, services, repositories, DTOs, and exceptions
- JPA with H2 database, validation, and response entities
- Pagination and dynamic search endpoints for user‑facing data
- Deployment on a Tomcat server with practical configuration tips
With consistent terminology and clearly explained code examples, this book helps you connect the dots between backend architecture and real‑world impact. Each technical decision—every layer, test, and naming convention—isn’t just about code quality, it’s about making life easier for:
- The developer who inherits your code
- The learner trying to understand the flow
- The user who relies on the application to solve a real problem
Take your Spring Boot skills to the next level and build APIs that truly work—with clarity, confidence, and purpose.
Table of Contents
Spring Boot API: Electrical Items Insurance
Table of Contents
- What you will learn
- On completing the learning, you will
- Introduction - Spring Boot Electrical Items Insurance
-
1 AGILE USER STORIES
- What Is a User Story?
- Why Are User Stories Important?
- User Stories and Acceptance Criteria
- How to Write Effective User Stories
- User Stories in Agile Workflows
- Sprint Planning
- Continuous Collaboration
- TDD and BDD Integration
- Examples of User Stories in an Online Insurance System
- User Stories in Gherkin Format
- What is Gherkin?
- The GWT Structure
- Explaining Gherkin with an Insurance Company Example
- Scenario analysis
-
2 QUICK SPRING BOOT SETUP
- Creating a Simple Spring Boot Project
- What is pom.xml?
- Analysis of the pom.xml code sections
- Creating a Basic Controller
- Analysis of the HealthCheckController code
- Analysis of the DemoApplication code
- Creating a Basic Model
- Analysis of the DemoApplication code
- Analysis of the mapping code
- Creating a Basic Service
- Analysis of the mapping code
- Creating a Basic DTO
- What is a DTO?
- Analysis of the QuoteResponseDto?
- Analysis of the calculatequotevaluedto mapping?
- Summarizing our basic API
-
3 TEST-DRIVEN DEVELOPMENT
- JUnit 5 versus JUnit 4
- Creating a Maven Project
- pom.xml
- Product Type Factor Tests
- More Tests
- Product Value Factor Tests
- Calculate Quote Tests
- More robust testing
- Separation of Concerns
- Modularity
- Maintainability
- Testability
- Application of Separation of Concern in Java and Other Languages
- Separation of Concern for the business logic
- Separation of Concern for the tests
- Create a test suite
- Understanding the manifest and jar files
- Configure the project to build a jar file
- Maven configuration (command/script)
- Summary
-
4 SPRING BOOT API – INSURANCE QUOTE BACKEND
- Explanation of common layers
- User Stories
- Project setup
- Starter poms
- The Model Class
- Data Transfer Objects (DTO)
- The Repository Class
- The Service Class
- Create functionality
- Read functionality
- Update functionality
- Delete functionality
- Find record by its id functionality
- RestTemplate
- External Service Client
- The Exception Classes
- The Controller Class
- HTTP responses
- Handling HTTP Requests with Spring's Mapping Annotations
- Adding database functionality
- Configuring the database
- Server Port
- Database setup
- JPA & Hibernate Configuration
- H2 Console Access
- SQL Records
- The Application Class – the main method
- Test the endpoints
- CORS
- HTTP Client in IntelliJ IDEA Ultimate Edition
- Download Postman
- Testing the API with Postman
- The database table
- Derived Queries - (SQL Queries)
- Naming convention
- Supported Keywords
- Basic Derived Query
- Using GreaterThan
- Using LessThan
- Using And
- Using Or
- Using Between
- Using Like
- Using In
- Using OrderBy
- Optional
- Derived queries in the Repository layer
- Derived queries in the Service layer
- Derived queries in the Controller layer
- Why These Endpoints Belong in the Controller
- Test the SQL endpoints
- Quote Calculations as a service
-
5 PRODUCT DESCRIPTION MICROSERVICE
- Creating a Maven Project for the Microservice
- Project setup
- The database table
- Testing the API with Postman
-
6 CUSTOMER MICROSERVICE
- Creating a Maven Project for the Microservice
- Project setup
- Database Records
- The database table
- Testing the API with Postman
- 7 TESTING THE MICROSERVICES INTEGRATION
-
8 PAGINATION AND DYNAMIC SEARCHING
- Pagination with sorting
- Dynamic searching
-
9 VALIDATION
- Layered approach for where and what to validate
- Global Exception handler
- Entity Field Validation
- Controller Method Validation
- Query Parameter Validation
-
10 MOCKING
- Introduction to mocking
- Why We Use Mocking
- Mockito – A Popular Mocking Framework
-
11 LOGGING
- Introduction to logging with SLF4J
- Controller Layer Logging
- Testing the API with Postman
- Testing the API controllers with Postman
- Service Layer Logging
- Testing the API service methods with Postman
- Repository Layer Logging
- Exceptions Layer Logging
-
12 SWAGGER
- Introduction to Swagger
- What is Swagger?
- The Springdoc OpenAPI Dependency
- Compatibility with Spring Boot Versions
- Swagger Integration with our application
- Generated Endpoints and API Documentation
- Documenting our InsuredItem endpoints
- Testing and Interactive Features
- Schema Generation and Validation Documentation
- Advanced Endpoint Documentation
-
13 RESTTEMPLATE AND WEBCLIENT
- RestTemplate - A Classic Approach
- WebClient - A Modern, Reactive Solution
- Analysis of the WebClientConfig code
- Analysis of the ProductClientService code
- Analysis of the CustomerController getProductTypes() code
- Analysis of the ProductClientService code
- Analysis of the CustomerController getProductDescriptionByType() code
- Separate Configuration Class Approach (CustomerMicroservice)
- Main Application Class Approach (InsuredItem Microservice)
-
14 GLOSSARY OF TERMS
- Spring API terms
- WebClient terms
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them