@Test public void testextractAndCreateAlarmEntryFromResponseVersion1() 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(getAlarmListStringVersion1()).getDocumentElement(); List<AlarmInfo> infoList = AlarmNotificationUtil.extractAndCreateAlarmEntryFromResponse(notificationElement, m_registry, m_device, m_deviceAdapterId, 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> extractAndCreateAlarmEntryFromResponse(Element outputElement, SchemaRegistry schemaRegistry, Device device, DeviceAdapterId deviceAdapterId, String ietfAlarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { NodeList baselist = outputElement.getChildNodes(); for (int i = 0; i < baselist.getLength(); i++) { Node node = baselist.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element nodeEle = (Element) node; String nodeName = nodeEle.getLocalName(); QName expectedAlarmListQName = QName.create(ietfAlarmNs, ALARMLIST_TAG); QName qname = QName.create(nodeEle.getNamespaceURI(), nodeName); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { NodeList alarmListBaseListNode = nodeEle.getChildNodes(); for (int j = 0; j < alarmListBaseListNode.getLength(); j++) { Node alarmListBaseNode = alarmListBaseListNode.item(j); if (alarmListBaseNode.getNodeType() == Node.ELEMENT_NODE) { Element alarmListEle = (Element) alarmListBaseNode; try { info = getAlarmInfoFromAlarmElement(schemaRegistry, device, alarmListEle, ietfAlarmNs); if (info != null) { alarmInfoList.add(info); } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, " + "more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } } } } } } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } return alarmInfoList; }
AlarmNotificationUtil { public static List<AlarmInfo> extractAndCreateAlarmEntryFromResponse(Element outputElement, SchemaRegistry schemaRegistry, Device device, DeviceAdapterId deviceAdapterId, String ietfAlarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { NodeList baselist = outputElement.getChildNodes(); for (int i = 0; i < baselist.getLength(); i++) { Node node = baselist.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element nodeEle = (Element) node; String nodeName = nodeEle.getLocalName(); QName expectedAlarmListQName = QName.create(ietfAlarmNs, ALARMLIST_TAG); QName qname = QName.create(nodeEle.getNamespaceURI(), nodeName); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { NodeList alarmListBaseListNode = nodeEle.getChildNodes(); for (int j = 0; j < alarmListBaseListNode.getLength(); j++) { Node alarmListBaseNode = alarmListBaseListNode.item(j); if (alarmListBaseNode.getNodeType() == Node.ELEMENT_NODE) { Element alarmListEle = (Element) alarmListBaseNode; try { info = getAlarmInfoFromAlarmElement(schemaRegistry, device, alarmListEle, ietfAlarmNs); if (info != null) { alarmInfoList.add(info); } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, " + "more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } } } } } } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } return alarmInfoList; } }
AlarmNotificationUtil { public static List<AlarmInfo> extractAndCreateAlarmEntryFromResponse(Element outputElement, SchemaRegistry schemaRegistry, Device device, DeviceAdapterId deviceAdapterId, String ietfAlarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { NodeList baselist = outputElement.getChildNodes(); for (int i = 0; i < baselist.getLength(); i++) { Node node = baselist.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element nodeEle = (Element) node; String nodeName = nodeEle.getLocalName(); QName expectedAlarmListQName = QName.create(ietfAlarmNs, ALARMLIST_TAG); QName qname = QName.create(nodeEle.getNamespaceURI(), nodeName); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { NodeList alarmListBaseListNode = nodeEle.getChildNodes(); for (int j = 0; j < alarmListBaseListNode.getLength(); j++) { Node alarmListBaseNode = alarmListBaseListNode.item(j); if (alarmListBaseNode.getNodeType() == Node.ELEMENT_NODE) { Element alarmListEle = (Element) alarmListBaseNode; try { info = getAlarmInfoFromAlarmElement(schemaRegistry, device, alarmListEle, ietfAlarmNs); if (info != null) { alarmInfoList.add(info); } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, " + "more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } } } } } } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } return alarmInfoList; } private  AlarmNotificationUtil(); }
AlarmNotificationUtil { public static List<AlarmInfo> extractAndCreateAlarmEntryFromResponse(Element outputElement, SchemaRegistry schemaRegistry, Device device, DeviceAdapterId deviceAdapterId, String ietfAlarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { NodeList baselist = outputElement.getChildNodes(); for (int i = 0; i < baselist.getLength(); i++) { Node node = baselist.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element nodeEle = (Element) node; String nodeName = nodeEle.getLocalName(); QName expectedAlarmListQName = QName.create(ietfAlarmNs, ALARMLIST_TAG); QName qname = QName.create(nodeEle.getNamespaceURI(), nodeName); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { NodeList alarmListBaseListNode = nodeEle.getChildNodes(); for (int j = 0; j < alarmListBaseListNode.getLength(); j++) { Node alarmListBaseNode = alarmListBaseListNode.item(j); if (alarmListBaseNode.getNodeType() == Node.ELEMENT_NODE) { Element alarmListEle = (Element) alarmListBaseNode; try { info = getAlarmInfoFromAlarmElement(schemaRegistry, device, alarmListEle, ietfAlarmNs); if (info != null) { alarmInfoList.add(info); } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, " + "more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } } } } } } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, more details in debug", e); LOGGER.debug("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> extractAndCreateAlarmEntryFromResponse(Element outputElement, SchemaRegistry schemaRegistry, Device device, DeviceAdapterId deviceAdapterId, String ietfAlarmNs) { List<AlarmInfo> alarmInfoList = new ArrayList<>(); try { NodeList baselist = outputElement.getChildNodes(); for (int i = 0; i < baselist.getLength(); i++) { Node node = baselist.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element nodeEle = (Element) node; String nodeName = nodeEle.getLocalName(); QName expectedAlarmListQName = QName.create(ietfAlarmNs, ALARMLIST_TAG); QName qname = QName.create(nodeEle.getNamespaceURI(), nodeName); AlarmInfo info = null; if (qname.equals(expectedAlarmListQName)) { NodeList alarmListBaseListNode = nodeEle.getChildNodes(); for (int j = 0; j < alarmListBaseListNode.getLength(); j++) { Node alarmListBaseNode = alarmListBaseListNode.item(j); if (alarmListBaseNode.getNodeType() == Node.ELEMENT_NODE) { Element alarmListEle = (Element) alarmListBaseNode; try { info = getAlarmInfoFromAlarmElement(schemaRegistry, device, alarmListEle, ietfAlarmNs); if (info != null) { alarmInfoList.add(info); } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, " + "more details in debug", e); LOGGER.debug("Exception while processing alarm:", e); } } } } } } } catch (Exception e) { LOGGER.error("Could not process alarm due to exception on unexpected response, more details in debug", e); LOGGER.debug("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);  }