DeviceSubsystem extends AbstractSubSystem { @Override protected Map<ModelNodeId, List<Element>> retrieveStateAttributes(Map<ModelNodeId, Pair<List<QName>, List<FilterNode>>> attributes) { GetRequest getRequest = prepareRequest(attributes); try { Device device = PmaServer.getCurrentDevice(); DeviceInterface deviceInterface = AdapterUtils.getAdapterContext(device, m_adapterManager).getDeviceInterface(); Future<NetConfResponse> future = deviceInterface.get(device, getRequest); NetConfResponse response = future.get(); if (response != null) { return m_util.getStateResponse(attributes, response.getData()); } } catch (ExecutionException | InterruptedException | IllegalStateException e) { LOGGER.error("Error while retrieving state attributes", e); } return Collections.emptyMap(); } DeviceSubsystem(NetconfDeviceAlignmentService das, SchemaRegistry schemaRegistry,
                           AdapterManager adapterManager); @Override void notifyChanged(List<ChangeNotification> changeNotificationList); @Override void notifyPreCommitChange(List<ChangeNotification> changeNotificationList);  }
@Test public void testNcSessionMgrIsContactedToRetrieveStateValues() throws GetAttributeException, ExecutionException, NetconfMessageBuilderException, IOException, SAXException { Map<ModelNodeId, Pair<List<QName>, List<FilterNode>>> attributes = getAttributes(); m_deviceSubsystem.retrieveStateAttributes(attributes, new NetconfQueryParams(UNBOUNDED, true)); verify(m_deviceInterface).get(eq(m_device), m_requestCaptor.capture()); String expectedGetRequest = "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + " <get>\n" + " <filter type=\"subtree\">\n" + " <interfaces-state xmlns=\"urn:ietf:ns\">\n" + " <test1>\n" + " <containment-node xmlns=\"urn:containment:ns\">\n" + " <match-node xmlns=\"urn:match:ns\">match-value</match-node>\n" + " <inner-select-node xmlns=\"urn:inner:select:ns\"/>\n" + " </containment-node>\n" + " <select-node xmlns=\"urn:select:ns\"/>\n" + " </test1>\n" + " <test3>\n" + " <leaf-match xmlns=\"urn:leafmatch:ns\">leaf-match-value</leaf-match>\n" + " </test3>\n" + " <leaf1/>\n" + " <leaf2/>\n" + " </interfaces-state>\n" + " </filter>\n" + " </get>\n" + "</rpc>"; TestUtil.assertXMLEquals(DocumentUtils.stringToDocument(expectedGetRequest).getDocumentElement(), DocumentUtils.stringToDocument(m_requestCaptor.getValue().requestToString().trim()).getDocumentElement()); }