@Test public void shouldApplyDeleteUniquenessConstraintRuleSchemaRuleCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); record.setInUse( false ); final Collection<DynamicRecord> recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( schemaStore, times( 1 ) ).updateRecord( record ); verify( metaDataStore, never() ).setLatestConstraintIntroducingTx( transactionId ); verify( cacheAccess, times( 1 ) ).removeSchemaRuleFromCache( command.getKey() ); }
@Test public void shouldApplyDeleteUniquenessConstraintRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); record.setInUse( false ); final Collection<DynamicRecord> recordsAfter = singletonList( record ); final ConstraintRule rule = uniquenessConstraintRule( 0L, 1, 2, 3L ); final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( schemaStore, times( 1 ) ).setHighestPossibleIdInUse( record.getId() ); verify( schemaStore, times( 1 ) ).updateRecord( record ); verify( metaDataStore, never() ).setLatestConstraintIntroducingTx( transactionId ); verify( cacheAccess, times( 1 ) ).removeSchemaRuleFromCache( command.getKey() ); }
@Test public void shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplierFacade( newIndexApplier(), newApplier( true ) ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); record.setInUse( false ); final Collection<DynamicRecord> recordsAfter = singletonList( record ); final StoreIndexDescriptor rule = indexRule( 0, 1, 2, new IndexProviderDescriptor( "K", "X.Y" ) ); final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( schemaStore, times( 1 ) ).setHighestPossibleIdInUse( record.getId() ); verify( schemaStore, times( 1 ) ).updateRecord( record ); verify( indexingService, times( 1 ) ).dropIndex( rule ); verify( cacheAccess, times( 1 ) ).removeSchemaRuleFromCache( command.getKey() ); }
cacheAccess.removeSchemaRuleFromCache( command.getKey() ); break; default:
cacheAccess.removeSchemaRuleFromCache( command.getKey() ); break; default:
@Test public void shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore() throws Exception { // given final BatchTransactionApplier base = newApplier( false ); final BatchTransactionApplier indexApplier = newIndexApplier(); final BatchTransactionApplierFacade applier = new BatchTransactionApplierFacade( base, indexApplier ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); record.setInUse( false ); final Collection<DynamicRecord> recordsAfter = singletonList( record ); final StoreIndexDescriptor rule = indexRule( 0, 1, 2, new IndexProviderDescriptor( "K", "X.Y" ) ); final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( Collections.emptyList(), recordsAfter, rule ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( schemaStore, times( 1 ) ).updateRecord( record ); verify( indexingService, times( 1 ) ).dropIndex( rule ); verify( cacheAccess, times( 1 ) ).removeSchemaRuleFromCache( command.getKey() ); }
private void assertSchemaRule( SchemaRuleCommand readSchemaCommand ) { assertEquals( id, readSchemaCommand.getKey() ); assertTrue( SchemaDescriptorPredicates.hasLabel( readSchemaCommand.getSchemaRule(), labelId ) ); assertTrue( SchemaDescriptorPredicates.hasProperty( readSchemaCommand.getSchemaRule(), propertyKey ) ); }