Skip to content

Commit

Permalink
Fixed broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fickludd committed Mar 27, 2017
1 parent 9b729d1 commit 12323e9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Expand Up @@ -25,6 +25,7 @@
import java.util.function.Supplier; import java.util.function.Supplier;


import org.neo4j.concurrent.WorkSync; import org.neo4j.concurrent.WorkSync;
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.kernel.api.labelscan.LabelScanWriter; import org.neo4j.kernel.api.labelscan.LabelScanWriter;
import org.neo4j.kernel.api.labelscan.NodeLabelUpdate; import org.neo4j.kernel.api.labelscan.NodeLabelUpdate;
import org.neo4j.kernel.impl.api.TransactionApplier; import org.neo4j.kernel.impl.api.TransactionApplier;
Expand All @@ -44,6 +45,7 @@
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.neo4j.kernel.impl.store.record.Record.NO_NEXT_PROPERTY; import static org.neo4j.kernel.impl.store.record.Record.NO_NEXT_PROPERTY;
import static org.neo4j.kernel.impl.store.record.Record.NO_NEXT_RELATIONSHIP; import static org.neo4j.kernel.impl.store.record.Record.NO_NEXT_RELATIONSHIP;


Expand All @@ -54,6 +56,7 @@ public void shouldProvideLabelScanStoreUpdatesSortedByNodeId() throws Exception
{ {
// GIVEN // GIVEN
IndexingService indexing = mock( IndexingService.class ); IndexingService indexing = mock( IndexingService.class );
when( indexing.convertToIndexUpdates( any() ) ).thenAnswer( o -> Iterables.empty() );
LabelScanWriter writer = new OrderVerifyingLabelScanWriter( 10, 15, 20 ); LabelScanWriter writer = new OrderVerifyingLabelScanWriter( 10, 15, 20 );
WorkSync<Supplier<LabelScanWriter>,LabelUpdateWork> labelScanSync = WorkSync<Supplier<LabelScanWriter>,LabelUpdateWork> labelScanSync =
spy( new WorkSync<>( singletonProvider( writer ) ) ); spy( new WorkSync<>( singletonProvider( writer ) ) );
Expand Down
Expand Up @@ -27,6 +27,7 @@
import java.util.function.Supplier; import java.util.function.Supplier;


import org.neo4j.concurrent.WorkSync; import org.neo4j.concurrent.WorkSync;
import org.neo4j.helpers.collection.Iterables;
import org.neo4j.kernel.api.index.SchemaIndexProvider.Descriptor; import org.neo4j.kernel.api.index.SchemaIndexProvider.Descriptor;
import org.neo4j.kernel.api.labelscan.LabelScanWriter; import org.neo4j.kernel.api.labelscan.LabelScanWriter;
import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory; import org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory;
Expand All @@ -44,6 +45,7 @@


import static java.util.Collections.singleton; import static java.util.Collections.singleton;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
Expand All @@ -66,6 +68,7 @@ public class NeoTransactionIndexApplierTest
public void setup() public void setup()
{ {
when( transactionToApply.transactionId() ).thenReturn( 1L ); when( transactionToApply.transactionId() ).thenReturn( 1L );
when( indexingService.convertToIndexUpdates( any() ) ).thenAnswer( o -> Iterables.empty() );
} }


@Test @Test
Expand Down
Expand Up @@ -38,6 +38,9 @@
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.collection.Iterables; import org.neo4j.helpers.collection.Iterables;
import org.neo4j.kernel.api.exceptions.TransactionFailureException; import org.neo4j.kernel.api.exceptions.TransactionFailureException;
import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException;
import org.neo4j.kernel.api.index.IndexEntryUpdate;
import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor;
import org.neo4j.kernel.impl.api.index.IndexingUpdateService; import org.neo4j.kernel.impl.api.index.IndexingUpdateService;
import org.neo4j.kernel.impl.api.index.NodeUpdates; import org.neo4j.kernel.impl.api.index.NodeUpdates;
import org.neo4j.kernel.api.properties.DefinedProperty; import org.neo4j.kernel.api.properties.DefinedProperty;
Expand Down Expand Up @@ -1218,11 +1221,12 @@ private Iterable<NodeUpdates> indexUpdatesOf( NeoStores neoStores, TransactionRe
NodePropertyCommandsExtractor extractor = new NodePropertyCommandsExtractor(); NodePropertyCommandsExtractor extractor = new NodePropertyCommandsExtractor();
transaction.accept( extractor ); transaction.accept( extractor );


OnlineIndexUpdates lazyIndexUpdates = new OnlineIndexUpdates( neoStores.getNodeStore(), CollectingIndexingUpdateService indexingUpdateService = new CollectingIndexingUpdateService();
mock( IndexingUpdateService.class ), OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( neoStores.getNodeStore(),
indexingUpdateService,
new PropertyPhysicalToLogicalConverter( neoStores.getPropertyStore() ) ); new PropertyPhysicalToLogicalConverter( neoStores.getPropertyStore() ) );
lazyIndexUpdates.feed( extractor.propertyCommandsByNodeIds(), extractor.nodeCommandsById() ); onlineIndexUpdates.feed( extractor.propertyCommandsByNodeIds(), extractor.nodeCommandsById() );
return Iterables.empty(); return indexingUpdateService.nodeUpdatesList;
} }


private PhysicalTransactionRepresentation transactionRepresentationOf( TransactionRecordState writeTransaction ) private PhysicalTransactionRepresentation transactionRepresentationOf( TransactionRecordState writeTransaction )
Expand Down Expand Up @@ -1364,4 +1368,21 @@ private RelationshipGroupCommand singleRelationshipGroupCommand( Collection<Stor
{ {
return (RelationshipGroupCommand) Iterables.single( filter( t -> t instanceof RelationshipGroupCommand, commands ) ); return (RelationshipGroupCommand) Iterables.single( filter( t -> t instanceof RelationshipGroupCommand, commands ) );
} }

private class CollectingIndexingUpdateService implements IndexingUpdateService
{
final List<NodeUpdates> nodeUpdatesList = new ArrayList<>();

@Override
public void apply( IndexUpdates updates ) throws IOException, IndexEntryConflictException
{
}

@Override
public Iterable<IndexEntryUpdate<LabelSchemaDescriptor>> convertToIndexUpdates( NodeUpdates nodeUpdates )
{
nodeUpdatesList.add( nodeUpdates );
return Iterables.empty();
}
}
} }

0 comments on commit 12323e9

Please sign in to comment.