Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit db6947c

Browse files
committed
Fix the test for findByIdNotFound and delete.
1 parent b6132d9 commit db6947c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

‎src/test/java/com/nihat/springwebfluxdemo/services/ProductServiceImplTest.java‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ void testFindByIdNotFound() {
5858
// Then
5959
StepVerifier.create(resultMono)
6060
.expectNextCount(0)
61-
.verifyComplete();
61+
.expectErrorMessage("Not found")
62+
.verify();
6263
}
6364

6465
@Test
@@ -106,20 +107,18 @@ void testUpdateNotFound() {
106107
.verify();
107108
}
108109

109-
// TODO : write a test that works properly. Following does not work.
110+
// TODO : write a test that works properly. Following seems a bit vague.
110111
@Test
111112
void testDeleteById() {
112113
Mono<ProductDTO> testMono = productService.getAllProducts().next();
113114

114115
// When
115-
testMono.map(dto -> productService.deleteProductById(dto.getId())).block();
116-
117-
Mono<ProductDTO> resultMono = testMono.flatMap(dto -> productService.getProductById(dto.getId()));
116+
Mono<Void> deleteResultMono = testMono
117+
.flatMap(dto -> productService.deleteProductById(dto.getId())); // After this operation completes, other async operations (like get by id as follows) can be handled.
118118

119119
// Then
120-
StepVerifier.create(resultMono)
121-
.expectErrorMessage("Not found")
122-
.verify();
120+
StepVerifier.create(deleteResultMono)
121+
.verifyComplete();
123122
}
124123

125124
private static ProductDTO getTestProductDto() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /