Search in sources :

Example 6 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class IntegrityValidatorTest method deletingNodeWithRelationshipsIsNotAllowed.

@Test
public void deletingNodeWithRelationshipsIsNotAllowed() throws Exception {
    // Given
    NeoStores store = mock(NeoStores.class);
    IndexingService indexes = mock(IndexingService.class);
    IntegrityValidator validator = new IntegrityValidator(store, indexes);
    NodeRecord record = new NodeRecord(1L, false, 1L, -1L);
    record.setInUse(false);
    // When
    try {
        validator.validateNodeRecord(record);
        fail("Should have thrown integrity error.");
    } catch (Exception e) {
    // good
    }
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) NeoStores(org.neo4j.kernel.impl.store.NeoStores) UniquePropertyValueValidationException(org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException) ConstraintValidationException(org.neo4j.kernel.api.exceptions.schema.ConstraintValidationException) Test(org.junit.Test)

Example 7 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class TransactionRecordStateTest method nodeWithDynamicLabelRecord.

private TransactionRecordState nodeWithDynamicLabelRecord(NeoStores store, AtomicLong nodeId, AtomicLong dynamicLabelRecordId) {
    TransactionRecordState recordState = newTransactionRecordState(store);
    nodeId.set(store.getNodeStore().nextId());
    int[] labelIds = new int[20];
    for (int i = 0; i < labelIds.length; i++) {
        int labelId = (int) store.getLabelTokenStore().nextId();
        recordState.createLabelToken("Label" + i, labelId);
        labelIds[i] = labelId;
    }
    recordState.nodeCreate(nodeId.get());
    for (int labelId : labelIds) {
        recordState.addLabelToNode(labelId, nodeId.get());
    }
    // Extract the dynamic label record id (which is also a verification that we allocated one)
    NodeRecord node = Iterables.single(recordChangeSet.getNodeRecords().changes()).forReadingData();
    dynamicLabelRecordId.set(Iterables.single(node.getDynamicLabelRecords()).getId());
    return recordState;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord)

Example 8 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class WriteTransactionCommandOrderingTest method inUseNode.

private static NodeRecord inUseNode() {
    NodeRecord record = new NodeRecord(1, false, -1, -1);
    record.setInUse(true);
    return record;
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord)

Example 9 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class WriteTransactionCommandOrderingTest method injectAllPossibleCommands.

private TransactionRecordState injectAllPossibleCommands() {
    RecordChangeSet recordChangeSet = mock(RecordChangeSet.class);
    RecordChanges<Integer, LabelTokenRecord, Void> labelTokenChanges = mock(RecordChanges.class);
    RecordChanges<Integer, RelationshipTypeTokenRecord, Void> relationshipTypeTokenChanges = mock(RecordChanges.class);
    RecordChanges<Integer, PropertyKeyTokenRecord, Void> propertyKeyTokenChanges = mock(RecordChanges.class);
    RecordChanges<Long, NodeRecord, Void> nodeRecordChanges = mock(RecordChanges.class);
    RecordChanges<Long, RelationshipRecord, Void> relationshipRecordChanges = mock(RecordChanges.class);
    RecordChanges<Long, PropertyRecord, PrimitiveRecord> propertyRecordChanges = mock(RecordChanges.class);
    RecordChanges<Long, RelationshipGroupRecord, Integer> relationshipGroupChanges = mock(RecordChanges.class);
    RecordChanges<Long, SchemaRecord, SchemaRule> schemaRuleChanges = mock(RecordChanges.class);
    when(recordChangeSet.getLabelTokenChanges()).thenReturn(labelTokenChanges);
    when(recordChangeSet.getRelationshipTypeTokenChanges()).thenReturn(relationshipTypeTokenChanges);
    when(recordChangeSet.getPropertyKeyTokenChanges()).thenReturn(propertyKeyTokenChanges);
    when(recordChangeSet.getNodeRecords()).thenReturn(nodeRecordChanges);
    when(recordChangeSet.getRelRecords()).thenReturn(relationshipRecordChanges);
    when(recordChangeSet.getPropertyRecords()).thenReturn(propertyRecordChanges);
    when(recordChangeSet.getRelGroupRecords()).thenReturn(relationshipGroupChanges);
    when(recordChangeSet.getSchemaRuleChanges()).thenReturn(schemaRuleChanges);
    List<RecordProxy<Long, NodeRecord, Void>> nodeChanges = new LinkedList<>();
    RecordChange<Long, NodeRecord, Void> deletedNode = mock(RecordChange.class);
    when(deletedNode.getBefore()).thenReturn(inUseNode());
    when(deletedNode.forReadingLinkage()).thenReturn(missingNode());
    nodeChanges.add(deletedNode);
    RecordChange<Long, NodeRecord, Void> createdNode = mock(RecordChange.class);
    when(createdNode.getBefore()).thenReturn(missingNode());
    when(createdNode.forReadingLinkage()).thenReturn(createdNode());
    nodeChanges.add(createdNode);
    RecordChange<Long, NodeRecord, Void> updatedNode = mock(RecordChange.class);
    when(updatedNode.getBefore()).thenReturn(inUseNode());
    when(updatedNode.forReadingLinkage()).thenReturn(inUseNode());
    nodeChanges.add(updatedNode);
    when(nodeRecordChanges.changes()).thenReturn(nodeChanges);
    when(nodeRecordChanges.changeSize()).thenReturn(3);
    when(recordChangeSet.changeSize()).thenReturn(3);
    when(labelTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, LabelTokenRecord, Void>>emptyList());
    when(relationshipTypeTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, RelationshipTypeTokenRecord, Void>>emptyList());
    when(propertyKeyTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, PropertyKeyTokenRecord, Void>>emptyList());
    when(relationshipRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipRecord, Void>>emptyList());
    when(propertyRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, PropertyRecord, PrimitiveRecord>>emptyList());
    when(relationshipGroupChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipGroupRecord, Integer>>emptyList());
    when(schemaRuleChanges.changes()).thenReturn(Collections.<RecordProxy<Long, SchemaRecord, SchemaRule>>emptyList());
    NeoStores neoStores = mock(NeoStores.class);
    when(neoStores.getNodeStore()).thenReturn(mock(NodeStore.class));
    when(neoStores.getRelationshipGroupStore()).thenReturn(mock(RelationshipGroupStore.class));
    when(neoStores.getRelationshipStore()).thenReturn(mock(RelationshipStore.class));
    return new TransactionRecordState(neoStores, mock(IntegrityValidator.class), recordChangeSet, 0, null, null, null, null, null);
}
Also used : RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PrimitiveRecord(org.neo4j.kernel.impl.store.record.PrimitiveRecord) RecordProxy(org.neo4j.kernel.impl.transaction.state.RecordAccess.RecordProxy) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) LinkedList(java.util.LinkedList) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore)

Example 10 with NodeRecord

use of org.neo4j.kernel.impl.store.record.NodeRecord in project neo4j by neo4j.

the class DynamicIndexStoreViewTest method setUp.

@Before
public void setUp() {
    NodeRecord nodeRecord = getNodeRecord();
    when(labelScanStore.allNodeLabelRanges()).thenReturn(nodeLabelRanges);
    when(neoStores.getCounts()).thenReturn(countStore);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    when(nodeStore.newRecord()).thenReturn(nodeRecord);
    when(nodeStore.getRecord(anyLong(), any(NodeRecord.class), any(RecordLoad.class))).thenReturn(nodeRecord);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) Before(org.junit.Before)

Aggregations

NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)257 Test (org.junit.Test)190 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)62 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)51 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)38 Command (org.neo4j.kernel.impl.transaction.command.Command)29 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)28 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)27 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)26 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)23 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)23 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)22 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)22 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)22 ArrayList (java.util.ArrayList)19 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)19 File (java.io.File)15 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)13 NodeStore (org.neo4j.kernel.impl.store.NodeStore)11 ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)10