FruIdEventsHelperUtil { public static List<Event> addFruIDtoCpuEvents( List<Event> aggregatedEvents, List<CpuInfo> cpuInfoList ) { List<Event> events = new ArrayList<Event>(); CpuInfo cpuInfo = new CpuInfo(); try { for ( int i = 0; i < aggregatedEvents.size(); i++ ) { Event event = aggregatedEvents.get( i ); Map<EventComponent, String> eventComponentIdentifier = event.getHeader().getComponentIdentifier(); Map<String, String> eventBody = event.getBody().getData(); String componentId = eventComponentIdentifier.get( EventComponent.CPU ); for ( int j = 0; j < cpuInfoList.size(); j++ ) { if ( componentId.contains( cpuInfoList.get( j ).getLocation() ) ) { cpuInfo = cpuInfoList.get( j ); eventBody.put( "fruID", cpuInfo.getFruId() ); break; } } events.add( event ); } return events; } catch ( Exception e ) { logger.error( "HMS aggregator error in adding Fru ID to CPU Events", e ); } return null; }  static List<Event> addFruIDtoEvents( List<Event> aggregatedEvents, String nodeID,
                                                ServerComponent serverComponent ); static List<Event> addFruIDtoSwitchEventsHelper( List<Event> aggregatedSwitchEvents, String switchID ); static List<Event> addFruIDtoCpuEvents( List<Event> aggregatedEvents, List<CpuInfo> cpuInfoList ); static List<Event> addFruIDtoMemoryEvents( List<Event> aggregatedEvents, List<MemoryInfo> memoryInfoList ); static List<Event> addFruIDtoStorageEvents( List<Event> aggregatedEvents, List<StorageInfo> storageInfoList ); static List<Event> addFruIDtoStorageControllerEvents( List<Event> aggregatedEvents,
                                                                 List<StorageController> storageControllerList ); static List<Event> addFruIDtoEthernetControllerEvents( List<Event> aggregatedEvents,
                                                                  List<EthernetController> ethernetControllerList ); static List<Event> addFruIDtoHostEvents( List<Event> aggregatedEvents, String serverFruID ); static List<Event> addFruIDtoSwitchEvents( List<Event> aggregatedEvents, String switchFruID );  }
@Test public void addFruIDtoCpuEventsTest() { List<Event> events = new ArrayList<Event>(); List<Event> cpuEventsFruID = new ArrayList<Event>(); Event event = new Event(); Body body = new Body(); Header header = new Header(); try { body.setDescription( "CPU for rack EVO:RACK node N5 and CPU processor 0 has shutdown due to POST Failure." ); Map<String, String> data = new HashMap<String, String>(); data.put( "unit", EventUnitType.DISCRETE.toString() ); data.put( "eventName", "CPU_POST_FAILURE" ); body.setData( data ); Map<EventComponent, String> compIdentifier = new HashMap<EventComponent, String>(); compIdentifier.put( EventComponent.CPU, "0" ); compIdentifier.put( EventComponent.SERVER, "N5" ); header.addComponentIdentifier( compIdentifier ); header.setAgent( "HMS" ); header.setEventName( EventCatalog.CPU_POST_FAILURE ); header.setSeverity( EventSeverity.CRITICAL ); header.setVersion( "1.0" ); event.setBody( body ); event.setHeader( header ); events.add( event ); List<CpuInfo> cpuInfoList = new ArrayList<CpuInfo>(); CpuInfo cpuInfo = new CpuInfo(); ComponentIdentifier cpuComponentIdentifier = new ComponentIdentifier(); cpuComponentIdentifier.setManufacturer( "intel" ); cpuComponentIdentifier.setProduct( "Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz" ); cpuInfo.setComponentIdentifier( cpuComponentIdentifier ); cpuInfo.setCpuFrequencyInHertz( 2593 ); cpuInfo.setHostId( "N5" ); cpuInfo.setNumOfCores( 8 ); cpuInfo.setLocation( "0" ); cpuInfo.setFruId( "-9458916751211679985" ); cpuInfoList.add( cpuInfo ); cpuEventsFruID = FruIdEventsHelperUtil.addFruIDtoCpuEvents( events, cpuInfoList ); Map<String, String> eventData = cpuEventsFruID.get( 0 ).getBody().getData(); assertNotNull( eventData.get( "fruID" ) ); } catch ( Exception e ) { logger.info( "Integrate FRU ID with CPU Events Test Failed" ); } }