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
}
}
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;
}
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;
}
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);
}
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);
}
Aggregations