Contents Of Collection Are Updated But Never Queried

Problem You might have seen a warning message similar to Contents of collection are updated but never queried or more specifically Contents of collection ‘collection variable name’ are updated but never queried. So the collection variable may be any instance of an collection API, for example, List, Set, or even Map.

‘AutoCloseable’ used without ‘try’-with-resources statement

Problem The warning message ‘AutoCloseable’ used without ‘try’-with-resources statement may appear in your Junit class(es) when you might have the similar kind of line (MockitoAnnotations.initMocks(this); is replaced in Mockito 3 by MockitoAnnotations.openMocks(this);) as shown below in your Junit class: Junit 5 Or

Completable Future To Fetch Data Asynchronously

Asynchronous Data Here I am going to show you how to fetch data asynchronously. So, data which are not coordinated in time will be fetched any time. This means that data is sent at irregular intervals, without any specific time or synchronization between the sender and receiver. In this example I am going to use CompletableFuture from Java 8’s new…

How To Write Junit Test For Spring Boot Main Class

Introduction Here I am going to show you how to write Junit test for Spring Boot main class. A class having main method in Spring boot application is called main class and the purpose of this class is to deploy the application into embedded Tomcat server without configuring deployment descriptor or generating war file for the application. This way you…

Apache POI Insert Line Break In Excel Cell Data

Introduction Here I am going to show you how to insert line break in excel cell data using Apache POI in Java language. There may be requirements where you need to write long text in a cell or in multiple cells of excel file, but the long text is not fit within the view port or screen of the device;…

Convert Date From One Format To Another Format In Java

Introduction In this example I am going to show you how to convert date from one format to another format in Java programming language. There are many situations where you need to convert date format in your Java based application from one format to another format. You can use prior to Java 8 and Java 8 onward ways to convert…

Write Or Append To A File Using Java

Introduction In this short example code I will show you how to create a new file for writing into it or if the file already exists then append to it instead of creating a new file using Java programming language. If you have a requirement that either you need to log some data into an existing file or create a…

Junit 5 Test Report Using SonarQube Jacoco Gradle

Table of Contents Introduction Prerequisites Project Setup The Junit 5 Test Class Generating Test Reports Scanning Project with Sonar Source Code Introduction In this Spring Boot based application I am going to show you how to generate Junit 5 test report using SonarQube Jacoco gradle build tool. You need to generate such test reports to ensure that your source code…

Detect Hidden Rows In Excel File Using Apache POI

Table of Contents Introduction Prerequisites Project Setup Detect Hidden Rows/Cells in Excel Java Code Testing Hidden Rows/Cells Source Code Introduction Here in this example I am going to show you how to detect hidden rows in excel file using Apache POI library with the help of Java program. The following data are used in the excel sheet. The first two…

Merge Cells In Excel Sheet Using Apache POI Java

Table of Contents Introduction Prerequisites Project Setup Merge Cells in Excel Testing Merged Cells Source Code Introduction Here I am going to show you how to merge cells in excel sheet using Apache POI in Java programming language. In other words I will merge two or more columns from single row or multiple rows in excel file using Java with…