ServerRestService { @GET @Path( "/" ) @Produces( "application/json" ) public Map<String, HmsNode> getHosts() throws HMSRestException { Map<String, HmsNode> nodeMapCopy = new ConcurrentHashMap<String, HmsNode>(); Set<Entry<String, HmsNode>> nodeEntrySet = serverConnector.getNodeMap().entrySet(); if ( nodeEntrySet != null && nodeEntrySet.size() > 0 ) { Iterator<Entry<String, HmsNode>> itr = nodeEntrySet.iterator(); while ( itr.hasNext() ) { Entry<String, HmsNode> curItem = itr.next(); HmsNode hmsNode = curItem.getValue(); HmsNode hmsNodeCopy = (HmsNode) HmsGenericUtil.maskPassword( hmsNode ); nodeMapCopy.put( curItem.getKey(), hmsNodeCopy ); } } return nodeMapCopy; }  @GET @Path( "/" ) @Produces( "application/json" ) Map<String, HmsNode> getHosts(); @GET @Path( "/{host_id}" ) @Produces( "application/json" ) ServerNode getHostNode( @PathParam( "host_id" ) String host_id ); @GET @Path( "/jnlpRemoteConsoleSupportFiles/{host_id}/{path : .*}" ) @Produces( MediaType.APPLICATION_OCTET_STREAM ) Response getJnlpSupportFiles( @PathParam( "host_id" ) String host_id, @PathParam( "path" ) String path ); @GET @Path( "/{host_id}/startremoteconsole" ) @Produces( "application/json" ) RemoteConsoleConnectionInfo startRemoteConsoleConnection( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/remoteconsoledetails" ) @Produces( "application/json" ) RemoteConsoleCapabilities getHostRemoteConsoleCapabilities( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/powerstatus" ) @Produces( "application/json" ) ServerNodePowerStatus getHostPowerStatus( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/selftest" ) @Produces( "application/json" ) SelfTestResults getHostSelfTestResults( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/bmcusers" ) @Produces( "application/json" ) List<BmcUser> getBmcUsers( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/cpuinfo" ) @Produces( "application/json" ) List<CPUInfo> getCpuInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/storageinfo" ) @Produces( "application/json" ) List<HddInfo> getHddInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/storagecontrollerinfo" ) @Produces( "application/json" ) List<StorageControllerInfo> getStorageControllerInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/memoryinfo" ) @Produces( "application/json" ) List<PhysicalMemory> getMemoryInfo( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/acpipowerstate" ) @Produces( "application/json" ) AcpiPowerState getHostAcpiPowerState( @PathParam( "host_id" ) String host_id ); @GET @Path( "/{host_id}/nicinfo" ) @Produces( "application/json" ) List<EthernetController> getNicInfo( @PathParam( "host_id" ) String host_id ); @PUT @Path( "/update" ) @Consumes( MediaType.APPLICATION_FORM_URLENCODED ) @Produces( "application/json" ) BaseResponse updateNodes( @Form HMSRestServerActionsForm actions ); @PUT @Path( "/{host_id}" ) @Produces( "application/json" ) BaseResponse updateNodes( @PathParam( "host_id" ) String host_id, @QueryParam( "action" ) String action ); @GET @Path( "/{host_id}/bootoptions" ) @Produces( "application/json" ) SystemBootOptions getSystemBootOptions( @PathParam( "host_id" ) String host_id ); @PUT @Path( "/{host_id}/bootoptions" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse getSystemBootOptions( @PathParam( "host_id" ) String host_id,
                                              SystemBootOptions systemBootOptions ); @PUT @Path( "/{host_id}/chassisidentify" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse chassisIdentify( @PathParam( "host_id" ) String host_id,
                                         ChassisIdentifyOptions chassisIdentifyOptions ); @PUT @Path( "/{host_id}/selinfo" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) SelInfo selInfo( @PathParam( "host_id" ) String host_id, SelOption selOption ); @PUT @Path( "/{host_id}/setpassword" ) @Consumes( MediaType.APPLICATION_JSON ) @Produces( "application/json" ) BaseResponse setBmcPassword( @PathParam( "host_id" ) String host_id, SetNodePassword nodePassword ); @GET @Path( "/{host_id}/supportedAPI" ) @Produces( "application/json" ) List<HmsApi> getAvailableNodeOperations( @PathParam( "host_id" ) String host_id ); @DELETE @Path( "/{hostId}" ) @Produces( "application/json" ) Response removeServer( @PathParam( "hostId" ) String hostId );  }
@Test public void getHosts() throws HMSRestException { ServerNodeConnector.getInstance().setNodeMap( new ConcurrentHashMap<String, HmsNode>() ); insertNodeInNodeMap( getServerNode() ); ServerRestService restService = new ServerRestService(); Map<String, HmsNode> hostMap = restService.getHosts(); Set<Entry<String, HmsNode>> nodeEntrySet = hostMap.entrySet(); if ( nodeEntrySet != null && nodeEntrySet.size() > 0 ) { Iterator<Entry<String, HmsNode>> itr = nodeEntrySet.iterator(); while ( itr.hasNext() ) { Entry<String, HmsNode> curItem = itr.next(); ServerNode servNode = (ServerNode) curItem.getValue(); assertEquals( servNode.getNodeID(), "N1" ); assertEquals( servNode.getBoardProductName(), "S2600GZ" ); assertEquals( servNode.getBoardVendor(), "Intel" ); assertEquals( servNode.getIbIpAddress(), "10.28.197.28" ); assertEquals( servNode.getManagementIp(), "10.28.197.208" ); assertEquals( servNode.getOsUserName(), "testuser" ); assertEquals( servNode.getOsPassword(), "****" ); } } nodeEntrySet = ServerNodeConnector.getInstance().getNodeMap().entrySet(); if ( nodeEntrySet != null && nodeEntrySet.size() > 0 ) { Iterator<Entry<String, HmsNode>> itr = nodeEntrySet.iterator(); while ( itr.hasNext() ) { Entry<String, HmsNode> curItem = itr.next(); ServerNode servNode = (ServerNode) curItem.getValue(); assertEquals( servNode.getNodeID(), "N1" ); assertEquals( servNode.getBoardProductName(), "S2600GZ" ); assertEquals( servNode.getBoardVendor(), "Intel" ); assertEquals( servNode.getIbIpAddress(), "10.28.197.28" ); assertEquals( servNode.getManagementIp(), "10.28.197.208" ); assertEquals( servNode.getOsUserName(), "testuser" ); assertEquals( servNode.getOsPassword(), "password" ); } } }