Fixed the remaining tests

This commit is contained in:
Andres Taylor
2011-10-14 17:49:18 +02:00
parent 6cd68b8db2
commit 4e64019e30
3 changed files with 15 additions and 23 deletions

View File

@@ -1,7 +1,5 @@
package org.neo4j.cineasts.domain;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.neo4j.cineasts.repository.MovieRepository;
@@ -26,13 +24,9 @@ public class DomainTest extends RestTestBase {
@Autowired
protected UserRepository userRepository;
@Before
public void setUp() throws Exception {
}
@Test
public void actorCanPlayARoleInAMovie() {
Person tomHanks = new Person("1","Tom Hanks").persist();
Person tomHanks = new Person("1", "Tom Hanks").persist();
Movie forestGump = new Movie("1", "Forrest Gump").persist();
Role role = tomHanks.playedIn(forestGump, "Forrest");
@@ -41,16 +35,15 @@ public class DomainTest extends RestTestBase {
assertEquals("created and looked up movie equal", forestGump, foundForestGump);
Role firstRole = foundForestGump.getRoles().iterator().next();
assertEquals("role forrest",role, firstRole);
assertEquals("role forrest","Forrest", firstRole.getName());
assertEquals("role forrest", role, firstRole);
assertEquals("role forrest", "Forrest", firstRole.getName());
}
@Test
@Ignore("Fails over REST")
public void canFindMovieByTitleQuery() {
Movie forestGump = new Movie("1", "Forrest Gump").persist();
Iterator<Movie> queryResults = movieRepository.findAllByQuery("search", "title", "Forre*").iterator();
assertTrue("found movie by query",queryResults.hasNext());
assertTrue("found movie by query", queryResults.hasNext());
Movie foundMovie = queryResults.next();
assertEquals("created and looked up movie equal", forestGump, foundMovie);
assertFalse("found only one movie by query", queryResults.hasNext());
@@ -58,23 +51,22 @@ public class DomainTest extends RestTestBase {
@Test
public void userCanRateMovie() {
Movie movie= new Movie("1","Forrest Gump").persist();
User user = new User("ich","Micha","password").persist();
Movie movie = new Movie("1", "Forrest Gump").persist();
User user = new User("ich", "Micha", "password").persist();
Rating awesome = user.rate(movie, 5, "Awesome");
User foundUser = userRepository.findByPropertyValue("login", "ich");
Rating rating = user.getRatings().iterator().next();
assertEquals(awesome,rating);
assertEquals("Awesome",rating.getComment());
assertEquals(5,rating.getStars());
assertEquals(5,movie.getStars(),0);
assertEquals(awesome, rating);
assertEquals("Awesome", rating.getComment());
assertEquals(5, rating.getStars());
assertEquals(5, movie.getStars(), 0);
}
@Test
@Ignore("Fails over REST")
public void canFindUserByLogin() {
User user = new User("ich","Micha","password").persist();
User user = new User("ich", "Micha", "password").persist();
User foundUser = userRepository.findByPropertyValue("login", "ich");
assertEquals(user, foundUser);
}

View File

@@ -1,5 +1,6 @@
package org.neo4j.cineasts.movieimport;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.neo4j.cineasts.domain.Movie;
@@ -20,6 +21,7 @@ import static org.junit.Assert.assertEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/movies-test-context.xml"})
@Transactional
@Ignore("Should not be run nilly-willy - talks with http://api.themoviedb.org")
public class MovieDbImportServiceTest extends RestTestBase {
@Autowired

View File

@@ -5,6 +5,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.neo4j.cineasts.domain.Movie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.rest.support.RestTestBase;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
@@ -23,12 +24,11 @@ import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/movies-test-context.xml"})
@Transactional
public class MoviesRepositoryTest {
public class MoviesRepositoryTest extends RestTestBase {
@Autowired
CineastsRepository repository;
@Test
@Ignore("Fails over REST")
public void testGetMovie() throws Exception {
Movie movie = new Movie("1", "Test-Movie").persist();
Movie found = repository.getMovie("1");
@@ -37,7 +37,6 @@ public class MoviesRepositoryTest {
}
@Test
@Ignore("Fails over REST")
public void testFindTwoMovies() throws Exception {
Movie movie1 = new Movie("1", "Test-Movie1").persist();
Movie movie2 = new Movie("2", "Test-Movie2").persist();
@@ -48,7 +47,6 @@ public class MoviesRepositoryTest {
}
@Test
@Ignore("Fails over REST")
public void testFindTwoMoviesButRestrictToOne() throws Exception {
Movie movie1 = new Movie("1", "Test-Movie1").persist();
Movie movie2 = new Movie("2", "Test-Movie2").persist();