AggregatorImpl implements Aggregator { @Override public String dispatchRequest(NetconfClientInfo clientInfo, String netconfRequest) throws DispatchException { LOGGER.info("Aggregator dispatch request:\n {}", netconfRequest); AggregatorRpcMessage aggregatorRpcMessage = buildAggregatorRpcMessage(netconfRequest); String response; if (aggregatorRpcMessage.isNetworkManagerMessage()) { response = dispatchNetworkManageRequest(clientInfo, aggregatorRpcMessage); LOGGER.info("Network manager request response:\n {}", response); } else { response = dispatchGlobalRequest(clientInfo, aggregatorRpcMessage); LOGGER.info("Global request response:\n {}", response); } return response; } AggregatorImpl(); @Override String dispatchRequest(NetconfClientInfo clientInfo, String netconfRequest); @Override void publishNotification(Notification notification); @Override void publishNotification(String deviceName, Notification notification); @Override void addProcessor(Set<ModuleIdentifier> moduleIdentifiers, GlobalRequestProcessor globalRequestProcessor); @Override void addProcessor(String deviceType, Set<ModuleIdentifier> moduleIdentifiers,
                             DeviceConfigProcessor deviceConfigProcessor); @Override void addProcessor(NotificationProcessor notificationProcessor); @Override void removeProcessor(GlobalRequestProcessor globalRequestProcessor); @Override void removeProcessor(DeviceConfigProcessor deviceConfigProcessor); @Override void removeProcessor(NotificationProcessor notificationProcessor); @Override void removeProcessor(String deviceType, Set<ModuleIdentifier> moduleIdentifiers,
                                DeviceConfigProcessor deviceConfigProcessor); @Override Set<String> getSystemCapabilities(); @Override void registerDeviceManager(DeviceManagementProcessor deviceManagementProcessor); @Override void unregisterDeviceManager(); @Override Set<ProcessorCapability> getProcessorCapabilities(); @Override Set<ModuleIdentifier> getModuleIdentifiers();  }
@Test public void dispatchRequestDeviceAddTest() throws Exception { String response = m_aggregator.dispatchRequest(m_clientInfo, REQUEST_DEVICE_ADD); verify(m_deviceManagementProcessor).processRequest(eq(m_clientInfo), anyString()); assertFalse(response.isEmpty()); }
@Test public void dispatchRequestDeviceGetTest() throws Exception { when(m_deviceManagementProcessor.processRequest(eq(m_clientInfo), anyString())).thenReturn(REQUEST_DEVICE_GET); String response = m_aggregator.dispatchRequest(m_clientInfo, REQUEST_DEVICE_GET); verify(m_deviceManagementProcessor).processRequest(eq(m_clientInfo), anyString()); assertEquals(REQUEST_DEVICE_GET, response); }
@Test public void dispatchRequestDeviceGetConfigTest() throws Exception { when(m_deviceManagementProcessor.processRequest(eq(m_clientInfo), anyString())).thenReturn(REQUEST_DEVICE_GET_CONFIG); String response = m_aggregator.dispatchRequest(m_clientInfo, REQUEST_DEVICE_GET_CONFIG); verify(m_deviceManagementProcessor).processRequest(eq(m_clientInfo), anyString()); assertEquals(REQUEST_DEVICE_GET_CONFIG, response); }
@Test public void dispatchRequestDeviceConfigTest() throws Exception { when(m_deviceManagementProcessor.getDeviceTypeByDeviceName(anyString())).thenReturn("DPU"); String response = m_aggregator.dispatchRequest(m_clientInfo, REQUEST_DEVICE_CONFIG); assertFalse(response.isEmpty()); }
@Test public void dispatchRequestDeviceConfigGetTest() throws Exception { String response = m_aggregator.dispatchRequest(m_clientInfo, REQUEST_DEVICE_SERVICE_GET); assertFalse(response.isEmpty()); }