[dna-commits] DNA SVN: r835 - in trunk/dna-jcr/src: main/java/org/jboss/dna/jcr/cache and 2 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Apr 16 12:08:24 EDT 2009


Author: rhauch
Date: 2009-04-16 12:08:24 -0400 (Thu, 16 Apr 2009)
New Revision: 835

Added:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NewNodeInfo.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/NewNodeInfoTest.java
Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrItem.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrItemTest.java
   trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/ChangedNodeInfoTest.java
Log:
DNA-362 AbstractJcrItem.isNew and isModified Are Not Implemented

Applied the patch, but rather than have ChangedNodeInfo contain a boolean that says whether its new, there is now a NewNodeInfo (that extends ChangedNodeInfo) that IMO makes it more obvious that this is a new node and clears up the places in SessionCache that instantiate it.

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrItem.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrItem.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrItem.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -82,26 +82,6 @@
     /**
      * {@inheritDoc}
      * 
-     * @return <code>false</code>
-     * @see javax.jcr.Item#isModified()
-     */
-    public final boolean isModified() {
-        return false;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @return <code>false</code>
-     * @see javax.jcr.Item#isNew()
-     */
-    public final boolean isNew() {
-        return false;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
      * @see javax.jcr.Item#isSame(javax.jcr.Item)
      */
     public boolean isSame( Item otherItem ) throws RepositoryException {

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -1448,6 +1448,34 @@
     /**
      * {@inheritDoc}
      * 
+     * @see javax.jcr.Item#isModified()
+     */
+    public final boolean isModified() {
+        try {
+            return nodeInfo().isModified();
+        }
+        catch (RepositoryException re) {
+            throw new IllegalStateException(re);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see javax.jcr.Item#isNew()
+     */
+    public final boolean isNew() {
+        try {
+            return nodeInfo().isNew();
+        }
+        catch (RepositoryException re) {
+            throw new IllegalStateException(re);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
      * @throws UnsupportedOperationException always
      * @see javax.jcr.Node#merge(java.lang.String, boolean)
      */

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -154,6 +154,34 @@
     /**
      * {@inheritDoc}
      * 
+     * @see javax.jcr.Item#isModified()
+     */
+    public final boolean isModified() {
+        try {
+            return propertyInfo().isModified();
+        }
+        catch (RepositoryException re) {
+            throw new IllegalStateException(re);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see javax.jcr.Item#isNew()
+     */
+    public final boolean isNew() {
+        try {
+            return propertyInfo().isNew();
+        }
+        catch (RepositoryException re) {
+            throw new IllegalStateException(re);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
      * @return false
      * @see javax.jcr.Item#isNode()
      */

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -77,6 +77,7 @@
 import org.jboss.dna.jcr.cache.EmptyChildren;
 import org.jboss.dna.jcr.cache.ImmutableChildren;
 import org.jboss.dna.jcr.cache.ImmutableNodeInfo;
+import org.jboss.dna.jcr.cache.NewNodeInfo;
 import org.jboss.dna.jcr.cache.NodeInfo;
 import org.jboss.dna.jcr.cache.PropertyInfo;
 import com.google.common.base.ReferenceType;
@@ -728,7 +729,8 @@
             Property dnaProp = propertyFactory.create(name, objValue);
 
             // Create the property info ...
-            PropertyInfo newProperty = new PropertyInfo(id, definition.getId(), propertyType, dnaProp, definition.isMultiple());
+            PropertyInfo newProperty = new PropertyInfo(id, definition.getId(), propertyType, dnaProp, definition.isMultiple(),
+                                                        existing == null, existing != null);
 
             // Finally update the cached information and record the change ...
             node.setProperty(newProperty, factories());
@@ -841,7 +843,8 @@
             Property dnaProp = propertyFactory.create(name, objValues);
 
             // Create the property info ...
-            PropertyInfo newProperty = new PropertyInfo(id, definition.getId(), propertyType, dnaProp, definition.isMultiple());
+            PropertyInfo newProperty = new PropertyInfo(id, definition.getId(), propertyType, dnaProp, definition.isMultiple(),
+                                                        existing == null, existing != null);
 
             // Finally update the cached information and record the change ...
             node.setProperty(newProperty, factories());
@@ -1040,7 +1043,7 @@
                 JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
                 org.jboss.dna.graph.property.Property uuidProperty = propertyFactory.create(JcrLexicon.UUID, desiredUuid);
                 PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), PropertyType.STRING, uuidProperty,
-                                                         defn.isMultiple());
+                                                         defn.isMultiple(), true, false);
                 properties.put(JcrLexicon.UUID, propInfo);
             }
 
@@ -1052,7 +1055,8 @@
                                                                               false);
             PropertyDefinitionId primaryTypeDefinitionId = primaryTypeDefn.getId();
             PropertyInfo primaryTypeInfo = new PropertyInfo(new PropertyId(desiredUuid, primaryTypeProp.getName()),
-                                                            primaryTypeDefinitionId, PropertyType.NAME, primaryTypeProp, false);
+                                                            primaryTypeDefinitionId, PropertyType.NAME, primaryTypeProp, false,
+                                                            true, false);
             properties.put(primaryTypeProp.getName(), primaryTypeInfo);
 
             // Create the property info for the "dna:nodeDefinition" child property ...
@@ -1065,15 +1069,13 @@
                 PropertyDefinitionId nodeDefnDefinitionId = nodeDefnDefn.getId();
                 PropertyInfo nodeDefinitionInfo = new PropertyInfo(new PropertyId(desiredUuid, nodeDefinitionProp.getName()),
                                                                    nodeDefnDefinitionId, PropertyType.STRING, nodeDefinitionProp,
-                                                                   true);
+                                                                   true, true, false);
                 properties.put(nodeDefinitionProp.getName(), nodeDefinitionInfo);
             }
 
             // Now create the child node info, putting it in the changed map (and not the cache map!) ...
-            NodeInfo info = new ImmutableNodeInfo(location, primaryTypeName, null, definition.getId(), node.getUuid(), null,
-                                                  properties);
-            ChangedNodeInfo changedInfo = new ChangedNodeInfo(info);
-            changedNodes.put(desiredUuid, changedInfo);
+            NewNodeInfo newInfo = new NewNodeInfo(location, primaryTypeName, definition.getId(), node.getUuid(), properties);
+            changedNodes.put(desiredUuid, newInfo);
 
             // ---------------------------------------
             // Now record the changes to the store ...
@@ -1741,7 +1743,7 @@
             // Record the property in the node information ...
             PropertyId propId = new PropertyId(uuid, name);
             JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
-            PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), propertyType, dnaProp, defn.isMultiple());
+            PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), propertyType, dnaProp, defn.isMultiple(), false, false);
             props.put(name, propInfo);
         }
 
@@ -1757,7 +1759,8 @@
                                                                                        false);
             PropertyId propId = new PropertyId(uuid, JcrLexicon.UUID);
             JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
-            PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), PropertyType.STRING, uuidProperty, defn.isMultiple());
+            PropertyInfo propInfo = new PropertyInfo(propId, defn.getId(), PropertyType.STRING, uuidProperty, defn.isMultiple(),
+                                                     false, false);
             props.put(JcrLexicon.UUID, propInfo);
         } else {
             // Make sure there is NOT a "jcr:uuid" property ...

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -379,4 +379,22 @@
         changedProperties.put(name, null);
         return changed;
     }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#isNew()
+     */
+    public boolean isNew() {
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.jcr.cache.NodeInfo#isModified()
+     */
+    public boolean isModified() {
+        return true;
+    }
 }

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ImmutableNodeInfo.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -179,4 +179,24 @@
     public PropertyInfo getProperty( Name name ) {
         return this.properties.get(name);
     }
+
+    /**
+     * 
+     * {@inheritDoc}
+     * @return {@code false} always as this object represents unmodified nodes only
+     * @see org.jboss.dna.jcr.cache.NodeInfo#isNew()
+     */
+    public boolean isNew() {
+        return false;
+    }
+
+    /**
+     * 
+     * {@inheritDoc}
+     * @return {@code false} always as this object represents unmodified nodes only
+     * @see org.jboss.dna.jcr.cache.NodeInfo#isModified()
+     */
+    public boolean isModified() {
+        return false;
+    }
 }

Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NewNodeInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NewNodeInfo.java	                        (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NewNodeInfo.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -0,0 +1,79 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import java.util.Map;
+import java.util.UUID;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.jcr.NodeDefinitionId;
+
+/**
+ * 
+ */
+public class NewNodeInfo extends ChangedNodeInfo {
+    /**
+     * Create an immutable NodeInfo instance.
+     * 
+     * @param originalLocation the original location
+     * @param primaryTypeName the name of the node's primary type
+     * @param definition the definition used when creating the node
+     * @param parent the parent
+     * @param properties the unmodifiable map of properties; may be null if there are no properties
+     */
+    public NewNodeInfo( Location originalLocation,
+                        Name primaryTypeName,
+                        NodeDefinitionId definition,
+                        UUID parent,
+                        Map<Name, PropertyInfo> properties ) {
+        super(new ImmutableNodeInfo(originalLocation, primaryTypeName, null, definition, parent, null, properties));
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Always returns true.
+     * </p>
+     * 
+     * @see org.jboss.dna.jcr.cache.ChangedNodeInfo#isNew()
+     */
+    @Override
+    public boolean isNew() {
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Always returns false, since a new node is not persisted yet.
+     * </p>
+     * 
+     * @see org.jboss.dna.jcr.cache.ChangedNodeInfo#isModified()
+     */
+    @Override
+    public boolean isModified() {
+        return false;
+    }
+
+}


Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NewNodeInfo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/NodeInfo.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -104,4 +104,23 @@
      * @return the property information, or null if this node has no property with the supplied name
      */
     public PropertyInfo getProperty( Name name );
+
+    /**
+     * Indicates whether the node represented by this {@link NodeInfo} is new (i.e., does not yet exist in the persistent
+     * repository).
+     * 
+     * @return {@code true} if the node represented by this {@link NodeInfo} has not yet been saved to the persistent repository.
+     * @see javax.jcr.Item#isNew()
+     */
+    public boolean isNew();
+
+    /**
+     * Indicates whether the node represented by this {@link NodeInfo} is modified (i.e., exists in the persistent repository with
+     * different child items).
+     * 
+     * @return {@code true} if the immediate child items of the node represented by this {@link NodeInfo} have been modified since
+     *         the last time the node was saved to the persistent repository
+     * @see javax.jcr.Item#isModified()
+     */
+    public boolean isModified();
 }

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/PropertyInfo.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -48,17 +48,26 @@
     private final Property dnaProperty;
     private final int propertyType;
     private final boolean multiValued;
+    private final boolean isNew;
+    private final boolean isModified;
 
     public PropertyInfo( PropertyId propertyId,
                          PropertyDefinitionId definitionId,
                          int propertyType,
                          Property dnaProperty,
-                         boolean multiValued ) {
+                         boolean multiValued,
+                         boolean isNew,
+                         boolean isModified ) {
         this.propertyId = propertyId;
         this.definitionId = definitionId;
         this.propertyType = propertyType;
         this.dnaProperty = dnaProperty;
         this.multiValued = multiValued;
+        this.isNew = isNew;
+        this.isModified = isModified;
+
+        assert isNew ? !isModified : true;
+        assert isModified ? !isNew : true;
     }
 
     /**
@@ -123,6 +132,27 @@
     }
 
     /**
+     * Indicates whether this property/value combination is new (i.e., does not yet exist in the persistent repository).
+     * 
+     * @return {@code true} if the property has not yet been saved to the persistent repository.
+     * @see javax.jcr.Item#isNew()
+     */
+    public boolean isNew() {
+        return this.isNew;
+    }
+
+    /**
+     * Indicates whether this property/value combination is modified (i.e., exists in the persistent repository with a different
+     * value or values).
+     * 
+     * @return {@code true} if the property has been modified since the last time it was saved to the persistent repository
+     * @see javax.jcr.Item#isModified()
+     */
+    public boolean isModified() {
+        return this.isModified;
+    }
+
+    /**
      * {@inheritDoc}
      * 
      * @see java.lang.Object#hashCode()

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrItemTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrItemTest.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrItemTest.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -73,6 +73,14 @@
                 return false;
             }
 
+            public boolean isNew() {
+                return false;
+            }
+
+            public boolean isModified() {
+                return false;
+            }
+
             public void refresh( boolean keepChanges ) {
                 throw new UnsupportedOperationException();
             }

Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/ChangedNodeInfoTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/ChangedNodeInfoTest.java	2009-04-16 15:31:14 UTC (rev 834)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/ChangedNodeInfoTest.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -151,6 +151,16 @@
     }
 
     @Test
+    public void shouldNotBeNew() {
+        assertThat(changes.isNew(), is(false));
+    }
+
+    @Test
+    public void shouldBeModified() {
+        assertThat(changes.isModified(), is(true));
+    }
+
+    @Test
     public void shouldHaveLocationFromOriginal() {
         assertThat(changes.getOriginalLocation(), is(sameInstance(location)));
     }

Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/NewNodeInfoTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/NewNodeInfoTest.java	                        (rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/NewNodeInfoTest.java	2009-04-16 16:08:24 UTC (rev 835)
@@ -0,0 +1,672 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * Unless otherwise indicated, all code in JBoss DNA is licensed
+ * to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.jcr.cache;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.jboss.dna.jcr.cache.IsNodeInfoWithChildrenHavingNames.hasChildren;
+import static org.jboss.dna.jcr.cache.IsNodeInfoWithChildrenHavingUuids.hasChildren;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItems;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.JcrLexicon;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.graph.property.Path.Segment;
+import org.jboss.dna.jcr.NodeDefinitionId;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class NewNodeInfoTest {
+
+    private ExecutionContext context;
+    private PathFactory pathFactory;
+    private UUID uuid;
+    private Name primaryTypeName;
+    private Name[] requiredPrimaryTypes;
+    private Location location;
+    private NodeDefinitionId definitionId;
+    private Map<Name, PropertyInfo> properties;
+    private ChangedNodeInfo changes;
+
+    @Before
+    public void beforeEach() {
+        context = new ExecutionContext();
+        context.getNamespaceRegistry().register("acme", "http://example.com/acme");
+        pathFactory = context.getValueFactories().getPathFactory();
+
+        // Set up the original ...
+        uuid = UUID.randomUUID();
+        location = Location.create(uuid);
+        primaryTypeName = name("acme:geniusType");
+        requiredPrimaryTypes = new Name[] {name("acme:requiredTypeA"), name("acme:requiredTypeB")};
+        definitionId = new NodeDefinitionId(name("acme:geniusContainerType"), name("acme:geniuses"), requiredPrimaryTypes);
+        properties = new HashMap<Name, PropertyInfo>();
+
+        // Create the changed node representation ...
+        changes = new NewNodeInfo(location, primaryTypeName, definitionId, uuid, properties);
+    }
+
+    protected Name name( String name ) {
+        return context.getValueFactories().getNameFactory().create(name);
+    }
+
+    protected Segment segment( String segment ) {
+        return pathFactory.createSegment(segment);
+    }
+
+    /**
+     * Utility to set a property to the original node representation. This will replace any existing property with the same name.
+     * 
+     * @param name the name of the property; may not be null
+     * @return the new property representation; never null
+     */
+    protected PropertyInfo makePropertyInOriginal( String name ) {
+        Name propName = name(name);
+        PropertyInfo propertyInfo = mock(PropertyInfo.class);
+        stub(propertyInfo.getPropertyName()).toReturn(propName);
+        properties.put(propName, propertyInfo);
+        return propertyInfo;
+    }
+
+    /**
+     * Utility to change a property in the changed representation.
+     * 
+     * @param name the name of the property to change; may not be null
+     * @return the new property; never null
+     */
+    protected PropertyInfo setPropertyInChanged( String name ) {
+        Name propName = name(name);
+        PropertyInfo propertyInfo = mock(PropertyInfo.class);
+        stub(propertyInfo.getPropertyName()).toReturn(propName);
+        changes.setProperty(propertyInfo, context.getValueFactories());
+        return propertyInfo;
+    }
+
+    protected ChildNode addChildInChanged( String childName ) {
+        ChildNode newChild = changes.addChild(name(childName), UUID.randomUUID(), pathFactory);
+        return newChild;
+    }
+
+    protected void removeChildFromChanged( ChildNode child ) {
+        // Verify that a child node with the supplied UUID is contained.
+        // Note that it may not be the same ChildNode instance if another SNS node with smaller index was removed
+        assertThat(changes.getChildren().getChild(child.getUuid()), is(notNullValue()));
+        // Now remove the child, making sure the result is the same as the next 'getChildren()' call ...
+        assertThat(changes.removeChild(child.getUuid(), pathFactory), is(notNullValue()));
+        // Verify it no longer exists ...
+        assertThat(changes.getChildren().getChild(child.getUuid()), is(nullValue()));
+    }
+
+    @Test
+    public void shouldBeNew() {
+        assertThat(changes.isNew(), is(true));
+    }
+
+    @Test
+    public void shouldNotBeModified() {
+        assertThat(changes.isModified(), is(false));
+    }
+
+    @Test
+    public void shouldInitiallyHaveLocation() {
+        assertThat(changes.getOriginalLocation(), is(sameInstance(location)));
+    }
+
+    @Test
+    public void shouldInitiallyHaveParentUuid() {
+        assertThat(changes.getParent(), is(sameInstance(uuid)));
+    }
+
+    @Test
+    public void shouldInitiallyHavePrimaryTypeName() {
+        assertThat(changes.getPrimaryTypeName(), is(sameInstance(primaryTypeName)));
+    }
+
+    @Test
+    public void shouldInitiallyHaveMixinNoTypeNames() {
+        assertThat(changes.getMixinTypeNames().size(), is(0));
+    }
+
+    @Test
+    public void shouldUpdateMixinTypeNamesWhenSettingJcrMixinTypeProperty() {
+        // Create the DNA property ...
+        Property mixinTypes = context.getPropertyFactory().create(JcrLexicon.MIXIN_TYPES, "dna:type1", "dna:type2");
+
+        // Modify the property ...
+        PropertyInfo newPropertyInfo = mock(PropertyInfo.class);
+        stub(newPropertyInfo.getPropertyName()).toReturn(mixinTypes.getName());
+        stub(newPropertyInfo.getProperty()).toReturn(mixinTypes);
+        PropertyInfo previous = changes.setProperty(newPropertyInfo, context.getValueFactories());
+        assertThat(previous, is(nullValue()));
+
+        // Verify that the mixin types were updated ...
+        assertThat(changes.getProperty(name("jcr:mixinTypes")), is(sameInstance(newPropertyInfo)));
+        assertThat(changes.getMixinTypeNames(), hasItems(name("dna:type2"), name("dna:type1")));
+    }
+
+    @Test
+    public void shouldHaveNodeDefinitionId() {
+        assertThat(changes.getDefinitionId(), is(sameInstance(definitionId)));
+    }
+
+    @Test
+    public void shouldHaveNoChildren() {
+        assertThat(changes.getChildren().size(), is(0));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterAddingChild() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add child ...
+        ChildNode childA1 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(1));
+        assertThat(changes.getChildren(), hasChildren(segment("childA")));
+
+        // Add more children ...
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        ChildNode childA3 = addChildInChanged("childA");
+
+        // Verify that all children are there in the proper order ...
+        assertThat(changes.getChildren().size(), is(4));
+        assertThat(changes.getChildren(), hasChildren(segment("childA[1]"),
+                                                      segment("childB[1]"),
+                                                      segment("childA[2]"),
+                                                      segment("childA[3]")));
+        assertThat(changes.getChildren(), hasChildren(childA1.getUuid(), childB1.getUuid(), childA2.getUuid(), childA3.getUuid()));
+        assertThat(changes.getChildren(), hasItems(childA1, childB1, childA2, childA3));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterAddingMultipleChildren() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Add some children in the changed representation ...
+        ChildNode childA3 = addChildInChanged("childA");
+        ChildNode childC1 = addChildInChanged("childC");
+        ChildNode childC2 = addChildInChanged("childC");
+
+        // Verify that all children are there in the proper order ...
+        assertThat(changes.getChildren().size(), is(6));
+        assertThat(changes.getChildren(), hasChildren(segment("childA[1]"),
+                                                      segment("childB[1]"),
+                                                      segment("childA[2]"),
+                                                      segment("childA[3]"),
+                                                      segment("childC[1]"),
+                                                      segment("childC[2]")));
+        assertThat(changes.getChildren(), hasChildren(childA1.getUuid(),
+                                                      childB1.getUuid(),
+                                                      childA2.getUuid(),
+                                                      childA3.getUuid(),
+                                                      childC1.getUuid(),
+                                                      childC2.getUuid()));
+        assertThat(changes.getChildren(), hasItems(childA1, childB1, childA2, childA3, childC1, childC2));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterAddingMultipleChildrenAndRemovingOthers() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Add some children in the changed representation ...
+        ChildNode childA3 = addChildInChanged("childA");
+        ChildNode childC1 = addChildInChanged("childC");
+        ChildNode childC2 = addChildInChanged("childC");
+
+        // Delete a child that was added and another that was an original ...
+        removeChildFromChanged(childC1);
+        removeChildFromChanged(childA2);
+
+        // Verify that all children are there in the proper order ...
+        assertThat(changes.getChildren().size(), is(4));
+        assertThat(changes.getChildren(), hasChildren(segment("childA[1]"),
+                                                      segment("childB[1]"),
+                                                      segment("childA[2]"),
+                                                      segment("childC[1]")));
+        assertThat(changes.getChildren(), hasChildren(childA1.getUuid(), childB1.getUuid(), childA3.getUuid(), childC2.getUuid()));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterAddingMultipleChildrenAndThenRemovingThoseJustAdded() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Add some children in the changed representation ...
+        ChildNode childA3 = addChildInChanged("childA");
+        ChildNode childC1 = addChildInChanged("childC");
+        ChildNode childC2 = addChildInChanged("childC");
+
+        // Delete a child that was added and another that was an original...
+        removeChildFromChanged(childA3);
+        removeChildFromChanged(childC1); // causes replacement of 'childC2' with lower SNS index
+        removeChildFromChanged(childC2);
+
+        // Verify that all children are there in the proper order ...
+        assertThat(changes.getChildren().size(), is(3));
+        assertThat(changes.getChildren(), hasChildren(segment("childA[1]"), segment("childB[1]"), segment("childA[2]")));
+        assertThat(changes.getChildren(), hasChildren(childA1.getUuid(), childB1.getUuid(), childA2.getUuid()));
+
+        // Do it again, but change the order of delete to delete from the back ...
+
+        // Add some children in the changed representation ...
+        childA3 = addChildInChanged("childA");
+        childC1 = addChildInChanged("childC");
+        childC2 = addChildInChanged("childC");
+
+        // Delete a child that was added and another that was an original ...
+        removeChildFromChanged(childC2);
+        removeChildFromChanged(childC1);
+        removeChildFromChanged(childA3);
+
+        // Verify that all children are there in the proper order ...
+        assertThat(changes.getChildren().size(), is(3));
+        assertThat(changes.getChildren(), hasChildren(segment("childA[1]"), segment("childB[1]"), segment("childA[2]")));
+        assertThat(changes.getChildren(), hasChildren(childA1.getUuid(), childB1.getUuid(), childA2.getUuid()));
+
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterDeletingChild() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Delete a child that was added and another that was an original ...
+        removeChildFromChanged(childA1);
+
+        // Verify that all children are there in the proper order ...
+        assertThat(changes.getChildren().size(), is(2));
+        assertThat(changes.getChildren(), hasChildren(segment("childB[1]"), segment("childA[1]")));
+        assertThat(changes.getChildren(), hasChildren(childB1.getUuid(), childA2.getUuid()));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterDeletingMultipleChildren() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Delete a child that was added and another that was an original ...
+        removeChildFromChanged(childA1);
+        removeChildFromChanged(childA2);
+
+        // Verify that all children are there in the proper order ...
+        assertThat(changes.getChildren().size(), is(1));
+        assertThat(changes.getChildren(), hasChildren(segment("childB[1]")));
+        assertThat(changes.getChildren(), hasChildren(childB1.getUuid()));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterDeletingAllChildrenFromTheFirsttChildToTheLast() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Delete all children, from the front to the back ...
+        removeChildFromChanged(childA1); // causes replacement of 'childA2' with lower SNS index
+        removeChildFromChanged(childA2);
+        removeChildFromChanged(childB1);
+
+        // Verify that all children have been removed ...
+        assertThat(changes.getChildren().size(), is(0));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterDeletingAllChildrenFromTheLastChildToTheFirst() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Delete all children, from the back to the front ...
+        removeChildFromChanged(childA2);
+        removeChildFromChanged(childB1);
+        removeChildFromChanged(childA1);
+
+        // Verify that all children have been removed ...
+        assertThat(changes.getChildren().size(), is(0));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterAddingSomeChildrenThenDeletingAllChildrenFromTheFirstChildToTheLast() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Add some children in the changed representation ...
+        ChildNode childA3 = addChildInChanged("childA");
+        ChildNode childC1 = addChildInChanged("childC");
+        ChildNode childC2 = addChildInChanged("childC");
+
+        // Delete all children, from the front to the back ...
+        removeChildFromChanged(childA3);
+        removeChildFromChanged(childC1); // causes replacement of 'childC2' with lower SNS index
+        removeChildFromChanged(childC2);
+        removeChildFromChanged(childA1); // causes replacement of 'childA2' with lower SNS index
+        removeChildFromChanged(childB1);
+        removeChildFromChanged(childA2);
+
+        // Verify that all children have been removed ...
+        assertThat(changes.getChildren().size(), is(0));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterAddingSomeChildrenThenDeletingAllChildrenFromTheLastChildToTheFirst() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Add some children in the changed representation ...
+        ChildNode childA3 = addChildInChanged("childA");
+        ChildNode childC1 = addChildInChanged("childC");
+        ChildNode childC2 = addChildInChanged("childC");
+
+        // Delete all children, from the back to the front ...
+        removeChildFromChanged(childC2);
+        removeChildFromChanged(childC1);
+        removeChildFromChanged(childA3);
+        removeChildFromChanged(childA2);
+        removeChildFromChanged(childB1);
+        removeChildFromChanged(childA1);
+
+        // Verify that all children have been removed ...
+        assertThat(changes.getChildren().size(), is(0));
+    }
+
+    @Test
+    public void shouldHaveChildrenAfterReorderingChildren() {
+
+    }
+
+    @Test
+    @SuppressWarnings( "unused" )
+    public void shouldNotRemoveFromNodeInfoWithNoChildChangesAChildThatMatchesSegmentButNotUuid() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Create a bogus node that has a new UUID but with the same segment as 'childA3' ...
+        Children before = changes.getChildren();
+        int beforeSize = before.size();
+        assertThat(changes.removeChild(UUID.randomUUID(), pathFactory), is(nullValue()));
+        Children after = changes.getChildren();
+        assertThat(after.size(), is(beforeSize));
+        assertThat(after, is(sameInstance(before)));
+        assertThat(after, is(sameInstance(changes.getChildren())));
+    }
+
+    @Test
+    @SuppressWarnings( "unused" )
+    public void shouldNotRemoveFromNodeInfoWithSomeChildChangesAChildThatMatchesSegmentButNotUuid() {
+        assertThat(changes.getChildren().size(), is(0));
+
+        // Add some children ...
+        ChildNode childA1 = addChildInChanged("childA");
+        ChildNode childB1 = addChildInChanged("childB");
+        ChildNode childA2 = addChildInChanged("childA");
+        assertThat(changes.getChildren().size(), is(3));
+
+        // Add some children in the changed representation ...
+        ChildNode childA3 = addChildInChanged("childA");
+        ChildNode childC1 = addChildInChanged("childC");
+        ChildNode childC2 = addChildInChanged("childC");
+
+        // Create a bogus node that has a new UUID but with the same segment as 'childA3' ...
+        Children before = changes.getChildren();
+        int beforeSize = before.size();
+        assertThat(changes.removeChild(UUID.randomUUID(), pathFactory), is(nullValue()));
+        Children after = changes.getChildren();
+        assertThat(after.size(), is(beforeSize));
+        assertThat(after, is(sameInstance(before)));
+        assertThat(after, is(sameInstance(changes.getChildren())));
+    }
+
+    @Test
+    public void shouldFindPropertyThatHasNotBeenModifiedButIsInOriginal() {
+        PropertyInfo propertyInfo = makePropertyInOriginal("test");
+        assertThat(changes.getProperty(name("test")), is(sameInstance(propertyInfo)));
+    }
+
+    @Test
+    public void shouldFindPropertyThatHasBeenModifiedFromOriginal() {
+        PropertyInfo propertyInfo = makePropertyInOriginal("test");
+        assertThat(changes.getProperty(name("test")), is(sameInstance(propertyInfo)));
+
+        // Modify the property ...
+        PropertyInfo newPropertyInfo = mock(PropertyInfo.class);
+        stub(newPropertyInfo.getPropertyName()).toReturn(name("test"));
+        PropertyInfo previous = changes.setProperty(newPropertyInfo, context.getValueFactories());
+        assertThat(previous, is(sameInstance(propertyInfo)));
+
+        // Verify we can find the new property ...
+        assertThat(changes.getProperty(name("test")), is(sameInstance(newPropertyInfo)));
+    }
+
+    @Test
+    public void shouldNotFindPropertyThatHasBeenDeletedFromOriginal() {
+        PropertyInfo propertyInfo = makePropertyInOriginal("test");
+        assertThat(changes.getProperty(name("test")), is(sameInstance(propertyInfo)));
+
+        // Delete the property ...
+        PropertyInfo previous = changes.removeProperty(name("test"));
+        assertThat(previous, is(sameInstance(propertyInfo)));
+
+        // Verify we can not find the new property ...
+        assertThat(changes.getProperty(name("test")), is(nullValue()));
+    }
+
+    @Test
+    public void shouldNotFindPropertyThatIsNotInOriginal() {
+        assertThat(changes.getProperty(name("test")), is(nullValue()));
+
+        makePropertyInOriginal("test");
+        assertThat(changes.getProperty(name("nonExistant")), is(nullValue()));
+    }
+
+    @Test
+    public void shouldFindAllPropertyNamesWhenChangedNodeHasNoChangedProperties() {
+        PropertyInfo propA = makePropertyInOriginal("propA");
+        PropertyInfo propB = makePropertyInOriginal("propB");
+        PropertyInfo propC = makePropertyInOriginal("propC");
+        PropertyInfo propD = makePropertyInOriginal("propD");
+        Set<Name> names = changes.getPropertyNames();
+        assertThat(names.size(), is(4));
+        assertThat(names, hasItems(propA.getPropertyName(),
+                                   propB.getPropertyName(),
+                                   propC.getPropertyName(),
+                                   propD.getPropertyName()));
+    }
+
+    @Test
+    public void shouldFindAllPropertyNamesWhenChangedNodeHasDeletedAllProperties() {
+        PropertyInfo propA = makePropertyInOriginal("propA");
+        PropertyInfo propB = makePropertyInOriginal("propB");
+        PropertyInfo propC = makePropertyInOriginal("propC");
+        PropertyInfo propD = makePropertyInOriginal("propD");
+        // Remove all properties ...
+        assertThat(changes.removeProperty(propA.getPropertyName()), is(sameInstance(propA)));
+        assertThat(changes.removeProperty(propB.getPropertyName()), is(sameInstance(propB)));
+        assertThat(changes.removeProperty(propC.getPropertyName()), is(sameInstance(propC)));
+        assertThat(changes.removeProperty(propD.getPropertyName()), is(sameInstance(propD)));
+        // Now ask for names
+        Set<Name> names = changes.getPropertyNames();
+        assertThat(names.size(), is(0));
+    }
+
+    @Test
+    public void shouldFindAllPropertyNamesWhenChangedNodeHasDeletedSomeProperties() {
+        PropertyInfo propA = makePropertyInOriginal("propA");
+        PropertyInfo propB = makePropertyInOriginal("propB");
+        PropertyInfo propC = makePropertyInOriginal("propC");
+        PropertyInfo propD = makePropertyInOriginal("propD");
+        // Remove some properties ...
+        assertThat(changes.removeProperty(propB.getPropertyName()), is(sameInstance(propB)));
+        assertThat(changes.removeProperty(propD.getPropertyName()), is(sameInstance(propD)));
+        // Now ask for names
+        Set<Name> names = changes.getPropertyNames();
+        assertThat(names.size(), is(2));
+        assertThat(names, hasItems(propA.getPropertyName(), propC.getPropertyName()));
+    }
+
+    @Test
+    @SuppressWarnings( "unused" )
+    public void shouldFindAllPropertyNamesWhenChangedNodeHasChangedSomeProperties() {
+        PropertyInfo propA = makePropertyInOriginal("propA");
+        PropertyInfo propB = makePropertyInOriginal("propB");
+        PropertyInfo propC = makePropertyInOriginal("propC");
+        PropertyInfo propD = makePropertyInOriginal("propD");
+        // Change some properties ...
+        PropertyInfo propB2 = setPropertyInChanged("propB");
+        PropertyInfo propC2 = setPropertyInChanged("propC");
+        // Now ask for names
+        Set<Name> names = changes.getPropertyNames();
+        assertThat(names.size(), is(4));
+        assertThat(names, hasItems(propA.getPropertyName(),
+                                   propB2.getPropertyName(),
+                                   propC2.getPropertyName(),
+                                   propD.getPropertyName()));
+    }
+
+    @Test
+    @SuppressWarnings( "unused" )
+    public void shouldFindAllPropertyNamesWhenChangedNodeHasAddedSomeProperties() {
+        PropertyInfo propA = makePropertyInOriginal("propA");
+        PropertyInfo propB = makePropertyInOriginal("propB");
+        PropertyInfo propC = makePropertyInOriginal("propC");
+        PropertyInfo propD = makePropertyInOriginal("propD");
+        // Add some properties ...
+        PropertyInfo propE = setPropertyInChanged("propE");
+        PropertyInfo propF = setPropertyInChanged("propF");
+        PropertyInfo propG = setPropertyInChanged("propG");
+        // Now ask for names
+        Set<Name> names = changes.getPropertyNames();
+        assertThat(names.size(), is(7));
+        assertThat(names, hasItems(propA.getPropertyName(),
+                                   propB.getPropertyName(),
+                                   propC.getPropertyName(),
+                                   propD.getPropertyName(),
+                                   propE.getPropertyName(),
+                                   propF.getPropertyName()));
+    }
+
+    @Test
+    @SuppressWarnings( "unused" )
+    public void shouldFindAllPropertyNamesWhenChangedNodeHasChangedAndDeletedAndAddedSomeProperties() {
+        PropertyInfo propA = makePropertyInOriginal("propA");
+        PropertyInfo propB = makePropertyInOriginal("propB");
+        PropertyInfo propC = makePropertyInOriginal("propC");
+        PropertyInfo propD = makePropertyInOriginal("propD");
+        // Change some properties ...
+        PropertyInfo propB2 = setPropertyInChanged("propB");
+        PropertyInfo propC2 = setPropertyInChanged("propC");
+        // Add some properties ...
+        PropertyInfo propE = setPropertyInChanged("propE");
+        // Remove some properties ...
+        assertThat(changes.removeProperty(propB2.getPropertyName()), is(sameInstance(propB2)));
+        assertThat(changes.removeProperty(propD.getPropertyName()), is(sameInstance(propD)));
+        // Now ask for names
+        Set<Name> names = changes.getPropertyNames();
+        assertThat(names.size(), is(3));
+        assertThat(names, hasItems(propA.getPropertyName(), propC2.getPropertyName(), propE.getPropertyName()));
+    }
+
+    @Test
+    @SuppressWarnings( "unused" )
+    public void shouldFindAllPropertyNamesWhenChangedNodeHasChangedAndDeletedAllProperties() {
+        PropertyInfo propA = makePropertyInOriginal("propA");
+        PropertyInfo propB = makePropertyInOriginal("propB");
+        PropertyInfo propC = makePropertyInOriginal("propC");
+        PropertyInfo propD = makePropertyInOriginal("propD");
+        // Change some properties ...
+        PropertyInfo propB2 = setPropertyInChanged("propB");
+        PropertyInfo propC2 = setPropertyInChanged("propC");
+        // Remove all properties ...
+        assertThat(changes.removeProperty(propA.getPropertyName()), is(sameInstance(propA)));
+        assertThat(changes.removeProperty(propB2.getPropertyName()), is(sameInstance(propB2)));
+        assertThat(changes.removeProperty(propC2.getPropertyName()), is(sameInstance(propC2)));
+        assertThat(changes.removeProperty(propD.getPropertyName()), is(sameInstance(propD)));
+        // Now ask for names
+        Set<Name> names = changes.getPropertyNames();
+        assertThat(names.size(), is(0));
+    }
+
+}


Property changes on: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/cache/NewNodeInfoTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the dna-commits mailing list