コード例 #1
0
 @Test
 public void listing3_2_create_single_user() {
   usersAndMovies.createSingleUser();
   try (Transaction tx = graphDb.beginTx()) {
     assertNotNull(graphDb.getNodeById(0));
     tx.success();
   }
 }
コード例 #2
0
 @Test
 public void listing3_7_create_movies() {
   try (Transaction tx = graphDb.beginTx()) {
     assertNotNull(graphDb.getNodeById(3));
     assertNotNull(graphDb.getNodeById(4));
     assertNotNull(graphDb.getNodeById(5));
     tx.success();
   }
 }
コード例 #3
0
 @Test
 public void listing3_3_create_multiple_users() {
   usersAndMovies.createMultipleUsersInSingleTransaction();
   try (Transaction tx = graphDb.beginTx()) {
     assertNotNull(graphDb.getNodeById(1));
     assertNotNull(graphDb.getNodeById(2));
     tx.success();
   }
 }
コード例 #4
0
 @Test
 public void listing3_11_node_labels_and_property() {
   try {
     usersAndMovies.addLabelToMovies();
   } catch (Exception e) {
     // ignore if index already exist
   }
   try (Transaction tx = graphDb.beginTx()) {
     ResourceIterable<Node> movies =
         graphDb.findNodesByLabelAndProperty(DynamicLabel.label("MOVIES"), "name", "Fargo");
     assertEquals(1, IteratorUtil.count(movies));
     tx.success();
   }
 }
コード例 #5
0
 @Test
 public void listing3_4_create_realationships_between_users() {
   usersAndMovies.createSimpleRelationshipsBetweenUsers();
   try (Transaction tx = graphDb.beginTx()) {
     assertTrue(usersAndMovies.user1.hasRelationship(MyRelationshipTypes.IS_FRIEND_OF));
     tx.success();
   }
 }
コード例 #6
0
 @Test
 public void listing3_8_add_type_properties_to_all_nodes() {
   usersAndMovies.addTypePropertiesToNodes();
   try (Transaction tx = graphDb.beginTx()) {
     assertEquals("User", usersAndMovies.user1.getProperty("type"));
     assertEquals("Movie", usersAndMovies.movie1.getProperty("type"));
     tx.success();
   }
 }
コード例 #7
0
 @Test
 public void listing3_6_add_more_properties_to_user_nodes() {
   usersAndMovies.addMorePropertiesToUsers();
   try (Transaction tx = graphDb.beginTx()) {
     assertTrue(usersAndMovies.user1.hasProperty("year_of_birth"));
     assertEquals(1982, usersAndMovies.user1.getProperty("year_of_birth"));
     tx.success();
   }
 }
コード例 #8
0
 @Test
 public void listing3_5_add_properties_to_user_nodes() {
   usersAndMovies.addPropertiesToUserNodes();
   try (Transaction tx = graphDb.beginTx()) {
     assertTrue(usersAndMovies.user1.hasProperty("name"));
     assertEquals("John Johnson", usersAndMovies.user1.getProperty("name"));
     tx.success();
   }
 }
コード例 #9
0
 @Test
 public void listing3_10_node_labels() {
   usersAndMovies.addLabelToMovies();
   try (Transaction tx = graphDb.beginTx()) {
     ResourceIterable<Node> movies =
         GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(DynamicLabel.label("MOVIES"));
     assertEquals(3, IteratorUtil.count(movies));
     tx.success();
   }
 }
コード例 #10
0
 @Test
 public void listing3_9_add_properties_to_relationships() {
   usersAndMovies.addPropertiesToRelationships();
   try (Transaction tx = graphDb.beginTx()) {
     Relationship hasSeen =
         usersAndMovies.user1.getSingleRelationship(
             MyRelationshipTypes.HAS_SEEN, Direction.OUTGOING);
     assertEquals(5, hasSeen.getProperty("stars"));
     tx.success();
   }
 }