LibraryConsultAdapter implements GlobalRequestProcessor, DeviceConfigProcessor { @Override public String processRequest(NetconfClientInfo clientInfo, String netconfRequest) throws DispatchException { QueryYangModuleInUseRpc queryYangModuleInUseRpc = QueryYangModuleInUseRpc.getInstance(netconfRequest); return processRequestInternal(netconfRequest, null, (Document document, String devName) -> { UsedYangModules usedYangModules = queryYangModuleInUseRpc.getUsedYangModules(); if (usedYangModules == null) { return null; } List<YangModule> yangModules = usedYangModules.getYangModules(); if ((yangModules != null) && (!yangModules.isEmpty())) { YangModule filterModule = yangModules.get(0); return m_libConsultMgr.getSpecificUsedYangModules(filterModule.getName(), filterModule.getRevision(), document); } return m_libConsultMgr.getAllUsedYangModules(document); }); } LibraryConsultAdapter(Aggregator aggregator, LibConsultMgr libConsultMgr); void init(); void destroy(); @Override String processRequest(NetconfClientInfo clientInfo, String netconfRequest); @Override String processRequest(String deviceName, String netconfRequest);  }
@Test public void processWithInvalidRequest() throws Exception { Document emptyResponse = DocumentUtils.stringToDocument(GET_NOTHING); String result = m_libraryConsultAdapter.processRequest(m_clientInfo, INVALID_REQUEST); Document docResult = DocumentUtils.stringToDocument(result); TestUtil.assertXMLEquals(emptyResponse.getDocumentElement(), docResult.getDocumentElement()); }
@Test public void processRequestGetAllUsedYangModules() throws Exception { m_libraryConsultAdapter.processRequest(m_clientInfo, REQUEST_ALL_USED_YANG_MODULES); verify(m_libConsultMgr).getAllUsedYangModules(any()); }
@Test public void processRequestGetSpecificYangModules() throws Exception { m_libraryConsultAdapter.processRequest(m_clientInfo, REQUEST_SPECIFIC_USED_YANG_MODULE); verify(m_libConsultMgr).getSpecificUsedYangModules(anyString(), anyString(), any()); }
@Test public void processRequestGetYangModulesUsedPerDev() throws Exception { m_libraryConsultAdapter.processRequest(DEVICE_NAME_A, REQUEST_USED_YANG_MODULE_PER_DEV); verify(m_libConsultMgr).getUsedYangModulesPerDevice(any(), anyString()); }