Theme implements Serializable { public Theme( String id, String name, String rootDir ) { this.id = id; this.name = name; this.themeRootDir = rootDir; } Theme( String id, String name, String rootDir ); String getName(); void setName( String name ); Set<ThemeResource> getResources(); void setResources( Set<ThemeResource> resources ); void addResource( ThemeResource themeResource ); String getThemeRootDir(); @Override boolean equals( Object o ); @Override int hashCode(); boolean isHidden(); void setHidden( boolean hidden ); String getId(); void setId( String id );  }
@Test public void testTheme() { Theme theme = new Theme( ID, NAME, ROOT_DIR ); theme.setHidden( HIDDEN ); assertEquals( ID, theme.getId() ); assertEquals( NAME, theme.getName() ); assertEquals( HIDDEN, theme.isHidden() ); assertEquals( ROOT_DIR, theme.getThemeRootDir() ); assertNotNull( theme.getResources() ); assertEquals( 0, theme.getResources().size() ); ThemeResource resource = new ThemeResource( theme, "resource" ); theme.addResource( resource ); assertEquals( resource, theme.getResources().toArray()[0] ); String newName = "newName"; String newId = "newId"; boolean newHidden = !HIDDEN; theme.setHidden( newHidden ); theme.setId( newId ); theme.setName( newName ); theme.setResources( null ); assertEquals( newId, theme.getId() ); assertEquals( newName, theme.getName() ); assertEquals( newHidden, theme.isHidden() ); assertNull( theme.getResources() ); theme = new Theme( ID, NAME, ROOT_DIR ); Theme diffTheme = new Theme( newId, newName, ROOT_DIR ); assertTrue( theme.equals( theme ) ); assertFalse( theme.equals( null ) ); assertFalse( theme.equals( new String() ) ); assertFalse( theme.equals( new Theme( ID, null, ROOT_DIR ) ) ); assertFalse( theme.equals( new Theme( ID, "newName", ROOT_DIR ) ) ); assertTrue( theme.equals( new Theme( ID, NAME, ROOT_DIR ) ) ); theme.setName( null ); assertFalse( theme.equals( new Theme( ID, NAME, ROOT_DIR ) ) ); assertNotEquals( theme.hashCode(), diffTheme.hashCode() ); diffTheme.setName( null ); assertEquals( 0, diffTheme.hashCode() ); }