Search in sources :

Example 31 with RecordAccessStub

use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.

the class OwnerCheckTest method shouldReportNodeWithReferenceToTheGraphGlobalChain.

@Test
public void shouldReportNodeWithReferenceToTheGraphGlobalChain() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<NodeRecord, ConsistencyReport.NodeConsistencyReport> nodeChecker = decorator.decorateNodeChecker(dummyNodeCheck());
    RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker(dummyNeoStoreCheck());
    RecordAccessStub records = new RecordAccessStub();
    NodeRecord node = records.add(inUse(new NodeRecord(1, false, NONE, 7)));
    NeoStoreRecord master = records.add(new NeoStoreRecord());
    master.setNextProp(node.getNextProp());
    // when
    ConsistencyReport.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records);
    ConsistencyReport.NodeConsistencyReport nodeReport = check(ConsistencyReport.NodeConsistencyReport.class, nodeChecker, node, records);
    // then
    verifyZeroInteractions(masterReport);
    verify(nodeReport).multipleOwners(master);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 32 with RecordAccessStub

use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.

the class OwnerCheckTest method shouldReportDynamicRecordOwnedByOtherDynamicRecordAndPropertyKey.

@Test
public void shouldReportDynamicRecordOwnedByOtherDynamicRecordAndPropertyKey() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true, DynamicStore.PROPERTY_KEY);
    RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> dynChecker = decorator.decorateDynamicChecker(RecordType.PROPERTY_KEY_NAME, dummyDynamicCheck(configureDynamicStore(50), DynamicStore.PROPERTY_KEY));
    RecordCheck<PropertyKeyTokenRecord, ConsistencyReport.PropertyKeyTokenConsistencyReport> keyCheck = decorator.decoratePropertyKeyTokenChecker(dummyPropertyKeyCheck());
    DynamicRecord owned = records.addPropertyKeyName(inUse(string(new DynamicRecord(42))));
    DynamicRecord dynamic = records.addPropertyKeyName(inUse(string(new DynamicRecord(1))));
    PropertyKeyTokenRecord key = records.add(inUse(new PropertyKeyTokenRecord(1)));
    dynamic.setNextBlock(owned.getId());
    key.setNameId((int) owned.getId());
    // when
    ConsistencyReport.DynamicConsistencyReport dynReport = check(ConsistencyReport.DynamicConsistencyReport.class, dynChecker, dynamic, records);
    ConsistencyReport.PropertyKeyTokenConsistencyReport keyReport = check(ConsistencyReport.PropertyKeyTokenConsistencyReport.class, keyCheck, key, records);
    // then
    verifyNoMoreInteractions(dynReport);
    verify(keyReport).nameMultipleOwners(dynamic);
    verifyNoMoreInteractions(keyReport);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 33 with RecordAccessStub

use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.

the class OwnerCheckTest method shouldNotReportAnythingForNodesNotInUse.

@Test
public void shouldNotReportAnythingForNodesNotInUse() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<NodeRecord, ConsistencyReport.NodeConsistencyReport> nodeChecker = decorator.decorateNodeChecker(dummyNodeCheck());
    RecordAccessStub records = new RecordAccessStub();
    NodeRecord node1 = records.add(notInUse(new NodeRecord(1, false, NONE, 6)));
    NodeRecord node2 = records.add(notInUse(new NodeRecord(2, false, NONE, 6)));
    // when
    ConsistencyReport.NodeConsistencyReport report1 = check(ConsistencyReport.NodeConsistencyReport.class, nodeChecker, node1, records);
    ConsistencyReport.NodeConsistencyReport report2 = check(ConsistencyReport.NodeConsistencyReport.class, nodeChecker, node2, records);
    // then
    verifyZeroInteractions(report1);
    verifyZeroInteractions(report2);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 34 with RecordAccessStub

use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.

the class OwnerCheckTest method shouldReportDynamicRecordOwnedByTwoOtherDynamicRecords.

@Test
public void shouldReportDynamicRecordOwnedByTwoOtherDynamicRecords() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true, DynamicStore.STRING);
    RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> checker = decorator.decorateDynamicChecker(RecordType.STRING_PROPERTY, dummyDynamicCheck(configureDynamicStore(50), DynamicStore.STRING));
    DynamicRecord record1 = records.add(inUse(string(new DynamicRecord(1))));
    DynamicRecord record2 = records.add(inUse(string(new DynamicRecord(2))));
    DynamicRecord record3 = records.add(inUse(string(new DynamicRecord(3))));
    record1.setNextBlock(record3.getId());
    record2.setNextBlock(record3.getId());
    // when
    ConsistencyReport.DynamicConsistencyReport report1 = check(ConsistencyReport.DynamicConsistencyReport.class, checker, record1, records);
    ConsistencyReport.DynamicConsistencyReport report2 = check(ConsistencyReport.DynamicConsistencyReport.class, checker, record2, records);
    // then
    verifyNoMoreInteractions(report1);
    verify(report2).nextMultipleOwners(record1);
    verifyNoMoreInteractions(report2);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 35 with RecordAccessStub

use of org.neo4j.consistency.store.RecordAccessStub in project neo4j by neo4j.

the class OwnerCheckTest method shouldReportOrphanedDynamicPropertyKeyRecord.

@Test
public void shouldReportOrphanedDynamicPropertyKeyRecord() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck owners = new OwnerCheck(true, DynamicStore.PROPERTY_KEY);
    RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> stringCheck = owners.decorateDynamicChecker(RecordType.PROPERTY_KEY_NAME, dummyDynamicCheck(configureDynamicStore(60), DynamicStore.PROPERTY_KEY));
    DynamicRecord record = string(inUse(new DynamicRecord(42)));
    // when
    ConsistencyReport.DynamicConsistencyReport report = check(ConsistencyReport.DynamicConsistencyReport.class, stringCheck, record, records);
    owners.scanForOrphanChains(ProgressMonitorFactory.NONE);
    records.checkDeferred();
    // then
    verify(report).orphanDynamicRecord();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) 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