Revert "JAVA-20167 Changes in MovieRepositoryIntegrationTest"

This reverts commit b50712ae42.
This commit is contained in:
n 2023-06-15 20:37:24 +03:00
parent 19039a3d2e
commit 17d635bd0d
2 changed files with 21 additions and 58 deletions

View File

@ -105,18 +105,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j.test</groupId>
<artifactId>neo4j-harness</artifactId>
<version>5.5.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>

View File

@ -1,9 +1,5 @@
package com.baeldung.spring.data.neo4j;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import com.baeldung.spring.data.neo4j.config.MovieDatabaseNeo4jTestConfiguration;
import com.baeldung.spring.data.neo4j.domain.Movie;
import com.baeldung.spring.data.neo4j.domain.Person;
@ -11,44 +7,37 @@ import com.baeldung.spring.data.neo4j.domain.Role;
import com.baeldung.spring.data.neo4j.repository.MovieRepository;
import com.baeldung.spring.data.neo4j.repository.PersonRepository;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.neo4j.harness.Neo4j;
import org.neo4j.harness.Neo4jBuilders;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.*;
import static junit.framework.TestCase.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MovieDatabaseNeo4jTestConfiguration.class)
@ActiveProfiles(profiles = "test")
@DataNeo4jTest
class MovieRepositoryIntegrationTest {
public class MovieRepositoryIntegrationTest {
@Autowired
private static MovieRepository movieRepository;
private MovieRepository movieRepository;
@Autowired
private static PersonRepository personRepository;
private PersonRepository personRepository;
public MovieRepositoryIntegrationTest() {
}
private static Neo4j embeddedDatabaseServer;
@BeforeAll
static void initializeNeo4j() {
embeddedDatabaseServer = Neo4jBuilders.newInProcessBuilder()
.withDisabledServer()
.build();
@Before
public void initializeDatabase() {
System.out.println("seeding embedded database");
Movie italianJob = new Movie();
italianJob.setTitle("The Italian Job");
@ -71,23 +60,9 @@ class MovieRepositoryIntegrationTest {
movieRepository.save(italianJob);
}
@DynamicPropertySource
static void neo4jProperties(DynamicPropertyRegistry registry) {
registry.add("spring.neo4j.uri", embeddedDatabaseServer::boltURI);
registry.add("spring.neo4j.authentication.username", () -> "neo4j");
registry.add("spring.neo4j.authentication.password", () -> null);
}
@AfterAll
static void stopNeo4j() {
embeddedDatabaseServer.close();
}
@Test
@DirtiesContext
void testFindByTitle() {
public void testFindByTitle() {
System.out.println("findByTitle");
String title = "The Italian Job";
Movie result = movieRepository.findByTitle(title);
@ -97,7 +72,7 @@ class MovieRepositoryIntegrationTest {
@Test
@DirtiesContext
void testCount() {
public void testCount() {
System.out.println("count");
long movieCount = movieRepository.count();
@ -106,7 +81,7 @@ class MovieRepositoryIntegrationTest {
@Test
@DirtiesContext
void testFindAll() {
public void testFindAll() {
System.out.println("findAll");
Collection<Movie> result = movieRepository.findAll();
assertNotNull(result);
@ -115,7 +90,7 @@ class MovieRepositoryIntegrationTest {
@Test
@DirtiesContext
void testFindByTitleContaining() {
public void testFindByTitleContaining() {
System.out.println("findByTitleContaining");
String title = "Italian";
Collection<Movie> result = movieRepository.findByTitleContaining(title);
@ -125,7 +100,7 @@ class MovieRepositoryIntegrationTest {
@Test
@DirtiesContext
void testGraph() {
public void testGraph() {
System.out.println("graph");
List<Map<String, Object>> graph = movieRepository.graph(5);
assertEquals(1, graph.size());
@ -139,7 +114,7 @@ class MovieRepositoryIntegrationTest {
@Test
@DirtiesContext
void testDeleteMovie() {
public void testDeleteMovie() {
System.out.println("deleteMovie");
movieRepository.delete(movieRepository.findByTitle("The Italian Job"));
assertNull(movieRepository.findByTitle("The Italian Job"));
@ -147,7 +122,7 @@ class MovieRepositoryIntegrationTest {
@Test
@DirtiesContext
void testDeleteAll() {
public void testDeleteAll() {
System.out.println("deleteAll");
movieRepository.deleteAll();
Collection<Movie> result = movieRepository.findAll();