コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowIllegalArgumentChangingTypeOfFieldOnRelationshipIndex()
        public virtual void ShouldThrowIllegalArgumentChangingTypeOfFieldOnRelationshipIndex()
        {
            string indexName = "index";

            CreateRelationshipExplicitIndexWithSingleRelationship(Db, indexName);

            long relId;

            using (Transaction tx = Db.beginTx())
            {
                Node         node = Db.createNode();
                Relationship rel  = node.CreateRelationshipTo(node, _type);
                relId = rel.Id;
                RelationshipIndex index = Db.index().forRelationships(indexName);
                index.add(rel, "key", "otherValue");
                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                RelationshipIndex index = Db.index().forRelationships(indexName);
                index.remove(Db.getRelationshipById(relId), "key");
                tx.Success();
            }

            ExpectedException.expect(typeof(System.ArgumentException));
            using (Transaction tx = Db.beginTx())
            {
                RelationshipIndex index = Db.index().forRelationships(indexName);
                index.add(Db.getRelationshipById(relId), "key", ValueContext.numeric(52));
                tx.Success();
            }
        }
コード例 #2
0
        private bool RelationshipExistsByQuery(RelationshipIndex index, Node startNode, Node endNode, bool specifyStartNode)
        {
            bool found = false;

            using (Transaction tx = Db.beginTx(), IndexHits <Relationship> query = index.Query("key", QueryContext.numericRange("key", 0, 3), specifyStartNode ? startNode : null, null))
            {
                foreach (Relationship relationship in query)
                {
                    if (relationship.StartNodeId == startNode.Id && relationship.EndNodeId == endNode.Id)
                    {
                        found = true;
                        break;
                    }
                }

                tx.Success();
            }
            return(found);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void question5346011()
        public virtual void Question5346011()
        {
            GraphDatabaseService service = (new TestGraphDatabaseFactory()).newImpermanentDatabase();

            using (Transaction tx = service.BeginTx())
            {
                RelationshipIndex index = service.Index().forRelationships("exact");
                // ...creation of the nodes and relationship
                Node         node1        = service.CreateNode();
                Node         node2        = service.CreateNode();
                string       uuid         = "xyz";
                Relationship relationship = node1.CreateRelationshipTo(node2, RelationshipType.withName("related"));
                index.add(relationship, "uuid", uuid);
                // query
                using (IndexHits <Relationship> hits = index.Get("uuid", uuid, node1, node2))
                {
                    assertEquals(1, hits.Size());
                }
                tx.Success();
            }
            service.Shutdown();
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAcceptValuesWithNullToString() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAcceptValuesWithNullToString()
        {
            using (Transaction tx = Db.beginTx())
            {
                Node              node              = Db.createNode();
                Node              otherNode         = Db.createNode();
                Relationship      rel               = node.CreateRelationshipTo(otherNode, RelationshipType.withName("recovery"));
                Index <Node>      nodeIndex         = Db.index().forNodes("node-index");
                RelationshipIndex relationshipIndex = Db.index().forRelationships("rel-index");

                // Add
                AssertAddFailsWithIllegalArgument(nodeIndex, node, "key1", new ClassWithToStringAlwaysNull());
                AssertAddFailsWithIllegalArgument(relationshipIndex, rel, "key1", new ClassWithToStringAlwaysNull());

                // Remove
                AssertRemoveFailsWithIllegalArgument(nodeIndex, node, "key1", new ClassWithToStringAlwaysNull());
                AssertRemoveFailsWithIllegalArgument(relationshipIndex, rel, "key1", new ClassWithToStringAlwaysNull());
                tx.Success();
            }

            ForceRecover();
        }
コード例 #5
0
 public ReadOnlyRelationshipIndexFacade(RelationshipIndex @delegate) : base(@delegate)
 {
     this.@delegate = @delegate;
 }