Use idiomatic AssertJ assertions for true, false, and null

This commit is contained in:
Sam Brannen
2022-01-10 14:15:55 +01:00
parent 2a80b64d40
commit df263d01b9
75 changed files with 345 additions and 333 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -149,7 +149,7 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
testContextManager.beforeTestMethod(testInstance, method);
assertThat(countDownLatch.await(2, TimeUnit.SECONDS)).isEqualTo(true);
assertThat(countDownLatch.await(2, TimeUnit.SECONDS)).isTrue();
verify(listener, only()).beforeTestMethod(testContext);
assertThat(TrackingAsyncUncaughtExceptionHandler.asyncException.getMessage())

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -175,7 +175,7 @@ class RegisterExtensionSpringExtensionTests {
@Test
void valueParameterFromDefaultValueForPropertyPlaceholder(@Value("${bogus:false}") Boolean defaultValue) {
assertThat(defaultValue).as("Default value should have been injected via @Value by Spring").isNotNull();
assertThat(defaultValue).as("default value").isEqualTo(false);
assertThat(defaultValue).as("default value").isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -169,7 +169,7 @@ class SpringExtensionTests {
@Test
void valueParameterFromDefaultValueForPropertyPlaceholder(@Value("${bogus:false}") Boolean defaultValue) {
assertThat(defaultValue).as("Default value should have been injected via @Value by Spring").isNotNull();
assertThat(defaultValue).as("default value").isEqualTo(false);
assertThat(defaultValue).as("default value").isFalse();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -155,7 +155,7 @@ class ReflectionTestUtilsTests {
assertThat(person.getName()).as("name (protected field)").isEqualTo("Tom");
assertThat(person.getAge()).as("age (private field)").isEqualTo(42);
assertThat(person.getEyeColor()).as("eye color (package private field)").isEqualTo("blue");
assertThat(person.likesPets()).as("'likes pets' flag (package private boolean field)").isEqualTo(true);
assertThat(person.likesPets()).as("'likes pets' flag (package private boolean field)").isTrue();
assertThat(person.getFavoriteNumber()).as("'favorite number' (package field)").isEqualTo(PI);
}
@@ -167,7 +167,7 @@ class ReflectionTestUtilsTests {
assertThat(target.getName()).as("name (protected field)").isEqualTo("Tom");
assertThat(target.getAge()).as("age (private field)").isEqualTo(42);
assertThat(target.getEyeColor()).as("eye color (package private field)").isEqualTo("blue");
assertThat(target.likesPets()).as("'likes pets' flag (package private boolean field)").isEqualTo(true);
assertThat(target.likesPets()).as("'likes pets' flag (package private boolean field)").isTrue();
assertThat(target.getFavoriteNumber()).as("'favorite number' (package field)").isEqualTo(PI);
}
@@ -260,7 +260,7 @@ class ReflectionTestUtilsTests {
assertThat(person.getName()).as("name (private method)").isEqualTo("Jerry");
assertThat(person.getAge()).as("age (protected method)").isEqualTo(33);
assertThat(person.getEyeColor()).as("eye color (package private method)").isEqualTo("green");
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isEqualTo(false);
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isFalse();
assertThat(person.getFavoriteNumber()).as("'favorite number' (protected method for a Number)").isEqualTo(Integer.valueOf(42));
assertThat(invokeGetterMethod(person, "getId")).isEqualTo(Long.valueOf(1));
@@ -284,7 +284,7 @@ class ReflectionTestUtilsTests {
assertThat(person.getName()).as("name (private method)").isEqualTo("Tom");
assertThat(person.getAge()).as("age (protected method)").isEqualTo(42);
assertThat(person.getEyeColor()).as("eye color (package private method)").isEqualTo("blue");
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isEqualTo(true);
assertThat(person.likesPets()).as("'likes pets' flag (protected method for a boolean)").isTrue();
assertThat(person.getFavoriteNumber()).as("'favorite number' (protected method for a Number)").isEqualTo(PI);
assertThat(invokeGetterMethod(person, "id")).isEqualTo(Long.valueOf(99));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -851,7 +851,7 @@ public class HtmlUnitRequestBuilderTests {
public void buildRequestSessionIsNew() throws Exception {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getSession().isNew()).isEqualTo(true);
assertThat(actualRequest.getSession().isNew()).isTrue();
}
@Test
@@ -861,7 +861,7 @@ public class HtmlUnitRequestBuilderTests {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getSession().isNew()).isEqualTo(false);
assertThat(actualRequest.getSession().isNew()).isFalse();
}
@Test
@@ -873,7 +873,7 @@ public class HtmlUnitRequestBuilderTests {
HttpSession sessionToRemove = actualRequest.getSession();
sessionToRemove.invalidate();
assertThat(sessions.containsKey(sessionToRemove.getId())).isEqualTo(false);
assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse();
assertSingleSessionCookie("JSESSIONID=" + sessionToRemove.getId()
+ "; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/test; Domain=example.com");
@@ -882,8 +882,8 @@ public class HtmlUnitRequestBuilderTests {
actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getSession().isNew()).isEqualTo(true);
assertThat(sessions.containsKey(sessionToRemove.getId())).isEqualTo(false);
assertThat(actualRequest.getSession().isNew()).isTrue();
assertThat(sessions.containsKey(sessionToRemove.getId())).isFalse();
}
// --- setContextPath