@Test public void testextractAndCreateAlarmEntryFromNotificationVersion1() throws NetconfMessageBuilderException, URISyntaxException { QNameModule qNameModule = QNameModule.create(new URI(BBF_ALARM_TYPES_NS), REV); when(m_module.getQNameModule()).thenReturn(qNameModule); when(m_registry.getModuleByNamespace(BBF_ALARM_TYPES_NS)).thenReturn(m_module); when(m_device.getDeviceName()).thenReturn("R1.S1.LT1.PON1.ONT1"); Element notificationElement = DocumentUtils.stringToDocument(getAlarmNotificationStringVersion1()).getDocumentElement(); List<AlarmInfo> infoList = AlarmNotificationUtil.extractAndCreateAlarmEntryFromNotification(notificationElement, m_registry, m_device, AlarmConstants.ALARM_NAMESPACE); assertEquals(1, infoList.size()); AlarmInfo info = infoList.get(0); assertEquals("dummyText", info.getAlarmText()); assertEquals(AlarmSeverity.MAJOR, info.getSeverity()); Optional<Revision> revision = qNameModule.getRevision(); StringBuffer fullAlarmTypeId = new StringBuffer(); fullAlarmTypeId.append("{dpu-al}(").append(BBF_ALARM_TYPES_NS); if (revision.isPresent()) { fullAlarmTypeId.append("?revision=").append(revision.get()); } fullAlarmTypeId.append(")").append("xdsl-fe-los"); assertEquals(fullAlarmTypeId.toString(), info.getAlarmTypeId()); assertEquals("", info.getAlarmTypeQualifier()); assertEquals(MODEL_NODE_ID, info.getSourceObject()); assertEquals("R1.S1.LT1.PON1.ONT1", info.getDeviceName()); }
public static List<AlarmInfo> extractAndCreateAlarmEntryFromNotification(Element outputElement, SchemaRegistry schemaRegistry, Device device, String alarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { QName expectedAlarmListQName = QName.create(alarmNs, AlarmConstants.ALARM_NOTIFICATION); QName qname = QName.create(outputElement.getNamespaceURI(), outputElement.getLocalName()); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { info = getAlarmInfoFromAlarmNotificationElement(schemaRegistry, device, outputElement, alarmNs); if (info != null) { alarmInfoList.add(info); } } } catch (Exception e) { LOGGER.error(String.format("Could not process alarm: %s due to exception %s", outputElement, e)); throw new RuntimeException("Exception while processing alarm", e); } return alarmInfoList; }
AlarmNotificationUtil { public static List<AlarmInfo> extractAndCreateAlarmEntryFromNotification(Element outputElement, SchemaRegistry schemaRegistry, Device device, String alarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { QName expectedAlarmListQName = QName.create(alarmNs, AlarmConstants.ALARM_NOTIFICATION); QName qname = QName.create(outputElement.getNamespaceURI(), outputElement.getLocalName()); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { info = getAlarmInfoFromAlarmNotificationElement(schemaRegistry, device, outputElement, alarmNs); if (info != null) { alarmInfoList.add(info); } } } catch (Exception e) { LOGGER.error(String.format("Could not process alarm: %s due to exception %s", outputElement, e)); throw new RuntimeException("Exception while processing alarm", e); } return alarmInfoList; } }
AlarmNotificationUtil { public static List<AlarmInfo> extractAndCreateAlarmEntryFromNotification(Element outputElement, SchemaRegistry schemaRegistry, Device device, String alarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { QName expectedAlarmListQName = QName.create(alarmNs, AlarmConstants.ALARM_NOTIFICATION); QName qname = QName.create(outputElement.getNamespaceURI(), outputElement.getLocalName()); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { info = getAlarmInfoFromAlarmNotificationElement(schemaRegistry, device, outputElement, alarmNs); if (info != null) { alarmInfoList.add(info); } } } catch (Exception e) { LOGGER.error(String.format("Could not process alarm: %s due to exception %s", outputElement, e)); throw new RuntimeException("Exception while processing alarm", e); } return alarmInfoList; } private  AlarmNotificationUtil(); }
AlarmNotificationUtil { public static List<AlarmInfo> extractAndCreateAlarmEntryFromNotification(Element outputElement, SchemaRegistry schemaRegistry, Device device, String alarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { QName expectedAlarmListQName = QName.create(alarmNs, AlarmConstants.ALARM_NOTIFICATION); QName qname = QName.create(outputElement.getNamespaceURI(), outputElement.getLocalName()); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { info = getAlarmInfoFromAlarmNotificationElement(schemaRegistry, device, outputElement, alarmNs); if (info != null) { alarmInfoList.add(info); } } } catch (Exception e) { LOGGER.error(String.format("Could not process alarm: %s due to exception %s", outputElement, e)); throw new RuntimeException("Exception while processing alarm", e); } return alarmInfoList; } private  AlarmNotificationUtil(); static Timestamp parseTimestampValue(String dateInString); static List<AlarmInfo> extractAndCreateAlarmEntryFromResponse(Element outputElement, SchemaRegistry schemaRegistry,
                                                                         Device device, DeviceAdapterId deviceAdapterId,
                                                                         String ietfAlarmNs); static List<AlarmInfo> extractAndCreateAlarmEntryFromNotification(Element outputElement, SchemaRegistry schemaRegistry,
                                                                             Device device, String alarmNs); }
AlarmNotificationUtil { public static List<AlarmInfo> extractAndCreateAlarmEntryFromNotification(Element outputElement, SchemaRegistry schemaRegistry, Device device, String alarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { QName expectedAlarmListQName = QName.create(alarmNs, AlarmConstants.ALARM_NOTIFICATION); QName qname = QName.create(outputElement.getNamespaceURI(), outputElement.getLocalName()); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { info = getAlarmInfoFromAlarmNotificationElement(schemaRegistry, device, outputElement, alarmNs); if (info != null) { alarmInfoList.add(info); } } } catch (Exception e) { LOGGER.error(String.format("Could not process alarm: %s due to exception %s", outputElement, e)); throw new RuntimeException("Exception while processing alarm", e); } return alarmInfoList; } private  AlarmNotificationUtil(); static Timestamp parseTimestampValue(String dateInString); static List<AlarmInfo> extractAndCreateAlarmEntryFromResponse(Element outputElement, SchemaRegistry schemaRegistry,
                                                                         Device device, DeviceAdapterId deviceAdapterId,
                                                                         String ietfAlarmNs); static List<AlarmInfo> extractAndCreateAlarmEntryFromNotification(Element outputElement, SchemaRegistry schemaRegistry,
                                                                             Device device, String alarmNs);  }