Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleSingleNodePath()
        public virtual void ShouldHandleSingleNodePath()
        {
            // Given
            Node node;

            using (Transaction tx = Db.beginTx())
            {
                node = Db.createNode();
                tx.Success();
            }

            // When
            Path mapped = _mapper.mapPath(path(AsNodeValues(node), AsRelationshipsValues()));

            // Then
            using (Transaction ignore = Db.beginTx())
            {
                assertThat(mapped.Length(), equalTo(0));
                assertThat(mapped.StartNode(), equalTo(node));
                assertThat(mapped.EndNode(), equalTo(node));
                assertThat(Iterables.asList(mapped.Relationships()), hasSize(0));
                assertThat(Iterables.asList(mapped.ReverseRelationships()), hasSize(0));
                assertThat(Iterables.asList(mapped.Nodes()), equalTo(singletonList(node)));
                assertThat(Iterables.asList(mapped.ReverseNodes()), equalTo(singletonList(node)));
                assertThat(mapped.LastRelationship(), nullValue());
                assertThat(Iterators.asList(mapped.GetEnumerator()), equalTo(singletonList(node)));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reading a node command might leave a node record which referred to
        /// labels in one or more dynamic records as marked as heavy even if that
        /// node already had references to dynamic records, changed in a transaction,
        /// but had no labels on that node changed within that same transaction.
        /// Now defensively only marks as heavy if there were one or more dynamic
        /// records provided when providing the record object with the label field
        /// value. This would give the opportunity to load the dynamic records the
        /// next time that record would be ensured heavy.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverNodeWithDynamicLabelRecords()
        public virtual void ShouldRecoverNodeWithDynamicLabelRecords()
        {
            // GIVEN
            _database = (new TestGraphDatabaseFactory()).setFileSystem(Fs).newImpermanentDatabase();
            Node node;

            Label[] labels = new Label[] { label("a"), label("b"), label("c"), label("d"), label("e"), label("f"), label("g"), label("h"), label("i"), label("j"), label("k") };
            using (Transaction tx = _database.beginTx())
            {
                node = _database.createNode(labels);
                tx.Success();
            }

            // WHEN
            using (Transaction tx = _database.beginTx())
            {
                node.SetProperty("prop", "value");
                tx.Success();
            }
            EphemeralFileSystemAbstraction snapshot = Fs.snapshot();

            _database.shutdown();
            _database = (new TestGraphDatabaseFactory()).setFileSystem(snapshot).newImpermanentDatabase();

            // THEN
            using (Transaction ignored = _database.beginTx())
            {
                node = _database.getNodeById(node.Id);
                foreach (Label label in labels)
                {
                    assertTrue(node.HasLabel(label));
                }
            }
        }
Exemplo n.º 3
0
 private void DoTransaction()
 {
     using (Transaction transaction = _database.beginTx())
     {
         _database.createNode();
         transaction.Success();
     }
 }
Exemplo n.º 4
0
        private void CreateNode(string label)
        {
            using (Transaction tx = _db.beginTx())
            {
                _db.createNode(label(label));

                tx.Success();
            }
        }
Exemplo n.º 5
0
 private Node CreateNode()
 {
     using (Transaction tx = _db.beginTx())
     {
         Node n = _db.createNode();
         tx.Success();
         return(n);
     }
 }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _cluster = ClusterRule.startCluster();
            _slave   = _cluster.AnySlave;

            // Create some basic data
            using (Transaction tx = _slave.beginTx())
            {
                Node node = _slave.createNode(Label.label("Person"));
                node.SetProperty("name", "Bob");
                node.CreateRelationshipTo(_slave.createNode(), RelationshipType.withName("KNOWS"));

                tx.Success();
            }

            // And now monitor the master for incoming calls
            _cluster.Master.DependencyResolver.resolveDependency(typeof(Monitors)).addMonitorListener(_masterMonitor);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void should_remove_all_data()
        public virtual void ShouldRemoveAllData()
        {
            using (Transaction tx = _db.beginTx())
            {
                RelationshipType relationshipType = RelationshipType.withName("R");

                Node n1 = _db.createNode();
                Node n2 = _db.createNode();
                Node n3 = _db.createNode();

                n1.CreateRelationshipTo(n2, relationshipType);
                n2.CreateRelationshipTo(n1, relationshipType);
                n3.CreateRelationshipTo(n1, relationshipType);

                tx.Success();
            }

            CleanDatabaseContent(_db);

            assertThat(NodeCount(), @is(0L));
        }
Exemplo n.º 8
0
 private void CreateAliens()
 {
     using (Transaction tx = _db.beginTx())
     {
         for (int i = 0; i < 32; i++)
         {
             Node alien = _db.createNode(_alien);
             alien.SetProperty(SPECIMEN, i / 2);
         }
         tx.Success();
     }
 }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testUpdateDoubleArrayProperty()
        public virtual void TestUpdateDoubleArrayProperty()
        {
            Node node;

            using (Transaction tx = _db.beginTx())
            {
                node = _db.createNode();
                node.SetProperty("foo", new double[] { 0, 0, 0, 0 });
                tx.Success();
            }

            using (Transaction ignore = _db.beginTx())
            {
                for (int i = 0; i < 100; i++)
                {
                    double[] data = ( double[] )node.GetProperty("foo");
                    data[2] = i;
                    data[3] = i;
                    node.SetProperty("foo", data);
                    assertArrayEquals(new double[] { 0, 0, i, i }, ( double[] )node.GetProperty("foo"), 0.1D);
                }
            }
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void validateIndexedNodePropertiesInLucene()
        internal virtual void ValidateIndexedNodePropertiesInLucene()
        {
            setUp(default_schema_provider.name(), GraphDatabaseSettings.SchemaIndex.NATIVE10.providerName());
            Label  label        = Label.label("indexedNodePropertiesTestLabel");
            string propertyName = "indexedNodePropertyName";

            CreateIndex(label, propertyName);

            using (Transaction ignored = _database.beginTx())
            {
                _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
            }

            System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () =>
            {
                using (Transaction transaction = _database.beginTx())
                {
                    Node node = _database.createNode(label);
                    node.setProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1));
                    transaction.success();
                }
            });
            assertThat(argumentException.Message, equalTo("Property value size is too large for index. Please see index documentation for limitations."));
        }