Testing is an essential skill for any Java developer. It helps you ensure the quality and reliability of your code, as well as find and fix bugs faster. On this page, you will find a collection of tutorials that will teach you how to test Java code using JUnit 5 and Mockito. JUnit 5 is…
Read More Testing Java Code
Welcome to a tutorial on Docker’s best practices and considerations for production. By the end of this tutorial, you will understand what Docker is, why it’s beneficial, and the best practices for using Docker in a production environment. To learn more about Docker, check out other Docker tutorials for beginners. This tutorial is designed for…
Read More Docker in Production: Best Practices and Considerations
Mocking a static or private method is often necessary when writing unit tests. However, before Mockito 3.4.0, it was impossible to explicitly mock static methods. Thus, PowerMock offers solutions to the defined use case. In this article, we will look at the introduction of PowerMock and explore examples of mocking private, static, and final methods.…
Read More A Guide to Mocking Private and Static Methods Using PowerMock
Docker and DevOps are pivotal in modern development workflows. In this beginner-friendly tutorial, I will guide you through the integration of Docker with Continuous Integration and Continuous Deployment (CI/CD) pipelines, explaining each concept in detail for a better understanding. To learn more about Docker, please check out my other Docker Tutorials for Beginners. Prerequisites Before…
Read More Docker and DevOps: How Docker Integrates with CI/CD Pipelines
Welcome to this tutorial on string formatting in Java. String formatting, in simple terms, is the method of adding or altering content within a string. We can do this in three ways – using printf(), MessageFormat, and something called the Formatter class. Most Java developers favour the Formatter class, so that’s what we’ll focus on.…
Read More Java String Formatter: A Guide with Examples
In this tutorial, you will learn how to install Docker on a macOS system. Docker is a powerful platform for containerizing applications, which simplifies the process of creating, deploying, and running software. By the end of this tutorial, you will have a working installation of Docker Desktop for Mac and will be ready to start…
Read More How to Install Docker on MacOS?
In this tutorial, we will explore how to ignore unknown JSON fields in Java using Jackson. We will cover the default behaviour, ignoring unknown properties on a class level, ignoring unknown properties globally, and how to deal with incomplete JSON. Additionally, we will discuss security concerns related to ignoring unknown properties using annotations. If you’re…
Read More Ignore Unknown JSON Fields with Java Jackson
In this tutorial, we are going to learn how to convert from our local time to EST/EDT date and time. This is useful in different situations, for example, when you are contacting a colleague in a different timezone or if you are checking out flights. This requires that you convert a date/time from one timezone…
Read More Converting date to EST/EDT Timezone in Java
In this tutorial, you will learn about the difference between two Spring Boot dependencies – Spring Boot Actuator and Spring Boot Starter Actuator. If you’re new to Spring Boot, these terms may sound confusing, but don’t worry, by the end of this tutorial, you’ll understand the difference between them. Spring Boot is a popular framework…
Read More Spring Boot Actuator vs Spring Boot Starter Actuator
In a microservices architecture, it is common to have multiple services communicating with each other over the network. This distributed nature of the architecture can make it challenging to diagnose and debug issues when they arise. To address this problem, developers often use monitoring(Micrometer) and tracing tools(Zipkin) to track the flow of requests between microservices.…
Read More Micrometer and Zipkin: How to Trace HTTP Requests in Spring Boot 3
class UserIdComparator implements Comparator<User> { public int compare(User user1, User user2) { if (user1.userId == user2.userId) { return 0; } else if (user1.userId > user2.userId) { return 1; } else { return -1; } } } We will now create a UsernameComparator class that establishes the comparison logic based on the username field. This class…
Read More Comparator interface in Java
In this tutorial, you will learn how to rename columns in Pandas DataFrame. In a nutshell, Pandas is a popular data analysis and manipulation library in Python. It provides powerful tools for reading, writing, filtering, and transforming data in a variety of formats, such as CSV, Excel, and SQL databases. If you want to learn how…
Read More Rename Columns in Pandas DataFrame: Explained
Reversing a string is a common task in Java programming, and there are several ways to accomplish this. In this tutorial, we’ll explore four different methods for reversing a string in Java, using the StringBuilder class, the for loop, recursion, and a character array. We’ll provide examples of each method and explain how they work.…
Read More Reverse a String in Java
In this tutorial, you’ll learn how to use the @PutMapping annotation in your RESTful web services app to handle HTTP PUT requests with a JSON or XML payload. This allows you to update user details, for example. Here’s an example CURL command to send an HTTP PUT request with JSON data containing user details: HTTP…
Read More @PutMapping in Spring Boot REST
In this REST Assured tutorial, I will demonstrate how to evaluate the JSON content that is returned in the response body of an HTTP response. What is REST Assured? REST Assured is a Java-based library for testing RESTful web services. It provides a domain-specific language (DSL) for writing tests that interact with web services using…
Read More Validate JSON Response with REST Assured