From 89a44f3da4ba5c5129bee93bb4102dd03536cce6 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Thu, 4 Mar 2021 20:29:05 +0100 Subject: [PATCH] Fix some assertions See gh-25499 --- .../autoconfigure/neo4j/Neo4jAutoConfigurationTests.java | 4 ++-- .../gradle/tasks/buildinfo/BuildInfoIntegrationTests.java | 4 ++-- .../bundling/BootBuildImageRegistryIntegrationTests.java | 4 ++-- .../boot/maven/AbstractArchiveIntegrationTests.java | 2 +- .../boot/maven/BuildImageRegistryIntegrationTests.java | 4 ++-- .../org/springframework/boot/SpringApplicationTests.java | 6 +++--- .../boot/rsocket/netty/NettyRSocketServerFactoryTests.java | 5 ++--- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfigurationTests.java index 42af59258d..3c892cc488 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -284,7 +284,7 @@ class Neo4jAutoConfigurationTests { @Test void securityWithCustomCertificates(@TempDir File directory) throws IOException { File certFile = new File(directory, "neo4j-driver.cert"); - assertThat(certFile.createNewFile()); + assertThat(certFile.createNewFile()).isTrue(); Neo4jProperties properties = new Neo4jProperties(); properties.getSecurity().setTrustStrategy(TrustStrategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoIntegrationTests.java index e25342e897..31e4f41de7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -80,7 +80,7 @@ class BuildInfoIntegrationTests { Properties second = buildInfoProperties(); String secondBuildTime = second.getProperty("build.time"); assertThat(secondBuildTime).isNotNull(); - assertThat(Instant.parse(firstBuildTime).isBefore(Instant.parse(secondBuildTime))); + assertThat(Instant.parse(firstBuildTime)).isBefore(Instant.parse(secondBuildTime)); } @TestTemplate diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageRegistryIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageRegistryIntegrationTests.java index 841b57c9e1..de7531dcec 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageRegistryIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageRegistryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -61,7 +61,7 @@ public class BootBuildImageRegistryIntegrationTests { @BeforeEach void setUp() { - assertThat(registry.isRunning()); + assertThat(registry.isRunning()).isTrue(); this.registryAddress = registry.getHost() + ":" + registry.getFirstMappedPort(); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java index b542cff6d3..3e983a8b84 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AbstractArchiveIntegrationTests.java @@ -64,7 +64,7 @@ abstract class AbstractArchiveIntegrationTests { private JarAssert(File actual) { super(actual, JarAssert.class); - assertThat(actual.exists()); + assertThat(actual).exists(); } JarAssert doesNotHaveEntryWithName(String name) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageRegistryIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageRegistryIntegrationTests.java index 654d070d29..d1b0bda10a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageRegistryIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageRegistryIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -55,7 +55,7 @@ public class BuildImageRegistryIntegrationTests extends AbstractArchiveIntegrati @BeforeEach void setUp() { - assertThat(registry.isRunning()); + assertThat(registry.isRunning()).isTrue(); this.dockerClient = registry.getDockerClient(); this.registryAddress = registry.getHost() + ":" + registry.getFirstMappedPort(); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 648ce7f5ad..5137ec6850 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -1228,10 +1228,10 @@ class SpringApplicationTests { application.addListeners(listener); application.run(); ApplicationStartingEvent startingEvent = listener.getEvent(ApplicationStartingEvent.class); - assertThat(startingEvent.getBootstrapContext().get(String.class)); + assertThat(startingEvent.getBootstrapContext().get(String.class)).isEqualTo("boot"); ApplicationEnvironmentPreparedEvent environmentPreparedEvent = listener .getEvent(ApplicationEnvironmentPreparedEvent.class); - assertThat(environmentPreparedEvent.getBootstrapContext().get(String.class)); + assertThat(environmentPreparedEvent.getBootstrapContext().get(String.class)).isEqualTo("boot"); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/netty/NettyRSocketServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/netty/NettyRSocketServerFactoryTests.java index 4e82dddf77..06a52b391b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/netty/NettyRSocketServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/rsocket/netty/NettyRSocketServerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -54,7 +54,6 @@ import org.springframework.messaging.rsocket.RSocketStrategies; import org.springframework.util.SocketUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.will; import static org.mockito.Mockito.inOrder; @@ -203,7 +202,7 @@ class NettyRSocketServerFactoryTests { String payload = "test payload"; Mono responseMono = this.requester.route("test").data(payload).retrieveMono(String.class); StepVerifier.create(responseMono) - .verifyErrorSatisfies((ex) -> assertThatExceptionOfType(ClosedChannelException.class)); + .verifyErrorSatisfies((ex) -> assertThat(ex).isInstanceOf(ClosedChannelException.class)); } private RSocketRequester createRSocketTcpClient() {