HmsInventory { public boolean addHost( ServerNode serverNode ) { if ( serverNode == null ) { logger.warn( "In addHost, ServerNode is null." ); return false; } List<ServerNode> hosts = this.getHosts(); if ( hosts == null ) { logger.warn( "In addHost, invenotry does not contain any hosts." ); hosts = new ArrayList<ServerNode>(); } hosts.add( serverNode ); return this.setHosts( hosts ); } private  HmsInventory(); static HmsInventory getInstance(); boolean loadInventory( final String inventoryFile ); boolean saveInventory( final String inventoryFile, boolean backup ); boolean saveInventory( final String inventoryFile ); boolean saveInventory( final boolean backup ); boolean saveInventory(); List<ServerNode> getHosts(); List<SwitchNode> getSwitches(); String getInventoryFile(); ServerNode getServerNode( final String hostId ); SwitchNode getSwitchNode( final String switchId ); boolean addHost( ServerNode serverNode ); boolean removeHost( final String hostId ); boolean setHosts( List<ServerNode> hosts );  }
@Test public void testAddHost() { HmsInventory hmsInventory = HmsInventory.getInstance(); assertTrue( hmsInventory.loadInventory( props.getProperty( HMS_IB_INVENTORY_LOCATION_PROPERTY ) ) ); final String nodeId = this.getNodeId( this.getDateTimeInMillis() ); assertTrue( hmsInventory.addHost( getServerNode( nodeId ) ) ); List<ServerNode> hosts = hmsInventory.getHosts(); assertNotNull( hosts ); List<String> nodeIds = this.getAllNodeIds( hosts ); assertTrue( nodeIds.contains( nodeId ) ); }