use of org.neo4j.kernel.impl.transaction.state.storeview.NodeStoreScan in project neo4j by neo4j.
the class NodeStoreScanTest method shouldGiveBackCompletionPercentage.
@Test
public void shouldGiveBackCompletionPercentage() throws Throwable {
// given
final int total = 10;
when(nodeStore.getHighId()).thenReturn((long) total);
NodeRecord inUseRecord = new NodeRecord(42);
inUseRecord.setInUse(true);
when(nodeStore.getRecord(anyLong(), any(NodeRecord.class), any(RecordLoad.class))).thenReturn(inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord);
final PercentageSupplier percentageSupplier = new PercentageSupplier();
final NodeStoreScan scan = new NodeStoreScan(nodeStore, locks, total) {
private int read = 0;
@Override
public void acceptUpdate(MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId) {
// no-op
}
@Override
public void configure(List list) {
// no-op
}
@Override
public void process(NodeRecord node) {
// then
read++;
float expected = (float) read / total;
float actual = percentageSupplier.get();
assertEquals(String.format("%f==%f", expected, actual), expected, actual, 0.0);
}
};
percentageSupplier.setStoreScan(scan);
// when
scan.run();
}
Aggregations