Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInsertDifferentTypesOfThings() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInsertDifferentTypesOfThings()
        {
            // GIVEN
            BatchInserter inserter = BatchInserters.Inserter(Directory.databaseDir(), FileSystemRule.get(), stringMap(GraphDatabaseSettings.log_queries.name(), "true", GraphDatabaseSettings.record_format.name(), RecordFormat, GraphDatabaseSettings.log_queries_filename.name(), Directory.file("query.log").AbsolutePath));
            long          node1Id;
            long          node2Id;
            long          relationshipId;

            try
            {
                // WHEN
                node1Id = inserter.createNode(SomeProperties(1), Enum.GetValues(typeof(Labels)));
                node2Id = node1Id + 10;
                inserter.createNode(node2Id, SomeProperties(2), Enum.GetValues(typeof(Labels)));
                relationshipId = inserter.CreateRelationship(node1Id, node2Id, MyRelTypes.TEST, SomeProperties(3));
                inserter.CreateDeferredSchemaIndex(Labels.One).on("key").create();
                inserter.CreateDeferredConstraint(Labels.Two).assertPropertyIsUnique("key").create();
            }
            finally
            {
                inserter.Shutdown();
            }

            // THEN
            GraphDatabaseService db = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(Directory.databaseDir()).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE).newGraphDatabase();

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Node node1 = Db.getNodeById(node1Id);
                    Node node2 = Db.getNodeById(node2Id);
                    assertEquals(SomeProperties(1), node1.AllProperties);
                    assertEquals(SomeProperties(2), node2.AllProperties);
                    assertEquals(relationshipId, single(node1.Relationships).Id);
                    assertEquals(relationshipId, single(node2.Relationships).Id);
                    assertEquals(SomeProperties(3), single(node1.Relationships).AllProperties);
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void insertIntoExistingDatabase() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void InsertIntoExistingDatabase()
        {
            File storeDir = Directory.databaseDir();

            GraphDatabaseService db = NewDb(storeDir, RecordFormat);

            try
            {
                CreateThreeNodes(db);
            }
            finally
            {
                Db.shutdown();
            }

            BatchInserter inserter = BatchInserters.Inserter(Directory.databaseDir(), FileSystemRule.get());

            try
            {
                long start = inserter.createNode(SomeProperties(5), Labels.One);
                long end   = inserter.createNode(SomeProperties(5), Labels.One);
                inserter.CreateRelationship(start, end, MyRelTypes.TEST, SomeProperties(5));
            }
            finally
            {
                inserter.Shutdown();
            }

            db = NewDb(storeDir, RecordFormat);
            try
            {
                VerifyNodeCount(db, 4);
            }
            finally
            {
                Db.shutdown();
            }
        }