a movie can apparently have more then one director, as this was failing when the mapping was a single
This commit is contained in:
@@ -253,20 +253,62 @@
|
||||
<version>4.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>7.1.2.v20100523</version>
|
||||
<configuration>
|
||||
<webAppConfig>
|
||||
<contextPath>/</contextPath>
|
||||
</webAppConfig>
|
||||
<!--scanIntervalSeconds>1</scanIntervalSeconds -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>7.6.5.v20120716</version>
|
||||
<configuration>
|
||||
<scanIntervalSeconds>10</scanIntervalSeconds>
|
||||
<stopKey>foo</stopKey>
|
||||
<stopPort>9999</stopPort>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-jetty</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<scanIntervalSeconds>0</scanIntervalSeconds>
|
||||
<daemon>true</daemon>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>stop-jetty</id>
|
||||
<phase>post-integration-test</phase>
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<!-- Must use java 1.5 or higher for annotations -->
|
||||
@@ -281,6 +323,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.1</version>
|
||||
<configuration>
|
||||
<useFile>true</useFile>
|
||||
<includes>
|
||||
|
||||
@@ -234,5 +234,8 @@ public class Movie {
|
||||
return nodeId != null ? nodeId.hashCode() : super.hashCode();
|
||||
}
|
||||
|
||||
public Set<Director> getDirectors() {
|
||||
return directors;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<context:spring-configured/>
|
||||
|
||||
<neo4j:config storeDirectory="data/graph.db"/>
|
||||
<neo4j:config storeDirectory="target/data/graph.db"/>
|
||||
<neo4j:repositories base-package="org.neo4j.cineasts.repository"/>
|
||||
|
||||
<!--neo4j:config graphDatabaseService="graphDatabaseService"/>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.neo4j.cineasts.integrationtests;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class DatabasePopulationIT {
|
||||
@Test
|
||||
public void shouldPopulateDatabase() throws Exception {
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpGet httpget = new HttpGet("http://localhost:8080/populate");
|
||||
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), is(200));
|
||||
assertThat(getContent(response), Matchers.containsString("Neo"));
|
||||
}
|
||||
|
||||
private String getContent(HttpResponse response) throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
response.getEntity().writeTo(buffer);
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.neo4j.cineasts.movieimport;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.neo4j.cineasts.domain.Actor;
|
||||
import org.neo4j.cineasts.domain.Director;
|
||||
import org.neo4j.cineasts.domain.Movie;
|
||||
import org.neo4j.cineasts.domain.Person;
|
||||
import org.neo4j.cineasts.repository.MovieRepository;
|
||||
@@ -11,7 +12,11 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author mh
|
||||
@@ -49,4 +54,13 @@ public class MovieDbImportServiceTest {
|
||||
assertEquals("movie-id","105955", actor.getId());
|
||||
assertEquals("movie-title","George M. Williamson", actor.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldImportMovieWithTwoDirectors() throws Exception {
|
||||
Movie movie = importService.importMovie("603");
|
||||
|
||||
movie = movieRepository.findById(movie.getId());
|
||||
|
||||
assertThat(movie.getDirectors().size(), is(2));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user