This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into features/interceptors
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/test/java/de/sample/schulung/spring/blog/persistence/JpaBlogPostSinkTests.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.sample.schulung.spring.blog.persistence; | ||
|
||
import de.sample.schulung.spring.blog.domain.BlogPost; | ||
import de.sample.schulung.spring.blog.domain.BlogPostSink; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.ComponentScan; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@DataJpaTest | ||
@ComponentScan(basePackageClasses = JpaBlogPostSinkTests.class) | ||
public class JpaBlogPostSinkTests { | ||
|
||
@Autowired | ||
BlogPostSink sink; | ||
|
||
/* | ||
* Testfall: | ||
* - Erzeugen eines Blogposts -> Liste der BlogPosts: Länge=1 mit dem einem BlogPost | ||
*/ | ||
@Test | ||
void shouldReturnCreatedBlogPost() { | ||
final var post = BlogPost.builder() | ||
.title("test") | ||
.content("Das ist der Content") | ||
.timestamp(LocalDateTime.now()) | ||
.build(); | ||
sink.create(post); | ||
assertThat(post.getId()) | ||
.isNotNull(); | ||
assertThat(sink.findAll()) | ||
.hasSize(1) | ||
.first() | ||
.extracting(BlogPost::getId) | ||
.isEqualTo(post.getId()); | ||
} | ||
|
||
} |