示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void validateExplicitIndexedNodeProperties()
        internal virtual void ValidateExplicitIndexedNodeProperties()
        {
            setUp();
            Label  label                    = Label.label("explicitIndexedNodePropertiesTestLabel");
            string propertyName             = "explicitIndexedNodeProperties";
            string explicitIndexedNodeIndex = "explicitIndexedNodeIndex";

            using (Transaction transaction = _database.beginTx())
            {
                Node node = _database.createNode(label);
                _database.index().forNodes(explicitIndexedNodeIndex).add(node, propertyName, "shortString");
                transaction.Success();
            }

            System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () =>
            {
                using (Transaction transaction = _database.beginTx())
                {
                    Node node        = _database.createNode(label);
                    string longValue = StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1);
                    _database.index().forNodes(explicitIndexedNodeIndex).add(node, propertyName, longValue);
                    transaction.Success();
                }
            });
            assertEquals("Property value size is too large for index. Please see index documentation for limitations.", argumentException.Message);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureIndexNamesCanBeRead()
        public virtual void MakeSureIndexNamesCanBeRead()
        {
            BeginTx();
            assertEquals(0, _graphDb.index().nodeIndexNames().length);
            string       name1      = "my-index-1";
            Index <Node> nodeIndex1 = _graphDb.index().forNodes(name1);

            assertContains(Arrays.asList(_graphDb.index().nodeIndexNames()), name1);
            string name2 = "my-index-2";

            _graphDb.index().forNodes(name2);
            assertContains(Arrays.asList(_graphDb.index().nodeIndexNames()), name1, name2);
            _graphDb.index().forRelationships(name1);
            assertContains(Arrays.asList(_graphDb.index().nodeIndexNames()), name1, name2);
            assertContains(Arrays.asList(_graphDb.index().relationshipIndexNames()), name1);
            FinishTx(true);

            RestartTx();
            assertContains(Arrays.asList(_graphDb.index().nodeIndexNames()), name1, name2);
            assertContains(Arrays.asList(_graphDb.index().relationshipIndexNames()), name1);
            nodeIndex1.Delete();
            assertContains(Arrays.asList(_graphDb.index().nodeIndexNames()), name1, name2);
            assertContains(Arrays.asList(_graphDb.index().relationshipIndexNames()), name1);
            FinishTx(true);
            BeginTx();
            assertContains(Arrays.asList(_graphDb.index().nodeIndexNames()), name2);
            assertContains(Arrays.asList(_graphDb.index().relationshipIndexNames()), name1);
            FinishTx(false);
        }