fix multiple sql files test
This commit is contained in:
parent
fd47fa836d
commit
b8af6bec2b
|
@ -4,6 +4,7 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.boot.domain.User;
|
import com.baeldung.boot.domain.User;
|
||||||
|
@ -18,7 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DataJpaTest
|
@DataJpaTest
|
||||||
public class UserRepositoryIntegrationTest {
|
@ActiveProfiles("multiplesqlfiles")
|
||||||
|
public class UserRepositoryMultipleSqlFilesIntTest {
|
||||||
|
|
||||||
@Autowired private UserRepository userRepository;
|
@Autowired private UserRepository userRepository;
|
||||||
|
|
||||||
|
@ -26,7 +28,7 @@ public class UserRepositoryIntegrationTest {
|
||||||
public void givenTwoImportFilesWhenFindAllShouldReturnSixUsers() {
|
public void givenTwoImportFilesWhenFindAllShouldReturnSixUsers() {
|
||||||
Collection<User> users = userRepository.findAll();
|
Collection<User> users = userRepository.findAll();
|
||||||
|
|
||||||
assertThat(users.size()).isEqualTo(3);
|
assertThat(users.size()).isEqualTo(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,6 +25,7 @@ public class UserRepositoryIntegrationTest {
|
||||||
userRepository.save(new User("Bob", "bob@domain.com"));
|
userRepository.save(new User("Bob", "bob@domain.com"));
|
||||||
List<User> users = (List<User>) userRepository.findAll();
|
List<User> users = (List<User>) userRepository.findAll();
|
||||||
|
|
||||||
|
// 2 additional users are saved in the CommandLineRunner bean
|
||||||
assertThat(users.size()).isEqualTo(3);
|
assertThat(users.size()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
spring.jpa.properties.hibernate.hbm2ddl.import_files=import_active_users.sql,import_inactive_users.sql
|
Loading…
Reference in New Issue