ComponentEventRestService { @GET @Path( "/host/nme/{host_id}" ) @Produces( "application/json" ) public List<Event> getComponnetNmeEvents( @PathParam( "host_id" ) String host_id ) throws HMSRestException { if ( !serverConnector.getNodeMap().containsKey( host_id ) ) throw new HMSRestException( Status.NOT_FOUND.getStatusCode(), "Invalid Request", "Can't find host with id " + host_id ); else { List<Event> events = new ArrayList<Event>(); ServerNode node = (ServerNode) serverConnector.getNodeMap().get( host_id ); try { for ( ServerComponent component : ServerComponent.values() ) { try { executeServerMonitorTask( node, component ); } catch ( HmsException e ) { logger.error( "Exception occured while executing ServerMonitor task for component" + component, e ); } events.addAll( EventMonitoringSubscriptionHolder.getEventList( node, component, true ) ); } return events; } catch ( Exception e ) { logger.error( "Error getting sensor events for node :" + host_id, e ); throw new HMSRestException( Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Server Error", e.getMessage() ); } } }  @GET @Path( "/host/{host_id}/{event_source}" ) @Produces( "application/json" ) List<Event> getComponnetEvents( @PathParam( "host_id" ) String host_id,
                                           @PathParam( "event_source" ) EventComponent event_source ); @GET @Path( "/host/nme/{host_id}" ) @Produces( "application/json" ) List<Event> getComponnetNmeEvents( @PathParam( "host_id" ) String host_id ); @GET @Path( value = "/host/HMS" ) @Produces( "application/json" ) List<Event> getComponentEvents(); @GET @Path( "/switches/{switch_id}/{event_source}" ) @Produces( "application/json" ) List<Event> getSwitchComponentEvents( @PathParam( "switch_id" ) String switchId,
                                                 @PathParam( "event_source" ) EventComponent eventSource ); @GET @Path( "/switches/nme/{switch_id}" ) @Produces( "application/json" ) List<Event> getSwitchComponentNmeEvents( @PathParam( "switch_id" ) String switchId );  }
@Test public void getComponentNmeEvents_nodeInNodeMap_boardServiceFound_HDD() throws Exception { insertNodeInNodeMap( getServerNode() ); addBoardServiceForNode(); ComponentEventRestService restService = new ComponentEventRestService(); List<Event> hddEvents = restService.getComponnetNmeEvents( "N1" ); assertNotNull( hddEvents ); assertTrue( hddEvents.size() > 0 ); assertNotNull( hddEvents.get( 0 ) ); }