FruIdEventsHelperUtil { public static List<Event> addFruIDtoStorageControllerEvents( List<Event> aggregatedEvents, List<StorageController> storageControllerList ) { List<Event> events = new ArrayList<Event>(); StorageController storageController = new StorageController(); 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_CONTROLLER ); for ( int j = 0; j < storageControllerList.size(); j++ ) { String deviceNameProduct = storageControllerList.get( j ).getDeviceName() + " " + storageControllerList.get( j ).getComponentIdentifier().getProduct(); if ( componentId.equals( deviceNameProduct ) ) { storageController = storageControllerList.get( j ); eventBody.put( "fruID", storageController.getFruId() ); break; } } events.add( event ); } return events; } catch ( Exception e ) { logger.error( "HMS aggregator error in adding Fru ID to Storage Controller 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 addFruIDtoStorageControllerEventsTest() { List<Event> events = new ArrayList<Event>(); List<Event> storageControllerEventsFruID = new ArrayList<Event>(); Event event = new Event(); Body body = new Body(); Header header = new Header(); try { body.setDescription( "Storage Adapter for the rack EVO:RACK node N3, Patsburg 4-Port SATA Storage Control Unit operational status is down" ); Map<String, String> data = new HashMap<String, String>(); data.put( "unit", "DISCRETE" ); data.put( "eventName", "STORAGE_CONTROLLER_DOWN" ); body.setData( data ); Map<EventComponent, String> compIdentifier = new HashMap<EventComponent, String>(); compIdentifier.put( EventComponent.STORAGE_CONTROLLER, "vmhba0 Patsburg 4-Port SATA Storage Control Unit" ); compIdentifier.put( EventComponent.SERVER, "N5" ); header.addComponentIdentifier( compIdentifier ); header.setAgent( "HMS" ); header.setEventName( EventCatalog.STORAGE_CONTROLLER_DOWN ); header.setSeverity( EventSeverity.ERROR ); header.setVersion( "1.0" ); event.setBody( body ); event.setHeader( header ); events.add( event ); List<StorageController> StorageControllerList = new ArrayList<StorageController>(); StorageController storageControllerInfo = new StorageController(); ComponentIdentifier componentIdentifier = new ComponentIdentifier(); componentIdentifier.setManufacturer( "Intel Corporation" ); componentIdentifier.setProduct( "Patsburg 4-Port SATA Storage Control Unit" ); storageControllerInfo.setComponentIdentifier( componentIdentifier ); storageControllerInfo.setDeviceName( "vmhba0" ); storageControllerInfo.setNumOfStorageDevicesConnected( 1 ); storageControllerInfo.setDriver( "ahci" ); storageControllerInfo.setFirmwareVersion( "23fh.56" ); storageControllerInfo.setFruId( "944039473-157926983" ); storageControllerInfo.setOperationalStatus( "offline" ); StorageControllerList.add( storageControllerInfo ); storageControllerEventsFruID = FruIdEventsHelperUtil.addFruIDtoStorageControllerEvents( events, StorageControllerList ); Map<String, String> eventData = storageControllerEventsFruID.get( 0 ).getBody().getData(); assertNotNull( eventData.get( "fruID" ) ); } catch ( Exception e ) { logger.info( "Integrate FRU ID with Storage Controller Events Test Failed" ); } }