Learn how to work with assertions in Java using the assert keyword.
Search Results for: Java assert
Single Assert Call for Multiple Properties in Java Unit Testing
Learn three approaches to verifying multiple properties in one assert call using JUnit5 and AsssertJ.
Extract Values using AssertJ in Java
Learn two ways to extract an object’s value to be asserted on.
Assert That a Java Optional Has a Certain Value
We may need to write assertions on Optional values. We explore a few ways to do this, both with JUnit assertions and with the AssertJ library.
Assert Two Lists for Equality Ignoring Order in Java
Learn how to make order agnostic comparison of lists when writing unit tests.
String Not Empty Test Assertions in Java
Learn about different ways of checking for empty Strings in Java
AssertJ’s Java 8 Features
Learn about AssertJ Java 8 related features such as Optionals, Predicates and the new LocalDate/Time APIs.
Supply Enum Value to an Annotation From a Constant in Java
Learn about Java’s limitations in supplying an enum value from a constant to an annotation and explored our alternatives.
Check if a Number Is Power of 2 in Java
Explore a few ways to determine if a number is a power of 2 in Java.
Finding the Second Smallest Integer in an Array in Java
Explore a few approaches to finding the second smallest number in an array.
Introduction to JavaParser
A quick and practical guide to JavaParser.
Get the First and the Last Elements From an Array in Java
Learn how to access the first and last elements of a Java array.
Convert InputStream to Stream in Java
Learn how to take an InputStream and convert it into a functional Stream in Java.
How to Convert Between ZonedDateTime and Date in Java
Learn how to convert between ZonedDateTime and Date in Java.
Convert an Optional to an ArrayList in Java
Explore various approaches to converting Optional to ArrayList.
Converting short to byte[] in Java
Learn how to convert a short value to a byte[] array.
How to Convert Between java.sql.Timestamp and ZonedDateTime in Java
Learn how to convert between ZonedDateTime and java.sql.Timestamp classes in Java.
Avoiding the IndexOutOfBoundsException When Using List.subList() in Java
In Java, subList() creates a sub-list from a larger list, but it can throw an exception if you give it invalid starting or ending positions. Learn how to avoid this error.
How to Implement Elvis Operator in Java 8
Implement the Elvis operator in Java 8 using the Optional class and ternary operator.
Remove All Characters Before a Specific Character in Java
Explore several approaches to removing all characters before a specified character in a string.