Skip to content

Commit 4509164

Browse files
committed
Polish "Add unit test for cassandra health checker"
Closes gh-15583
1 parent db22a81 commit 4509164

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cassandra/CassandraHealthIndicatorTests.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.data.cassandra.core.cql.CqlOperations;
2828

2929
import static org.assertj.core.api.Assertions.assertThat;
30+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
3031
import static org.mockito.ArgumentMatchers.any;
3132
import static org.mockito.BDDMockito.given;
3233
import static org.mockito.Mockito.mock;
@@ -36,12 +37,12 @@
3637
*
3738
* @author Oleksii Bondar
3839
*/
39-
4040
public class CassandraHealthIndicatorTests {
4141

42-
@Test(expected = IllegalArgumentException.class)
43-
public void throwsExceptionOnNullCassandraOperations() {
44-
new CassandraHealthIndicator(null);
42+
@Test
43+
public void createWhenCassandraOperationsIsNullShouldThrowException() {
44+
assertThatIllegalArgumentException()
45+
.isThrownBy(() -> new CassandraHealthIndicator(null));
4546
}
4647

4748
@Test
@@ -54,9 +55,7 @@ public void verifyHealthStatusWhenExhausted() {
5455
given(cassandraOperations.getCqlOperations()).willReturn(cqlOperations);
5556
given(cqlOperations.queryForResultSet(any(Select.class))).willReturn(resultSet);
5657
given(resultSet.isExhausted()).willReturn(true);
57-
5858
Health health = healthIndicator.health();
59-
6059
assertThat(health.getStatus()).isEqualTo(Status.UP);
6160
}
6261

@@ -74,9 +73,7 @@ public void verifyHealthStatusWithVersion() {
7473
given(resultSet.one()).willReturn(row);
7574
String expectedVersion = "1.0.0";
7675
given(row.getString(0)).willReturn(expectedVersion);
77-
7876
Health health = healthIndicator.health();
79-
8077
assertThat(health.getStatus()).isEqualTo(Status.UP);
8178
assertThat(health.getDetails().get("version")).isEqualTo(expectedVersion);
8279
}

0 commit comments

Comments
 (0)