Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRetrieveMultipleNodesWithSameValueFromIndex()
        public virtual void ShouldRetrieveMultipleNodesWithSameValueFromIndex()
        {
            // this test was included here for now as a precondition for the following test

            // given
            GraphDatabaseService graph = DbRule.GraphDatabaseAPI;

            Neo4jMatchers.createIndex(graph, _label1, "name");

            Node node1;
            Node node2;

            using (Transaction tx = graph.BeginTx())
            {
                node1 = graph.CreateNode(_label1);
                node1.SetProperty("name", "Stefan");

                node2 = graph.CreateNode(_label1);
                node2.SetProperty("name", "Stefan");
                tx.Success();
            }

            using (Transaction tx = graph.BeginTx())
            {
                ResourceIterator <Node> result = graph.FindNodes(_label1, "name", "Stefan");
                assertEquals(asSet(node1, node2), asSet(result));

                tx.Success();
            }
        }
        internal static StartNode Dense(GraphDatabaseService graphDb)
        {
            Node node;
            IDictionary <string, IList <StartRelationship> > relationshipMap;

            using (Transaction tx = graphDb.BeginTx())
            {
                node            = graphDb.CreateNode();
                relationshipMap = BuildSparseDenseRels(node);

                IList <StartRelationship> bulk     = new List <StartRelationship>();
                RelationshipType          bulkType = withName("BULK");

                for (int i = 0; i < 200; i++)
                {
                    Relationship r = node.CreateRelationshipTo(graphDb.CreateNode(), bulkType);
                    bulk.Add(new StartRelationship(r.Id, Direction.OUTGOING, bulkType));
                }

                string bulkKey = ComputeKey("BULK", Direction.OUTGOING);
                relationshipMap[bulkKey] = bulk;

                tx.Success();
            }
            return(new StartNode(node.Id, relationshipMap));
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void addingALabelUsingAnInvalidIdentifierShouldFail()
        public virtual void AddingALabelUsingAnInvalidIdentifierShouldFail()
        {
            // Given
            GraphDatabaseService graphDatabase = DbRule.GraphDatabaseAPI;

            // When I set an empty label
            try
            {
                using (Transaction ignored = graphDatabase.BeginTx())
                {
                    graphDatabase.CreateNode().addLabel(label(""));
                    fail("Should have thrown exception");
                }
            }
            catch (ConstraintViolationException)
            {               // Happy
            }

            // And When I set a null label
            try
            {
                using (Transaction ignored = graphDatabase.BeginTx())
                {
                    graphDatabase.CreateNode().addLabel(() => null);
                    fail("Should have thrown exception");
                }
            }
            catch (ConstraintViolationException)
            {               // Happy
            }
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void already_indexed_relationship_should_not_fail_on_create_or_fail()
        public virtual void AlreadyIndexedRelationshipShouldNotFailOnCreateOrFail()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String index = indexes.newInstance();
            string index = _indexes.newInstance();
            string key   = "name";
            string value = "Peter";
            GraphDatabaseService graphdb = graphdb();

            _helper.createRelationshipIndex(index);
            Relationship rel;

            using (Transaction tx = graphdb.BeginTx())
            {
                Node node1 = graphdb.CreateNode();
                Node node2 = graphdb.CreateNode();
                rel = node1.CreateRelationshipTo(node2, MyRelationshipTypes.Knows);
                graphdb.Index().forRelationships(index).add(rel, key, value);
                tx.Success();
            }

            // When & Then
            GenConflict.get().expectedStatus(201).payloadType(MediaType.APPLICATION_JSON_TYPE).payload("{\"key\": \"" + key + "\", \"value\": \"" + value + "\", \"uri\":\"" + _functionalTestHelper.relationshipUri(rel.Id) + "\"}").post(_functionalTestHelper.relationshipIndexUri() + index + "?uniqueness=create_or_fail");
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenMultipleResultsForSingleNode()
        public virtual void ShouldThrowWhenMultipleResultsForSingleNode()
        {
            // given
            GraphDatabaseService graph = DbRule.GraphDatabaseAPI;

            Neo4jMatchers.createIndex(graph, _label1, "name");

            Node node1;
            Node node2;

            using (Transaction tx = graph.BeginTx())
            {
                node1 = graph.CreateNode(_label1);
                node1.SetProperty("name", "Stefan");

                node2 = graph.CreateNode(_label1);
                node2.SetProperty("name", "Stefan");
                tx.Success();
            }

            try
            {
                using (Transaction tx = graph.BeginTx())
                {
                    graph.FindNode(_label1, "name", "Stefan");
                    fail("Expected MultipleFoundException but got none");
                }
            }
            catch (MultipleFoundException e)
            {
                assertThat(e.Message, equalTo(format("Found multiple nodes with label: '%s', property name: 'name' " + "and property value: 'Stefan' while only one was expected.", _label1)));
            }
        }
Example #6
0
 protected internal override void generateInitialData(GraphDatabaseService graphDb)
 {
     using (Transaction tx = graphDb.BeginTx())
     {
         Node node1 = set(graphDb.CreateNode());
         Node node2 = set(graphDb.CreateNode(), property("key", "exampleValue"));
         node1.CreateRelationshipTo(node2, RelationshipType.withName("C"));
         tx.Success();
     }
 }
 protected internal override void generateInitialData(GraphDatabaseService graphDb)
 {
     // TODO: create bigger sample graph here
     using (Org.Neo4j.Graphdb.Transaction tx = graphDb.BeginTx())
     {
         Node node1 = set(graphDb.CreateNode(label("Foo")));
         Node node2 = set(graphDb.CreateNode(label("Foo")), property("key", "value"));
         node1.CreateRelationshipTo(node2, RelationshipType.withName("C"));
         tx.Success();
     }
 }
        private void CreateInitialData(GraphDatabaseService graphdb)
        {
            using (Transaction tx = graphdb.BeginTx())
            {
                Node first = Properties(graphdb.CreateNode());
                Node other = Properties(graphdb.CreateNode());
                Properties(first.CreateRelationshipTo(other, RelationshipType.withName("KNOWS")));
                Properties(other.CreateRelationshipTo(first, RelationshipType.withName("DISTRUSTS")));

                tx.Success();
            }
        }
        private static void BareStartAndEnd(GraphDatabaseService graphDb)
        {
            using (Org.Neo4j.Graphdb.Transaction tx = graphDb.BeginTx())
            {
                _bare = graphDb.CreateNode().Id;

                Node x = graphDb.CreateNode(), y = graphDb.CreateNode();
                _start = x.Id;
                _end   = y.Id;
                x.CreateRelationshipTo(y, withName("GEN"));

                tx.Success();
            }
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void given4instanceClusterWhenMasterGoesDownThenElectNewMaster() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Given4instanceClusterWhenMasterGoesDownThenElectNewMaster()
        {
            ClusterManager clusterManager = (new ClusterManager.Builder(TestDirectory.directory(TestName.MethodName))).withCluster(ClusterManager.clusterOfSize(4)).build();

            try
            {
                clusterManager.Start();
                ClusterManager.ManagedCluster cluster = clusterManager.Cluster;
                cluster.Await(allSeesAllAsAvailable());

                Logging.Logger.info("STOPPING MASTER");
                cluster.Shutdown(cluster.Master);
                Logging.Logger.info("STOPPED MASTER");

                cluster.Await(ClusterManager.masterAvailable());

                GraphDatabaseService master = cluster.Master;
                Logging.Logger.info("CREATE NODE");
                using (Transaction tx = master.BeginTx())
                {
                    master.CreateNode();
                    Logging.Logger.info("CREATED NODE");
                    tx.Success();
                }

                Logging.Logger.info("STOPPING CLUSTER");
            }
            finally
            {
                clusterManager.SafeShutdown();
            }
        }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getNodesWithLabelsWithTxAddsAndRemoves()
        public virtual void getNodesWithLabelsWithTxAddsAndRemoves()
        {
            // GIVEN
            GraphDatabaseService beansAPI = DbRule.GraphDatabaseAPI;
            Node node1 = CreateNode(beansAPI, Labels.MyLabel, Labels.MyOtherLabel);
            Node node2 = CreateNode(beansAPI, Labels.MyLabel, Labels.MyOtherLabel);

            // WHEN
            Node        node3;
            ISet <Node> nodesWithMyLabel;
            ISet <Node> nodesWithMyOtherLabel;

            using (Transaction tx = beansAPI.BeginTx())
            {
                node3 = beansAPI.CreateNode(Labels.MyLabel);
                node2.RemoveLabel(Labels.MyLabel);
                // extracted here to be asserted below
                nodesWithMyLabel      = asSet(beansAPI.FindNodes(Labels.MyLabel));
                nodesWithMyOtherLabel = asSet(beansAPI.FindNodes(Labels.MyOtherLabel));
                tx.Success();
            }

            // THEN
            assertEquals(asSet(node1, node3), nodesWithMyLabel);
            assertEquals(asSet(node1, node2), nodesWithMyOtherLabel);
        }
Example #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createDateArrayOnLatestDatabase()
        internal virtual void CreateDateArrayOnLatestDatabase()
        {
            File      storeDir    = _testDirectory.storeDir();
            Label     label       = Label.label("DateNode");
            string    propertyKey = "a";
            LocalDate date        = DateValue.date(1991, 5, 3).asObjectCopy();

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(label);
                node.SetProperty(propertyKey, new LocalDate[] { date, date });
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                using (ResourceIterator <Node> nodes = restartedDatabase.FindNodes(label))
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    Node        node   = nodes.next();
                    LocalDate[] points = ( LocalDate[] )node.GetProperty(propertyKey);
                    assertThat(points, arrayWithSize(2));
                }
            }
            restartedDatabase.Shutdown();
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createDatePropertyOnLatestDatabase()
        internal virtual void CreateDatePropertyOnLatestDatabase()
        {
            File      storeDir    = _testDirectory.storeDir();
            Label     label       = Label.label("DateNode");
            string    propertyKey = "a";
            LocalDate date        = DateValue.date(1991, 5, 3).asObjectCopy();

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(label);
                node.SetProperty(propertyKey, date);
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                assertNotNull(restartedDatabase.FindNode(label, propertyKey, date));
            }
            restartedDatabase.Shutdown();
        }
Example #14
0
        public override void CreateTestGraph(GraphDatabaseService graphDb)
        {
            IList <Node> deleted = new List <Node>();

            using (Transaction tx = graphDb.BeginTx())
            {
                for (int i = 0; i < _nNodes; i++)
                {
                    Node node = graphDb.CreateNode();
                    if (_random.nextBoolean())
                    {
                        _nodeIds.Add(node.Id);
                    }
                    else
                    {
                        deleted.Add(node);
                    }
                }
                tx.Success();
            }

            using (Transaction tx = graphDb.BeginTx())
            {
                foreach (Node node in deleted)
                {
                    node.Delete();
                }
                tx.Success();
            }
        }
Example #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void failToCreatePointOnOldDatabase()
        internal virtual void FailToCreatePointOnOldDatabase()
        {
            File storeDir = _testDirectory.storeDir();
            GraphDatabaseService        nonUpgradedStore = startNonUpgradableDatabaseWithFormat(storeDir, StandardV3_2.NAME);
            TransactionFailureException exception        = assertThrows(typeof(TransactionFailureException), () =>
            {
                using (Transaction transaction = nonUpgradedStore.BeginTx())
                {
                    Node node = nonUpgradedStore.CreateNode();
                    node.setProperty("a", pointValue(Cartesian, 1.0, 2.0));
                    transaction.success();
                }
            });

            assertEquals("Current record format does not support POINT_PROPERTIES. Please upgrade your store to the format that support requested capability.", Exceptions.rootCause(exception).Message);
            nonUpgradedStore.Shutdown();

            GraphDatabaseService restartedOldFormatDatabase = startNonUpgradableDatabaseWithFormat(storeDir, StandardV3_2.NAME);

            using (Transaction transaction = restartedOldFormatDatabase.BeginTx())
            {
                Node node = restartedOldFormatDatabase.CreateNode();
                node.SetProperty("c", "d");
                transaction.success();
            }
            restartedOldFormatDatabase.Shutdown();
        }
Example #16
0
        private long CreateNodeWithProperty(GraphDatabaseService graphDb, string propertyKey, object value)
        {
            Node p = graphDb.CreateNode();

            p.SetProperty(propertyKey, value);
            return(p.Id);
        }
Example #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createPointArrayPropertyOnLatestDatabase()
        internal virtual void CreatePointArrayPropertyOnLatestDatabase()
        {
            File       storeDir    = _testDirectory.storeDir();
            Label      pointNode   = Label.label("PointNode");
            string     propertyKey = "a";
            PointValue pointValue  = pointValue(Cartesian, 1.0, 2.0);

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(pointNode);
                node.SetProperty(propertyKey, new PointValue[] { pointValue, pointValue });
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                using (ResourceIterator <Node> nodes = restartedDatabase.FindNodes(pointNode))
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    Node         node   = nodes.next();
                    PointValue[] points = ( PointValue[] )node.GetProperty(propertyKey);
                    assertThat(points, arrayWithSize(2));
                }
            }
            restartedDatabase.Shutdown();
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createPointPropertyOnLatestDatabase()
        internal virtual void CreatePointPropertyOnLatestDatabase()
        {
            File       storeDir    = _testDirectory.storeDir();
            Label      pointNode   = Label.label("PointNode");
            string     propertyKey = "a";
            PointValue pointValue  = pointValue(Cartesian, 1.0, 2.0);

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(pointNode);
                node.SetProperty(propertyKey, pointValue);
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                assertNotNull(restartedDatabase.FindNode(pointNode, propertyKey, pointValue));
            }
            restartedDatabase.Shutdown();
        }
Example #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void failToCreateDateArrayOnOldDatabase()
        internal virtual void FailToCreateDateArrayOnOldDatabase()
        {
            File storeDir = _testDirectory.storeDir();
            GraphDatabaseService        nonUpgradedStore = startNonUpgradableDatabaseWithFormat(storeDir, StandardV3_2.NAME);
            LocalDate                   date             = DateValue.date(1991, 5, 3).asObjectCopy();
            TransactionFailureException failureException = assertThrows(typeof(TransactionFailureException), () =>
            {
                using (Transaction transaction = nonUpgradedStore.BeginTx())
                {
                    Node node = nonUpgradedStore.CreateNode();
                    node.setProperty("a", new LocalDate[] { date, date });
                    transaction.success();
                }
            });

            assertEquals("Current record format does not support TEMPORAL_PROPERTIES. Please upgrade your store " + "to the format that support requested capability.", Exceptions.rootCause(failureException).Message);
            nonUpgradedStore.Shutdown();

            GraphDatabaseService restartedOldFormatDatabase = startNonUpgradableDatabaseWithFormat(storeDir, StandardV3_2.NAME);

            using (Transaction transaction = restartedOldFormatDatabase.BeginTx())
            {
                Node node = restartedOldFormatDatabase.CreateNode();
                node.SetProperty("c", "d");
                transaction.success();
            }
            restartedOldFormatDatabase.Shutdown();
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldUseConcurrentlyCreatedNode()
        internal virtual void ShouldUseConcurrentlyCreatedNode()
        {
            // given
            GraphDatabaseService graphdb = mock(typeof(GraphDatabaseService));
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") Index<org.neo4j.graphdb.Node> index = mock(Index.class);
            Index <Node> index = mock(typeof(Index));
            Transaction  tx    = mock(typeof(Transaction));

            when(graphdb.BeginTx()).thenReturn(tx);
            when(index.GraphDatabase).thenReturn(graphdb);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") IndexHits<org.neo4j.graphdb.Node> getHits = mock(IndexHits.class);
            IndexHits <Node> getHits = mock(typeof(IndexHits));

            when(index.get("key1", "value1")).thenReturn(getHits);
            Node createdNode = mock(typeof(Node));

            when(graphdb.CreateNode()).thenReturn(createdNode);
            Node concurrentNode = mock(typeof(Node));

            when(index.PutIfAbsent(createdNode, "key1", "value1")).thenReturn(concurrentNode);
            UniqueFactory.UniqueNodeFactory unique = new UniqueNodeFactoryAnonymousInnerClass(this, index);

            // when
            UniqueEntity <Node> node = unique.GetOrCreateWithOutcome("key1", "value1");

            // then
            assertSame(node.Entity(), concurrentNode);
            assertFalse(node.WasCreated());
            verify(index).get("key1", "value1");
            verify(index).putIfAbsent(createdNode, "key1", "value1");
            verify(graphdb, times(1)).createNode();
            verify(tx).success();
        }
Example #21
0
 private static void CreateNode(GraphDatabaseService database)
 {
     using (Transaction transaction = database.BeginTx())
     {
         database.CreateNode();
         transaction.Success();
     }
 }
Example #22
0
 private static void CreateSomeData(GraphDatabaseService oldMaster)
 {
     using (Transaction tx = oldMaster.BeginTx())
     {
         oldMaster.CreateNode();
         tx.Success();
     }
 }
Example #23
0
 private static void CreateNode(GraphDatabaseService database, string propertyName, Label testLabel)
 {
     using (Transaction transaction = database.BeginTx())
     {
         Node node = database.CreateNode(testLabel);
         node.SetProperty(propertyName, "value");
         transaction.Success();
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testLowGrabSize()
        public virtual void TestLowGrabSize()
        {
            IDictionary <string, string> config = new Dictionary <string, string>();

            config["relationship_grab_size"] = "1";
            GraphDatabaseService graphDb = GetImpermanentDatabase(config);

            Node node1;
            Node node2;

            using (Transaction tx = graphDb.BeginTx())
            {
                node1 = graphDb.CreateNode();
                node2 = graphDb.CreateNode();
                node1.CreateRelationshipTo(node2, MyRelTypes.TEST);
                node2.CreateRelationshipTo(node1, MyRelTypes.TEST2);
                node1.CreateRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
                tx.Success();
            }

            using (Transaction tx = graphDb.BeginTx())
            {
                RelationshipType[] types = new RelationshipType[] { MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL };

                assertEquals(3, Iterables.count(node1.GetRelationships(types)));

                assertEquals(3, Iterables.count(node1.Relationships));

                assertEquals(3, Iterables.count(node2.GetRelationships(types)));

                assertEquals(3, Iterables.count(node2.Relationships));

                assertEquals(2, Iterables.count(node1.GetRelationships(OUTGOING)));

                assertEquals(1, Iterables.count(node1.GetRelationships(INCOMING)));

                assertEquals(1, Iterables.count(node2.GetRelationships(OUTGOING)));

                assertEquals(2, Iterables.count(node2.GetRelationships(INCOMING)));

                tx.Success();
            }
            graphDb.Shutdown();
        }
Example #25
0
        private Node CloneNodeData(GraphDatabaseService graphDb, Node node)
        {
            Node newNode = graphDb.CreateNode();

            foreach (KeyValuePair <string, object> property in node.AllProperties.SetOfKeyValuePairs())
            {
                newNode.SetProperty(property.Key, property.Value);
            }
            return(newNode);
        }
Example #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void creatingAndDeletingEntitiesShouldNotThrow()
        public virtual void CreatingAndDeletingEntitiesShouldNotThrow()
        {
            // Given
            GraphDatabaseService dataBase = DbRule.GraphDatabaseAPI;
            Node myNode;

            // When
            using (Transaction bobTransaction = dataBase.BeginTx())
            {
                myNode = dataBase.CreateNode();
                myNode.SetProperty("Name", "Bob");

                myNode.CreateRelationshipTo(dataBase.CreateNode(), RelTypes.Asd);
                bobTransaction.Success();
            }

            // When
            GraphDatabaseServiceCleaner.cleanupAllRelationshipsAndNodes(dataBase);
        }
Example #27
0
            internal virtual Node GetNode(GraphDatabaseService graphdb, IDictionary <string, Node> nodes, string name)
            {
                Node node = nodes[name];

                if (node == null)
                {
                    if (nodes.Count == 0)
                    {
                        node = graphdb.CreateNode();
                    }
                    else
                    {
                        node = graphdb.CreateNode();
                    }
                    node.SetProperty("name", name);
                    nodes[name] = node;
                }
                return(node);
            }
Example #28
0
        public override void CreateTestGraph(GraphDatabaseService graphDb)
        {
            Relationship deleted;

            using (Transaction tx = graphDb.BeginTx())
            {
                Node a = graphDb.CreateNode(), b = graphDb.CreateNode(), c = graphDb.CreateNode(), d = graphDb.CreateNode(), e = graphDb.CreateNode(), f = graphDb.CreateNode();

                a.CreateRelationshipTo(b, withName("CIRCLE"));
                b.CreateRelationshipTo(c, withName("CIRCLE"));
                _one = c.CreateRelationshipTo(d, withName("CIRCLE")).Id;
                d.CreateRelationshipTo(e, withName("CIRCLE"));
                e.CreateRelationshipTo(f, withName("CIRCLE"));
                f.CreateRelationshipTo(a, withName("CIRCLE"));

                a.CreateRelationshipTo(b, withName("TRIANGLE"));
                a.CreateRelationshipTo(c, withName("TRIANGLE"));
                b.CreateRelationshipTo(c, withName("TRIANGLE"));
                _none = (deleted = c.CreateRelationshipTo(b, withName("TRIANGLE"))).Id;
                RelationshipScanCursorTestBase._c = c.Id;
                RelationshipScanCursorTestBase._d = d.Id;

                d.CreateRelationshipTo(e, withName("TRIANGLE"));
                e.CreateRelationshipTo(f, withName("TRIANGLE"));
                f.CreateRelationshipTo(d, withName("TRIANGLE"));

                _loop = a.CreateRelationshipTo(a, withName("LOOP")).Id;

                tx.Success();
            }

            _relationshipIds = new List <long>();
            using (Transaction tx = graphDb.BeginTx())
            {
                deleted.Delete();
                foreach (Relationship relationship in graphDb.AllRelationships)
                {
                    _relationshipIds.Add(relationship.Id);
                }
                tx.Success();
            }
        }
Example #29
0
        /// <summary>
        /// This can be safely removed in version 1.11 an onwards.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void createUniqueShouldBeBackwardsCompatibleWith1_8()
        public virtual void CreateUniqueShouldBeBackwardsCompatibleWith1_8()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String index = indexes.newInstance();
            string index = _indexes.newInstance();
            string key   = "name";
            string value = "Peter";
            GraphDatabaseService graphdb = graphdb();

            _helper.createRelationshipIndex(index);
            using (Transaction tx = graphdb.BeginTx())
            {
                Node         node1 = graphdb.CreateNode();
                Node         node2 = graphdb.CreateNode();
                Relationship rel   = node1.CreateRelationshipTo(node2, MyRelationshipTypes.Knows);
                graphdb.Index().forRelationships(index).add(rel, key, value);
                tx.Success();
            }
            GenConflict.get().expectedStatus(200).payloadType(MediaType.APPLICATION_JSON_TYPE).payload("{\"key\": \"" + key + "\", \"value\": \"" + value + "\", \"start\": \"" + _functionalTestHelper.nodeUri(_helper.createNode()) + "\", \"end\": \"" + _functionalTestHelper.nodeUri(_helper.createNode()) + "\", \"type\":\"" + MyRelationshipTypes.Knows + "\"}").post(_functionalTestHelper.relationshipIndexUri() + index + "?unique");
        }
Example #30
0
 private static void CreateNodes(Label marker, string property, GraphDatabaseService database)
 {
     using (Transaction transaction = database.BeginTx())
     {
         for (int i = 0; i < 10; i++)
         {
             Node node = database.CreateNode(marker);
             node.SetProperty(property, "a");
         }
         transaction.Success();
     }
 }