HealthMonitorEventAggregatorTask implements IEventAggregatorTask { @Override public List<Event> processEvents( ServerNode node, ServerComponent component ) throws HMSRestException { List<Event> aggregatedEvents = new ArrayList<Event>(); aggregatedEvents.addAll( getIBEvents( node, component ) ); List<Event> oobEvents = getOOBEvents( node, component ); aggregatedEvents.addAll( oobEvents ); initiateInventoryRefreshOnOutOfBand( oobEvents ); try { aggregatedEvents = EventFilterService.filterOrMassageEvents( NODE, component, aggregatedEvents ); } catch ( Exception e ) { logger.warn( "Error filtering events for HMS:: Component:" + component, e ); } return aggregatedEvents; }  @Override List<Event> getAggregatedEvents( ServerNode node, ServerComponent component ); @Override List<Event> processEvents( ServerNode node, ServerComponent component ); @Override List<Event> getAggregatedSwitchEvents( String switchId, SwitchComponentEnum component ); @Override List<Event> getAggregatedEvents( ServerNode node, ServerComponent component, boolean oobMonitoring,
                                            boolean ibMonitoring ); @Override List<Event> getAggregatedSwitchEvents( String switchId, SwitchComponentEnum component,
                                                  boolean switchMonitoring );  }
@Test public void testProcessEvents() throws HmsException { PowerMockito.mockStatic( MonitoringUtil.class ); PowerMockito.mockStatic( AgentHealthMonitoringUtil.class ); List<Event> eventsLst = new ArrayList<Event>(); Event event = new Event(); Body body = new Body(); Map<String, String> data = new HashMap<String, String>(); data.put( Constants.HMS_INV_FROM_AGG_AVAILABILITY_STATUS, new String( "true" ) ); body.setData( data ); event.setBody( body ); eventsLst.add( event ); when( MonitoringUtil.getHealthMonitorEventsOOB() ).thenReturn( eventsLst ); InbandServiceTestImpl inbandSvc = new InbandServiceTestImpl(); List<ServerComponentEvent> eventLst = inbandSvc.getComponentEventList( null, ServerComponent.CPU ); when( AgentHealthMonitoringUtil.getCPUUsage() ).thenReturn( eventLst.get( 0 ) ); eventLst = inbandSvc.getComponentEventList( null, ServerComponent.MEMORY ); when( AgentHealthMonitoringUtil.getHMSMemoryUsage() ).thenReturn( eventLst.get( 0 ) ); ServerComponentEvent sensor = new ServerComponentEvent(); sensor.setComponentId( "HMS_AGENT_THREAD_USAGE" ); sensor.setUnit( EventUnitType.COUNT ); sensor.setEventName( NodeEvent.HMS_AGENT_THREAD_COUNT ); sensor.setValue( 1 ); when( AgentHealthMonitoringUtil.getThreadCount() ).thenReturn( sensor ); HealthMonitorEventAggregatorTask task = new HealthMonitorEventAggregatorTask(); ServerNode serverNode = new ServerNode(); List<Event> events = task.processEvents( serverNode, ServerComponent.HMS ); Assert.assertNotNull( events ); Event eventObj = events.get( events.size() - 1 ); Map<String, String> map = eventObj.getBody().getData(); String value = map.get( Constants.HMS_INV_FROM_AGG_AVAILABILITY_STATUS ); Assert.assertEquals( "true", value ); }