Fix Ambiguous Method Call Error in Mockito
1. Overview In this tutorial, we’ll see how to avoid ambiguous method calls in the specific context of the Mockito framework. In Java, method overloading allows a class to have multiple methods with...
View ArticleInclude null Value in JSON Serialization
1. Introduction When we work with Java objects and need to convert them into JSON format, it’s crucial to handle null values appropriately. Omitting null values from the JSON output might not align...
View Article@Subselect Annotation in Hibernate
1. Introduction In this tutorial, we’ll review the @Subselet annotation in Hibernate, how to use it, and its benefits. We’ll also see Hibernate’s constraints on entities annotated as @Subselect and...
View ArticleJava Weekly, Issue 535 – Out with the RestTemplate (again)
1. Spring and Java >> Java 22 Delivers Foreign Memory & Memory API, Unnamed Variables & Patterns, and Return of JavaOne [infoq.com] Last week, we celebrated the release of Java 22, but...
View ArticleFind Map Keys with Duplicate Values in Java
1. Overview Map is an efficient structure for key-value storage and retrieval. In this tutorial, we’ll explore different approaches to finding map keys with duplicate values in a Set. In other words,...
View ArticleMerge Overlapping Intervals in a Java Collection
1. Overview In this tutorial, we’ll look at taking a Collection of intervals and merging any that overlap. 2. Understanding the Problem First, let’s define what an interval is. We’ll describe it as a...
View ArticleFinding Element by Attribute in Selenium
1. Introduction Selenium offers plenty of methods to locate elements on a webpage, and we often need to find an element based on its attribute. Attributes are additional pieces of information that can...
View ArticleThe @Struct Annotation Type in Hibernate – Structured User-Defined Types
1. Overview In this tutorial, we’ll review Hibernate’s @Struct annotation which let’s developers create structured user-defined types. Support for structured user-defined types, a.k.a structured types,...
View ArticleGet Last n Characters From a String
1. Overview In this tutorial, we’ll explore a few different ways to get the last n characters from a String. Let’s pretend that we have the following String whose value represents a date: String s =...
View ArticleLogging in Spring Boot With Loki
1. Introduction Grafana Labs developed Loki, an open-source log aggregation system inspired by Prometheus. Its purpose is to store and index log data, facilitating efficient querying and analysis of...
View ArticleCheck if an Element Is Present in a Set in Java
1. Overview In this short tutorial, we’ll cast light on how to check if an element is present in a Set in Java. First, we’ll kick things off by exploring solutions using core JDK. Then, we’ll elucidate...
View ArticleConvert TemporalAccessor to LocalDate
1. Introduction Dealing with date and time values is a common task. Sometimes, we may need to convert a TemporalAccessor object to a LocalDate object to perform date-specific operations. Hence, this...
View ArticleGet a Path to a Resource in a Java JAR File
1. Introduction Resources within a JAR file are typically accessed using a path relative to the root of the JAR file in Java. Furthermore, it’s essential to understand how these paths are structured to...
View ArticleJava Weekly, Issue 536 – Java keeps evolving through JEPs
1. Spring and Java >> Code Before super() – JEP 447 [javaspecialists.eu] A revolution is coming to Java! Soon, you will be able to add custom code before a super() call >> Java users on...
View ArticleInternet Address Resolution SPI in Java
1. Introduction In this tutorial, we’ll discuss Java’s JEP 418, which establishes a new Service Provider Interface (SPI) for Internet host and address resolution. 2. Internet Address Resolution Any...
View ArticleLogging in Apache Camel
1. Overview Logging is essential in software development as it aids in recording every footprint of an application. It helps with tracking the activities and state of an application. Essentially, it’s...
View ArticleMapping Enum With MapStruct
1. Introduction In this tutorial, we’ll learn how to map one enum type to another using MapStruct, mapping enums to built-in Java types such as int and String, and vice versa. 2. Maven Let’s add the...
View ArticleDisable @EnableScheduling on Spring Tests
1. Introduction In this tutorial, we’ll dive into the topic of testing Spring applications which utilize scheduled tasks. Their extensive usage might cause a headache when we try to develop tests,...
View ArticleMultiple-Level Mock Injection Into Mockito Spy Objects
1. Overview In this tutorial, we’ll discuss the well-known Mockito annotations @InjectMock, @Mock, @Spy and understand how they work together in multiple-level injection scenarios. We’ll talk about...
View Article