AlarmUtil { public static ModelNodeId toNodeId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, String dbId, String mountRegistryKey) { ModelNodeId modelNodeId = new ModelNodeId(); String moduleNamespace = null; LocationPath locationPath = AlarmUtil.buildLocationPath(dbId); Step[] steps = locationPath.getSteps(); List<org.opendaylight.yangtools.yang.common.QName> qNameList = new ArrayList<>(); for (Step stepNode : steps) { moduleNamespace = buildNodeId(schemaRegistry, modelNodeId, stepNode, moduleNamespace, qNameList); if (moduleNamespace == null) { SchemaPath schemaPath = SchemaPath.create(qNameList, true); ModelNodeId mountModelNodeId = new ModelNodeId(); for (ModelNodeRdn rdn : modelNodeId.getRdns()) { ModelNodeRdn mountrdn = new ModelNodeRdn(rdn.getRdnName(), rdn.getNamespace(), removeSingleQuotes(rdn.getRdnValue())); mountModelNodeId.addRdn(mountrdn); } SchemaRegistry mountRegistry = getMountRegistry(schemaRegistry, dsm, schemaPath, mountModelNodeId.getParentId(), mountRegistryKey); if (mountRegistry != null) { schemaRegistry = mountRegistry; moduleNamespace = buildNodeId(schemaRegistry, modelNodeId, stepNode, moduleNamespace, qNameList); } } Expression[] predicates = stepNode.getPredicates(); if (predicates != null) { for (int predicateCount = 0; predicateCount < predicates.length; predicateCount++) { moduleNamespace = buildNodeId(schemaRegistry, modelNodeId, predicates[predicateCount], moduleNamespace); } } } return modelNodeId; } private  AlarmUtil(); static Step[] splitXpathByJXPath(String xPath); static Map<String, Pair<String, SchemaRegistry>> getPrefixToNsMap(ModelNodeId modelNodeId, ModelNodeDataStoreManager dsm,
                                                                             SchemaRegistry schemaRegistry, String mountKey); static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element); static ModelNodeId toNodeIdUsingRegistry(String dbId, SchemaRegistry registry); static Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId); static List<AlarmInfo> convertAlarmToAlarmInfoList(List<Alarm> existingBaaAlarms, SchemaRegistry schemaRegistry,
                                                              ModelNodeDataStoreManager dsm); static String xPathAlarmString(Map<String, Pair<String, SchemaRegistry>> prefixToNsMap, ModelNodeId modelNodeId); static String toDbId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, ModelNodeId modelNodeId,
                                Map<String, Pair<String, SchemaRegistry>> prefixToNsMap); static QName getNodeName(Step stepNode); static ModelNodeId toNodeId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, String dbId,
                                       String mountRegistryKey); static ModelNodeId toNodeId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, String dbId); static String xPathString(Map<String, Pair<String, SchemaRegistry>> prefixToNsMap, NamespaceContext nsContext,
                                     ModelNodeId modelNodeId);  }
@Test public void testToNodeId() { ModelNodeId actualNodeId = AlarmUtil.toNodeId(m_schemaRegistry, null, DB_ID); assertEquals(MODEL_NODE_ID, actualNodeId); actualNodeId = AlarmUtil.toNodeId(m_schemaRegistry, null, YET_ANOTHER_DB_ID); assertEquals(YET_ANOTHER_MODEL_NODE_ID, actualNodeId); actualNodeId = AlarmUtil.toNodeId(m_schemaRegistry, null, YET_ANOTHER_DB_ID); assertNotEquals(YET_ANOTHER_MODEL_NODE_ID_INVALID, actualNodeId); actualNodeId = AlarmUtil.toNodeId(m_schemaRegistry, m_dsm, DB_ID_FOR_INTF); assertEquals(INTF_MODEL_NODE_ID, actualNodeId); }
@Test(expected = JXPathInvalidSyntaxException.class) public void testToNodeId_throw_Exception() { ModelNodeId actualNodeId = AlarmUtil.toNodeId(m_schemaRegistry, null, DB_ID_WITH_INTF_INVALID); assertEquals(YET_ANOTHER_MODEL_NODE_ID, actualNodeId); }