//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void constraintRuleNameMustNotBeTheEmptyString()
        public virtual void ConstraintRuleNameMustNotBeTheEmptyString()
        {
            //noinspection RedundantStringConstructorCall
            string name = "";

            ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1), name);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertParseNodePropertyExistsRule(String serialized, String name) throws Exception
        private void AssertParseNodePropertyExistsRule(string serialized, string name)
        {
            // GIVEN
            long ruleId      = 87;
            int  propertyKey = 51;
            int  labelId     = 45;
            ConstraintDescriptor constraint = ConstraintDescriptorFactory.existsForLabel(labelId, propertyKey);

            sbyte[] bytes = DecodeBase64(serialized);

            // WHEN
            ConstraintRule deserialized = AssertConstraintRule(SchemaRuleSerialization.Deserialize(ruleId, ByteBuffer.wrap(bytes)));

            // THEN
            assertThat(deserialized.Id, equalTo(ruleId));
            assertThat(deserialized.ConstraintDescriptor, equalTo(constraint));
            assertThat(deserialized.Schema(), equalTo(constraint.Schema()));
            assertException(deserialized.getOwnedIndex, typeof(System.InvalidOperationException));
            assertThat(deserialized.Name, @is(name));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void constraintRuleNameMustNotContainNullCharacter()
        public virtual void ConstraintRuleNameMustNotContainNullCharacter()
        {
            string name = "a\0b";

            ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1), name);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rulesCreatedWithNullNameMustRetainComputedNameAfterDeserialisation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RulesCreatedWithNullNameMustRetainComputedNameAfterDeserialisation()
        {
            assertThat(SerialiseAndDeserialise(ForLabel(LABEL_ID, PROPERTY_ID_1).withId(RULE_ID)).Name, @is("index_1"));
            assertThat(SerialiseAndDeserialise(UniqueForLabel(LABEL_ID, PROPERTY_ID_1).withIds(RULE_ID_2, RULE_ID)).Name, @is("index_2"));
            assertThat(SerialiseAndDeserialise(ForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withId(RULE_ID)).Name, @is("index_1"));
            assertThat(SerialiseAndDeserialise(UniqueForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withIds(RULE_ID_2, RULE_ID)).Name, @is("index_2"));
            assertThat(SerialiseAndDeserialise(ForLabel(LABEL_ID, IntStream.range(1, 200).toArray()).withId(RULE_ID)).Name, @is("index_1"));

            string name = null;

            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1), name)).Name, @is("constraint_1"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.uniqueForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is("constraint_2"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.nodeKeyForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is("constraint_2"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1), name)).Name, @is("constraint_2"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is("constraint_1"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is("constraint_2"));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rulesCreatedWithNameMustRetainGivenNameAfterDeserialisation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RulesCreatedWithNameMustRetainGivenNameAfterDeserialisation()
        {
            string name = "custom_rule";

            assertThat(SerialiseAndDeserialise(NamedForLabel(name, LABEL_ID, PROPERTY_ID_1).withId(RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedUniqueForLabel(name, LABEL_ID, PROPERTY_ID_1).withIds(RULE_ID_2, RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedForLabel(name, LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withId(RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedUniqueForLabel(name, LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withIds(RULE_ID_2, RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedForLabel(name, LABEL_ID, IntStream.range(1, 200).toArray()).withId(RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1), name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.uniqueForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.nodeKeyForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1), name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is(name));
        }
Пример #6
0
 public static ConstraintRule NodePropertyExistenceConstraintRule(long ruleId, int labelId, int propertyId)
 {
     return(ConstraintRule.constraintRule(ruleId, ConstraintDescriptorFactory.existsForLabel(labelId, propertyId)));
 }