NcCompliantAdapterDeviceInterface implements DeviceInterface { @Override public Future<NetConfResponse> get(Device device, GetRequest getRequest) throws ExecutionException { if (m_ncm.isConnected(device)) { return m_ncm.executeNetconf(device, getRequest); } else { throw new IllegalStateException(String.format("Device not connected %s", device.getDeviceName())); } } NcCompliantAdapterDeviceInterface(NetconfConnectionManager ncm); @Override Future<NetConfResponse> align(Device device, EditConfigRequest request, NetConfResponse getConfigResponse); @Override Pair<AbstractNetconfRequest, Future<NetConfResponse>> forceAlign(Device device, NetConfResponse getConfigResponse); @Override Future<NetConfResponse> get(Device device, GetRequest getRequest); @Override void veto(Device device, EditConfigRequest request, Document oldDataStore, Document updatedDataStore); @Override Future<NetConfResponse> getConfig(Device device, GetConfigRequest getConfigRequest); @Override ConnectionState getConnectionState(Device device); @Override Notification normalizeNotification(Notification notification);  }
@Test public void testGet() throws ExecutionException { m_deviceInterface.get(m_device, m_getRequest); verify(m_ncm).executeNetconf(m_device, m_getRequest); }
@Test public void testGetWhenDeviceNotConnected() throws ExecutionException { when(m_ncm.isConnected(m_device)).thenReturn(false); try { m_deviceInterface.get(m_device, m_getRequest); } catch (IllegalStateException e) { assertTrue(e.getMessage().contains(DEVICE_NOT_CONNECTED_TEST_DEVICE)); } }