@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 ); }
@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 ); }
@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 ); }
@Test public void shouldApplyCreateIndexRuleSchemaRuleCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplierFacade( newApplier( false ), newIndexApplier() ); final DynamicRecord record = DynamicRecord.dynamicRecord( 21, true ); record.setCreated(); 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 ) ).createIndexes( rule ); verify( cacheAccess, times( 1 ) ).addSchemaRule( rule ); }
@Test public void shouldApplyNodePropertyCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setNodeId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( lockService, times( 1 ) ).acquireNodeLock( 42, LockService.LockType.WRITE_LOCK ); verify( propertyStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }
@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 shouldApplyRelationshipGroupCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); // when final RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 1 ); final RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 1, 2, 3, 4, 5, 6, true ); final Command command = new Command.RelationshipGroupCommand( before, after ); boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipGroupStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( relationshipGroupStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyRelationshipGroupCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); // when final RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 1 ); final RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 1, 2, 3, 4, 5, 6, true ); final Command command = new Command.RelationshipGroupCommand( before, after ); final boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipGroupStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyNodePropertyCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setNodeId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( lockService, times( 1 ) ).acquireNodeLock( 42, LockService.LockType.WRITE_LOCK ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyRelPropertyCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setRelId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( propertyStore, times( 1 ) ).setHighestPossibleIdInUse( 12 ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyNodeCommandToTheStoreAndInvalidateTheCache() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final NodeRecord before = new NodeRecord( 11 ); before.setLabelField( 42, asList( one, two ) ); final NodeRecord after = new NodeRecord( 12 ); after.setInUse( false ); after.setLabelField( 42, asList( one, two, three ) ); final Command.NodeCommand command = new Command.NodeCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( lockService, times( 1 ) ).acquireNodeLock( command.getKey(), LockService.LockType.WRITE_LOCK ); verify( nodeStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyRelationshipCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final RelationshipRecord before = new RelationshipRecord( 12 ); final RelationshipRecord record = new RelationshipRecord( 12, 3, 4, 5 ); record.setInUse( true ); final Command command = new Command.RelationshipCommand( before, record ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipStore, times( 1 ) ).setHighestPossibleIdInUse( record.getId() ); verify( relationshipStore, times( 1 ) ).updateRecord( record ); }
@Test public void shouldApplyRelPropertyCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setRelId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyRelationshipCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final RelationshipRecord before = new RelationshipRecord( 12 ); final RelationshipRecord record = new RelationshipRecord( 12, 3, 4, 5 ); record.setInUse( true ); final Command command = new Command.RelationshipCommand( before, record ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipStore, times( 1 ) ).updateRecord( record ); }
@Test public void shouldApplyRelationshipCommandToTheStoreAndInvalidateTheCache() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final RelationshipRecord before = new RelationshipRecord( 12 ); final RelationshipRecord record = new RelationshipRecord( 12, 3, 4, 5 ); record.setInUse( false ); final Command command = new Command.RelationshipCommand( before, record ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipStore, times( 1 ) ).updateRecord( record ); }
@Test public void shouldApplyNeoStoreCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final NeoStoreRecord before = new NeoStoreRecord(); final NeoStoreRecord after = new NeoStoreRecord(); after.setNextProp( 42 ); final Command command = new Command.NeoStoreCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( metaDataStore, times( 1 ) ).setGraphNextProp( after.getNextProp() ); }
@Test public void shouldApplyLabelTokenCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final LabelTokenRecord before = new LabelTokenRecord( 42 ); final LabelTokenRecord after = new LabelTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command command = new LabelTokenCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( labelTokenStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyNeoStoreCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final NeoStoreRecord before = new NeoStoreRecord(); final NeoStoreRecord after = new NeoStoreRecord(); after.setNextProp( 42 ); final Command command = new Command.NeoStoreCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( metaDataStore, times( 1 ) ).setGraphNextProp( after.getNextProp() ); }
@Test public void shouldApplyPropertyKeyTokenCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final PropertyKeyTokenRecord before = new PropertyKeyTokenRecord( 42 ); final PropertyKeyTokenRecord after = new PropertyKeyTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command command = new PropertyKeyTokenCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( propertyKeyTokenStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyRelationshipTypeTokenCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord( 42 ); final RelationshipTypeTokenRecord after = new RelationshipTypeTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command command = new RelationshipTypeTokenCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipTypeTokenStore, times( 1 ) ).updateRecord( after ); }