Search in sources :

Example 21 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportDynamicArrayRecordOwnedByTwoPropertyRecords.

@Test
public void shouldReportDynamicArrayRecordOwnedByTwoPropertyRecords() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true, DynamicStore.ARRAY);
    RecordCheck<PropertyRecord, ConsistencyReport.PropertyConsistencyReport> propChecker = decorator.decoratePropertyChecker(dummyPropertyChecker());
    DynamicRecord dynamic = records.add(inUse(array(new DynamicRecord(42))));
    PropertyRecord property1 = records.add(inUse(new PropertyRecord(1)));
    PropertyRecord property2 = records.add(inUse(new PropertyRecord(2)));
    PropertyKeyTokenRecord key = records.add(inUse(new PropertyKeyTokenRecord(10)));
    property1.addPropertyBlock(propertyBlock(key, PropertyType.ARRAY, dynamic.getId()));
    property2.addPropertyBlock(propertyBlock(key, PropertyType.ARRAY, dynamic.getId()));
    // when
    ConsistencyReport.PropertyConsistencyReport report1 = check(ConsistencyReport.PropertyConsistencyReport.class, propChecker, property1, records);
    ConsistencyReport.PropertyConsistencyReport report2 = check(ConsistencyReport.PropertyConsistencyReport.class, propChecker, property2, records);
    // then
    verifyNoMoreInteractions(report1);
    verify(report2).arrayMultipleOwners(property1);
    verifyNoMoreInteractions(report2);
}
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 22 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportOrphanedDynamicRelationshipLabelRecord.

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

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

the class OwnerCheckTest method shouldNotReportOrphanIfOwnedByNode.

@Test
public void shouldNotReportOrphanIfOwnedByNode() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true);
    PropertyRecord record = inUse(new PropertyRecord(42));
    ConsistencyReport.PropertyConsistencyReport report = check(ConsistencyReport.PropertyConsistencyReport.class, decorator.decoratePropertyChecker(dummyPropertyChecker()), record, records);
    ConsistencyReport.NodeConsistencyReport nodeReport = check(ConsistencyReport.NodeConsistencyReport.class, decorator.decorateNodeChecker(dummyNodeCheck()), inUse(new NodeRecord(10, false, NONE, 42)), records);
    // when
    decorator.scanForOrphanChains(ProgressMonitorFactory.NONE);
    records.checkDeferred();
    // then
    verifyNoMoreInteractions(report);
    verifyNoMoreInteractions(nodeReport);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 24 with RecordAccessStub

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

the class OwnerCheckTest method shouldNotReportOrphanIfOwnedByNeoStore.

@Test
public void shouldNotReportOrphanIfOwnedByNeoStore() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true);
    PropertyRecord record = inUse(new PropertyRecord(42));
    ConsistencyReport.PropertyConsistencyReport report = check(ConsistencyReport.PropertyConsistencyReport.class, decorator.decoratePropertyChecker(dummyPropertyChecker()), record, records);
    NeoStoreRecord master = inUse(new NeoStoreRecord());
    master.setNextProp(42);
    ConsistencyReport.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, decorator.decorateNeoStoreChecker(dummyNeoStoreCheck()), master, records);
    // when
    decorator.scanForOrphanChains(ProgressMonitorFactory.NONE);
    records.checkDeferred();
    // then
    verifyNoMoreInteractions(report);
    verifyNoMoreInteractions(masterReport);
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 25 with RecordAccessStub

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

the class OwnerCheckTest method shouldReportDynamicRecordOwnedByTwoRelationshipLabels.

@Test
public void shouldReportDynamicRecordOwnedByTwoRelationshipLabels() throws Exception {
    // given
    RecordAccessStub records = new RecordAccessStub();
    OwnerCheck decorator = new OwnerCheck(true, DynamicStore.RELATIONSHIP_TYPE);
    RecordCheck<RelationshipTypeTokenRecord, ConsistencyReport.RelationshipTypeConsistencyReport> checker = decorator.decorateRelationshipTypeTokenChecker(dummyRelationshipLabelCheck());
    DynamicRecord dynamic = records.addRelationshipTypeName(inUse(string(new DynamicRecord(42))));
    RelationshipTypeTokenRecord record1 = records.add(inUse(new RelationshipTypeTokenRecord(1)));
    RelationshipTypeTokenRecord record2 = records.add(inUse(new RelationshipTypeTokenRecord(2)));
    record1.setNameId((int) dynamic.getId());
    record2.setNameId((int) dynamic.getId());
    // when
    ConsistencyReport.RelationshipTypeConsistencyReport report1 = check(ConsistencyReport.RelationshipTypeConsistencyReport.class, checker, record1, records);
    ConsistencyReport.RelationshipTypeConsistencyReport report2 = check(ConsistencyReport.RelationshipTypeConsistencyReport.class, checker, record2, records);
    // then
    verifyNoMoreInteractions(report1);
    verify(report2).nameMultipleOwners(record1);
    verifyNoMoreInteractions(report2);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) 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