//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); }
//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); }
//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); }
//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); }
//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)); }
public IndexDescriptor(SchemaDescriptor schema, Type type, Optional <string> userSuppliedName, IndexProviderDescriptor providerDescriptor) { this.SchemaConflict = schema; this.TypeConflict = type; this.UserSuppliedNameConflict = userSuppliedName; this.ProviderDescriptorConflict = providerDescriptor; }
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); } }
//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(); }
//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(); }
//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); }
//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(); }
//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"))); }
//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()); }
//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)); }
//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); }
//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)); }
public static StoreIndexDescriptor ConstraintIndexRule(long ruleId, int labelId, int propertyId, IndexProviderDescriptor descriptor) { return(IndexDescriptorFactory.uniqueForSchema(forLabel(labelId, propertyId), descriptor).withId(ruleId)); }
public static IndexDescriptor UniqueForSchema(SchemaDescriptor schema, IndexProviderDescriptor providerDescriptor) { return(UniqueForSchema(schema, null, providerDescriptor)); }
//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())); }
public static IndexDescriptor UniqueForSchema(SchemaDescriptor schema, Optional <string> name, IndexProviderDescriptor providerDescriptor) { return(new IndexDescriptor(schema, UNIQUE, name, providerDescriptor)); }
public static IndexDescriptor ForSchema(SchemaDescriptor schema, Optional <string> name, IndexProviderDescriptor providerDescriptor) { return(new IndexDescriptor(schema, GENERAL, name, providerDescriptor)); }
private static string FileNameFriendly(IndexProviderDescriptor descriptor) { return(FileNameFriendly(descriptor.Key + "-" + descriptor.Version)); }
private static DefaultIndexProviderMap CreateDefaultProviderMap(Dependencies dependencies, IndexProviderDescriptor descriptor) { return(new DefaultIndexProviderMap(dependencies, Config.defaults(GraphDatabaseSettings.default_schema_provider, descriptor.Name()))); }