Search in sources :

Example 6 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportDynamicRecordOwnedByTwoPropertyKeys.

@Test
public void shouldReportDynamicRecordOwnedByTwoPropertyKeys() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true, DynamicStore.PROPERTY_KEY);
    RecordCheck<PropertyKeyTokenRecord, ConsistencyReport.PropertyKeyTokenConsistencyReport> checker = decorator.decoratePropertyKeyTokenChecker(dummyPropertyKeyCheck());
    DynamicRecord dynamic = records.addPropertyKeyName(inUse(string(new DynamicRecord(42))));
    PropertyKeyTokenRecord record1 = records.add(inUse(new PropertyKeyTokenRecord(1)));
    PropertyKeyTokenRecord record2 = records.add(inUse(new PropertyKeyTokenRecord(2)));
    record1.setNameId((int) dynamic.getId());
    record2.setNameId((int) dynamic.getId());
    // when
    ConsistencyReport.PropertyKeyTokenConsistencyReport report1 = check(ConsistencyReport.PropertyKeyTokenConsistencyReport.class, checker, record1, records);
    ConsistencyReport.PropertyKeyTokenConsistencyReport report2 = check(ConsistencyReport.PropertyKeyTokenConsistencyReport.class, checker, record2, records);
    // then
    verifyNoMoreInteractions(report1);
    verify(report2).nameMultipleOwners(record1);
    verifyNoMoreInteractions(report2);
}
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 7 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportDynamicStringRecordOwnedByOtherDynamicAndProperty.

@Test
public void shouldReportDynamicStringRecordOwnedByOtherDynamicAndProperty() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true, DynamicStore.STRING);
    RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> dynChecker = decorator.decorateDynamicChecker(RecordType.STRING_PROPERTY, dummyDynamicCheck(configureDynamicStore(50), DynamicStore.STRING));
    RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> propChecker = decorator.decoratePropertyChecker(dummyPropertyChecker());
    DynamicRecord owned = records.add(inUse(string(new DynamicRecord(42))));
    DynamicRecord dynamic = records.add(inUse(string(new DynamicRecord(100))));
    dynamic.setNextBlock(owned.getId());
    PropertyRecord property = records.add(inUse(new PropertyRecord(1)));
    PropertyKeyTokenRecord key = records.add(inUse(new PropertyKeyTokenRecord(10)));
    property.addPropertyBlock(propertyBlock(key, PropertyType.STRING, owned.getId()));
    // when
    ConsistencyReport.DynamicConsistencyReport dynReport = check(ConsistencyReport.DynamicConsistencyReport.class, dynChecker, dynamic, records);
    ConsistencyReport.PropertyConsistencyReport propReport = check(ConsistencyReport.PropertyConsistencyReport.class, propChecker, property, records);
    // then
    verifyNoMoreInteractions(dynReport);
    verify(propReport).stringMultipleOwners(dynamic);
    verifyNoMoreInteractions(dynReport);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) 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 8 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportOrphanedDynamicArrayRecord.

@Test
public void shouldReportOrphanedDynamicArrayRecord() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck owners = new OwnerCheck(true, DynamicStore.ARRAY);
    RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> stringCheck = owners.decorateDynamicChecker(RecordType.ARRAY_PROPERTY, dummyDynamicCheck(configureDynamicStore(60), DynamicStore.ARRAY));
    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)

Example 9 with RecordAccessStub

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

the class OwnerCheckTest method shouldNotReportAnythingForNodesWithDifferentPropertyChains.

@Test
public void shouldNotReportAnythingForNodesWithDifferentPropertyChains() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<NodeRecord, ConsistencyReport.NodeConsistencyReport> nodeChecker = decorator.decorateNodeChecker(dummyNodeCheck());
    RecordAccessStub records = new RecordAccessStub();
    NodeRecord node1 = records.add(inUse(new NodeRecord(1, false, NONE, 7)));
    NodeRecord node2 = records.add(inUse(new NodeRecord(2, false, NONE, 8)));
    // 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 10 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportNodeStoreReferencingSameChainAsRelationship.

@Test
public void shouldReportNodeStoreReferencingSameChainAsRelationship() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker(dummyRelationshipChecker());
    RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker(dummyNeoStoreCheck());
    RecordAccessStub records = new RecordAccessStub();
    NeoStoreRecord master = records.add(new NeoStoreRecord());
    master.setNextProp(7);
    RelationshipRecord relationship = records.add(inUse(new RelationshipRecord(1, 0, 1, 0)));
    relationship.setNextProp(7);
    // when
    ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
    ConsistencyReport.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records);
    // then
    verifyZeroInteractions(relationshipReport);
    verify(masterReport).multipleOwners(relationship);
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) 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