@Test public void showsRemovedRelationships() throws Exception { // Given state.relationshipDoDelete(1l, 1, 1l, 2l); state.relationshipDoDelete(2l, 1, 1l, 1l); when(ops.relationshipGetAllProperties(1l)) .thenReturn(IteratorUtil.<DefinedProperty>emptyIterator()); when(ops.relationshipGetAllProperties(2l)) .thenReturn(asList(Property.stringProperty(1, "p")).iterator()); when(ops.propertyKeyGetName(1)).thenReturn("key"); // When & Then TxStateTransactionDataSnapshot snapshot = snapshot(); assertThat(idList(snapshot.deletedRelationships()), equalTo(asList(1l, 2l))); assertThat(single(snapshot.removedRelationshipProperties()).key(), equalTo("key")); }
@Test public void shouldListRemovedNodeProperties() throws Exception { // Given DefinedProperty prevProp = stringProperty(1, "prevValue"); state.nodeDoRemoveProperty(1l, prevProp); when(ops.propertyKeyGetName(1)).thenReturn("theKey"); when(ops.nodeGetProperty(1, 1)).thenReturn(prevProp); // When Iterable<PropertyEntry<Node>> propertyEntries = snapshot().removedNodeProperties(); // Then PropertyEntry<Node> entry = single(propertyEntries); assertThat(entry.key(), equalTo("theKey")); assertThat(entry.previouslyCommitedValue(), equalTo((Object) "prevValue")); assertThat(entry.entity().getId(), equalTo(1l)); }
@Test public void showsDeletedNodes() throws Exception { // Given state.nodeDoDelete(1l); state.nodeDoDelete(2l); when(ops.nodeGetAllProperties(1l)).thenReturn(IteratorUtil.<DefinedProperty>emptyIterator()); when(ops.nodeGetAllProperties(2l)) .thenReturn(asList(Property.stringProperty(1, "p")).iterator()); when(ops.nodeGetLabels(1l)).thenReturn(PrimitiveIntCollections.emptyIterator()); when(ops.nodeGetLabels(2l)).thenReturn(PrimitiveIntCollections.iterator(15)); when(ops.propertyKeyGetName(1)).thenReturn("key"); when(ops.labelGetName(15)).thenReturn("label"); // When & Then TxStateTransactionDataSnapshot snapshot = snapshot(); assertThat(idList(snapshot.deletedNodes()), equalTo(asList(1l, 2l))); assertThat(single(snapshot.removedLabels()).label().name(), equalTo("label")); assertThat(single(snapshot.removedNodeProperties()).key(), equalTo("key")); }
@Test public void shouldListAddedRelationshipProperties() throws Exception { // Given DefinedProperty prevProp = stringProperty(1, "prevValue"); state.relationshipDoReplaceProperty(1l, prevProp, stringProperty(1, "newValue")); when(ops.propertyKeyGetName(1)).thenReturn("theKey"); when(ops.relationshipGetProperty(1, 1)).thenReturn(prevProp); // When Iterable<PropertyEntry<Relationship>> propertyEntries = snapshot().assignedRelationshipProperties(); // Then PropertyEntry<Relationship> entry = single(propertyEntries); assertThat(entry.key(), equalTo("theKey")); assertThat(entry.value(), equalTo((Object) "newValue")); assertThat(entry.previouslyCommitedValue(), equalTo((Object) "prevValue")); assertThat(entry.entity().getId(), equalTo(1l)); }
@Override public String propertyKeyGetName(Statement state, int propertyKeyId) throws PropertyKeyIdNotFoundKernelException { return storeLayer.propertyKeyGetName(propertyKeyId); }