FruIdEventsHelperUtil { public static List<Event> addFruIDtoEthernetControllerEvents( List<Event> aggregatedEvents, List<EthernetController> ethernetControllerList ) { List<Event> events = new ArrayList<Event>(); EthernetController ethernetController = new EthernetController(); 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.NIC ); boolean foundEthernetControllerFru = false; for ( int j = 0; j < ethernetControllerList.size() && foundEthernetControllerFru == false; j++ ) { for ( int k = 0; k < ethernetControllerList.get( j ).getPortInfos().size(); k++ ) { if ( componentId.contains( ethernetControllerList.get( j ).getPortInfos().get( k ).getDeviceName() ) ) { ethernetController = ethernetControllerList.get( j ); eventBody.put( "fruID", ethernetController.getFruId() ); foundEthernetControllerFru = true; break; } } } events.add( event ); } return events; } catch ( Exception e ) { logger.error( "HMS aggregator error in adding Fru ID to Ethernet Controller or NIC 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 addFruIDtoEthernetControllerEventsTest() { List<Event> events = new ArrayList<Event>(); List<Event> ethernetControllerEventsFruID = new ArrayList<Event>(); Event event = new Event(); Body body = new Body(); Header header = new Header(); try { body.setDescription( "NIC for rack EVO:RACK node N5 Ethernet Controller {EC} and NIC vmnic2 Link status is down" ); Map<String, String> data = new HashMap<String, String>(); data.put( "unit", "DISCRETE" ); data.put( "eventName", "NIC_LINK_DOWN" ); body.setData( data ); Map<EventComponent, String> compIdentifier = new HashMap<EventComponent, String>(); compIdentifier.put( EventComponent.NIC, "vmnic0" ); compIdentifier.put( EventComponent.SERVER, "N5" ); header.addComponentIdentifier( compIdentifier ); header.setAgent( "HMS" ); header.setEventName( EventCatalog.NIC_LINK_DOWN ); header.setSeverity( EventSeverity.ERROR ); header.setVersion( "1.0" ); event.setBody( body ); event.setHeader( header ); events.add( event ); List<EthernetController> ethernetControllerInfoList = new ArrayList<EthernetController>(); List<PortInfo> portInfoList = new ArrayList<PortInfo>(); PortInfo portInfo = new PortInfo(); EthernetController ethernetController = new EthernetController(); ComponentIdentifier ethernetControllerComponentIdentifier = new ComponentIdentifier(); ethernetControllerComponentIdentifier.setManufacturer( "Intel Corporation" ); ethernetControllerComponentIdentifier.setProduct( "I350 Gigabit Network Connection" ); ethernetController.setComponentIdentifier( ethernetControllerComponentIdentifier ); ethernetController.setFruId( "32023948731211679985" ); ethernetController.setHostId( "N5" ); ethernetController.setSpeedInMbps( "1000" ); ethernetController.setFirmwareVersion( "1.61, 0x80000919" ); portInfo.setMacAddress( "c4:54:44:72:c5:d4" ); portInfo.setDeviceName( "vmnic0" ); portInfoList.add( portInfo ); ethernetController.setPortInfos( portInfoList ); ethernetControllerInfoList.add( ethernetController ); ethernetControllerEventsFruID = FruIdEventsHelperUtil.addFruIDtoEthernetControllerEvents( events, ethernetControllerInfoList ); Map<String, String> eventData = ethernetControllerEventsFruID.get( 0 ).getBody().getData(); assertNotNull( eventData.get( "fruID" ) ); } catch ( Exception e ) { logger.info( "Integrate FRU ID with Ethernet Controller Events Test Failed" ); } }