Skip to content

Commit

Permalink
chore: clean codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hantsy committed Nov 27, 2022
1 parent f8f8d28 commit c21f589
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.demo;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -20,6 +21,7 @@

import java.time.Duration;
import java.util.List;
import java.util.concurrent.CountDownLatch;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -59,16 +61,22 @@ public void initialize(ConfigurableApplicationContext configurableApplicationCon
@Autowired
private PostRepository posts;

@SneakyThrows
@BeforeEach
public void setup() {
var countDownLatch = new CountDownLatch(1);
this.posts
.saveAll(
List.of(
Post.builder().title("Post one").content("content of post one").build(),
Post.builder().title("Post two").content("content of post two").build()
)
)
.subscribe(data -> log.debug("saved data: {}", data));
.subscribe(data -> {
log.debug("saved data: {}", data);
countDownLatch.countDown();;
});
countDownLatch.await(1000, java.util.concurrent.TimeUnit.MILLISECONDS);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ public void setup() {
Post.builder().title("Post two").content("content of post two").build()
)
)
.doOnTerminate(countDownLatch::countDown)
.subscribe(data -> log.debug("saved data: {}", data));
//.doOnTerminate(countDownLatch::countDown)
.subscribe(data -> {
log.debug("saved data: {}", data);
countDownLatch.countDown();
});

countDownLatch.await(1000, java.util.concurrent.TimeUnit.MILLISECONDS);
}
Expand Down

0 comments on commit c21f589

Please sign in to comment.