@DataJpaTest: This is Spring Boot’s test annotation and indicates that we want it to perform all of its automated scanning of entity class definitions and Spring Data JPA repositories.
@Autowired VideoRepository: Automatically injects an instance of our VideoRepository object to test against.
@BeforeEach: This is JUnit 5’s annotation and ensures that this method runs before each test method.
repository.saveAll(): Using VideoRepository, it saves a batch of test data.
xxxxxxxxxx
@DataJpaTest
public class VideoRepositoryHsqlTest {
@Autowired VideoRepository repository;
@BeforeEach
void setUp() {
repository.saveAll( //
List.of( //
new VideoEntity( //
"alice", //
"Need HELP with your SPRING BOOT 3 App?", //
"SPRING BOOT 3 will only speed things up."),
new VideoEntity("alice", //
"Don't do THIS to your own CODE!", //
"As a pro developer, never ever EVER do this to
your code."),
new VideoEntity("bob", //
"SECRETS to fix BROKEN CODE!", //
"Discover ways to not only debug your code")));
}
}