Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
45091647
Commit
45091647
authored
Dec 30, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Add unit test for cassandra health checker"
Closes gh-15583
parent
db22a817
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
CassandraHealthIndicatorTests.java
...boot/actuate/cassandra/CassandraHealthIndicatorTests.java
+5
-8
No files found.
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cassandra/CassandraHealthIndicatorTests.java
View file @
45091647
...
@@ -27,6 +27,7 @@ import org.springframework.data.cassandra.core.CassandraOperations;
...
@@ -27,6 +27,7 @@ import org.springframework.data.cassandra.core.CassandraOperations;
import
org.springframework.data.cassandra.core.cql.CqlOperations
;
import
org.springframework.data.cassandra.core.cql.CqlOperations
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalArgumentException
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
@@ -36,12 +37,12 @@ import static org.mockito.Mockito.mock;
...
@@ -36,12 +37,12 @@ import static org.mockito.Mockito.mock;
*
*
* @author Oleksii Bondar
* @author Oleksii Bondar
*/
*/
public
class
CassandraHealthIndicatorTests
{
public
class
CassandraHealthIndicatorTests
{
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
public
void
throwsExceptionOnNullCassandraOperations
()
{
public
void
createWhenCassandraOperationsIsNullShouldThrowException
()
{
new
CassandraHealthIndicator
(
null
);
assertThatIllegalArgumentException
()
.
isThrownBy
(()
->
new
CassandraHealthIndicator
(
null
));
}
}
@Test
@Test
...
@@ -54,9 +55,7 @@ public class CassandraHealthIndicatorTests {
...
@@ -54,9 +55,7 @@ public class CassandraHealthIndicatorTests {
given
(
cassandraOperations
.
getCqlOperations
()).
willReturn
(
cqlOperations
);
given
(
cassandraOperations
.
getCqlOperations
()).
willReturn
(
cqlOperations
);
given
(
cqlOperations
.
queryForResultSet
(
any
(
Select
.
class
))).
willReturn
(
resultSet
);
given
(
cqlOperations
.
queryForResultSet
(
any
(
Select
.
class
))).
willReturn
(
resultSet
);
given
(
resultSet
.
isExhausted
()).
willReturn
(
true
);
given
(
resultSet
.
isExhausted
()).
willReturn
(
true
);
Health
health
=
healthIndicator
.
health
();
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
}
}
...
@@ -74,9 +73,7 @@ public class CassandraHealthIndicatorTests {
...
@@ -74,9 +73,7 @@ public class CassandraHealthIndicatorTests {
given
(
resultSet
.
one
()).
willReturn
(
row
);
given
(
resultSet
.
one
()).
willReturn
(
row
);
String
expectedVersion
=
"1.0.0"
;
String
expectedVersion
=
"1.0.0"
;
given
(
row
.
getString
(
0
)).
willReturn
(
expectedVersion
);
given
(
row
.
getString
(
0
)).
willReturn
(
expectedVersion
);
Health
health
=
healthIndicator
.
health
();
Health
health
=
healthIndicator
.
health
();
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
health
.
getDetails
().
get
(
"version"
)).
isEqualTo
(
expectedVersion
);
assertThat
(
health
.
getDetails
().
get
(
"version"
)).
isEqualTo
(
expectedVersion
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment