Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportUnreferencedConstraintIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportUnreferencedConstraintIndex()
        {
            // given
            int ruleId = 0;

            DynamicRecord record = InUse(DynamicRecord(ruleId));

            IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0");

            StoreIndexDescriptor rule = constraintIndexRule(ruleId, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId);

            when(Checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule);

            Add(InUse(new LabelTokenRecord(_labelId)));
            Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId)));

            // when
            Check(record);
            SchemaRecordCheck obligationChecker = Checker().forObligationChecking();

            Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(obligationChecker, record);

            // then
            verify(report).missingObligation(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.UniquenessConstraint);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportTwoIndexRulesWithDuplicateContent() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportTwoIndexRulesWithDuplicateContent()
        {
            // given
            int ruleId1 = 0;
            int ruleId2 = 1;

            DynamicRecord record1 = InUse(DynamicRecord(ruleId1));
            DynamicRecord record2 = InUse(DynamicRecord(ruleId2));

            IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0");

            StoreIndexDescriptor rule1 = constraintIndexRule(ruleId1, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId1);
            StoreIndexDescriptor rule2 = constraintIndexRule(ruleId2, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId2);

            when(Checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
            when(Checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);

            Add(InUse(new LabelTokenRecord(_labelId)));
            Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId)));

            // when
            Check(record1);
            Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(record2);

            // then
            verify(report).duplicateRuleContent(record1);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotReportConstraintIndexRuleWithoutBackReference() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldNotReportConstraintIndexRuleWithoutBackReference()
        {
            // given
            int ruleId = 1;

            DynamicRecord record = InUse(DynamicRecord(ruleId));

            IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0");

            StoreIndexDescriptor rule = constraintIndexRule(ruleId, _labelId, _propertyKeyId, providerDescriptor);

            when(Checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule);

            Add(InUse(new LabelTokenRecord(_labelId)));
            Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId)));

            // when
            Check(record);
            SchemaRecordCheck obligationChecker = Checker().forObligationChecking();

            Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(obligationChecker, record);

            // then
            verifyZeroInteractions(report);
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportConstraintIndexNotReferencingBack() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportConstraintIndexNotReferencingBack()
        {
            // given
            int ruleId1 = 0;
            int ruleId2 = 1;

            DynamicRecord record1 = InUse(DynamicRecord(ruleId1));
            DynamicRecord record2 = InUse(DynamicRecord(ruleId2));

            IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0");

            StoreIndexDescriptor rule1 = constraintIndexRule(ruleId1, _labelId, _propertyKeyId, providerDescriptor, ( long )ruleId1);
            ConstraintRule       rule2 = uniquenessConstraintRule(ruleId2, _labelId, _propertyKeyId, ruleId1);

            when(Checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
            when(Checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);

            Add(InUse(new LabelTokenRecord(_labelId)));
            Add(InUse(new PropertyKeyTokenRecord(_propertyKeyId)));

            // when
            Check(record1);
            Check(record2);
            SchemaRecordCheck obligationChecker = Checker().forObligationChecking();

            Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(obligationChecker, record1);
            Check(obligationChecker, record2);

            // then
            verify(report).constraintIndexRuleNotReferencingBack(record2);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSeeCorrectDirectoriesForSubProvider()
        public virtual void ShouldSeeCorrectDirectoriesForSubProvider()
        {
            IndexDirectoryStructure parentStructure = directoriesByProvider(_databaseStoreDir).forProvider(_provider);
            IndexProviderDescriptor subProvider     = new IndexProviderDescriptor("sub", "0.3");

            AssertCorrectDirectories(directoriesBySubProvider(parentStructure).forProvider(subProvider), path(_baseIndexDirectory, _provider.Key + "-" + _provider.Version), path(_baseIndexDirectory, _provider.Key + "-" + _provider.Version, _indexId.ToString(), subProvider.Key + "-" + subProvider.Version));
        }
Ejemplo n.º 6
0
 public IndexDescriptor(SchemaDescriptor schema, Type type, Optional <string> userSuppliedName, IndexProviderDescriptor providerDescriptor)
 {
     this.SchemaConflict             = schema;
     this.TypeConflict               = type;
     this.UserSuppliedNameConflict   = userSuppliedName;
     this.ProviderDescriptorConflict = providerDescriptor;
 }
Ejemplo n.º 7
0
        private void DeleteIndexFilesFor(IndexProviderDescriptor descriptor)
        {
            File databaseDirectory = this._databaseLayout.databaseDirectory();
            File rootDirectory     = subProviderDirectoryStructure(databaseDirectory).forProvider(descriptor).rootDirectory();

            File[] files = _fs.listFiles(rootDirectory);
            foreach (File indexFile in files)
            {
                _fs.deleteFile(indexFile);
            }
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustRebuildFusionIndexIfNativePartIsMissing() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustRebuildFusionIndexIfNativePartIsMissing()
        {
            // given
            InitializeIndexWithDataAndShutdown();

            // when
            IndexProviderDescriptor descriptor = NumberIndexProvider.NATIVE_PROVIDER_DESCRIPTOR;

            DeleteIndexFilesFor(descriptor);

            // then
            // ... should rebuild
            VerifyContent();
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustRebuildFusionIndexIfLucenePartIsMissing() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustRebuildFusionIndexIfLucenePartIsMissing()
        {
            // given
            InitializeIndexWithDataAndShutdown();

            // when
            IndexProviderDescriptor descriptor = LuceneIndexProviderFactory.ProviderDescriptor;

            DeleteIndexFilesFor(descriptor);

            // then
            // ... should rebuild
            VerifyContent();
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void shouldAcceptNativeIndexFileFromFusionProvider(org.neo4j.internal.kernel.api.schema.IndexProviderDescriptor descriptor) throws java.io.IOException
        private void ShouldAcceptNativeIndexFileFromFusionProvider(IndexProviderDescriptor descriptor)
        {
            // given
            File dir  = subProviderDirectoryStructure(_storeDir, descriptor).forProvider(descriptor).directoryForIndex(1);
            File file = new File(dir, "some-file");

            CreateFile(file);

            // when
            bool accepted = _filter.accept(file);

            // then
            assertTrue(accepted);
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustRebuildFusionIndexIfCompletelyMissing() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustRebuildFusionIndexIfCompletelyMissing()
        {
            // given
            InitializeIndexWithDataAndShutdown();

            // when
            IndexProviderDescriptor luceneDescriptor = LuceneIndexProviderFactory.ProviderDescriptor;
            IndexProviderDescriptor nativeDescriptor = NumberIndexProvider.NATIVE_PROVIDER_DESCRIPTOR;

            DeleteIndexFilesFor(luceneDescriptor);
            DeleteIndexFilesFor(nativeDescriptor);

            // then
            // ... should rebuild
            VerifyContent();
        }
Ejemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldThrowOnLookupOnUnknownProvider()
        internal virtual void ShouldThrowOnLookupOnUnknownProvider()
        {
            // given
            IndexProvider           provider   = mock(typeof(IndexProvider));
            IndexProviderDescriptor descriptor = new IndexProviderDescriptor("provider", "1.2");

            when(provider.ProviderDescriptor).thenReturn(descriptor);
            Dependencies dependencies = new Dependencies();

            dependencies.SatisfyDependency(provider);

            // when
            DefaultIndexProviderMap defaultIndexProviderMap = CreateDefaultProviderMap(dependencies, descriptor);

            defaultIndexProviderMap.Init();
            assertThrows(typeof(IndexProviderNotFoundException), () => defaultIndexProviderMap.Lookup(new IndexProviderDescriptor("provider2", "1.2")));
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotSupportMultipleProvidersWithSameDescriptor()
        internal virtual void ShouldNotSupportMultipleProvidersWithSameDescriptor()
        {
            // given
            IndexProviderDescriptor descriptor = new IndexProviderDescriptor("provider", "1.2");
            IndexProvider           provider1  = mock(typeof(IndexProvider));

            when(provider1.ProviderDescriptor).thenReturn(descriptor);
            IndexProvider provider2 = mock(typeof(IndexProvider));

            when(provider2.ProviderDescriptor).thenReturn(descriptor);

            Dependencies dependencies = new Dependencies();

            dependencies.SatisfyDependency(provider1);
            dependencies.SatisfyDependency(provider2);

            // when
            assertThrows(typeof(System.ArgumentException), () => CreateDefaultProviderMap(dependencies, descriptor).init());
        }
Ejemplo n.º 14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertParseIndexRule(String serialized, String name) throws Exception
        private void AssertParseIndexRule(string serialized, string name)
        {
            // GIVEN
            long                    ruleId        = 24;
            IndexDescriptor         index         = ForLabel(512, 4);
            IndexProviderDescriptor indexProvider = new IndexProviderDescriptor("index-provider", "25.0");

            sbyte[] bytes = DecodeBase64(serialized);

            // WHEN
            StoreIndexDescriptor deserialized = AssertIndexRule(SchemaRuleSerialization.Deserialize(ruleId, ByteBuffer.wrap(bytes)));

            // THEN
            assertThat(deserialized.Id, equalTo(ruleId));
            assertThat(deserialized, equalTo(index));
            assertThat(deserialized.Schema(), equalTo(index.Schema()));
            assertThat(deserialized.ProviderDescriptor(), equalTo(indexProvider));
            assertThat(deserialized.Name, @is(name));
            assertException(deserialized.getOwningConstraint, typeof(System.InvalidOperationException));
        }
Ejemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportInvalidPropertyReferenceFromIndexRule() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportInvalidPropertyReferenceFromIndexRule()
        {
            // given
            int schemaRuleId = 0;

            DynamicRecord           record             = InUse(DynamicRecord(schemaRuleId));
            IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("in-memory", "1.0");
            StoreIndexDescriptor    rule = indexRule(schemaRuleId, _labelId, _propertyKeyId, providerDescriptor);

            when(Checker().ruleAccess.loadSingleSchemaRule(schemaRuleId)).thenReturn(rule);

            Add(InUse(new LabelTokenRecord(_labelId)));
            PropertyKeyTokenRecord propertyKeyToken = Add(NotInUse(new PropertyKeyTokenRecord(_propertyKeyId)));

            // when
            Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport report = Check(record);

            // then
            verify(report).propertyKeyNotInUse(propertyKeyToken);
        }
Ejemplo n.º 16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertParseUniqueIndexRule(String serialized, String name) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        private void AssertParseUniqueIndexRule(string serialized, string name)
        {
            // GIVEN
            long                    ruleId        = 33;
            long                    constraintId  = 11;
            IndexDescriptor         index         = TestIndexDescriptorFactory.uniqueForLabel(61, 988);
            IndexProviderDescriptor indexProvider = new IndexProviderDescriptor("index-provider", "25.0");

            sbyte[] bytes = DecodeBase64(serialized);

            // WHEN
            StoreIndexDescriptor deserialized = AssertIndexRule(SchemaRuleSerialization.Deserialize(ruleId, ByteBuffer.wrap(bytes)));

            // THEN
            assertThat(deserialized.Id, equalTo(ruleId));
            assertThat(deserialized, equalTo(index));
            assertThat(deserialized.Schema(), equalTo(index.Schema()));
            assertThat(deserialized.ProviderDescriptor(), equalTo(indexProvider));
            assertThat(deserialized.OwningConstraint, equalTo(constraintId));
            assertThat(deserialized.Name, @is(name));
        }
Ejemplo n.º 17
0
 public static StoreIndexDescriptor ConstraintIndexRule(long ruleId, int labelId, int propertyId, IndexProviderDescriptor descriptor)
 {
     return(IndexDescriptorFactory.uniqueForSchema(forLabel(labelId, propertyId), descriptor).withId(ruleId));
 }
Ejemplo n.º 18
0
 public static IndexDescriptor UniqueForSchema(SchemaDescriptor schema, IndexProviderDescriptor providerDescriptor)
 {
     return(UniqueForSchema(schema, null, providerDescriptor));
 }
Ejemplo n.º 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleWeirdCharactersInProviderKey()
        public virtual void ShouldHandleWeirdCharactersInProviderKey()
        {
            IndexProviderDescriptor providerWithWeirdName = new IndexProviderDescriptor("native+lucene", "1.0");

            AssertCorrectDirectories(directoriesByProvider(_databaseStoreDir).forProvider(providerWithWeirdName), path(_baseIndexDirectory, "native_lucene-1.0"), path(_baseIndexDirectory, "native_lucene-1.0", _indexId.ToString()));
        }
Ejemplo n.º 20
0
 public static IndexDescriptor UniqueForSchema(SchemaDescriptor schema, Optional <string> name, IndexProviderDescriptor providerDescriptor)
 {
     return(new IndexDescriptor(schema, UNIQUE, name, providerDescriptor));
 }
Ejemplo n.º 21
0
 public static IndexDescriptor ForSchema(SchemaDescriptor schema, Optional <string> name, IndexProviderDescriptor providerDescriptor)
 {
     return(new IndexDescriptor(schema, GENERAL, name, providerDescriptor));
 }
Ejemplo n.º 22
0
 private static string FileNameFriendly(IndexProviderDescriptor descriptor)
 {
     return(FileNameFriendly(descriptor.Key + "-" + descriptor.Version));
 }
Ejemplo n.º 23
0
 private static DefaultIndexProviderMap CreateDefaultProviderMap(Dependencies dependencies, IndexProviderDescriptor descriptor)
 {
     return(new DefaultIndexProviderMap(dependencies, Config.defaults(GraphDatabaseSettings.default_schema_provider, descriptor.Name())));
 }