JAVA-22075 move Blaze persistence module to Spring Boot parent two (#14196)

* JAVA-22075 move Blaze persistence module to Spring Boot parent two

* JAVA-22075 remove unnecessary TestContextConfig file
This commit is contained in:
Kasra Madadipouya 2023-06-10 08:25:24 +02:00 committed by GitHub
parent 28cec53e65
commit 5a1906d88c
5 changed files with 30 additions and 50 deletions

View File

@ -8,10 +8,10 @@
<name>blaze-persistence</name> <name>blaze-persistence</name>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>com.baeldung</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>parent-boot-2</artifactId>
<version>2.4.0</version> <version>0.0.1-SNAPSHOT</version>
<relativePath/> <relativePath>../../parent-boot-2</relativePath>
</parent> </parent>
<dependencyManagement> <dependencyManagement>
@ -42,7 +42,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.blazebit</groupId> <groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5.4</artifactId> <artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
</dependency> </dependency>
<!-- Entity View dependencies --> <!-- Entity View dependencies -->
<dependency> <dependency>
@ -64,7 +64,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.blazebit</groupId> <groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-spring-data-2.4</artifactId> <artifactId>blaze-persistence-integration-spring-data-2.7</artifactId>
</dependency> </dependency>
<!-- Spring dependencies --> <!-- Spring dependencies -->
<dependency> <dependency>
@ -81,8 +81,8 @@
</dependency> </dependency>
<!-- Test dependencies --> <!-- Test dependencies -->
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -7,3 +7,4 @@ spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa spring.datasource.username=sa
spring.datasource.password=sa spring.datasource.password=sa
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.defer-datasource-initialization=true

View File

@ -1,21 +1,19 @@
package com.baeldung; package com.baeldung;
import com.baeldung.model.Person; import static org.junit.jupiter.api.Assertions.assertEquals;
import com.baeldung.model.Post;
import com.baeldung.repository.PersonRepository;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@ContextConfiguration(classes = TestContextConfig.class) import com.baeldung.model.Person;
@ExtendWith(SpringExtension.class) import com.baeldung.model.Post;
import com.baeldung.repository.PersonRepository;
@SpringBootTest
public class PersonUnitTest { public class PersonUnitTest {
@Autowired @Autowired

View File

@ -1,23 +1,21 @@
package com.baeldung; package com.baeldung;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.baeldung.model.Post; import com.baeldung.model.Post;
import com.baeldung.repository.PostRepository; import com.baeldung.repository.PostRepository;
import com.baeldung.repository.PostViewRepository; import com.baeldung.repository.PostViewRepository;
import com.baeldung.view.PostView; import com.baeldung.view.PostView;
import com.baeldung.view.PostWithAuthorView; import com.baeldung.view.PostWithAuthorView;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.ArrayList; @SpringBootTest
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ContextConfiguration(classes = TestContextConfig.class)
@ExtendWith(SpringExtension.class)
public class PostUnitTest { public class PostUnitTest {
@Autowired @Autowired
@ -36,8 +34,7 @@ public class PostUnitTest {
@Test @Test
public void givenPostIdAndAuthorName_whenFind_thenReturnCorrectResult() { public void givenPostIdAndAuthorName_whenFind_thenReturnCorrectResult() {
final Iterable<PostWithAuthorView> listIterable = final Iterable<PostWithAuthorView> listIterable = postRepository.findBy("Spring", "Peter");
postRepository.findBy("Spring", "Peter");
final List<PostView> list = new ArrayList<>(); final List<PostView> list = new ArrayList<>();
listIterable.forEach(list::add); listIterable.forEach(list::add);
assertEquals(4, list.size()); assertEquals(4, list.size());
@ -50,5 +47,4 @@ public class PostUnitTest {
listIterable.forEach(list::add); listIterable.forEach(list::add);
assertEquals(7, list.size()); assertEquals(7, list.size());
} }
} }

View File

@ -1,15 +0,0 @@
package com.baeldung;
import com.blazebit.persistence.integration.view.spring.EnableEntityViews;
import com.blazebit.persistence.spring.data.repository.config.EnableBlazeRepositories;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.baeldung")
@EnableEntityViews(basePackages = {"com.baeldung.view"})
@EnableBlazeRepositories(basePackages = "com.baeldung.repository")
public class TestContextConfig {
}