Integration Tests for WebClient with WireMock
Codersee | Kotlin, Spring & Cloud Computing
by Piotr
1M ago
Hi guys! Today we will learn how to do integration testing for Spring WebClient that invokes external REST APIs with WireMock and JUnit 5. As an example, we will implement a simple logic responsible for querying the GitHub API using coroutines. Nevertheless, I am pretty sure you will be able to easily adjust this article to your needs. (of course, if you are here only for the WireMock part, then I recommend skipping to the “WebClient Integration Testing With WireMock” chapter). Lastly, I just wanted to add that you can use this testing approach regardless of whether you are using WebClient, R ..read more
Visit website
Reactive Programming in Kotlin: A Step-by-Step Guide
Codersee | Kotlin, Spring & Cloud Computing
by Peter Lantukh
2M ago
In this article, we are going to tackle Reactive Programming in Kotlin. We will start with what exactly Reactive Programming is, how we could use it to our advantage, and what techniques we can use in Kotlin. I am going to explain everything in simple terms to make this article beginner-friendly (considering you know the basics of Kotlin, of course). In some future articles, we will put that knowledge into action on the example of the Ktor project, emphasizing the Reactive approach. So don’t forget to follow me on LinkedIn to not miss out Reactive Programming If you try to search for what Rea ..read more
Visit website
How To Create a Ktor Client To Connect To OpenWeatherMap API
Codersee | Kotlin, Spring & Cloud Computing
by Peter Lantukh
3M ago
This comprehensive guide is about setting up a Ktor client that effortlessly retrieves data from OpenWeatherMap API. I’ll tackle client configuration, API calls, models configuration, and error handling, leaving you with a weather-fetching client ready to be used on any platform. Ktor is a flexible library that provides the ability to create a non-blocking HTTP client, which enables you to perform requests and handle responses. Its functionality could be enhanced with plugins, such as logging, serialization, authentication, and so on. Its core benefit is that it’s a lightweight framework that ..read more
Visit website
Testing Micronaut Application in Kotlin
Codersee | Kotlin, Spring & Cloud Computing
by Piotr
3M ago
Hello and welcome to my next article, in which I will show you how to test a Micronaut application in Kotlin. To be even more specific- we will work with an application that exposes a REST API and connects to MongoDB. If you would like to learn how to do that step-by-step, then you can check out my other article. (But don’t worry, we will see its code snippets in this tutorial, too). For testing, we’re going to use JUnit 5, MockK, REST Assured, as well as the @MicronautTest and Micronaut Test Resources. Micronaut Project Overview Let’s start everything by checking the project we will test toda ..read more
Visit website
Fix “Can’t find a codec for CodecCacheKey” in Micronaut
Codersee | Kotlin, Spring & Cloud Computing
by Piotr
3M ago
If you have ever struggled with the “Unexpected error occurred: Can’t find a codec for CodecCacheKey” when testing in Micronaut, then you came to the right place In this short article, I will show you how to fix this issue based on the example project. Trigger The CodecCacheKey in Micronaut Test Before I show you how to fix this issue, let me quickly introduce you to how I trigger the CodecCacheKey issue when writing tests in Micronaut. (If you are interested in the whole project, check this article about Micronaut with MongoDB). So firstly, I created a simple AppUser data class: import io.m ..read more
Visit website
How To Use kotlinx.serialization with Ktor and Kotlin?
Codersee | Kotlin, Spring & Cloud Computing
by Peter Lantukh
3M ago
If you would like to learn how to use the kotlinx.serialization library with Ktor and Kotlin, then you just came to the right place! In this article I will show you how to configure it to work with: Ktor Server Ktor Client WebSockets in Ktor Before we start, I just wanted to note that we are going to use a modified project from the lesson about Ktor with Ktorm and PostgreSQL. So if you don’t know how to setup and use a Ktor server with PostgreSQL you should definitely check it up, because I will skip the basics. Additionally, if you’d like to explore kotlinx.serialization in details, then ch ..read more
Visit website
Secure REST API with Ktor – Role-based access control (RBAC)
Codersee | Kotlin, Spring & Cloud Computing
by Piotr
4M ago
Hello and welcome to the 3rd article in our secure REST API with Ktor series, in which I will show you how to set up role-based access control (RBAC), also known as role-based security. If you haven’t seen my previous articles, then I highly encourage you to check them out: Secure REST API with Ktor and JWT Access Tokens Secure Ktor app with JWT refresh tokens. Refresh token flow. Moreover, in this tutorial, we will build functionality based on the refresh token article, so I highly encourage you to fetch the code from this repo now. But don’t worry, if you are interested only in the RBAC pa ..read more
Visit website
Kotlinx.serialization in Kotlin- All You Need To Know
Codersee | Kotlin, Spring & Cloud Computing
by Peter Lantukh
4M ago
If you are working with Kotlin, then it is a matter of time before you will face a need to serialize and deserialize your data. In this topic, I am going to cover the most important scenarios of kotlinx.serialization in Kotlin and how to use it to your advantage in your projects. If you haven’t heard about it, then Kotlin Serialization is a cross-platform and multi-format framework built for this specific needs. It can be used with practically any Kotlin-based project, such as Android applications, Ktor applications, and Multiplatform (Common, JS, Native).  Setting Up To set up kotli ..read more
Visit website
Ktlint with pre-commit Hook: Git Hooks in Kotlin Made Easy
Codersee | Kotlin, Spring & Cloud Computing
by Piotr
4M ago
In this article, we will learn how easily we can automate our Kotlin project with git hooks on the example of Ktlint pre-commit check. At the end of this tutorial, you will know precisely: what are Git client-side Hooks, what types of client-side hooks Git offers, how to implement an automated code check before we commit our changes, and how to combine that together with Kotlin and Gradle. And although this guide may seem a bit specific, you can trust me that after reading it you will be able to adjust this knowledge to many other cases in your real-life scenarios. Git Hooks And Client-Side ..read more
Visit website
Secure REST API with Ktor and JWT Access Tokens
Codersee | Kotlin, Spring & Cloud Computing
by Piotr
5M ago
Hello and welcome to the first article in a series. This time, I will show you how to implement a simple REST API with Ktor and secure it with JWT (JSON Web Token) access tokens. To be even more specific, in this tutorial I will teach you: how to implement a simple REST API, what are JSON Web Tokens and what does the authentication mean, how to generate and validate JWT access tokens, and authenticate users, and how to read data using the JWTPrincipal. In the upcoming articles, we will continue the topic and learn additionally: how to implement a refresh token flow with Ktor [TBD], and how ..read more
Visit website

Follow Codersee | Kotlin, Spring & Cloud Computing on FeedSpot

Continue with Google
Continue with Apple
OR