@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)); }
void compareToRemoved(PropertyEntry<T> entry) { basicCompareTo(entry); try { entry.value(); fail("Should throw IllegalStateException"); } catch (IllegalStateException e) { // OK } assertNull(value()); }
@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 void afterCommit(TransactionData data, Object state) { for (PropertyEntry<Node> entry : data.removedNodeProperties()) { String key = entry.key(); Object value = entry.previouslyCommitedValue(); nodeProps.put(key, value); } for (PropertyEntry<Relationship> entry : data.removedRelationshipProperties()) { relProps.put(entry.key(), entry.previouslyCommitedValue()); } }
void basicCompareTo(PropertyEntry<T> entry) { assertEquals(entry.entity(), entity()); assertEquals(entry.key(), key()); assertEqualsMaybeNull(entry.previouslyCommitedValue(), previouslyCommitedValue()); }
void compareToAssigned(PropertyEntry<T> entry) { basicCompareTo(entry); assertEqualsMaybeNull(entry.value(), value()); }