use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class NodeInUseWithCorrectLabelsCheckTest method shouldReportNodeWithoutExpectedLabelWhenLabelsAreDynamicIndexToStore.
@Test
public void shouldReportNodeWithoutExpectedLabelWhenLabelsAreDynamicIndexToStore() throws Exception {
// given
int nodeId = 42;
long[] indexLabelIds = { 3, 7, 9, 10 };
long[] storeLabelIds = { 1, 2, 3, 4, 5, 6, 8, 9, 10 };
long missingLabelId = 7;
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, missingLabelId);
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class NodeInUseWithCorrectLabelsCheckTest method reportNodeWithoutLabelsWhenLabelsAreInlined.
@Test
public void reportNodeWithoutLabelsWhenLabelsAreInlined() {
int nodeId = 42;
long[] indexLabelIds = { 3 };
long[] storeLabelIds = {};
long missingLabelId = 3;
RecordAccessStub recordAccess = new RecordAccessStub();
NodeRecord node = inUse(withInlineLabels(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, missingLabelId);
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class OwnerCheckTest method shouldReportDynamicRecordOwnedByOtherDynamicRecordAndRelationshipLabel.
@Test
public void shouldReportDynamicRecordOwnedByOtherDynamicRecordAndRelationshipLabel() throws Exception {
// given
RecordAccessStub records = new RecordAccessStub();
OwnerCheck decorator = new OwnerCheck(true, DynamicStore.RELATIONSHIP_TYPE);
RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> dynChecker = decorator.decorateDynamicChecker(RecordType.RELATIONSHIP_TYPE_NAME, dummyDynamicCheck(configureDynamicStore(50), DynamicStore.RELATIONSHIP_TYPE));
RecordCheck<RelationshipTypeTokenRecord, ConsistencyReport.RelationshipTypeConsistencyReport> labelCheck = decorator.decorateRelationshipTypeTokenChecker(dummyRelationshipLabelCheck());
DynamicRecord owned = records.addRelationshipTypeName(inUse(string(new DynamicRecord(42))));
DynamicRecord dynamic = records.addRelationshipTypeName(inUse(string(new DynamicRecord(1))));
RelationshipTypeTokenRecord label = records.add(inUse(new RelationshipTypeTokenRecord(1)));
dynamic.setNextBlock(owned.getId());
label.setNameId((int) owned.getId());
// when
ConsistencyReport.DynamicConsistencyReport dynReport = check(ConsistencyReport.DynamicConsistencyReport.class, dynChecker, dynamic, records);
ConsistencyReport.RelationshipTypeConsistencyReport labelReport = check(ConsistencyReport.RelationshipTypeConsistencyReport.class, labelCheck, label, records);
// then
verifyNoMoreInteractions(dynReport);
verify(labelReport).nameMultipleOwners(dynamic);
verifyNoMoreInteractions(labelReport);
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class OwnerCheckTest method shouldReportRelationshipWithSamePropertyChainAsNode.
@Test
public void shouldReportRelationshipWithSamePropertyChainAsNode() throws Exception {
// given
OwnerCheck decorator = new OwnerCheck(true);
RecordCheck<NodeRecord, ConsistencyReport.NodeConsistencyReport> nodeChecker = decorator.decorateNodeChecker(dummyNodeCheck());
RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker(dummyRelationshipChecker());
RecordAccessStub records = new RecordAccessStub();
NodeRecord node = records.add(inUse(new NodeRecord(1, false, NONE, 7)));
RelationshipRecord relationship = records.add(inUse(new RelationshipRecord(1, 0, 1, 0)));
relationship.setNextProp(node.getNextProp());
// when
ConsistencyReport.NodeConsistencyReport nodeReport = check(ConsistencyReport.NodeConsistencyReport.class, nodeChecker, node, records);
ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
// then
verifyZeroInteractions(nodeReport);
verify(relationshipReport).multipleOwners(node);
}
use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.
the class OwnerCheckTest method shouldNotReportOrphanIfOwnedByRelationship.
@Test
public void shouldNotReportOrphanIfOwnedByRelationship() throws Exception {
// given
RecordAccessStub records = new RecordAccessStub();
OwnerCheck decorator = new OwnerCheck(true);
PropertyRecord record = inUse(new PropertyRecord(42));
ConsistencyReport.PropertyConsistencyReport report = check(ConsistencyReport.PropertyConsistencyReport.class, decorator.decoratePropertyChecker(dummyPropertyChecker()), record, records);
RelationshipRecord relationship = inUse(new RelationshipRecord(10, 1, 1, 0));
relationship.setNextProp(42);
ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, decorator.decorateRelationshipChecker(dummyRelationshipChecker()), relationship, records);
// when
decorator.scanForOrphanChains(ProgressMonitorFactory.NONE);
records.checkDeferred();
// then
verifyNoMoreInteractions(report);
verifyNoMoreInteractions(relationshipReport);
}
Aggregations