コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGetRelatedNodeConstraints()
        public virtual void ShouldGetRelatedNodeConstraints()
        {
            // given
            ConstraintRule constraint1 = ConstraintRule.constraintRule(1L, ConstraintDescriptorFactory.uniqueForLabel(1, 5, 6), null);
            ConstraintRule constraint2 = ConstraintRule.constraintRule(2L, ConstraintDescriptorFactory.uniqueForLabel(1, 5), null);
            ConstraintRule constraint3 = ConstraintRule.constraintRule(3L, ConstraintDescriptorFactory.uniqueForLabel(2, 5), null);

            _indexMap.putUniquenessConstraint(constraint1);
            _indexMap.putUniquenessConstraint(constraint2);
            _indexMap.putUniquenessConstraint(constraint3);

            // when/then
            assertEquals(asSet(constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), true, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), false, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5, 6), true, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(), EntityTokens(1), Properties(5), false, NODE));
            assertEquals(asSet(constraint1.ConstraintDescriptor, constraint2.ConstraintDescriptor, constraint3.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1, 2), EntityTokens(), Properties(), false, NODE));
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveNodeConstraints()
        public virtual void ShouldRemoveNodeConstraints()
        {
            // given
            ConstraintRule constraint1 = ConstraintRule.constraintRule(1L, ConstraintDescriptorFactory.uniqueForLabel(1, 5, 6), null);
            ConstraintRule constraint2 = ConstraintRule.constraintRule(2L, ConstraintDescriptorFactory.uniqueForLabel(1, 5), null);
            ConstraintRule constraint3 = ConstraintRule.constraintRule(3L, ConstraintDescriptorFactory.uniqueForLabel(2, 5), null);

            _indexMap.putUniquenessConstraint(constraint1);
            _indexMap.putUniquenessConstraint(constraint2);
            _indexMap.putUniquenessConstraint(constraint3);
            assertEquals(asSet(constraint2.ConstraintDescriptor), _indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), true, NODE));

            // and when
            _indexMap.removeUniquenessConstraint(constraint1.Id);
            _indexMap.removeUniquenessConstraint(constraint2.Id);
            _indexMap.removeUniquenessConstraint(constraint3.Id);

            // then
            assertTrue(_indexMap.getRelatedConstraints(EntityTokens(1), EntityTokens(), Properties(5), true, NODE).Count == 0);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldValidateUniquenessIndexes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
		 public virtual void ShouldValidateUniquenessIndexes()
		 {
			  // Given
			  NeoStores store = mock( typeof( NeoStores ) );
			  IndexingService indexes = mock( typeof( IndexingService ) );
			  IntegrityValidator validator = new IntegrityValidator( store, indexes );
			  UniquenessConstraintDescriptor constraint = ConstraintDescriptorFactory.uniqueForLabel( 1, 1 );

			  doThrow( new UniquePropertyValueValidationException( constraint, ConstraintValidationException.Phase.VERIFICATION, new Exception() ) ).when(indexes).validateIndex(2L);

			  ConstraintRule record = ConstraintRule.constraintRule( 1L, constraint, 2L );

			  // When
			  try
			  {
					validator.ValidateSchemaRule( record );
					fail( "Should have thrown integrity error." );
			  }
			  catch ( Exception )
			  {
					// good
			  }
		 }
コード例 #4
0
 private ConstraintRule GetRelationshipPropertyExistenceConstraintRule(long id, string type, string property)
 {
     return(ConstraintRule.constraintRule(id, ConstraintDescriptorFactory.existsForRelType(TypeId(type), PropId(property))));
 }
コード例 #5
0
 private ConstraintRule GetUniquePropertyConstraintRule(long id, string label, string property)
 {
     return(ConstraintRule.constraintRule(id, ConstraintDescriptorFactory.uniqueForLabel(LabelId(label), PropId(property)), 0L));
 }
コード例 #6
0
ファイル: SchemaStoreTest.cs プロジェクト: Neo4Net/Neo4Net
 private ConstraintRule ConstraintExistsRule(long ruleId, int labelId, params int[] propertyIds)
 {
     return(ConstraintRule.constraintRule(ruleId, ConstraintDescriptorFactory.existsForLabel(labelId, propertyIds)));
 }
コード例 #7
0
ファイル: SchemaStoreTest.cs プロジェクト: Neo4Net/Neo4Net
 private ConstraintRule ConstraintUniqueRule(long ruleId, long ownedIndexId, int labelId, params int[] propertyIds)
 {
     return(ConstraintRule.constraintRule(ruleId, ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyIds), ownedIndexId));
 }