DataProperty { public DataProperty( final String name, final Object value, final DataPropertyType type ) { this.name = name; this.value = value; this.type = type; } DataProperty( final String name, final Object value, final DataPropertyType type ); String getString(); boolean getBoolean(); long getLong(); double getDouble(); DataNodeRef getRef(); Date getDate(); DataPropertyType getType(); String getName(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override String toString();  }
@Test public void testDataProperty() { DataProperty prop = new DataProperty( PROP_NAME, PROP_VALUE, PROP_TYPE ); assertEquals( PROP_NAME, prop.getName() ); assertEquals( new String( PROP_VALUE ), prop.getString() ); assertEquals( PROP_TYPE, prop.getType() ); assertFalse( prop.getBoolean() ); assertEquals( 1, prop.getLong() ); assertEquals( 1.0, prop.getDouble(), .001 ); assertNotNull( prop.getRef() ); try { assertNull( prop.getDate() ); fail( "Should not be a date" ); } catch ( Exception e ) { } Date theDate = new Date(); DataProperty theProp = new DataProperty( null, theDate, null ); assertEquals( theDate, theProp.getDate() ); theProp = new DataProperty( null, null, null ); assertNull( theProp.getDate() ); assertEquals( 29791, theProp.hashCode() ); assertEquals( "DataProperty [name=" + PROP_NAME + ", type=" + PROP_TYPE + ", value=" + PROP_VALUE + "]", prop.toString() ); assertFalse( prop.equals( null ) ); assertTrue( prop.equals( prop ) ); assertFalse( prop.equals( new String() ) ); assertTrue( prop.equals( new DataProperty( PROP_NAME, PROP_VALUE, PROP_TYPE ) ) ); DataProperty nullProp = new DataProperty( null, PROP_VALUE, PROP_TYPE ); assertFalse( prop.equals( nullProp ) ); assertFalse( nullProp.equals( prop ) ); nullProp = new DataProperty( null, null, PROP_TYPE ); assertFalse( prop.equals( nullProp ) ); assertFalse( nullProp.equals( prop ) ); nullProp = new DataProperty( null, null, null ); assertFalse( prop.equals( nullProp ) ); assertFalse( nullProp.equals( prop ) ); assertNull( nullProp.getRef() ); }