AssertJ is a an assertions library for unit tests in Java that is well worth considering. Here are some examples.
Basic
import static org.assertj.core.api.Assertions.assertThat;
assertThat(something).isNotNull();
assertThat(something).isNull();
assertThat(something).isEqualTo(expectation);
assertThat(something.getId()).isGreaterThan(0);
Exceptions
import static org.assertj.core.api.Assertions.assertThatThrownBy;
assertThatThrownBy(() -> obj.action())
.isInstanceOf(IOException.class);
assertThatThrownBy(() -> obj.otherAction())
.isInstanceOf(TimeoutException.class)
.hasMessage("oops")
.hasFieldOrPropertyWithValue("code", HttpStatus.GATEWAY_TIMEOUT);
Dates
import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
import static org.assertj.core.api.Assertions.within;
assertThat(obj.getCreatedAt())
.isCloseTo(OffsetDateTime.now(), within(500, ChronoUnit.MILLIS));
Projections
assertThat(result.getParcels())
.extracting(Parcel::getWeight)
.isEqualTo(Arrays.asList(new BigDecimal(10), new BigDecimal(20)));