コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenPopulatingWithNonUniquePoints() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowWhenPopulatingWithNonUniquePoints()
        {
            Config        config   = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName()));
            BatchInserter inserter = NewBatchInserter(config);
            PointValue    point    = Values.pointValue(CoordinateReferenceSystem.WGS84, 0.0, 0.0);

            inserter.createNode(MapUtil.map("prop", point), TestLabels.LABEL_ONE);
            inserter.createNode(MapUtil.map("prop", point), TestLabels.LABEL_ONE);
            inserter.CreateDeferredConstraint(TestLabels.LABEL_ONE).assertPropertyIsUnique("prop").create();
            inserter.Shutdown();

            GraphDatabaseService db = GraphDatabaseService(config);

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    IEnumerator <IndexDefinition> indexes = Db.schema().Indexes.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue(indexes.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    IndexDefinition index = indexes.next();
                    Org.Neo4j.Graphdb.schema.Schema_IndexState indexState = Db.schema().getIndexState(index);
                    assertEquals(Org.Neo4j.Graphdb.schema.Schema_IndexState.Failed, indexState);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertFalse(indexes.hasNext());
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateIndexWithUniquePointsThatCollideOnSpaceFillingCurve() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateIndexWithUniquePointsThatCollideOnSpaceFillingCurve()
        {
            Config        config   = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName()));
            BatchInserter inserter = NewBatchInserter(config);
            Pair <PointValue, PointValue> collidingPoints = SpatialIndexValueTestUtil.pointsWithSameValueOnSpaceFillingCurve(config);

            inserter.createNode(MapUtil.map("prop", collidingPoints.First()), TestLabels.LABEL_ONE);
            inserter.createNode(MapUtil.map("prop", collidingPoints.Other()), TestLabels.LABEL_ONE);
            inserter.CreateDeferredConstraint(TestLabels.LABEL_ONE).assertPropertyIsUnique("prop").create();
            inserter.Shutdown();

            GraphDatabaseService db = GraphDatabaseService(config);

            try
            {
                AwaitIndexesOnline(db);
                using (Transaction tx = Db.beginTx())
                {
                    AssertSingleCorrectHit(db, collidingPoints.First());
                    AssertSingleCorrectHit(db, collidingPoints.Other());
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void explicitIndexPopulationWithBunchOfFields()
        internal virtual void ExplicitIndexPopulationWithBunchOfFields()
        {
            assertTimeout(ofMillis(TEST_TIMEOUT), () =>
            {
                BatchInserter batchNode = BatchInserters.inserter(_directory.databaseDir());
                LuceneBatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(batchNode);
                try
                {
                    BatchInserterIndex batchIndex = provider.nodeIndex("node_auto_index", stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext"));

                    IDictionary <string, object> properties = IntStream.range(0, 2000).mapToObj(i => Pair.of(Convert.ToString(i), randomAlphabetic(200))).collect(toMap(Pair.first, Pair.other));

                    long node = batchNode.createNode(properties, Label.label("NODE"));
                    batchIndex.add(node, properties);
                }
                finally
                {
                    provider.shutdown();
                    batchNode.shutdown();
                }
            });
        }