DataNode { public DataNode( final String name ) { super(); this.name = name; } DataNode( final String name ); DataNode addNode( final String name ); void addNode( final DataNode child ); Iterable<DataNode> getNodes(); DataNode getNode( final String name ); String getName(); void setProperty( final String name, String value ); void setProperty( final String name, boolean value ); void setProperty( final String name, double value ); void setProperty( final String name, long value ); void setProperty( final String name, Date value ); void setProperty( final String name, DataNodeRef value ); boolean hasProperty( final String name ); boolean hasNode( final String name ); DataProperty getProperty( final String name ); Iterable<DataProperty> getProperties(); void setId( Serializable id ); Serializable getId(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override String toString();  }
@Test public void testDataNode() { assertEquals( NODE_NAME, node.getName() ); assertEquals( NODE_ID, node.getId() ); assertEquals( -269422715, node.hashCode() ); assertEquals( "newNode/ {}\n", node.toString() ); assertFalse( node.equals( new DataNode( "diffNodeName" ) ) ); DataNode sameNode = new DataNode( NODE_NAME ); sameNode.setId( NODE_ID ); assertTrue( node.equals( sameNode ) ); DataNode origNode = new DataNode( NODE_NAME ); setChildNodes( origNode ); setProperties( origNode ); assertNotEquals( origNode.hashCode(), node.hashCode() ); DataNode dupNode = new DataNode( NODE_NAME ); setChildNodes( dupNode ); setProperties( dupNode ); assertEquals( origNode.toString(), dupNode.toString() ); assertTrue( origNode.equals( dupNode ) ); assertFalse( node.equals( dupNode ) ); assertFalse( node.equals( null ) ); assertFalse( node.equals( new String() ) ); DataNode diffNameNode = new DataNode( "diffName" ); diffNameNode.setId( NODE_ID ); assertFalse( node.equals( diffNameNode ) ); dupNode.setId( null ); origNode.setId( NODE_ID ); assertFalse( dupNode.equals( origNode ) ); assertFalse( origNode.equals( dupNode ) ); DataNode anotherDupNode = new DataNode( null ); anotherDupNode.setId( NODE_ID ); setChildNodes( anotherDupNode ); setProperties( anotherDupNode ); assertFalse( anotherDupNode.equals( origNode ) ); assertTrue( node.equals( node ) ); }