@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 ) ) ); }
@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 ) ) ); }
@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 ) ) ); }
@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 ) ) ); }