Example #1
0
        /// <summary>
        /// POST ${org.neo4j.server.rest.web}/index/relationship {
        /// "name":"index-name" "config":{ // optional map of index configuration
        /// params "key1":"value1", "key2":"value2" } }
        ///
        /// POST ${org.neo4j.server.rest.web}/index/relationship/{indexName}/{key}/{
        /// value} "http://uri.for.node.to.index"
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateANamedRelationshipIndexAndAddToIt() throws org.neo4j.server.rest.domain.JsonParseException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCreateANamedRelationshipIndexAndAddToIt()
        {
            string indexName       = _indexes.newInstance();
            int    expectedIndexes = _helper.RelationshipIndexes.Length + 1;
            IDictionary <string, string> indexSpecification = new Dictionary <string, string>();

            indexSpecification["name"] = indexName;
            JaxRsResponse response = HttpPostIndexRelationshipRoot(JsonHelper.createJsonFrom(indexSpecification));

            assertEquals(201, response.Status);
            assertNotNull(response.Headers.get("Location").get(0));
            assertEquals(expectedIndexes, _helper.RelationshipIndexes.Length);
            assertNotNull(_helper.createRelationshipIndex(indexName));
            // Add a relationship to the index
            string key              = "key";
            string value            = "value";
            string relationshipType = "related-to";
            long   relationshipId   = _helper.createRelationship(relationshipType);

            response = HttpPostIndexRelationshipNameKeyValue(indexName, relationshipId, key, value);
            assertEquals(Status.CREATED.StatusCode, response.Status);
            string indexUri = response.Headers.get("Location").get(0);

            assertNotNull(indexUri);
            assertEquals(Arrays.asList(( long? )relationshipId), _helper.getIndexedRelationships(indexName, key, value));
            // Get the relationship from the indexed URI (Location in header)
            response = HttpGet(indexUri);
            assertEquals(200, response.Status);
            string discoveredEntity          = response.Entity;
            IDictionary <string, object> map = JsonHelper.jsonToMap(discoveredEntity);

            assertNotNull(map["self"]);
        }
Example #2
0
        private static void SetupTheDatabase()
        {
            long relationship = _helper.createRelationship("LIKES");
            IDictionary <string, object> map = new Dictionary <string, object>();

            map["foo"] = "bar";
            _helper.setRelationshipProperties(relationship, map);
            _baseRelationshipUri = _functionalTestHelper.dataUri() + "relationship/" + relationship + "/properties/";
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setupTheDatabase()
        public virtual void SetupTheDatabase()
        {
            _nodeWithRelationships = _helper.createNode();
            _likes = _helper.createRelationship("LIKES", _nodeWithRelationships, _helper.createNode());
            _helper.createRelationship("LIKES", _helper.createNode(), _nodeWithRelationships);
            _helper.createRelationship("HATES", _nodeWithRelationships, _helper.createNode());
            _nodeWithoutRelationships = _helper.createNode();
            _nonExistingNode          = _helper.createNode();
            _helper.deleteNode(_nonExistingNode);
        }
Example #4
0
        private void CreateTheMatrix()
        {
            // Create the matrix example
            _thomasAnderson = CreateAndIndexNode("Thomas Anderson");
            _trinity        = CreateAndIndexNode("Trinity");
            long tank = CreateAndIndexNode("Tank");

            long knowsRelationshipId = _helper.createRelationship("KNOWS", _thomasAnderson, _trinity);

            _thomasAndersonLovesTrinity = _helper.createRelationship("LOVES", _thomasAnderson, _trinity);
            _helper.setRelationshipProperties(_thomasAndersonLovesTrinity, Collections.singletonMap("strength", 100));
            _helper.createRelationship("KNOWS", _thomasAnderson, tank);
            _helper.createRelationship("KNOWS", _trinity, tank);

            // index a relationship
            _helper.createRelationshipIndex("relationships");
            _helper.addRelationshipToIndex("relationships", "key", "value", knowsRelationshipId);

            // index a relationship
            _helper.createRelationshipIndex("relationships2");
            _helper.addRelationshipToIndex("relationships2", "key2", "value2", knowsRelationshipId);
        }