use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class DuplicatePropertyTest method shouldReportDuplicatePropertyIndexesInPropertyRecordForNode.
@Test
public void shouldReportDuplicatePropertyIndexesInPropertyRecordForNode() throws Exception {
// given
ChainCheck check = new ChainCheck();
RecordAccessStub records = new RecordAccessStub();
NodeRecord master = records.add(inUse(new NodeRecord(1, false, -1, 1)));
PropertyRecord propertyRecord = inUse(new PropertyRecord(1));
PropertyBlock firstBlock = new PropertyBlock();
firstBlock.setSingleBlock(1);
firstBlock.setKeyIndexId(1);
PropertyBlock secondBlock = new PropertyBlock();
secondBlock.setSingleBlock(1);
secondBlock.setKeyIndexId(2);
PropertyBlock thirdBlock = new PropertyBlock();
thirdBlock.setSingleBlock(1);
thirdBlock.setKeyIndexId(1);
propertyRecord.addPropertyBlock(firstBlock);
propertyRecord.addPropertyBlock(secondBlock);
propertyRecord.addPropertyBlock(thirdBlock);
records.add(propertyRecord);
// when
ConsistencyReport.NodeConsistencyReport report = mock(ConsistencyReport.NodeConsistencyReport.class);
CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> checkEngine = records.engine(master, report);
check.checkReference(master, propertyRecord, checkEngine, records);
// then
verify(report).propertyKeyNotUniqueInChain();
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class DuplicatePropertyTest method shouldReportDuplicatePropertyIndexesAcrossRecordsInPropertyChainForNode.
@Test
public void shouldReportDuplicatePropertyIndexesAcrossRecordsInPropertyChainForNode() throws Exception {
// given
ChainCheck check = new ChainCheck();
RecordAccessStub records = new RecordAccessStub();
RelationshipRecord master = records.add(inUse(new RelationshipRecord(1, 2, 3, 4)));
master.setNextProp(1);
PropertyRecord firstRecord = inUse(new PropertyRecord(1));
firstRecord.setNextProp(12);
PropertyBlock firstBlock = new PropertyBlock();
firstBlock.setSingleBlock(1);
firstBlock.setKeyIndexId(1);
PropertyBlock secondBlock = new PropertyBlock();
secondBlock.setSingleBlock(1);
secondBlock.setKeyIndexId(2);
PropertyRecord secondRecord = inUse(new PropertyRecord(12));
secondRecord.setPrevProp(1);
PropertyBlock thirdBlock = new PropertyBlock();
thirdBlock.setSingleBlock(1);
thirdBlock.setKeyIndexId(4);
PropertyBlock fourthBlock = new PropertyBlock();
fourthBlock.setSingleBlock(1);
fourthBlock.setKeyIndexId(1);
firstRecord.addPropertyBlock(firstBlock);
firstRecord.addPropertyBlock(secondBlock);
secondRecord.addPropertyBlock(thirdBlock);
secondRecord.addPropertyBlock(fourthBlock);
records.add(firstRecord);
records.add(secondRecord);
// when
ConsistencyReport.RelationshipConsistencyReport report = mock(ConsistencyReport.RelationshipConsistencyReport.class);
CheckerEngine<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> checkEngine = records.engine(master, report);
check.checkReference(master, firstRecord, checkEngine, records);
records.checkDeferred();
// then
verify(report).propertyKeyNotUniqueInChain();
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class DuplicatePropertyTest method shouldNotReportAnythingForConsistentChains.
@Test
public void shouldNotReportAnythingForConsistentChains() throws Exception {
// given
ChainCheck check = new ChainCheck();
RecordAccessStub records = new RecordAccessStub();
RelationshipRecord master = records.add(inUse(new RelationshipRecord(1, 2, 3, 4)));
master.setNextProp(1);
PropertyRecord firstRecord = inUse(new PropertyRecord(1));
firstRecord.setNextProp(12);
PropertyBlock firstBlock = new PropertyBlock();
firstBlock.setSingleBlock(1);
firstBlock.setKeyIndexId(1);
PropertyBlock secondBlock = new PropertyBlock();
secondBlock.setSingleBlock(1);
secondBlock.setKeyIndexId(2);
PropertyRecord secondRecord = inUse(new PropertyRecord(12));
secondRecord.setPrevProp(1);
PropertyBlock thirdBlock = new PropertyBlock();
thirdBlock.setSingleBlock(1);
thirdBlock.setKeyIndexId(4);
PropertyBlock fourthBlock = new PropertyBlock();
fourthBlock.setSingleBlock(11);
fourthBlock.setKeyIndexId(11);
firstRecord.addPropertyBlock(firstBlock);
firstRecord.addPropertyBlock(secondBlock);
secondRecord.addPropertyBlock(thirdBlock);
secondRecord.addPropertyBlock(fourthBlock);
records.add(firstRecord);
records.add(secondRecord);
// when
ConsistencyReport.RelationshipConsistencyReport report = mock(ConsistencyReport.RelationshipConsistencyReport.class);
CheckerEngine<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> checkEngine = records.engine(master, report);
check.checkReference(master, firstRecord, checkEngine, records);
records.checkDeferred();
// then
verifyZeroInteractions(report);
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class NodeInUseWithCorrectLabelsCheckTest method reportNodeWithoutLabelsWhenLabelsAreDynamic.
@Test
public void reportNodeWithoutLabelsWhenLabelsAreDynamic() {
int nodeId = 42;
long[] indexLabelIds = { 3, 7, 9, 10 };
long[] storeLabelIds = {};
long[] missingLabelIds = { 3, 7, 9, 10 };
RecordAccessStub recordAccess = new RecordAccessStub();
NodeRecord node = inUse(withDynamicLabels(recordAccess, new NodeRecord(nodeId, false, 0, 0), storeLabelIds));
ConsistencyReport.LabelScanConsistencyReport report = mock(ConsistencyReport.LabelScanConsistencyReport.class);
// when
CheckerEngine<LabelScanDocument, ConsistencyReport.LabelScanConsistencyReport> engine = recordAccess.engine(null, report);
checker(indexLabelIds, true).checkReference(null, node, engine, recordAccess);
recordAccess.checkDeferred();
// then
for (long missingLabelId : missingLabelIds) {
verify(report).nodeDoesNotHaveExpectedLabel(node, missingLabelId);
}
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class NodeInUseWithCorrectLabelsCheckTest method shouldReportNodeWithoutExpectedLabelWhenLabelsAreDynamicBothDirections.
@Test
public void shouldReportNodeWithoutExpectedLabelWhenLabelsAreDynamicBothDirections() throws Exception {
// given
int nodeId = 42;
long[] indexLabelIds = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
long[] storeLabelIds = { 1, 2, 3, 4, 5, 6, 8, 9, 10, 11 };
RecordAccessStub recordAccess = new RecordAccessStub();
NodeRecord node = inUse(withDynamicLabels(recordAccess, new NodeRecord(nodeId, false, 0, 0), storeLabelIds));
ConsistencyReport.LabelScanConsistencyReport report = mock(ConsistencyReport.LabelScanConsistencyReport.class);
// when
CheckerEngine<LabelScanDocument, ConsistencyReport.LabelScanConsistencyReport> engine = recordAccess.engine(null, report);
checker(indexLabelIds, true).checkReference(null, node, engine, recordAccess);
recordAccess.checkDeferred();
// then
verify(report).nodeDoesNotHaveExpectedLabel(node, 7);
verify(report).nodeLabelNotInIndex(node, 11);
}
Aggregations