Last active
May 7, 2020 21:06
-
-
Save lovewithmind/32a92424396bfd449ad91ac8afe2649b to your computer and use it in GitHub Desktop.
Using StepVerifier to test async Publisher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `should return person data given name of the person`(){ | |
val monoPerson = PersonManager.getProfile("PersonX") | |
val expectedResult = Person(name = "PersonX", age = 18) | |
StepVerifier.create(monoPerson) | |
.expectNext(expectedResult) | |
.verifyComplete() | |
} | |
@Test | |
fun `should return list of person data`(){ | |
val fluxList = PersonManager.getAllProfile() | |
StepVerifier.create(fluxList) | |
.expectNext(Person(name = "PersonX", age = 18)) | |
.expectNext(Person(name = "PersonY", age = 20)) | |
.verifyComplete() | |
} | |
@Test | |
fun `should wait for 12 second`() { | |
StepVerifier.withVirtualTime { Mono.delay(Duration.ofSeconds(12)) } | |
.thenAwait(Duration.ofSeconds(12)) | |
.expectNextCount(1) | |
.expectComplete() | |
.verify() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment