Developing RESTful APIs with Kotlin and Spring Boot Online Course
Kotlin is a modern, concise, and safe programming language that runs on the JVM, interoperates with Java, and supports cross-platform code reuse, making it highly popular for enterprise development. This course begins with objectives and prerequisites before introducing Kotlin’s core concepts, including variables, strings, loops, classes, inheritance, interfaces, type checking, casting, collections, arrays, lambdas, and scope functions. You’ll then apply these fundamentals to real-world development by integrating Kotlin with Spring Boot, building a course catalog service, writing unit tests for controllers, and working with RequestParam in endpoints. Finally, you’ll learn how to model relationships in JPA using Kotlin’s entity and data classes.
By the end of the course, you’ll be confident writing Kotlin code and building RESTful APIs with Spring Boot.
Who should take this course?
This course is ideal for backend developers, Java/Kotlin programmers, and software engineers who want to build scalable and efficient RESTful APIs. It’s best suited for those with prior experience in object-oriented programming and a basic understanding of web development who are looking to expand their skills with Kotlin and Spring Boot. Whether you’re a developer aiming to specialize in API development, a professional modernizing Java-based applications, or someone seeking to advance their backend expertise, this course will help you design and implement real-world RESTful services.
What you will learn
- Learn the Kotlin programming language and its benefits
- Write code using the Kotlin programming language
- Learn how to build applications using Kotlin
- Learn Kotlin and Java interoperability
- Integrate Spring Data JPA with Kotlin
- Test Kotlin using JUnit5
Course Outline
Getting Started with Kotlin Programming Language
- Couse Introduction
- Prerequisites
- Introduction to Kotlin
- How Kotlin Works with the JVM
Kotlin Fundamentals
- Project Setup
- Hello Kotlin!
- val and var Variables in Kotlin
- Basic Types - Int, Long, Double, String
- Conditionals - If and When Block
- Ranges, Loops
- while and do-While
- Break, Labels, and Return
Functions in Kotlin
- Defining and Invoking Functions
- Default Value Parameters and Named Arguments
- Top-Level Functions and Top-Level Properties
Classes, Interfaces, and Inheritance
- Introduction to Class - Creating a Class and Objects
- Primary Constructors
- Secondary Constructors
- Initializer Code Using init Block
- Data Classes
- Custom Getters and Setters
- Inheritance - Extending Classes
- Inheritance - Override Functions, Variables
- Object Keyword for Creating Instance of the Class
- Companion Object Keyword
- Interfaces
- Interfaces - Handling Conflicting Functions
- Interfaces - Defining and Overriding Variables
- Visibility Modifiers
- Type Checking, Casting, and Smart Cast
- Enum Class
Nulls in Kotlin
- Nullable and Non-Nullable Types in Kotlin
- Safe Call(?), Elvis Operator (? :), and Non-Null Assertion(!!) to Deal with Null Values
- Invoking or Assigning a Nullable Type to a Non-Nullable Type
Collections, Arrays, and Lambda Expressions
- Introduction to Collections
- Introduction to Lambda Expressions
- Lambdas and Higher Order Functions
- Filter Operations on Kotlin Collections
- Map Operations on Kotlin Collections
- FlatMap Operations in Collections
- Working with HashMaps
- Lazy Evaluation of Collections Using Sequences
- Nullability in Collections
Exceptions in Kotlin and Scope Functions
- Part 1 - Handling Exceptions in Kotlin Using try-catch
- Part 2 - Introduction to Scope Functions
- Apply and Also Scope Function
- Let Scope Function
- With and Run Scope Function
Getting Started with Kotlin and Spring Boot
- Overview of the App and Project Setup
- Build a Simple Endpoint - Greeting Controller
- Constructor Injection in Spring
- Setting Up Different Profiles in Spring Boot
- Set Up Logging in Kotlin
Integration/Unit Testing Using Junit 5
- Introduction to Automated Tests and Setting Up JUnit5
- Integration Test for Controller
- Unit Test for Controller - Using the Mock Mocking Library
Build the Course Catalog Service
- Set Up the Course Entity and CourseDTO
- Create CourseRepository and Configure JPA in application.yml File
- Build the POST Endpoint for Adding New Course
- Integration Test for the POST Endpoint Using JUnit5
- Build the Get Endpoint to Retrieve All Courses
- Integration Test for the GET Endpoint to Retrieve All the Courses
- Build the Update Endpoint to Update a Course
- Integration Test for the PUT Endpoint Using JUnit5
- Build the DELETE Endpoint to Delete a Course
Unit Testing Controller Layer (Web Tier)
- Setting Up the Unit Test for the CourseController
- Unit Test for the Post Endpoint in CourseController
- Unit Test for the GET Endpoint in CourseController
- Unit Test for the PUT Endpoint in CourseController
- Unit Test for the DELETE Endpoint in CourseController
Bean Validation Using Validators and ControllerAdvice
- Name and Category as Mandatory Using @NotBlank Annotation
- Implement Custom Error Handling Using ControllerAdvice Pattern
- Handle Global RuntimeException Using ControllerAdvice Pattern
Custom JPA Queries Using Spring Data JPA and DB Layer Testing Using @DataJpaTest
- Retrieve Courses by Name using JPA Query Creation Function
- Retrieve Courses by Name Using Native SQL Query
- Testing Multiple Sets of Data Using @Parameterized Test
GET Endpoint to Retrieve Courses by Name Using @RequestParam
- Use Existing GET Endpoint to Retrieve Courses by Name
- Write Integration Test to Retrieve Course by Name
Entity Relationships Using Spring Data JPA
- Adding Instructor Entity into the Course Catalog Service
- Adding the Relationship to the Entity Class
- Instructor Controller to Manage Instructor Data
- Update CourseService to Validate Instructor Data
- Fix the CourseController Integration Tests
- Fix the CourseController Unit Tests
Integrating with Postgres DB
- Setting Up the Postgres DB and App to Interact with Postgres
- Test the App with Postgres DB
Integration Testing Using TestContainers
- Setting Up TestContainers for the Integration Test
- Configure @DataJpaTest with TestContainers
Java and Kotlin Interoperability
- Invoking Kotlin Code from Java Class
- Invoking Java Code from Kotlin
- Useful JVM Annotations in Kotlin