Search in sources :

Example 1 with ChainCheck

use of org.neo4j.consistency.checking.ChainCheck 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 2 with ChainCheck

use of org.neo4j.consistency.checking.ChainCheck 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 3 with ChainCheck

use of org.neo4j.consistency.checking.ChainCheck 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)

Aggregations

Test (org.junit.Test)3 ChainCheck (org.neo4j.consistency.checking.ChainCheck)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)3 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)3 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)3 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)1