FruIdEventsHelperUtil { public static List<Event> addFruIDtoStorageEvents( List<Event> aggregatedEvents, List<StorageInfo> storageInfoList ) { List<Event> events = new ArrayList<Event>(); StorageInfo storageInfo = new StorageInfo(); 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.STORAGE ); for ( int j = 0; j < storageInfoList.size(); j++ ) { if ( componentId.equals( storageInfoList.get( j ).getId() ) ) { storageInfo = storageInfoList.get( j ); eventBody.put( "fruID", storageInfo.getFruId() ); break; } } events.add( event ); } return events; } catch ( Exception e ) { logger.error( "HMS aggregator error in adding Fru ID to Storage or HDD 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 addFruIDtoStorageEventsTest() { List<Event> events = new ArrayList<Event>(); List<Event> storageEventsFruID = new ArrayList<Event>(); Event event = new Event(); Body body = new Body(); Header header = new Header(); try { body.setDescription( "Storage drive for rack EVO:RACK node N3 and HDD HDD_0 drive slot is full: DrivePresence" ); Map<String, String> data = new HashMap<String, String>(); data.put( "unit", "DISCRETE" ); data.put( "eventName", "HDD_SLOT_FULL" ); body.setData( data ); Map<EventComponent, String> compIdentifier = new HashMap<EventComponent, String>(); compIdentifier.put( EventComponent.STORAGE, "0" ); compIdentifier.put( EventComponent.SERVER, "N5" ); header.addComponentIdentifier( compIdentifier ); header.setAgent( "HMS" ); header.setEventName( EventCatalog.HDD_UP ); header.setSeverity( EventSeverity.INFORMATIONAL ); header.setVersion( "1.0" ); event.setBody( body ); event.setHeader( header ); events.add( event ); List<StorageInfo> storageInfoList = new ArrayList<StorageInfo>(); StorageInfo storageInfo = new StorageInfo(); ComponentIdentifier cpuComponentIdentifier = new ComponentIdentifier(); cpuComponentIdentifier.setManufacturer( "ATA" ); cpuComponentIdentifier.setProduct( "32G MLC SATADOM" ); storageInfo.setComponentIdentifier( cpuComponentIdentifier ); storageInfo.setDiskCapacityInMB( 29579 ); storageInfo.setHostId( "N5" ); storageInfo.setFruId( "-9080809091211679985" ); storageInfo.setDiskType( "SSD" ); storageInfo.setLocation( "0" ); storageInfo.setId( "0" ); storageInfoList.add( storageInfo ); storageEventsFruID = FruIdEventsHelperUtil.addFruIDtoStorageEvents( events, storageInfoList ); Map<String, String> eventData = storageEventsFruID.get( 0 ).getBody().getData(); assertNotNull( eventData.get( "fruID" ) ); } catch ( Exception e ) { logger.info( "Integrate FRU ID with Storage or HDD Events Test Failed" ); } }