Search in sources :

Example 16 with RecordAccessStub

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);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) LabelScanDocument(org.neo4j.consistency.store.synthetic.LabelScanDocument) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 17 with RecordAccessStub

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);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) LabelScanDocument(org.neo4j.consistency.store.synthetic.LabelScanDocument) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 18 with RecordAccessStub

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);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 19 with RecordAccessStub

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);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 20 with RecordAccessStub

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);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)38 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)38 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)38 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)16 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)13 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)12 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)9 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)8 NeoStoreRecord (org.neo4j.kernel.impl.store.record.NeoStoreRecord)5 LabelScanDocument (org.neo4j.consistency.store.synthetic.LabelScanDocument)4 ChainCheck (org.neo4j.consistency.checking.ChainCheck)3 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)3 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)3