Search in sources :

Example 1 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportDynamicRecordOwnedByPropertyKeyAndOtherDynamicRecord.

@Test
public void shouldReportDynamicRecordOwnedByPropertyKeyAndOtherDynamicRecord() 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.PropertyKeyTokenConsistencyReport keyReport = check(ConsistencyReport.PropertyKeyTokenConsistencyReport.class, keyCheck, key, records);
    ConsistencyReport.DynamicConsistencyReport dynReport = check(ConsistencyReport.DynamicConsistencyReport.class, dynChecker, dynamic, records);
    // then
    verifyNoMoreInteractions(keyReport);
    verify(dynReport).nextMultipleOwners(key);
    verifyNoMoreInteractions(dynReport);
}
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 2 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportRelationshipWithReferenceToTheGraphGlobalChain.

@Test
public void shouldReportRelationshipWithReferenceToTheGraphGlobalChain() 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.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records);
    ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
    // then
    verifyZeroInteractions(masterReport);
    verify(relationshipReport).multipleOwners(master);
}
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)

Example 3 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportNodeWithSamePropertyChainAsRelationship.

@Test
public void shouldReportNodeWithSamePropertyChainAsRelationship() 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.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
    ConsistencyReport.NodeConsistencyReport nodeReport = check(ConsistencyReport.NodeConsistencyReport.class, nodeChecker, node, records);
    // then
    verifyZeroInteractions(relationshipReport);
    verify(nodeReport).multipleOwners(relationship);
}
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 4 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportOrphanedDynamicStringRecord.

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

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

the class OwnerCheckTest method shouldReportDynamicArrayRecordOwnedByOtherDynamicAndProperty.

@Test
public void shouldReportDynamicArrayRecordOwnedByOtherDynamicAndProperty() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true, DynamicStore.ARRAY);
    RecordCheck<DynamicRecord, ConsistencyReport.DynamicConsistencyReport> dynChecker = decorator.decorateDynamicChecker(RecordType.ARRAY_PROPERTY, dummyDynamicCheck(configureDynamicStore(50), DynamicStore.ARRAY));
    RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> propChecker = decorator.decoratePropertyChecker(dummyPropertyChecker());
    DynamicRecord owned = records.add(inUse(array(new DynamicRecord(42))));
    DynamicRecord dynamic = records.add(inUse(array(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.ARRAY, 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).arrayMultipleOwners(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)

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