private void AssertEqualityByDescriptor(IndexDescriptor descriptor) { StoreIndexDescriptor rule1 = descriptor.WithId(RULE_ID); StoreIndexDescriptor rule2 = descriptor.WithId(RULE_ID_2); StoreIndexDescriptor rule3 = (descriptor.Type() == IndexDescriptor.Type.GENERAL ? forSchema(descriptor.Schema()) : uniqueForSchema(descriptor.Schema())).withId(RULE_ID); AssertEquality(rule1, rule2); AssertEquality(rule1, rule3); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void detectUniqueIndexWithoutOwningConstraint() public virtual void DetectUniqueIndexWithoutOwningConstraint() { IndexDescriptor descriptor = UniqueForLabel(LABEL_ID, PROPERTY_ID_1); StoreIndexDescriptor indexRule = descriptor.WithId(RULE_ID); assertTrue(indexRule.IndexWithoutOwningConstraint); }
// PRIVATE // READ INDEX //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static org.neo4j.storageengine.api.schema.StoreIndexDescriptor readIndexRule(long id, ByteBuffer source) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException private static StoreIndexDescriptor ReadIndexRule(long id, ByteBuffer source) { IndexProviderDescriptor indexProvider = ReadIndexProviderDescriptor(source); sbyte indexRuleType = source.get(); Optional <string> name; switch (indexRuleType) { case GENERAL_INDEX: { SchemaDescriptor schema = ReadSchema(source); name = ReadRuleName(source); return(IndexDescriptorFactory.forSchema(schema, name, indexProvider).withId(id)); } case UNIQUE_INDEX: { long owningConstraint = source.Long; SchemaDescriptor schema = ReadSchema(source); name = ReadRuleName(source); IndexDescriptor descriptor = IndexDescriptorFactory.uniqueForSchema(schema, name, indexProvider); return(owningConstraint == NO_OWNING_CONSTRAINT_YET?descriptor.WithId(id) : descriptor.WithIds(id, owningConstraint)); } default: throw new MalformedSchemaRuleException(format("Got unknown index rule type '%d'.", indexRuleType)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateGeneralIndex() public virtual void ShouldCreateGeneralIndex() { // GIVEN IndexDescriptor descriptor = ForLabel(LABEL_ID, PROPERTY_ID_1); StoreIndexDescriptor indexRule = descriptor.WithId(RULE_ID); // THEN assertThat(indexRule.Id, equalTo(RULE_ID)); assertFalse(indexRule.CanSupportUniqueConstraint()); assertThat(indexRule.Schema(), equalTo(descriptor.Schema())); assertThat(indexRule, equalTo(descriptor)); assertThat(indexRule.ProviderDescriptor(), equalTo(ProviderDescriptor)); assertException(indexRule.getOwningConstraint, typeof(System.InvalidOperationException)); assertException(() => indexRule.WithOwningConstraint(RULE_ID_2), typeof(System.InvalidOperationException)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateUniqueIndex() public virtual void ShouldCreateUniqueIndex() { // GIVEN IndexDescriptor descriptor = UniqueForLabel(LABEL_ID, PROPERTY_ID_1); StoreIndexDescriptor indexRule = descriptor.WithId(RULE_ID); // THEN assertThat(indexRule.Id, equalTo(RULE_ID)); assertTrue(indexRule.CanSupportUniqueConstraint()); assertThat(indexRule.Schema(), equalTo(descriptor.Schema())); assertThat(indexRule, equalTo(descriptor)); assertThat(indexRule.ProviderDescriptor(), equalTo(ProviderDescriptor)); assertThat(indexRule.OwningConstraint, equalTo(null)); StoreIndexDescriptor withConstraint = indexRule.WithOwningConstraint(RULE_ID_2); assertThat(withConstraint.OwningConstraint, equalTo(RULE_ID_2)); assertThat(indexRule.OwningConstraint, equalTo(null)); // this is unchanged }