Search in sources :

Example 1 with KernelExceptionUserMessageMatcher

use of org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher 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)));
}
Also used : TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) KernelExceptionUserMessageMatcher(org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher) Test(org.junit.Test)

Example 2 with KernelExceptionUserMessageMatcher

use of org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher in project neo4j by neo4j.

the class SchemaStorageTest method shouldThrowExceptionOnNodeRuleNotFound.

@Test
public void shouldThrowExceptionOnNodeRuleNotFound() throws DuplicateSchemaRuleException, SchemaRuleNotFoundException {
    // GIVEN
    TokenNameLookup tokenNameLookup = getDefaultTokenNameLookup();
    // EXPECT
    expectedException.expect(SchemaRuleNotFoundException.class);
    expectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "No node property existence constraint was found for :Label1(prop1)."));
    // WHEN
    storage.constraintsGetSingle(ConstraintDescriptorFactory.existsForLabel(labelId(LABEL1), propId(PROP1)));
}
Also used : TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) KernelExceptionUserMessageMatcher(org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher) Test(org.junit.Test)

Example 3 with KernelExceptionUserMessageMatcher

use of org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher 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)

Aggregations

Test (org.junit.Test)3 TokenNameLookup (org.neo4j.kernel.api.TokenNameLookup)3 KernelExceptionUserMessageMatcher (org.neo4j.test.mockito.matcher.KernelExceptionUserMessageMatcher)3