updating test cases

This commit is contained in:
Sameera 2016-06-28 23:48:45 +05:30
parent 548365130a
commit 31b3e0fa16
2 changed files with 33 additions and 35 deletions

View File

@ -23,8 +23,6 @@ public class Movie {
@Relationship(type="ACTED_IN", direction = Relationship.INCOMING) private List<Role> roles; @Relationship(type="ACTED_IN", direction = Relationship.INCOMING) private List<Role> roles;
// end::movie[]
public Movie() { } public Movie() { }
public String getTitle() { public String getTitle() {

View File

@ -37,26 +37,26 @@ public class MovieRepositoryTest {
@Before @Before
public void initializeDatabase() { public void initializeDatabase() {
System.out.println("seeding embedded database"); System.out.println("seeding embedded database");
Movie matrix = new Movie(); Movie italianJob = new Movie();
matrix.setTitle("The Italian Job"); italianJob.setTitle("The Italian Job");
matrix.setReleased(1999); italianJob.setReleased(1999);
instance.save(matrix); instance.save(italianJob);
Person mark = new Person(); Person mark = new Person();
mark.setName("Mark Wahlberg"); mark.setName("Mark Wahlberg");
personRepository.save(mark); personRepository.save(mark);
Role neo = new Role(); Role charlie = new Role();
neo.setMovie(matrix); charlie.setMovie(italianJob);
neo.setPerson(mark); charlie.setPerson(mark);
Collection<String> roleNames = new HashSet(); Collection<String> roleNames = new HashSet();
roleNames.add("Charlie Croker"); roleNames.add("Charlie Croker");
neo.setRoles(roleNames); charlie.setRoles(roleNames);
List<Role> roles = new ArrayList(); List<Role> roles = new ArrayList();
roles.add(neo); roles.add(charlie);
matrix.setRoles(roles); italianJob.setRoles(roles);
instance.save(matrix); instance.save(italianJob);
} }
@Test @Test
@ -96,20 +96,20 @@ public class MovieRepositoryTest {
Collection<Movie> result = Collection<Movie> result =
instance.findByTitleContaining(title); instance.findByTitleContaining(title);
assertNotNull(result); assertNotNull(result);
assertEquals(1,result.size()); assertEquals(1, result.size());
} }
@Test @Test
@DirtiesContext @DirtiesContext
public void testGraph() { public void testGraph() {
System.out.println("graph"); System.out.println("graph");
List<Map<String,Object>> graph = instance.graph(5); List<Map<String, Object>> graph = instance.graph(5);
assertEquals(1,graph.size()); assertEquals(1, graph.size());
Map<String,Object> map = graph.get(0); Map<String, Object> map = graph.get(0);
assertEquals(2,map.size()); assertEquals(2, map.size());
String[] cast = (String[])map.get("cast"); String[] cast = (String[]) map.get("cast");
String movie = (String)map.get("movie"); String movie = (String) map.get("movie");
assertEquals("The Italian Job",movie); assertEquals("The Italian Job", movie);
assertEquals("Mark Wahlberg", cast[0]); assertEquals("Mark Wahlberg", cast[0]);
} }
@ -128,6 +128,6 @@ public class MovieRepositoryTest {
instance.deleteAll(); instance.deleteAll();
Collection<Movie> result = Collection<Movie> result =
(Collection<Movie>) instance.findAll(); (Collection<Movie>) instance.findAll();
assertEquals(0,result.size()); assertEquals(0, result.size());
} }
} }