Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportTwoUniquenessConstraintsReferencingSameIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportTwoUniquenessConstraintsReferencingSameIndex()
        {
            // given
            int ruleId1 = 0;
            int ruleId2 = 1;

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

            ConstraintRule rule1 = uniquenessConstraintRule(ruleId1, _labelId, _propertyKeyId, ruleId2);
            ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, _labelId, _propertyKeyId, 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).duplicateObligation(record1);
        }
Пример #2
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);
        }
Пример #3
0
 protected internal override ConstraintDescriptor ReadNonStandardConstraint(ConstraintRule rule, string errorMessage)
 {
     if (!rule.ConstraintDescriptor.enforcesPropertyExistence())
     {
         throw new System.InvalidOperationException("Unsupported constraint type: " + rule);
     }
     return(rule.ConstraintDescriptor);
 }
Пример #4
0
        public override ConstraintDescriptor ReadConstraint(ConstraintRule rule)
        {
            ConstraintDescriptor desc = rule.ConstraintDescriptor;

            switch (desc.Type())
            {
            case EXISTS:
                return(ReadNonStandardConstraint(rule, ERROR_MESSAGE_EXISTS));

            case UNIQUE_EXISTS:
                return(ReadNonStandardConstraint(rule, ERROR_MESSAGE_NODE_KEY));

            default:
                return(desc);
            }
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetLatestConstraintRule() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSetLatestConstraintRule()
        {
            // Given
            SchemaRecord beforeRecords = Serialize(_rule, _id, true, true);
            SchemaRecord afterRecords  = Serialize(_rule, _id, true, false);

            when(_neoStores.SchemaStore).thenReturn(_schemaStore);
            when(_neoStores.MetaDataStore).thenReturn(_metaDataStore);

            ConstraintRule schemaRule = ConstraintRule.constraintRule(_id, ConstraintDescriptorFactory.uniqueForLabel(_labelId, _propertyKey), 0);

            // WHEN
            VisitSchemaRuleCommand(_storeApplier, new Command.SchemaRuleCommand(beforeRecords, afterRecords, schemaRule));

            // THEN
            verify(_schemaStore).updateRecord(Iterables.first(afterRecords));
            verify(_metaDataStore).LatestConstraintIntroducingTx = _txId;
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportInvalidPropertyReferenceFromUniquenessConstraintRule() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportInvalidPropertyReferenceFromUniquenessConstraintRule()
        {
            // given
            int schemaRuleId = 0;
            int indexRuleId  = 1;

            DynamicRecord record = InUse(DynamicRecord(schemaRuleId));

            ConstraintRule rule = uniquenessConstraintRule(schemaRuleId, _labelId, _propertyKeyId, indexRuleId);

            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);
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReportUnreferencedUniquenessConstraint() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldReportUnreferencedUniquenessConstraint()
        {
            // given
            int ruleId = 0;

            DynamicRecord record = InUse(DynamicRecord(ruleId));

            ConstraintRule rule = uniquenessConstraintRule(ruleId, _labelId, _propertyKeyId, 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.ConstraintIndexRule);
        }
Пример #8
0
 public static ConstraintRule RelPropertyExistenceConstraintRule(long ruleId, int labelId, int propertyId)
 {
     return(ConstraintRule.constraintRule(ruleId, ConstraintDescriptorFactory.existsForRelType(labelId, propertyId)));
 }
Пример #9
0
 public static ConstraintRule UniquenessConstraintRule(long ruleId, int labelId, int propertyId, long indexId)
 {
     return(ConstraintRule.constraintRule(ruleId, ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyId), indexId));
 }
Пример #10
0
 public abstract ConstraintDescriptor ReadConstraint(ConstraintRule rule);
Пример #11
0
 protected internal virtual ConstraintDescriptor ReadNonStandardConstraint(ConstraintRule rule, string errorMessage)
 {
     // When opening a store in Community Edition that contains a Property Existence Constraint
     throw new System.InvalidOperationException(errorMessage);
 }
Пример #12
0
 public override ConstraintRule CreateUniquenessConstraintRule(long ruleId, UniquenessConstraintDescriptor descriptor, long indexId)
 {
     return(ConstraintRule.constraintRule(ruleId, descriptor, indexId));
 }
Пример #13
0
 public override ConstraintRule CreateExistenceConstraint(long ruleId, ConstraintDescriptor descriptor)
 {
     return(ConstraintRule.constraintRule(ruleId, descriptor));
 }
Пример #14
0
 public override ConstraintRule CreateNodeKeyConstraintRule(long ruleId, NodeKeyConstraintDescriptor descriptor, long indexId)
 {
     return(ConstraintRule.constraintRule(ruleId, descriptor, indexId));
 }