AlarmUtil { public static ModelNodeId toNodeIdUsingRegistry(String dbId, SchemaRegistry registry) { ModelNodeId modelNodeId = new ModelNodeId(); String moduleNamespace = null; LocationPath locationPath = AlarmUtil.buildLocationPath(dbId); Step[] steps = locationPath.getSteps(); for (Step stepNode : steps) { moduleNamespace = buildNodeIdUsingNodeElement(null, registry, modelNodeId, stepNode, moduleNamespace); Expression[] predicates = stepNode.getPredicates(); if (predicates != null) { for (int predicateCount = 0; predicateCount < predicates.length; predicateCount++) { moduleNamespace = buildNodeIdUsingNodeElement(null, registry, 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 testToNodeIdUsingRegistry() throws NetconfMessageBuilderException { when(m_schemaRegistry.getNamespaceURI("if")).thenReturn(IF_INTF_NS); ModelNodeId actualNodeId = AlarmUtil.toNodeIdUsingRegistry(DB_ID_WITH_INTF, m_schemaRegistry); assertEquals(INTF_MODEL_NODE_ID, actualNodeId); }
@Test public void testToNodeIdUsingRegistryWhenNamespaceMissingException() throws NetconfMessageBuilderException { m_expectedException.expect(AlarmProcessingException.class); m_expectedException.expectMessage("Namespace is missing for prefix 'if' in resource"); AlarmUtil.toNodeIdUsingRegistry(DB_ID_WITH_INTF, m_schemaRegistry); }