示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void restoreExplicitIndexesFromBackup() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RestoreExplicitIndexesFromBackup()
        {
            string databaseName = "destination";
            Config config       = ConfigWith(databaseName, Directory.absolutePath().AbsolutePath);
            File   fromPath     = new File(Directory.absolutePath(), "from");
            File   toPath       = config.Get(GraphDatabaseSettings.database_path);

            CreateDbWithExplicitIndexAt(fromPath, 100);

            (new RestoreDatabaseCommand(FileSystemRule.get(), fromPath, config, databaseName, true)).execute();

            GraphDatabaseService restoredDatabase = CreateDatabase(toPath, toPath.AbsolutePath);

            using (Transaction transaction = restoredDatabase.BeginTx())
            {
                IndexManager indexManager           = restoredDatabase.Index();
                string[]     nodeIndexNames         = indexManager.NodeIndexNames();
                string[]     relationshipIndexNames = indexManager.RelationshipIndexNames();

                foreach (string nodeIndexName in nodeIndexNames)
                {
                    CountNodesByKeyValue(indexManager, nodeIndexName, "a", "b");
                    CountNodesByKeyValue(indexManager, nodeIndexName, "c", "d");
                }

                foreach (string relationshipIndexName in relationshipIndexNames)
                {
                    CountRelationshipByKeyValue(indexManager, relationshipIndexName, "x", "y");
                }
            }
            restoredDatabase.Shutdown();
        }
示例#2
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");
        }
        private Index <Node> CreateIndex()
        {
            GraphDatabaseService graphDatabaseService = DbRule.GraphDatabaseAPI;

            using (Transaction transaction = graphDatabaseService.BeginTx())
            {
                Index <Node> index = graphDatabaseService.Index().forNodes("foo");
                transaction.Success();
                return(index);
            }
        }
示例#4
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");
        }
示例#5
0
 protected internal override Index <Node> ObtainEntityInTransaction(GraphDatabaseService graphDatabaseService)
 {
     return(graphDatabaseService.Index().forNodes("foo"));
 }
 protected internal override IndexManager ObtainEntityInTransaction(GraphDatabaseService graphDatabaseService)
 {
     return(graphDatabaseService.Index());
 }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void providerGetsFilledInAutomatically()
		 public virtual void ProviderGetsFilledInAutomatically()
		 {
			  IDictionary<string, string> correctConfig = MapUtil.stringMap( "type", "exact", Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, "lucene" );
			  File storeDir = TestDirectory.storeDir();
			  Neo4jTestCase.deleteFileOrDirectory( storeDir );
			  GraphDatabaseService graphDb = StartDatabase( storeDir );
			  using ( Transaction transaction = graphDb.BeginTx() )
			  {
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("default")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("wo-provider", MapUtil.stringMap("type", "exact"))) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("w-provider", MapUtil.stringMap("type", "exact", Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, "lucene"))) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("default")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("wo-provider", MapUtil.stringMap("type", "exact"))) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("w-provider", MapUtil.stringMap("type", "exact", Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, "lucene"))) );
					transaction.Success();
			  }

			  graphDb.Shutdown();

			  RemoveProvidersFromIndexDbFile( TestDirectory.databaseLayout() );
			  graphDb = StartDatabase( storeDir );

			  using ( Transaction ignored = graphDb.BeginTx() )
			  {
					// Getting the index w/o exception means that the provider has been reinstated
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("default")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("wo-provider", MapUtil.stringMap("type", "exact"))) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("w-provider", MapUtil.stringMap("type", "exact", Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, "lucene"))) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("default")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("wo-provider", MapUtil.stringMap("type", "exact"))) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("w-provider", MapUtil.stringMap("type", "exact", Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, "lucene"))) );
			  }

			  graphDb.Shutdown();

			  RemoveProvidersFromIndexDbFile( TestDirectory.databaseLayout() );
			  graphDb = StartDatabase( storeDir );

			  using ( Transaction ignored = graphDb.BeginTx() )
			  {
					// Getting the index w/o exception means that the provider has been reinstated
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("default")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("wo-provider")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forNodes("w-provider")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("default")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("wo-provider")) );
					assertEquals( correctConfig, graphDb.Index().getConfiguration(graphDb.Index().forRelationships("w-provider")) );
			  }

			  graphDb.Shutdown();
		 }
 protected internal override RelationshipIndex ObtainEntityInTransaction(GraphDatabaseService graphDatabaseService)
 {
     return(graphDatabaseService.Index().forRelationships("foo"));
 }