use of org.neo4j.kernel.api.TokenNameLookup in project neo4j by neo4j.
the class SchemaStorageTest method shouldThrowExceptionOnRelationshipDuplicateRuleFound.
@Test
public void shouldThrowExceptionOnRelationshipDuplicateRuleFound() throws DuplicateSchemaRuleException, SchemaRuleNotFoundException {
// GIVEN
TokenNameLookup tokenNameLookup = getDefaultTokenNameLookup();
SchemaStorage schemaStorageSpy = Mockito.spy(storage);
Mockito.when(schemaStorageSpy.loadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(getRelationshipPropertyExistenceConstraintRule(1L, TYPE1, PROP1), getRelationshipPropertyExistenceConstraintRule(2L, TYPE1, PROP1)));
//EXPECT
expectedException.expect(DuplicateSchemaRuleException.class);
expectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple relationship property existence constraints found for -[:Type1(prop1)]-."));
// WHEN
schemaStorageSpy.constraintsGetSingle(ConstraintDescriptorFactory.existsForRelType(typeId(TYPE1), propId(PROP1)));
}
use of org.neo4j.kernel.api.TokenNameLookup in project neo4j by neo4j.
the class SchemaStorageTest method getDefaultTokenNameLookup.
private TokenNameLookup getDefaultTokenNameLookup() {
TokenNameLookup tokenNameLookup = Mockito.mock(TokenNameLookup.class);
Mockito.when(tokenNameLookup.labelGetName(labelId(LABEL1))).thenReturn(LABEL1);
Mockito.when(tokenNameLookup.propertyKeyGetName(propId(PROP1))).thenReturn(PROP1);
Mockito.when(tokenNameLookup.relationshipTypeGetName(typeId(TYPE1))).thenReturn(TYPE1);
return tokenNameLookup;
}
use of org.neo4j.kernel.api.TokenNameLookup in project neo4j by neo4j.
the class OperationsFacadeTest method testThrowExceptionWhenDuplicateUniqueIndexFound.
@Test
public void testThrowExceptionWhenDuplicateUniqueIndexFound() throws SchemaRuleNotFoundException, DuplicateSchemaRuleException {
SchemaReadOperations readOperations = setupSchemaReadOperations();
NewIndexDescriptor index = NewIndexDescriptorFactory.forSchema(SchemaBoundary.map(descriptor));
Mockito.when(readOperations.uniqueIndexesGetForLabel(Mockito.any(KernelStatement.class), Mockito.eq(descriptor.getLabelId()))).thenReturn(Iterators.iterator(index, index));
TokenNameLookup tokenNameLookup = getDefaultTokenNameLookup();
expectedException.expect(DuplicateSchemaRuleException.class);
expectedException.expect(new KernelExceptionUserMessageMatcher<>(tokenNameLookup, "Multiple constraint indexs found for :Label1(Prop1)."));
operationsFacade.uniqueIndexGetForLabelAndPropertyKey(descriptor);
}
use of org.neo4j.kernel.api.TokenNameLookup in project neo4j by neo4j.
the class OperationsFacadeTest method getDefaultTokenNameLookup.
private TokenNameLookup getDefaultTokenNameLookup() {
TokenNameLookup tokenNameLookup = Mockito.mock(TokenNameLookup.class);
Mockito.when(tokenNameLookup.labelGetName(descriptor.getLabelId())).thenReturn(LABEL1);
Mockito.when(tokenNameLookup.propertyKeyGetName(descriptor.getPropertyKeyId())).thenReturn(PROP1);
return tokenNameLookup;
}
use of org.neo4j.kernel.api.TokenNameLookup in project neo4j by neo4j.
the class BuiltInProcedures method listConstraints.
@Description("List all constraints in the database.")
@Procedure(name = "db.constraints", mode = READ)
public Stream<ConstraintResult> listConstraints() {
Statement statement = tx.acquireStatement();
ReadOperations operations = statement.readOperations();
TokenNameLookup tokens = new StatementTokenNameLookup(operations);
return asList(operations.constraintsGetAll()).stream().map((constraint) -> constraint.prettyPrint(tokens)).sorted().map(ConstraintResult::new).onClose(statement::close);
}
Aggregations