Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into features/interceptors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Ueberfuhr committed Dec 22, 2023
2 parents 3a4c7f1 + db18f58 commit 3ace7ba
Showing 1 changed file with 42 additions and 0 deletions.
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());
}

}

0 comments on commit 3ace7ba

Please sign in to comment.