@Override public boolean visitLabelTokenCommand( LabelTokenCommand command ) { NamedToken labelId = labelTokenStore.getToken( (int) command.getKey() ); cacheAccess.addLabelToken( labelId ); return false; }
@Override public boolean visitPropertyKeyTokenCommand( PropertyKeyTokenCommand command ) { NamedToken index = propertyKeyTokenStore.getToken( (int) command.getKey() ); cacheAccess.addPropertyKeyToken( index ); return false; }
@Override public boolean visitRelationshipTypeTokenCommand( RelationshipTypeTokenCommand command ) { NamedToken type = relationshipTypeTokenStore.getToken( (int) command.getKey() ); cacheAccess.addRelationshipTypeToken( type ); return false; }
@Test public void shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); 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, times( 1 ) ).setLatestConstraintIntroducingTx( transactionId ); verify( cacheAccess, times( 1 ) ).addSchemaRule( rule ); }
cacheAccess.removeSchemaRuleFromCache( command.getKey() ); break; default: cacheAccess.addSchemaRule( command.getSchemaRule() );
@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 shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); 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, times( 1 ) ).setLatestConstraintIntroducingTx( transactionId ); verify( cacheAccess, times( 1 ) ).addSchemaRule( rule ); }
cacheAccess.removeSchemaRuleFromCache( command.getKey() ); break; default: cacheAccess.addSchemaRule( command.getSchemaRule() );
@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 shouldApplyCreateUniquenessConstraintRuleSchemaRuleCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); record.setCreated(); 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, times( 1 ) ).setLatestConstraintIntroducingTx( transactionId ); verify( cacheAccess, times( 1 ) ).addSchemaRule( rule ); }
@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() ); }
@Test public void shouldApplyLabelTokenCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final LabelTokenRecord before = new LabelTokenRecord( 42 ); final LabelTokenRecord after = new LabelTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command.LabelTokenCommand command = new Command.LabelTokenCommand( before, after ); final NamedToken token = new NamedToken( "token", 21 ); when( labelTokenStore.getToken( (int) command.getKey() ) ).thenReturn( token ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( labelTokenStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( labelTokenStore, times( 1 ) ).updateRecord( after ); verify( cacheAccess, times( 1 ) ).addLabelToken( token ); }
@Test public void shouldApplyPropertyKeyTokenCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final PropertyKeyTokenRecord before = new PropertyKeyTokenRecord( 42 ); final PropertyKeyTokenRecord after = new PropertyKeyTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command.PropertyKeyTokenCommand command = new Command.PropertyKeyTokenCommand( before, after ); final NamedToken token = new NamedToken( "token", 21 ); when( propertyKeyTokenStore.getToken( (int) command.getKey() ) ).thenReturn( token ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( propertyKeyTokenStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( propertyKeyTokenStore, times( 1 ) ).updateRecord( after ); verify( cacheAccess, times( 1 ) ).addPropertyKeyToken( token ); }
@Test public void shouldApplyRelationshipTypeTokenCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord( 42 ); final RelationshipTypeTokenRecord after = new RelationshipTypeTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand( before, after ); final NamedToken token = new NamedToken( "token", 21 ); when( relationshipTypeTokenStore.getToken( (int) command.getKey() ) ).thenReturn( token ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipTypeTokenStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( relationshipTypeTokenStore, times( 1 ) ).updateRecord( after ); verify( cacheAccess, times( 1 ) ).addRelationshipTypeToken( token ); }
@Test public void shouldApplyCreateUniquenessConstraintRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); record.setCreated(); 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, times( 1 ) ).setLatestConstraintIntroducingTx( transactionId ); verify( cacheAccess, times( 1 ) ).addSchemaRule( rule ); }
@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() ); }
@Override public boolean visitLabelTokenCommand( LabelTokenCommand command ) { NamedToken labelId = labelTokenStore.getToken( (int) command.getKey() ); cacheAccess.addLabelToken( labelId ); return false; }
@Override public boolean visitPropertyKeyTokenCommand( PropertyKeyTokenCommand command ) { NamedToken index = propertyKeyTokenStore.getToken( (int) command.getKey() ); cacheAccess.addPropertyKeyToken( index ); return false; }
@Override public boolean visitRelationshipTypeTokenCommand( RelationshipTypeTokenCommand command ) { NamedToken type = relationshipTypeTokenStore.getToken( (int) command.getKey() ); cacheAccess.addRelationshipTypeToken( type ); return false; }
@Test public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplierFacade( newIndexApplier(), newApplier( false ) ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); final Collection<DynamicRecord> recordsAfter = singletonList( record ); final StoreIndexDescriptor rule = constraintIndexRule( 0, 1, 2, new IndexProviderDescriptor( "K", "X.Y" ), 42L ); 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 ) ).activateIndex( rule.getId() ); verify( cacheAccess, times( 1 ) ).addSchemaRule( rule ); }