Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldPersistFulltextIndexSettings() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldPersistFulltextIndexSettings()
        {
            // Given
            File   indexFolder           = Directory.directory("indexFolder");
            string analyzerName          = "simple";
            string eventuallyConsistency = "true";
            string defaultAnalyzer       = "defaultAnalyzer";

            int[] propertyIds = new int[] { 1, 2, 3 };
            MultiTokenSchemaDescriptor schema = SchemaDescriptorFactory.multiToken(new int[] { 1, 2 }, EntityType.NODE, propertyIds);

            // A fulltext index descriptor with configurations
            Properties properties = properties(analyzerName, eventuallyConsistency);
            FulltextSchemaDescriptor fulltextSchemaDescriptor = new FulltextSchemaDescriptor(schema, properties);
            StoreIndexDescriptor     storeIndexDescriptor     = StoreIndexDescriptorFromSchema(fulltextSchemaDescriptor);
            TokenRegistry            tokenRegistry            = SimpleTokenHolder.CreatePopulatedTokenRegistry(Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY, propertyIds);
            SimpleTokenHolder        tokenHolder             = new SimpleTokenHolder(tokenRegistry);
            FulltextIndexDescriptor  fulltextIndexDescriptor = readOrInitialiseDescriptor(storeIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs);

            assertEquals(analyzerName, fulltextIndexDescriptor.AnalyzerName());
            assertEquals(bool.Parse(eventuallyConsistency), fulltextIndexDescriptor.EventuallyConsistent);

            // When persisting it
            FulltextIndexSettings.SaveFulltextIndexSettings(fulltextIndexDescriptor, indexFolder, Fs);

            // Then we should be able to load it back with settings being the same
            StoreIndexDescriptor    loadingIndexDescriptor = StoreIndexDescriptorFromSchema(schema);
            FulltextIndexDescriptor loadedDescriptor       = readOrInitialiseDescriptor(loadingIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs);

            assertEquals(fulltextIndexDescriptor.AnalyzerName(), loadedDescriptor.AnalyzerName());
            assertEquals(fulltextIndexDescriptor.EventuallyConsistent, loadedDescriptor.EventuallyConsistent);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBePossibleToCreateIndexWithDuplicateLabel() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBePossibleToCreateIndexWithDuplicateLabel()
        {
            // given
            SchemaWrite schemaWrite = SchemaWriteInNewTransaction();

            // when
            try
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.api.schema.MultiTokenSchemaDescriptor descriptor = org.neo4j.kernel.api.schema.SchemaDescriptorFactory.multiToken(new int[]{0, 0}, org.neo4j.storageengine.api.EntityType.NODE, 1);
                MultiTokenSchemaDescriptor descriptor = SchemaDescriptorFactory.multiToken(new int[] { 0, 0 }, EntityType.NODE, 1);
                schemaWrite.IndexCreate(descriptor);
                fail("Should have failed");
            }
            catch (RepeatedLabelInSchemaException)
            {
                // then good
            }
        }