Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
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
openSource
spring-boot-admin
Commits
65b95047
Commit
65b95047
authored
Jun 07, 2018
by
Thomas Bosch
Committed by
Johannes Edmeier
Jun 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish test
parent
b7aa64ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
StatusUpdaterTest.java
...centric/boot/admin/server/services/StatusUpdaterTest.java
+19
-7
No files found.
spring-boot-admin-server/src/test/java/de/codecentric/boot/admin/server/services/StatusUpdaterTest.java
View file @
65b95047
...
...
@@ -25,6 +25,7 @@ import de.codecentric.boot.admin.server.domain.values.Registration;
import
de.codecentric.boot.admin.server.eventstore.ConcurrentMapEventStore
;
import
de.codecentric.boot.admin.server.eventstore.InMemoryEventStore
;
import
de.codecentric.boot.admin.server.web.client.InstanceWebClient
;
import
reactor.core.publisher.Mono
;
import
reactor.test.StepVerifier
;
import
java.time.Duration
;
...
...
@@ -36,8 +37,10 @@ import org.springframework.boot.actuate.endpoint.http.ActuatorMediaType;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
com.github.tomakehurst.wiremock.core.Options
;
import
com.github.tomakehurst.wiremock.http.Fault
;
import
com.github.tomakehurst.wiremock.junit.WireMockClassRule
;
import
static
com
.
github
.
tomakehurst
.
wiremock
.
client
.
WireMock
.
aResponse
;
import
static
com
.
github
.
tomakehurst
.
wiremock
.
client
.
WireMock
.
get
;
import
static
com
.
github
.
tomakehurst
.
wiremock
.
client
.
WireMock
.
ok
;
import
static
com
.
github
.
tomakehurst
.
wiremock
.
client
.
WireMock
.
okForContentType
;
...
...
@@ -66,7 +69,7 @@ public class StatusUpdaterTest {
StepVerifier
.
create
(
repository
.
save
(
instance
)).
expectNextCount
(
1
).
verifyComplete
();
updater
=
new
StatusUpdater
(
repository
,
new
InstanceWebClient
(
instance
->
HttpHeaders
.
EMPTY
,
Duration
.
ofSeconds
(
5
),
Duration
.
ofSeconds
(
2
0
)));
new
InstanceWebClient
(
instance
->
HttpHeaders
.
EMPTY
,
Duration
.
ofSeconds
(
5
),
Duration
.
ofSeconds
(
1
0
)));
}
@Test
...
...
@@ -93,6 +96,16 @@ public class StatusUpdaterTest {
StepVerifier
.
create
(
repository
.
find
(
instance
.
getId
()))
.
assertNext
(
app
->
assertThat
(
app
.
getStatusInfo
().
getStatus
()).
isEqualTo
(
"UP"
))
.
verifyComplete
();
StepVerifier
.
create
(
repository
.
computeIfPresent
(
instance
.
getId
(),
(
key
,
instance
)
->
Mono
.
just
(
instance
.
deregister
())))
.
then
(()
->
StepVerifier
.
create
(
updater
.
updateStatus
(
instance
.
getId
())).
verifyComplete
())
.
thenCancel
()
.
verify
();
StepVerifier
.
create
(
repository
.
find
(
instance
.
getId
()))
.
assertNext
(
app
->
assertThat
(
app
.
getStatusInfo
().
getStatus
()).
isEqualTo
(
"UNKNOWN"
))
.
verifyComplete
();
}
@Test
...
...
@@ -168,21 +181,20 @@ public class StatusUpdaterTest {
@Test
public
void
test_update_offline
()
{
Instance
offlineInstance
=
Instance
.
create
(
InstanceId
.
of
(
"offline"
))
.
register
(
Registration
.
create
(
"foo"
,
"http://0.0.0.0/health"
).
build
());
StepVerifier
.
create
(
repository
.
save
(
offlineInstance
)).
expectNextCount
(
1
).
verifyComplete
();
wireMock
.
stubFor
(
get
(
"/health"
).
willReturn
(
aResponse
().
withFault
(
Fault
.
CONNECTION_RESET_BY_PEER
)));
StepVerifier
.
create
(
eventStore
)
.
expectSubscription
()
.
then
(()
->
StepVerifier
.
create
(
updater
.
updateStatus
(
offlineI
nstance
.
getId
())).
verifyComplete
())
.
then
(()
->
StepVerifier
.
create
(
updater
.
updateStatus
(
i
nstance
.
getId
())).
verifyComplete
())
.
assertNext
(
event
->
assertThat
(
event
).
isInstanceOf
(
InstanceStatusChangedEvent
.
class
))
.
thenCancel
()
.
verify
();
StepVerifier
.
create
(
repository
.
find
(
offlineI
nstance
.
getId
())).
assertNext
(
app
->
{
StepVerifier
.
create
(
repository
.
find
(
i
nstance
.
getId
())).
assertNext
(
app
->
{
assertThat
(
app
.
getStatusInfo
().
getStatus
()).
isEqualTo
(
"OFFLINE"
);
assertThat
(
app
.
getStatusInfo
().
getDetails
()).
containsKeys
(
"message"
,
"exception"
);
}).
verifyComplete
();
StepVerifier
.
create
(
updater
.
updateStatus
(
instance
.
getId
())).
verifyComplete
();
}
}
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