From 04ca7f137d743acb153b9de532800fbf20ed14cc Mon Sep 17 00:00:00 2001 From: Paul Vorbach Date: Sun, 27 Aug 2017 15:09:30 +0200 Subject: [PATCH] Identify and fix incomplete assertions Several calls to assertThat lacked a following assertion most often due to wrong use of parenthesis. See gh-10084 --- .../boot/actuate/health/RedisHealthIndicatorTests.java | 4 ++-- .../boot/actuate/health/SolrHealthIndicatorTests.java | 4 ++-- .../analyzer/NoSuchBeanDefinitionFailureAnalyzerTests.java | 4 +--- .../boot/jdbc/DatabaseDriverClassNameTests.java | 6 +++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/RedisHealthIndicatorTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/RedisHealthIndicatorTests.java index 7d6e8a9805..58f14ebefb 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/RedisHealthIndicatorTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/RedisHealthIndicatorTests.java @@ -100,8 +100,8 @@ public class RedisHealthIndicatorTests { redisConnectionFactory); Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); - assertThat(((String) health.getDetails().get("error")) - .contains("Connection failed")); + assertThat((String) health.getDetails().get("error")) + .contains("Connection failed"); verify(redisConnectionFactory).getConnection(); verify(redisConnection).info(); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/SolrHealthIndicatorTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/SolrHealthIndicatorTests.java index 8c2d9eb082..d305eea7d7 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/SolrHealthIndicatorTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/SolrHealthIndicatorTests.java @@ -94,8 +94,8 @@ public class SolrHealthIndicatorTests { SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient); Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); - assertThat(((String) health.getDetails().get("error")) - .contains("Connection failed")); + assertThat((String) health.getDetails().get("error")) + .contains("Connection failed"); } private NamedList mockResponse(int status) { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzerTests.java index e40398186b..a3cd952e90 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzerTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -166,8 +166,6 @@ public class NoSuchBeanDefinitionFailureAnalyzerTests { assertThat(analysis.getDescription()).startsWith(String.format( "Constructor in %s required a bean named '%s' that could not be found", StringNameHandler.class.getName(), "test-string")); - assertThat(analysis.getDescription().contains( - "No matching auto-configuration has been found for this bean name.")); assertThat(analysis.getAction()).startsWith(String.format( "Consider defining a bean named '%s' in your configuration.", "test-string")); diff --git a/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverClassNameTests.java b/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverClassNameTests.java index e4bcfa109c..193d5686f2 100644 --- a/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverClassNameTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverClassNameTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 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. @@ -75,8 +75,8 @@ public class DatabaseDriverClassNameTests { @Test public void databaseClassIsOfRequiredType() throws Exception { - assertThat(getInterfaceNames(this.className.replace('.', '/')) - .contains(this.requiredType.getName().replace('.', '/'))); + assertThat(getInterfaceNames(this.className.replace('.', '/'))) + .contains(this.requiredType.getName().replace('.', '/')); } private List getInterfaceNames(String className) throws IOException {