FruIdEventsHelperUtil { public static List<Event> addFruIDtoMemoryEvents( List<Event> aggregatedEvents, List<MemoryInfo> memoryInfoList ) { List<Event> events = new ArrayList<Event>(); MemoryInfo memoryInfo = new MemoryInfo(); 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.MEMORY ); for ( int j = 0; j < memoryInfoList.size(); j++ ) { if ( componentId.contains( memoryInfoList.get( j ).getLocation() ) ) { memoryInfo = memoryInfoList.get( j ); eventBody.put( "fruID", memoryInfo.getFruId() ); break; } } events.add( event ); } return events; } catch ( Exception e ) { logger.error( "HMS aggregator error in adding Fru ID to Memory 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 addFruIDtoMemoryEventsTest() { List<Event> events = new ArrayList<Event>(); List<Event> memoryEventsFruID = new ArrayList<Event>(); Event event = new Event(); Body body = new Body(); Header header = new Header(); try { body.setDescription( "Memory temperature for rack EVO:RACK node N5 and Memory ChannelA_Dimm0 has reached its maximum safe operating temperature. Current Memory temperature is 95.0 degrees C." ); Map<String, String> data = new HashMap<String, String>(); data.put( "unit", EventUnitType.DEGREES_CELSIUS.toString() ); data.put( "eventName", "MEMORY_TEMP_ABOVE_THRESHOLD" ); body.setData( data ); Map<EventComponent, String> compIdentifier = new HashMap<EventComponent, String>(); compIdentifier.put( EventComponent.MEMORY, "ChannelA_Dimm0" ); compIdentifier.put( EventComponent.SERVER, "N5" ); header.addComponentIdentifier( compIdentifier ); header.setAgent( "HMS" ); header.setEventName( EventCatalog.DIMM_TEMPERATURE_ABOVE_UPPER_THRESHOLD ); header.setSeverity( EventSeverity.WARNING ); header.setVersion( "1.0" ); event.setBody( body ); event.setHeader( header ); events.add( event ); List<MemoryInfo> memoryInfoList = new ArrayList<MemoryInfo>(); MemoryInfo memoryInfo = new MemoryInfo(); ComponentIdentifier memoryComponentIdentifier = new ComponentIdentifier(); memoryComponentIdentifier.setManufacturer( "Samsung" ); memoryComponentIdentifier.setSerialNumber( "14289B0C" ); memoryComponentIdentifier.setPartNumber( "M393B2G70QH0-YK0" ); memoryInfo.setComponentIdentifier( memoryComponentIdentifier ); memoryInfo.setMemorySpeedInHertz( 1333L ); memoryInfo.setHostId( "N5" ); memoryInfo.setLocation( "ChannelA_Dimm0" ); memoryInfo.setFruId( "179086051211679985" ); memoryInfoList.add( memoryInfo ); memoryEventsFruID = FruIdEventsHelperUtil.addFruIDtoMemoryEvents( events, memoryInfoList ); Map<String, String> eventData = memoryEventsFruID.get( 0 ).getBody().getData(); assertNotNull( eventData.get( "fruID" ) ); } catch ( Exception e ) { logger.info( "Integrate FRU ID with Memory Events Test Failed" ); } }