Search in sources :

Example 11 with TokenNameLookup

use of org.neo4j.kernel.api.TokenNameLookup in project neo4j by neo4j.

the class SchemaStorageTest method shouldThrowExceptionOnNodeDuplicateRuleFound.

@Test
public void shouldThrowExceptionOnNodeDuplicateRuleFound() throws DuplicateSchemaRuleException, SchemaRuleNotFoundException {
    // GIVEN
    TokenNameLookup tokenNameLookup = getDefaultTokenNameLookup();
    SchemaStorage schemaStorageSpy = Mockito.spy(storage);
    Mockito.when(schemaStorageSpy.loadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(getUniquePropertyConstraintRule(1L, LABEL1, PROP1), getUniquePropertyConstraintRule(2L, LABEL1, PROP1)));
    //EXPECT
    expectedException.expect(DuplicateSchemaRuleException.class);
    expectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple uniqueness constraints found for :Label1(prop1)."));
    // WHEN
    schemaStorageSpy.constraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(labelId(LABEL1), propId(PROP1)));
}
Also used : TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) KernelExceptionUserMessageMatcher(org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher) Test(org.junit.Test)

Example 12 with TokenNameLookup

use of org.neo4j.kernel.api.TokenNameLookup in project neo4j by neo4j.

the class SchemaStorageTest method shouldThrowExceptionOnRelationshipRuleNotFound.

@Test
public void shouldThrowExceptionOnRelationshipRuleNotFound() throws DuplicateSchemaRuleException, SchemaRuleNotFoundException {
    TokenNameLookup tokenNameLookup = getDefaultTokenNameLookup();
    // EXPECT
    expectedException.expect(SchemaRuleNotFoundException.class);
    expectedException.expect(new KernelExceptionUserMessageMatcher<>(tokenNameLookup, "No relationship property existence constraint was found for -[:Type1(prop1)]-."));
    //WHEN
    storage.constraintsGetSingle(ConstraintDescriptorFactory.existsForRelType(typeId(TYPE1), propId(PROP1)));
}
Also used : TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) Test(org.junit.Test)

Aggregations

TokenNameLookup (org.neo4j.kernel.api.TokenNameLookup)12 Test (org.junit.Test)7 StatementTokenNameLookup (org.neo4j.kernel.api.StatementTokenNameLookup)3 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)3 KernelExceptionUserMessageMatcher (org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher)3 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Set (java.util.Set)2 TimeUnit (java.util.concurrent.TimeUnit)2 Stream (java.util.stream.Stream)2 DependencyResolver (org.neo4j.graphdb.DependencyResolver)2 Label (org.neo4j.graphdb.Label)2 RelationshipType (org.neo4j.graphdb.RelationshipType)2 Iterators.asList (org.neo4j.helpers.collection.Iterators.asList)2 Iterators.asSet (org.neo4j.helpers.collection.Iterators.asSet)2 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)2 ReadOperations (org.neo4j.kernel.api.ReadOperations)2 Statement (org.neo4j.kernel.api.Statement)2 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)2