Build RESTful APIs Using Kotlin and Spring Boot

Video description

Kotlin is a modern, concise, and safe programming language and is one of the most popular JVM languages currently. It is also interoperable with Java and other languages and provides many ways to reuse code between multiple platforms for productive programming.

Section one covers the course objectives and prerequisites needed to make the most out of this course. In section two, we will be introduced to Kotlin programming language and why it’s a powerful language for enterprise development. Section three is about the fundamentals of Kotlin such as Val and var variables in Kotlin, basic string types, while and do-while, and so on.

Section five is about classes, inheritance, and interfaces in detail, object keywords for creating instances of the class, type checking, casting, and smart cast. In the next section, we will be introduced to collections, arrays, and lambda expressions in Kotlin. We will also understand the scope functions in Kotlin and its usage. Moving on, we will get started with Kotlin and Spring Boot and have an overview of the app we are going to build.

You will also learn to build the course catalog service to manage the courses and to code and learn how to write unit tests for the controller along with coding and learning the usage of RequestParam in the controller endpoint. We will wrap up the course by learning the technique to express relationships in JPA using Entity and data classes in Kotlin.

By the end of this course, you will be comfortable writing code using the Kotlin programming language and building RESTful APIs using Spring Boot and Kotlin.

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

Audience

This course is for developers who are interested in learning the Kotlin programming language, for developers who are interested in building applications using Kotlin and Spring Boot, and for Java developers who would like to learn the Kotlin programming language. Basic experience working with Java will be an advantage.

About The Author

Dilip Sundarraj: Dilip Sundarraj is a software engineer who has experience with building software since 2008. He is passionate about learning modern technologies and staying up to date with all the modern technologies, tools, frameworks, and more. He loves to share his knowledge with the world and that is one of the key reasons for him to be in the online teaching industry.

He loves interacting with other software developers and believes that this helps him share knowledge and learn from them. During his leisure time, he loves to play cricket, watch movies, and work out in the gym to have a balance between physical and mental strength.

Dilip has a YouTube channel named Code with Dilip, where he has been sharing a lot of technical content related to languages, frameworks, best practices, and more.

Table of contents

  1. Chapter 1 : Getting Started with Kotlin Programming Language
    1. Couse Introduction
    2. Prerequisites
    3. Introduction to Kotlin
    4. How Kotlin Works with the JVM
  2. Chapter 2 : Kotlin Fundamentals
    1. Project Setup
    2. Hello Kotlin!
    3. val and var Variables in Kotlin
    4. Basic Types - Int, Long, Double, String
    5. Conditionals - If and When Block
    6. Ranges, Loops
    7. while and do-While
    8. Break, Labels, and Return
  3. Chapter 3 : Functions in Kotlin
    1. Defining and Invoking Functions
    2. Default Value Parameters and Named Arguments
    3. Top-Level Functions and Top-Level Properties
  4. Chapter 4 : Classes, Interfaces, and Inheritance
    1. Introduction to Class - Creating a Class and Objects
    2. Primary Constructors
    3. Secondary Constructors
    4. Initializer Code Using init Block
    5. Data Classes
    6. Custom Getters and Setters
    7. Inheritance - Extending Classes
    8. Inheritance - Override Functions, Variables
    9. Object Keyword for Creating Instance of the Class
    10. Companion Object Keyword
    11. Interfaces
    12. Interfaces - Handling Conflicting Functions
    13. Interfaces - Defining and Overriding Variables
    14. Visibility Modifiers
    15. Type Checking, Casting, and Smart Cast
    16. Enum Class
  5. Chapter 5 : Nulls in Kotlin
    1. Nullable and Non-Nullable Types in Kotlin
    2. Safe Call(?), Elvis Operator (? :), and Non-Null Assertion(!!) to Deal with Null Values
    3. Invoking or Assigning a Nullable Type to a Non-Nullable Type
  6. Chapter 6 : Collections, Arrays, and Lambda Expressions
    1. Introduction to Collections
    2. Introduction to Lambda Expressions
    3. Lambdas and Higher Order Functions
    4. Filter Operations on Kotlin Collections
    5. Map Operations on Kotlin Collections
    6. FlatMap Operations in Collections
    7. Working with HashMaps
    8. Lazy Evaluation of Collections Using Sequences
    9. Nullability in Collections
  7. Chapter 7 : Exceptions in Kotlin and Scope Functions
    1. Part 1 - Handling Exceptions in Kotlin Using try-catch
    2. Part 2 - Introduction to Scope Functions
    3. Apply and Also Scope Function
    4. Let Scope Function
    5. With and Run Scope Function
  8. Chapter 8 : Getting Started with Kotlin and Spring Boot
    1. Overview of the App and Project Setup
    2. Build a Simple Endpoint - Greeting Controller
    3. Constructor Injection in Spring
    4. Setting Up Different Profiles in Spring Boot
    5. Set Up Logging in Kotlin
  9. Chapter 9 : Integration/Unit Testing Using Junit 5
    1. Introduction to Automated Tests and Setting Up JUnit5
    2. Integration Test for Controller
    3. Unit Test for Controller - Using the Mock Mocking Library
  10. Chapter 10 : Build the Course Catalog Service
    1. Set Up the Course Entity and CourseDTO
    2. Create CourseRepository and Configure JPA in application.yml File
    3. Build the POST Endpoint for Adding New Course
    4. Integration Test for the POST Endpoint Using JUnit5
    5. Build the Get Endpoint to Retrieve All Courses
    6. Integration Test for the GET Endpoint to Retrieve All the Courses
    7. Build the Update Endpoint to Update a Course
    8. Integration Test for the PUT Endpoint Using JUnit5
    9. Build the DELETE Endpoint to Delete a Course
  11. Chapter 11 : Unit Testing Controller Layer (Web Tier)
    1. Setting Up the Unit Test for the CourseController
    2. Unit Test for the Post Endpoint in CourseController
    3. Unit Test for the GET Endpoint in CourseController
    4. Unit Test for the PUT Endpoint in CourseController
    5. Unit Test for the DELETE Endpoint in CourseController
  12. Chapter 12 : Bean Validation Using Validators and ControllerAdvice
    1. Name and Category as Mandatory Using @NotBlank Annotation
    2. Implement Custom Error Handling Using ControllerAdvice Pattern
    3. Handle Global RuntimeException Using ControllerAdvice Pattern
  13. Chapter 13 : Custom JPA Queries Using Spring Data JPA and DB Layer Testing Using @DataJpaTest
    1. Retrieve Courses by Name using JPA Query Creation Function
    2. Retrieve Courses by Name Using Native SQL Query
    3. Testing Multiple Sets of Data Using @Parameterized Test
  14. Chapter 14 : GET Endpoint to Retrieve Courses by Name Using @RequestParam
    1. Use Existing GET Endpoint to Retrieve Courses by Name
    2. Write Integration Test to Retrieve Course by Name
  15. Chapter 15 : Entity Relationships Using Spring Data JPA
    1. Adding Instructor Entity into the Course Catalog Service
    2. Adding the Relationship to the Entity Class
    3. Instructor Controller to Manage Instructor Data
    4. Update CourseService to Validate Instructor Data
    5. Fix the CourseController Integration Tests
    6. Fix the CourseController Unit Tests
  16. Chapter 16 : Integrating with Postgres DB
    1. Setting Up the Postgres DB and App to Interact with Postgres
    2. Test the App with Postgres DB
  17. Chapter 17 : Integration Testing Using TestContainers
    1. Setting Up TestContainers for the Integration Test
    2. Configure @DataJpaTest with TestContainers
  18. Chapter 18 : Java and Kotlin Interoperability
    1. Invoking Kotlin Code from Java Class
    2. Invoking Java Code from Kotlin
    3. Useful JVM Annotations in Kotlin

Product information

  • Title: Build RESTful APIs Using Kotlin and Spring Boot
  • Author(s): Dilip Sundarraj
  • Release date: May 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781804616451