private static IndexDefinitionImpl MockIndexDefinition() { IndexDefinitionImpl indexDefinition = mock(typeof(IndexDefinitionImpl)); when(indexDefinition.IndexReference).thenReturn(IndexReference.NO_INDEX); return(indexDefinition); }
public override ConstraintDefinition Create() { AssertInUnterminatedTransaction(); IndexDefinitionImpl definition = new IndexDefinitionImpl(Actions, null, new Label[] { Label }, PropertyKeys.ToArray(), true); return(Actions.createPropertyUniquenessConstraint(definition)); }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } IndexDefinitionImpl other = ( IndexDefinitionImpl )obj; if (InternalIsNodeIndex()) { if (other._labels == null) { return(false); } if (_labels.Length != other._labels.Length) { return(false); } for (int i = 0; i < _labels.Length; i++) { if (!_labels[i].name().Equals(other._labels[i].name())) { return(false); } } } if (_relTypes != null) { if (other._relTypes == null) { return(false); } if (_relTypes.Length != other._relTypes.Length) { return(false); } for (int i = 0; i < _relTypes.Length; i++) { if (!_relTypes[i].name().Equals(other._relTypes[i].name())) { return(false); } } } return(Arrays.Equals(_propertyKeys, other._propertyKeys)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void includeCauseOfFailure() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void IncludeCauseOfFailure() { // given IndexDefinitionImpl indexDefinition = MockIndexDefinition(); when(indexDefinition.ToString()).thenReturn("IndexDefinition( of-some-sort )"); KernelTransaction kernelTransaction = MockKernelTransaction(); SchemaImpl schema = new SchemaImpl(() => kernelTransaction); // when System.InvalidOperationException e = assertThrows(typeof(System.InvalidOperationException), () => Schema.awaitIndexOnline(indexDefinition, 1, TimeUnit.MINUTES)); // then assertThat(e.Message, Matchers.containsString(indexDefinition.ToString())); assertThat(e.Message, Matchers.containsString(Exceptions.stringify(_cause))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static org.neo4j.internal.kernel.api.IndexReference getIndexReference(org.neo4j.internal.kernel.api.SchemaRead schemaRead, org.neo4j.internal.kernel.api.TokenRead tokenRead, IndexDefinitionImpl index) throws org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException private static IndexReference GetIndexReference(SchemaRead schemaRead, TokenRead tokenRead, IndexDefinitionImpl index) { // Use the precise embedded index reference when available. IndexReference reference = index.IndexReference; if (reference != null) { return(reference); } // Otherwise attempt to reverse engineer the schema that will let us look up the real IndexReference. int[] propertyKeyIds = ResolveAndValidatePropertyKeys(tokenRead, index.PropertyKeysArrayShared); SchemaDescriptor schema; if (index.NodeIndex) { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: int[] labelIds = ResolveAndValidateTokens("Label", index.LabelArrayShared, Label::name, tokenRead.nodeLabel); if (index.MultiTokenIndex) { schema = multiToken(labelIds, EntityType.NODE, propertyKeyIds); } else { schema = forLabel(labelIds[0], propertyKeyIds); } } else if (index.RelationshipIndex) { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: int[] relTypes = ResolveAndValidateTokens("Relationship type", index.RelationshipTypesArrayShared, RelationshipType::name, tokenRead.relationshipType); if (index.MultiTokenIndex) { schema = multiToken(relTypes, EntityType.RELATIONSHIP, propertyKeyIds); } else { schema = forRelType(relTypes[0], propertyKeyIds); } } else { throw new System.ArgumentException("The given index is neither a node index, nor a relationship index: " + index + "."); } reference = schemaRead.Index(schema); if (reference == IndexReference.NO_INDEX) { throw new SchemaRuleNotFoundException(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.IndexRule, schema); } return(reference); }