* BAEL-1412 add java 8 spring data features

* BAEL-21 new HTTP API overview

* BAEL-21 fix executor

* BAEL-1432 add custom gradle task

* BAEL-1567 add samples of cookie and session in serlvet

* BAEL-1567 use stream api

* BAEL-1567 fix optional

* BAEL-1679 add query annotation jpa spring data

* BAEL-1679 added new junits

* BAEL-1679 use assertJ, use givenWhenThen naming convention

* BAEL-1679 move query annotation examples to persistence modules

* BAEL-1679 fix formatting

* BAEL-659 add junits for repositories

* BAEL-659 add one junit

* BAEL-659 remove one duplicated dependency

* BAEL-659 fix test class name

* BAEL-1924 add import many files
This commit is contained in:
abialas 2018-06-26 23:54:11 +02:00 committed by maibin
parent 0e97b9d21b
commit b1b34e2fca
9 changed files with 48 additions and 9 deletions

View File

@ -1,4 +1,4 @@
package org.baeldung.model;
package org.baeldung.boot.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -1,6 +1,6 @@
package org.baeldung.repository;
package org.baeldung.boot.repository;
import org.baeldung.model.User;
import org.baeldung.boot.domain.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

View File

@ -3,7 +3,7 @@ package org.baeldung.endpoints.info;
import java.util.HashMap;
import java.util.Map;
import org.baeldung.repository.UserRepository;
import org.baeldung.boot.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;

View File

@ -0,0 +1,30 @@
package org.baeldung.boot.repository;
import org.baeldung.boot.domain.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Collection;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Created by adam.
*/
@RunWith(SpringRunner.class)
@DataJpaTest
public class UserRepositoryDataJpaIntegrationTest {
@Autowired private UserRepository userRepository;
@Test
public void givenTwoImportFilesWhenFindAllShouldReturnSixUsers() {
Collection<User> users = userRepository.findAll();
assertThat(users.size()).isEqualTo(6);
}
}

View File

@ -1,7 +1,7 @@
package org.baeldung.repository;
package org.baeldung.boot.repository;
import org.baeldung.boot.config.H2JpaConfig;
import org.baeldung.model.User;
import org.baeldung.boot.domain.User;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -27,8 +27,7 @@ public class UserRepositoryIntegrationTest {
private final String USER_NAME_ADAM = "Adam";
private final Integer ACTIVE_STATUS = 1;
@Autowired
private UserRepository userRepository;
@Autowired private UserRepository userRepository;
@Test
public void givenEmptyDBWhenFindOneByNameThenReturnEmptyOptional() {

View File

@ -2,3 +2,5 @@ spring.datasource.url=jdbc:mysql://localhost:3306/employee_int_test
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
spring.datasource.data=import_*_users.sql

View File

@ -16,4 +16,6 @@ hibernate.show_sql=true
hibernate.hbm2ddl.auto=create-drop
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
spring.jpa.properties.hibernate.hbm2ddl.import_files=import_active_users.sql,import_inactive_users.sql

View File

@ -0,0 +1,3 @@
insert into USERS(name, status, id) values('Peter', 1, 1);
insert into USERS(name, status, id) values('David', 1, 2);
insert into USERS(name, status, id) values('Ed', 1, 3);

View File

@ -0,0 +1,3 @@
insert into users(name, status, id) values('Monica', 0, 4);
insert into users(name, status, id) values('Paul', 0, 5);
insert into users(name, status, id) values('George', 0, 6);