X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fsal-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2FNetconfDeviceTest.java;h=318df85c8deb21cf681b24ad742928f145373764;hb=476cc2164a06b77e7dd38859e0124d82cd2c8847;hp=9708888f5d0c44fb24eab62ea88e101f21b0c8fe;hpb=0e180ee7955d6770dc7d46d94164cf15fc17d3f7;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDeviceTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDeviceTest.java index 9708888f5d..318df85c8d 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDeviceTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDeviceTest.java @@ -26,6 +26,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; +import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.util.ArrayList; @@ -39,8 +40,6 @@ import java.util.concurrent.Executors; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; import org.opendaylight.controller.config.util.xml.XmlUtil; import org.opendaylight.controller.md.sal.dom.api.DOMNotification; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; @@ -49,7 +48,6 @@ import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.netconf.api.NetconfMessage; import org.opendaylight.netconf.api.xml.XmlNetconfConstants; import org.opendaylight.netconf.sal.connect.api.MessageTransformer; -import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemas; import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver; import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler; import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities; @@ -76,50 +74,48 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration; import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry; -import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource; +import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; +import org.xml.sax.SAXException; +@SuppressWarnings("checkstyle:IllegalCatch") public class NetconfDeviceTest { - private static final NetconfMessage notification; + private static final NetconfMessage NOTIFICATION; - private static final ContainerNode compositeNode; + private static final ContainerNode COMPOSITE_NODE; static { try { - compositeNode = mockClass(ContainerNode.class); + COMPOSITE_NODE = mockClass(ContainerNode.class); } catch (final Exception e) { throw new RuntimeException(e); } try { - notification = new NetconfMessage(XmlUtil.readXmlToDocument(NetconfDeviceTest.class.getResourceAsStream("/notification-payload.xml"))); - } catch (Exception e) { + NOTIFICATION = new NetconfMessage(XmlUtil + .readXmlToDocument(NetconfDeviceTest.class.getResourceAsStream("/notification-payload.xml"))); + } catch (SAXException | IOException e) { throw new ExceptionInInitializerError(e); } } - private static final DOMRpcResult rpcResultC = new DefaultDOMRpcResult(compositeNode); + private static final DOMRpcResult RPC_RESULT = new DefaultDOMRpcResult(COMPOSITE_NODE); public static final String TEST_NAMESPACE = "test:namespace"; public static final String TEST_MODULE = "test-module"; public static final String TEST_REVISION = "2013-07-22"; public static final SourceIdentifier TEST_SID = RevisionSourceIdentifier.create(TEST_MODULE, Optional.of(TEST_REVISION)); - public static final String TEST_CAPABILITY = TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION; + public static final String TEST_CAPABILITY = + TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION; public static final SourceIdentifier TEST_SID2 = RevisionSourceIdentifier.create(TEST_MODULE + "2", Optional.of(TEST_REVISION)); - public static final String TEST_CAPABILITY2 = TEST_NAMESPACE + "?module=" + TEST_MODULE + "2" + "&revision=" + TEST_REVISION; + public static final String TEST_CAPABILITY2 = + TEST_NAMESPACE + "?module=" + TEST_MODULE + "2" + "&revision=" + TEST_REVISION; - private static final NetconfDeviceSchemasResolver stateSchemasResolver = new NetconfDeviceSchemasResolver() { - - @Override - public NetconfDeviceSchemas resolve(final NetconfDeviceRpc deviceRpc, final NetconfSessionPreferences remoteSessionCapabilities, final RemoteDeviceId id) { - return NetconfStateSchemas.EMPTY; - } - }; + private static final NetconfDeviceSchemasResolver STATE_SCHEMAS_RESOLVER = + (deviceRpc, remoteSessionCapabilities, id) -> NetconfStateSchemas.EMPTY; @Test public void testNetconfDeviceFlawedModelFailedResolution() throws Exception { @@ -144,12 +140,13 @@ public class NetconfDeviceTest { final Module first = Iterables.getFirst(schema.getModules(), null); final QName qName = QName.create(first.getQNameModule(), first.getName()); final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName); - final NetconfStateSchemas.RemoteYangSchema source2 = new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2")); + final NetconfStateSchemas.RemoteYangSchema source2 = + new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2")); return new NetconfStateSchemas(Sets.newHashSet(source1, source2)); }; - final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO - = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver); + final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice + .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver); final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) @@ -159,10 +156,12 @@ public class NetconfDeviceTest { .setSalFacade(facade) .build(); // Monitoring supported - final NetconfSessionPreferences sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2)); + final NetconfSessionPreferences sessionCaps = + getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2)); device.onRemoteSessionUp(sessionCaps, listener); - Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class)); + Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected( + any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class)); Mockito.verify(schemaFactory, times(2)).createSchemaContext(anyCollectionOf(SourceIdentifier.class)); } @@ -184,8 +183,8 @@ public class NetconfDeviceTest { schemaResolutionException)) .when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class)); - final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO - = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver); + final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice + .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, STATE_SCHEMAS_RESOLVER); final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) @@ -213,32 +212,29 @@ public class NetconfDeviceTest { final SchemaRepository schemaRepository = getSchemaRepository(); // Make fallback attempt to fail due to empty resolved sources - final MissingSchemaSourceException schemaResolutionException = new MissingSchemaSourceException("fail first", TEST_SID); - doReturn(Futures.immediateFailedCheckedFuture(schemaResolutionException)).when(schemaRepository).getSchemaSource(eq(TEST_SID), eq(ASTSchemaSource.class)); - doAnswer(new Answer() { - @Override - public Object answer(final InvocationOnMock invocation) throws Throwable { - if (((Collection) invocation.getArguments()[0]).size() == 2) { - return Futures.immediateFailedCheckedFuture(schemaResolutionException); - } else { - return Futures.immediateCheckedFuture(schema); - } + final MissingSchemaSourceException schemaResolutionException = + new MissingSchemaSourceException("fail first", TEST_SID); + doReturn(Futures.immediateFailedCheckedFuture(schemaResolutionException)) + .when(schemaRepository).getSchemaSource(eq(TEST_SID), eq(ASTSchemaSource.class)); + doAnswer(invocation -> { + if (((Collection) invocation.getArguments()[0]).size() == 2) { + return Futures.immediateFailedCheckedFuture(schemaResolutionException); + } else { + return Futures.immediateCheckedFuture(schema); } }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class)); - final NetconfDeviceSchemasResolver stateSchemasResolver = new NetconfDeviceSchemasResolver() { - @Override - public NetconfDeviceSchemas resolve(final NetconfDeviceRpc deviceRpc, final NetconfSessionPreferences remoteSessionCapabilities, final RemoteDeviceId id) { - final Module first = Iterables.getFirst(schema.getModules(), null); - final QName qName = QName.create(first.getQNameModule(), first.getName()); - final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName); - final NetconfStateSchemas.RemoteYangSchema source2 = new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2")); - return new NetconfStateSchemas(Sets.newHashSet(source1, source2)); - } + final NetconfDeviceSchemasResolver stateSchemasResolver = (deviceRpc, remoteSessionCapabilities, id) -> { + final Module first = Iterables.getFirst(schema.getModules(), null); + final QName qName = QName.create(first.getQNameModule(), first.getName()); + final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName); + final NetconfStateSchemas.RemoteYangSchema source2 = + new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2")); + return new NetconfStateSchemas(Sets.newHashSet(source1, source2)); }; - final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO - = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver); + final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice + .SchemaResourcesDTO(getSchemaRegistry(), schemaRepository, schemaFactory, stateSchemasResolver); final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) @@ -248,25 +244,30 @@ public class NetconfDeviceTest { .setSalFacade(facade) .build(); // Monitoring supported - final NetconfSessionPreferences sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2)); + final NetconfSessionPreferences sessionCaps = + getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2)); device.onRemoteSessionUp(sessionCaps, listener); - Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class)); + Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected( + any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class)); Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class)); } - private SchemaSourceRegistry getSchemaRegistry() { + private static SchemaSourceRegistry getSchemaRegistry() { final SchemaSourceRegistry mock = mock(SchemaSourceRegistry.class); final SchemaSourceRegistration mockReg = mock(SchemaSourceRegistration.class); doNothing().when(mockReg).close(); - doReturn(mockReg).when(mock).registerSchemaSource(any(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider.class), any(PotentialSchemaSource.class)); + doReturn(mockReg).when(mock).registerSchemaSource( + any(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider.class), + any(PotentialSchemaSource.class)); return mock; } - private SchemaRepository getSchemaRepository() { + private static SchemaRepository getSchemaRepository() { final SchemaRepository mock = mock(SchemaRepository.class); final SchemaSourceRepresentation mockRep = mock(SchemaSourceRepresentation.class); - doReturn(Futures.immediateCheckedFuture(mockRep)).when(mock).getSchemaSource(any(SourceIdentifier.class), eq(ASTSchemaSource.class)); + doReturn(Futures.immediateCheckedFuture(mockRep)) + .when(mock).getSchemaSource(any(SourceIdentifier.class), eq(ASTSchemaSource.class)); return mock; } @@ -275,8 +276,8 @@ public class NetconfDeviceTest { final RemoteDeviceHandler facade = getFacade(); final NetconfDeviceCommunicator listener = getListener(); - final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO - = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(), getSchemaFactory(), stateSchemasResolver); + final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO( + getSchemaRegistry(), getSchemaRepository(), getSchemaFactory(), STATE_SCHEMAS_RESOLVER); final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) @@ -285,8 +286,8 @@ public class NetconfDeviceTest { .setSalFacade(facade) .build(); - device.onNotification(notification); - device.onNotification(notification); + device.onNotification(NOTIFICATION); + device.onNotification(NOTIFICATION); verify(facade, times(0)).onNotification(any(DOMNotification.class)); @@ -295,11 +296,12 @@ public class NetconfDeviceTest { final DOMRpcService deviceRpc = mock(DOMRpcService.class); - device.handleSalInitializationSuccess(NetconfToNotificationTest.getNotificationSchemaContext(getClass(), false), sessionCaps, deviceRpc); + device.handleSalInitializationSuccess( + NetconfToNotificationTest.getNotificationSchemaContext(getClass(), false), sessionCaps, deviceRpc); verify(facade, timeout(10000).times(2)).onNotification(any(DOMNotification.class)); - device.onNotification(notification); + device.onNotification(NOTIFICATION); verify(facade, timeout(10000).times(3)).onNotification(any(DOMNotification.class)); } @@ -310,8 +312,8 @@ public class NetconfDeviceTest { final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory(); - final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO - = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, stateSchemasResolver); + final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO( + getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER); final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) @@ -324,7 +326,8 @@ public class NetconfDeviceTest { device.onRemoteSessionUp(sessionCaps, listener); verify(schemaContextProviderFactory, timeout(5000)).createSchemaContext(any(Collection.class)); - verify(facade, timeout(5000)).onDeviceConnected(any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class)); + verify(facade, timeout(5000)).onDeviceConnected( + any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class)); device.onRemoteSessionDown(); verify(facade, timeout(5000)).onDeviceDisconnected(); @@ -332,7 +335,8 @@ public class NetconfDeviceTest { device.onRemoteSessionUp(sessionCaps, listener); verify(schemaContextProviderFactory, timeout(5000).times(2)).createSchemaContext(any(Collection.class)); - verify(facade, timeout(5000).times(2)).onDeviceConnected(any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class)); + verify(facade, timeout(5000).times(2)).onDeviceConnected( + any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class)); } @Test @@ -342,8 +346,8 @@ public class NetconfDeviceTest { final SchemaContextFactory schemaContextProviderFactory = getSchemaFactory(); - final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO - = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, stateSchemasResolver); + final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = new NetconfDevice.SchemaResourcesDTO( + getSchemaRegistry(), getSchemaRepository(), schemaContextProviderFactory, STATE_SCHEMAS_RESOLVER); final NetconfDevice device = new NetconfDeviceBuilder() .setReconnectOnSchemasChange(true) .setSchemaResourcesDTO(schemaResourcesDTO) @@ -357,52 +361,49 @@ public class NetconfDeviceTest { Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&revision=" + TEST_REVISION)); Map moduleBasedCaps = new HashMap<>(); moduleBasedCaps.putAll(sessionCaps.getModuleBasedCapsOrigin()); - moduleBasedCaps.put(QName.create("test:qname:side:loading"), AvailableCapability.CapabilityOrigin.UserDefined); + moduleBasedCaps + .put(QName.create("(test:qname:side:loading)test"), AvailableCapability.CapabilityOrigin.UserDefined); netconfSpy.onRemoteSessionUp(sessionCaps.replaceModuleCaps(moduleBasedCaps), listener); ArgumentCaptor argument = ArgumentCaptor.forClass(NetconfSessionPreferences.class); - verify(netconfSpy, timeout(5000)).handleSalInitializationSuccess(any(SchemaContext.class), (NetconfSessionPreferences) argument.capture(), any(DOMRpcService.class)); - NetconfDeviceCapabilities netconfDeviceCaps = ((NetconfSessionPreferences) argument.getValue()).getNetconfDeviceCapabilities(); - - netconfDeviceCaps.getResolvedCapabilities().forEach(entry -> assertEquals("Builded 'AvailableCapability' schemas should match input capabilities.", - moduleBasedCaps.get(QName.create(entry.getCapability())).getName(), entry.getCapabilityOrigin().getName())); + verify(netconfSpy, timeout(5000)).handleSalInitializationSuccess( + any(SchemaContext.class), (NetconfSessionPreferences) argument.capture(), any(DOMRpcService.class)); + NetconfDeviceCapabilities netconfDeviceCaps = + ((NetconfSessionPreferences) argument.getValue()).getNetconfDeviceCapabilities(); + + netconfDeviceCaps.getResolvedCapabilities() + .forEach(entry -> assertEquals("Builded 'AvailableCapability' schemas should match input capabilities.", + moduleBasedCaps.get( + QName.create(entry.getCapability())).getName(), entry.getCapabilityOrigin().getName())); } - private SchemaContextFactory getSchemaFactory() { + private static SchemaContextFactory getSchemaFactory() throws Exception { final SchemaContextFactory schemaFactory = mockClass(SchemaContextFactory.class); - doReturn(Futures.immediateCheckedFuture(getSchema())).when(schemaFactory).createSchemaContext(any(Collection.class)); + doReturn(Futures.immediateCheckedFuture(getSchema())) + .when(schemaFactory).createSchemaContext(any(Collection.class)); return schemaFactory; } - private static SchemaContext parseYangStreams(final List streams) { - CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR - .newBuild(); - final SchemaContext schemaContext; - try { - schemaContext = reactor.buildEffective(streams); - } catch (ReactorException e) { - throw new RuntimeException("Unable to build schema context from " + streams, e); - } - return schemaContext; - } - - public static SchemaContext getSchema() { + public static SchemaContext getSchema() throws Exception { final List modelsToParse = Lists.newArrayList( NetconfDeviceTest.class.getResourceAsStream("/schemas/test-module.yang") ); - return parseYangStreams(modelsToParse); + return YangParserTestUtils.parseYangStreams(modelsToParse); } - private RemoteDeviceHandler getFacade() throws Exception { - final RemoteDeviceHandler remoteDeviceHandler = mockCloseableClass(RemoteDeviceHandler.class); - doNothing().when(remoteDeviceHandler).onDeviceConnected(any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class)); + private static RemoteDeviceHandler getFacade() throws Exception { + final RemoteDeviceHandler remoteDeviceHandler = + mockCloseableClass(RemoteDeviceHandler.class); + doNothing().when(remoteDeviceHandler).onDeviceConnected( + any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class)); doNothing().when(remoteDeviceHandler).onDeviceDisconnected(); doNothing().when(remoteDeviceHandler).onNotification(any(DOMNotification.class)); return remoteDeviceHandler; } - private T mockCloseableClass(final Class remoteDeviceHandlerClass) throws Exception { + private static T mockCloseableClass(final Class remoteDeviceHandlerClass) + throws Exception { final T mock = mockClass(remoteDeviceHandlerClass); doNothing().when(mock).close(); return mock; @@ -424,18 +425,19 @@ public class NetconfDeviceTest { public MessageTransformer getMessageTransformer() throws Exception { final MessageTransformer messageTransformer = mockClass(MessageTransformer.class); - doReturn(notification).when(messageTransformer).toRpcRequest(any(SchemaPath.class), any(NormalizedNode.class)); - doReturn(rpcResultC).when(messageTransformer).toRpcResult(any(NetconfMessage.class), any(SchemaPath.class)); - doReturn(compositeNode).when(messageTransformer).toNotification(any(NetconfMessage.class)); + doReturn(NOTIFICATION).when(messageTransformer).toRpcRequest(any(SchemaPath.class), any(NormalizedNode.class)); + doReturn(RPC_RESULT).when(messageTransformer).toRpcResult(any(NetconfMessage.class), any(SchemaPath.class)); + doReturn(COMPOSITE_NODE).when(messageTransformer).toNotification(any(NetconfMessage.class)); return messageTransformer; } - public NetconfSessionPreferences getSessionCaps(final boolean addMonitor, final Collection additionalCapabilities) { + public NetconfSessionPreferences getSessionCaps(final boolean addMonitor, + final Collection additionalCapabilities) { final ArrayList capabilities = Lists.newArrayList( XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0, XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1); - if(addMonitor) { + if (addMonitor) { capabilities.add(NetconfMessageTransformUtil.IETF_NETCONF_MONITORING.getNamespace().toString()); } @@ -447,7 +449,8 @@ public class NetconfDeviceTest { public NetconfDeviceCommunicator getListener() throws Exception { final NetconfDeviceCommunicator remoteDeviceCommunicator = mockCloseableClass(NetconfDeviceCommunicator.class); -// doReturn(Futures.immediateFuture(rpcResult)).when(remoteDeviceCommunicator).sendRequest(any(NetconfMessage.class), any(QName.class)); +// doReturn(Futures.immediateFuture(rpcResult)) +// .when(remoteDeviceCommunicator).sendRequest(any(NetconfMessage.class), any(QName.class)); return remoteDeviceCommunicator; } }