-
- /**
- * Verify if a stream was correctly written into {@link MonitoringModule#STREAM_LIST_SCHEMA_NODE} node in Restconf
- * module.
- * @param streamName Expected stream name
- * @param streamNode Writetn strem node from Restconf module
- */
- private final void verifyStream(final String streamName, final MapEntryNode streamNode) {
- assertNotNull("Stream node can not be null", streamNode);
- final Iterator entries = ((AbstractImmutableDataContainerAttrNode) streamNode)
- .getChildren().entrySet().iterator();
- boolean notAllowedKey = false;
-
- while (entries.hasNext()) {
- final Entry e = ((AbstractMap.SimpleImmutableEntry) entries.next());
- final String key = ((YangInstanceIdentifier.NodeIdentifier) e.getKey()).getNodeType().getLocalName();
-
- switch (key) {
- case RestconfMappingNodeConstants.NAME :
- assertEquals("Stream name value is not as expected",
- streamName, ((LeafNode) e.getValue()).getValue());
- break;
- case RestconfMappingNodeConstants.DESCRIPTION :
- assertEquals("Stream description value is not as expected",
- RestconfMappingStreamConstants.DESCRIPTION, ((LeafNode) e.getValue()).getValue());
- break;
- case RestconfMappingNodeConstants.REPLAY_SUPPORT :
- assertEquals("Stream replay support value is not as expected",
- RestconfMappingStreamConstants.REPLAY_SUPPORT, ((LeafNode) e.getValue()).getValue());
- break;
- case RestconfMappingNodeConstants.REPLAY_LOG :
- assertEquals("Stream replay log value is not as expected",
- RestconfMappingStreamConstants.REPLAY_LOG, ((LeafNode) e.getValue()).getValue());
- break;
- case RestconfMappingNodeConstants.EVENTS :
- assertEquals("Stream events value is not as expected",
- RestconfMappingStreamConstants.EVENTS, ((LeafNode) e.getValue()).getValue());
- break;
- default:
- notAllowedKey = true;
- break;
- }
- }
-
- assertFalse("Not allowed key in list stream found", notAllowedKey);
- }
-
- /**
- * There are multiple testing Restconf modules for different test cases. It is possible to distinguish them by
- * name or by namespace. This method is looking for Restconf test module by its name.
- * @param s Testing Restconf module name
- * @return Restconf module
- */
- private Module getTestingRestconfModule(final String s) {
- return RestconfMappingNodeUtilTest.schemaContext.findModuleByName(
- s, Draft18.RestconfModule.IETF_RESTCONF_QNAME.getRevision());
- }
-
- /**
- * Updates {@link this#mockStreamList} to NOT contains specified leaf.
- * @param leaf Leaf to be missing
- */
- private void prepareMockListWithMissingLeaf(final LeafSchemaNode leaf) {
- // prepare set of leaf without selected leaf
- final Set childLeafs = new HashSet<>(this.allStreamChildNodes);
- childLeafs.remove(leaf);
-
- // mock list leaf nodes
- when(this.mockStreamList.getChildNodes()).thenReturn(childLeafs);
- }
-
- /**
- * Updates {@link this#mockStreamList} to contains specified leaf which is not of type {@link LeafSchemaNode}.
- * @param leaf Leaf to be changes
- */
- private void prepareMockListWithIllegalLeaf(final LeafSchemaNode leaf) {
- // prepare set of leaf without selected leaf
- final Set childLeafs = new HashSet<>(this.allStreamChildNodes);
- childLeafs.remove(leaf);
-
- // add leaf-list with the same local name as removed leaf
- final String localName = leaf.getQName().getLocalName();
- final LeafListSchemaNode mockLeafList = mock(LeafListSchemaNode.class);
- when(mockLeafList.getQName()).thenReturn(QName.create("", localName));
- childLeafs.add(mockLeafList);
-
- // mock list leaf nodes
- when(this.mockStreamList.getChildNodes()).thenReturn(childLeafs);
- }