Search in sources :

Example 11 with RecordAccessStub

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

Example 12 with RecordAccessStub

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

Example 13 with RecordAccessStub

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

Example 14 with RecordAccessStub

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);
    }
}
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 15 with RecordAccessStub

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);
}
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)

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