2019-10-31 20:43:47 -05:00
|
|
|
package com.baeldung;
|
|
|
|
|
|
|
|
|
|
import com.baeldung.h2db.springboot.SpringBootH2Application;
|
2021-11-16 20:44:48 +00:00
|
|
|
import com.baeldung.h2db.springboot.daos.CountryRepository;
|
|
|
|
|
import com.baeldung.h2db.springboot.models.Country;
|
2019-10-31 20:43:47 -05:00
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
2021-11-16 20:44:48 +00:00
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
2019-10-31 20:43:47 -05:00
|
|
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
|
|
|
@SpringBootTest(classes = SpringBootH2Application.class)
|
|
|
|
|
public class SpringBootH2IntegrationTest {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2021-11-16 20:44:48 +00:00
|
|
|
private CountryRepository countryRepository;
|
2019-10-31 20:43:47 -05:00
|
|
|
|
|
|
|
|
@Test
|
2021-11-16 20:44:48 +00:00
|
|
|
public void givenInitData_whenApplicationStarts_thenDataIsLoaded() {
|
|
|
|
|
Iterable<Country> users = countryRepository.findAll();
|
2019-10-31 20:43:47 -05:00
|
|
|
|
2021-11-16 20:44:48 +00:00
|
|
|
assertThat(users).hasSize(5);
|
2019-10-31 20:43:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|