@Test public void shouldUpdateLabelStoreScanOnNodeCommands() throws Exception { // given final IndexBatchTransactionApplier applier = newIndexTransactionApplier(); final NodeRecord before = new NodeRecord( 11 ); before.setLabelField( 17, emptyDynamicRecords ); final NodeRecord after = new NodeRecord( 12 ); after.setLabelField( 18, emptyDynamicRecords ); final Command.NodeCommand command = new Command.NodeCommand( before, after ); LabelScanWriter labelScanWriter = mock( LabelScanWriter.class ); when( labelScanStore.get() ).thenReturn( labelScanWriter ); // when boolean result; try ( TransactionApplier txApplier = applier.startTx( transactionToApply ) ) { result = txApplier.visitNodeCommand( command ); } // then assertFalse( result ); }
@Test public void shouldDropIndexGivenDropSchemaRuleCommand() throws Exception { // Given final StoreIndexDescriptor indexRule = indexRule( 1, 42, 42, INDEX_DESCRIPTOR ); final IndexBatchTransactionApplier applier = newIndexTransactionApplier(); final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( singleton( createdDynamicRecord( 1 ) ), singleton( dynamicRecord( 1, false ) ), indexRule ); // When boolean result; try ( TransactionApplier txApplier = applier.startTx( transactionToApply ) ) { result = txApplier.visitSchemaRuleCommand( command ); } // Then assertFalse( result ); verify( indexingService ).dropIndex( indexRule ); }
@Test public void shouldProvideLabelScanStoreUpdatesSortedByNodeId() throws Exception { // GIVEN IndexingService indexing = mock( IndexingService.class ); when( indexing.convertToIndexUpdates( any(), eq( EntityType.NODE ) ) ).thenAnswer( o -> Iterables.empty() ); LabelScanWriter writer = new OrderVerifyingLabelScanWriter( 10, 15, 20 ); WorkSync<Supplier<LabelScanWriter>,LabelUpdateWork> labelScanSync = spy( new WorkSync<>( singletonProvider( writer ) ) ); WorkSync<IndexingUpdateService,IndexUpdatesWork> indexUpdatesSync = new WorkSync<>( indexing ); TransactionToApply tx = mock( TransactionToApply.class ); PropertyStore propertyStore = mock( PropertyStore.class ); try ( IndexBatchTransactionApplier applier = new IndexBatchTransactionApplier( indexing, labelScanSync, indexUpdatesSync, mock( NodeStore.class ), mock( RelationshipStore.class ), new PropertyPhysicalToLogicalConverter( propertyStore ), new IndexActivator( indexing ) ) ) { try ( TransactionApplier txApplier = applier.startTx( tx ) ) { // WHEN txApplier.visitNodeCommand( node( 15 ) ); txApplier.visitNodeCommand( node( 20 ) ); txApplier.visitNodeCommand( node( 10 ) ); } } // THEN all assertions happen inside the LabelScanWriter#write and #close verify( labelScanSync ).applyAsync( any() ); }
@Test public void shouldCreateIndexGivenCreateSchemaRuleCommand() throws Exception { // Given final StoreIndexDescriptor indexRule = indexRule( 1, 42, 42, INDEX_DESCRIPTOR ); final IndexBatchTransactionApplier applier = newIndexTransactionApplier(); final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand( emptyDynamicRecords, singleton( createdDynamicRecord( 1 ) ), indexRule ); // When boolean result; try ( TransactionApplier txApplier = applier.startTx( transactionToApply ) ) { result = txApplier.visitSchemaRuleCommand( command ); } // Then assertFalse( result ); verify( indexingService ).createIndexes( indexRule ); }
new PropertyPhysicalToLogicalConverter( propertyStore ), indexActivator ) ) try ( TransactionApplier txApplier = applier.startTx( tx ) )