From c894986ef8b0b40d7457c8c0c54a656ea0e9a521 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 7 Oct 2020 14:33:02 +0200 Subject: [PATCH] Bump upstreams for Silicon Adopt the following upstream versions: - odlparent-8.0.0 - yangtools-6.0.0 - mdsal-7.0.0 - controller-3.0.0 - infrautils-1.9.0 Since mdsal's testing infrastructure now operates on binding packaging, we ditch multiple testing copies of models, as we can now reuse already existing packaging. Change-Id: Iafa5e702e1e84fa9980a1168ec8d53b4f152b823 Signed-off-by: Robert Varga --- artifacts/pom.xml | 9 +- .../features-netconf-connector/pom.xml | 2 +- .../netconf-connector/odl-message-bus/pom.xml | 4 +- .../src/main/feature/feature.xml | 2 +- .../odl-netconf-callhome-ssh/pom.xml | 2 +- .../odl-netconf-clustered-topology/pom.xml | 2 +- .../odl-netconf-connector-all/pom.xml | 2 +- .../odl-netconf-connector/pom.xml | 6 +- .../src/main/feature/feature.xml | 4 +- .../odl-netconf-console/pom.xml | 2 +- .../odl-netconf-topology/pom.xml | 2 +- features/netconf-connector/pom.xml | 2 +- features/netconf/features-netconf/pom.xml | 2 +- .../odl-aaa-netconf-plugin-no-cluster/pom.xml | 2 +- .../netconf/odl-aaa-netconf-plugin/pom.xml | 2 +- features/netconf/odl-netconf-all/pom.xml | 2 +- features/netconf/odl-netconf-api/pom.xml | 6 +- .../src/main/feature/feature.xml | 8 +- features/netconf/odl-netconf-client/pom.xml | 4 +- .../src/main/feature/feature.xml | 2 +- features/netconf/odl-netconf-impl/pom.xml | 4 +- .../src/main/feature/feature.xml | 2 +- .../netconf/odl-netconf-mapping-api/pom.xml | 2 +- features/netconf/odl-netconf-mdsal/pom.xml | 2 +- .../netconf/odl-netconf-netty-util/pom.xml | 2 +- .../src/main/feature/feature.xml | 2 +- .../odl-netconf-notifications-api/pom.xml | 2 +- .../odl-netconf-notifications-impl/pom.xml | 4 +- .../src/main/feature/feature.xml | 2 +- features/netconf/odl-netconf-ssh/pom.xml | 2 +- features/netconf/odl-netconf-tcp/pom.xml | 2 +- features/netconf/odl-netconf-util/pom.xml | 4 +- .../src/main/feature/feature.xml | 2 +- features/netconf/pom.xml | 2 +- features/pom.xml | 2 +- features/restconf/features-restconf/pom.xml | 2 +- features/restconf/odl-mdsal-apidocs/pom.xml | 4 +- .../src/main/feature/feature.xml | 2 +- features/restconf/odl-restconf-all/pom.xml | 2 +- features/restconf/odl-restconf-common/pom.xml | 8 +- .../src/main/feature/feature.xml | 8 +- .../odl-restconf-nb-bierman02/pom.xml | 4 +- .../restconf/odl-restconf-nb-rfc8040/pom.xml | 4 +- .../src/main/feature/feature.xml | 2 +- features/restconf/odl-restconf/pom.xml | 2 +- features/restconf/pom.xml | 2 +- features/yanglib/features-yanglib/pom.xml | 2 +- features/yanglib/odl-yanglib/pom.xml | 2 +- .../odl-yanglib/src/main/feature/feature.xml | 2 +- features/yanglib/pom.xml | 2 +- karaf/pom.xml | 2 +- .../MdsalNetconfOperationServiceFactory.java | 9 +- .../mdsal/connector/ops/RuntimeRpc.java | 8 +- .../mdsal/connector/ops/RuntimeRpcTest.java | 18 +- .../impl/NetconfNotificationManager.java | 1 + .../impl/ops/NotificationsTransformUtil.java | 15 +- .../blueprint/mdsal-netconf-notification.xml | 2 +- .../impl/NetconfNotificationManagerTest.java | 3 +- .../ops/NotificationsTransformUtilTest.java | 3 +- ...nnectionNotificationTopicRegistration.java | 10 +- .../netconf/NetconfEventSource.java | 13 +- .../netconf/NetconfEventSourceMount.java | 19 +- .../StreamNotificationTopicRegistration.java | 2 +- .../netconf/AbstractCodecTest.java | 2 +- ...tionNotificationTopicRegistrationTest.java | 15 +- .../NetconfEventSourceManagerTest.java | 19 +- .../netconf/NetconfEventSourceMountTest.java | 14 +- .../netconf/NetconfEventSourceTest.java | 19 +- ...reamNotificationTopicRegistrationTest.java | 17 +- netconf/models/netconf-test-models/pom.xml | 31 ++ ...work-topology-augment-test@2016-08-08.yang | 21 + netconf/models/pom.xml | 4 +- .../api/capability/YangModuleCapability.java | 6 +- netconf/netconf-config/pom.xml | 2 +- .../console/impl/NetconfCommandsImplTest.java | 14 +- .../schemas/ietf-inet-types@2013-07-15.yang | 457 ------------------ .../schemas/netconf-node-optional.yang | 69 --- .../schemas/netconf-node-topology.yang | 367 -------------- .../schemas/network-topology@2013-10-21.yang | 339 ------------- .../src/test/resources/schemas/yang-ext.yang | 79 --- .../impl/NetconfTopologyImplTest.java | 16 +- netconf/netconf-topology-singleton/pom.xml | 13 +- .../singleton/impl/ProxyDOMActionService.java | 8 +- .../singleton/impl/ProxyDOMRpcService.java | 6 +- .../impl/actors/NetconfNodeActor.java | 18 +- .../singleton/messages/SchemaPathMessage.java | 26 +- .../messages/action/InvokeActionMessage.java | 4 +- .../messages/rpc/InvokeRpcMessage.java | 5 +- .../impl/AbstractBaseSchemasTest.java | 3 +- .../impl/MountPointEndToEndTest.java | 25 +- .../singleton/impl/NetconfNodeActorTest.java | 23 +- .../impl/NetconfNodeManagerTest.java | 1 - netconf/netconf-topology/pom.xml | 5 + netconf/netconf-util/pom.xml | 5 + .../netconf/util/NetconfUtil.java | 8 +- .../netconf/util/NodeContainerProxy.java | 13 +- .../netconf/util/NetconfUtilTest.java | 6 +- netconf/pom.xml | 2 +- netconf/sal-netconf-connector/pom.xml | 4 + .../sal/connect/api/MessageTransformer.java | 11 +- .../netconf/DeviceActionFactoryImpl.java | 4 +- .../netconf/LibraryModulesSchemas.java | 6 +- .../sal/connect/netconf/NetconfDevice.java | 10 +- .../connect/netconf/NetconfStateSchemas.java | 4 +- .../netconf/sal/KeepaliveSalFacade.java | 9 +- .../sal/NetconfDeviceNotificationService.java | 14 +- .../connect/netconf/sal/NetconfDeviceRpc.java | 8 +- .../netconf/sal/NetconfDeviceSalProvider.java | 4 +- .../sal/SchemalessNetconfDeviceRpc.java | 12 +- ...NetconfRemoteSchemaYangSourceProvider.java | 4 +- .../mapping/BaseRpcSchemalessTransformer.java | 31 +- .../mapping/DefaultBaseNetconfSchemas.java | 11 +- .../mapping/NetconfMessageTransformer.java | 92 ++-- .../mapping/OSGiBaseNetconfSchemas.java | 3 +- .../mapping/SchemalessMessageTransformer.java | 5 +- .../connect/netconf/util/NetconfBaseOps.java | 48 +- .../util/NetconfMessageTransformUtil.java | 26 +- .../util/NetconfRpcStructureTransformer.java | 6 +- .../netconf/AbstractBaseSchemasTest.java | 4 +- .../connect/netconf/NetconfDeviceTest.java | 5 +- .../NetconfNestedNotificationTest.java | 6 +- .../netconf/NetconfStateSchemasTest.java | 10 +- .../netconf/NetconfToRpcRequestTest.java | 5 +- ...KeepaliveSalFacadeResponseWaitingTest.java | 6 +- .../netconf/sal/KeepaliveSalFacadeTest.java | 20 +- .../netconf/sal/MountInstanceTest.java | 10 +- .../sal/NetconfDataTreeServiceImplTest.java | 44 +- .../sal/NetconfDeviceDataBrokerTest.java | 11 +- .../NetconfDeviceNotificationServiceTest.java | 6 +- .../netconf/sal/NetconfDeviceRpcTest.java | 18 +- .../sal/NetconfDeviceTopologyAdapterTest.java | 16 +- .../sal/SchemalessNetconfDeviceRpcTest.java | 4 +- .../sal/tx/NetconfDeviceWriteOnlyTxTest.java | 33 +- .../netconf/sal/tx/ReadOnlyTxTest.java | 18 +- .../sal/tx/WriteCandidateRunningTxTest.java | 14 +- .../netconf/sal/tx/WriteCandidateTxTest.java | 10 +- .../netconf/sal/tx/WriteRunningTxTest.java | 11 +- ...onfRemoteSchemaYangSourceProviderTest.java | 7 +- .../BaseRpcSchemalessTransformerTest.java | 6 +- .../NetconfMessageTransformerTest.java | 79 ++- .../SchemalessMessageTransformerTest.java | 13 +- .../schemas/ietf-inet-types@2013-07-15.yang | 457 ------------------ .../schemas/netconf-node-optional.yang | 69 --- .../schemas/netconf-node-topology.yang | 367 -------------- ...work-topology-augment-test@2016-08-08.yang | 26 - netconf/shaded-exificient-jar/pom.xml | 2 +- netconf/shaded-exificient/pom.xml | 2 +- netconf/shaded-sshd-jar/pom.xml | 9 +- netconf/shaded-sshd/pom.xml | 2 +- .../test/tool/MdsalOperationProvider.java | 15 - .../test/tool/NetconfDeviceSimulator.java | 6 +- .../netconf/test/tool/TesttoolParameters.java | 2 +- netconf/tools/pom.xml | 2 +- parent/pom.xml | 8 +- pom.xml | 2 +- restconf/pom.xml | 2 +- .../util/AbstractOperationDataSchemaNode.java | 6 +- .../common/util/AbstractOperationsModule.java | 38 +- .../util/OperationsContainerSchemaNode.java | 7 + .../common/util/OperationsLeafSchemaNode.java | 7 + restconf/restconf-models/pom.xml | 2 +- restconf/restconf-nb-bierman02/pom.xml | 5 + .../sal/rest/impl/JsonToPatchBodyReader.java | 4 +- .../impl/NormalizedNodeXmlBodyWriter.java | 3 +- .../StringModuleInstanceIdentifierCodec.java | 5 +- .../impl/XmlNormalizedNodeBodyReader.java | 4 +- .../sal/rest/impl/XmlToPatchBodyReader.java | 5 +- .../sal/restconf/impl/BrokerFacade.java | 68 +-- .../sal/restconf/impl/ControllerContext.java | 36 +- .../impl/DataNormalizationOperation.java | 7 +- .../sal/restconf/impl/DataNormalizer.java | 4 +- .../sal/restconf/impl/RestconfImpl.java | 31 +- .../listeners/AbstractNotificationsData.java | 4 +- .../streams/listeners/ListenerAdapter.java | 15 +- .../NotificationListenerAdapter.java | 15 +- .../md/sal/rest/common/TestRestconfUtils.java | 11 +- .../providers/AbstractBodyReaderTest.java | 10 +- .../TestJsonBodyReaderMountPoint.java | 11 +- .../TestXmlBodyReaderMountPoint.java | 26 +- .../test/providers/TestXmlBodyWriter.java | 3 +- .../to/cnsn/test/RestPutListDataTest.java | 5 +- ...NnToXmlWithDataFromSeveralModulesTest.java | 9 +- .../restconf/impl/test/BrokerFacadeTest.java | 24 +- .../sal/restconf/impl/test/Bug8072Test.java | 9 +- .../impl/test/InvokeRpcMethodTest.java | 25 +- .../test/JSONRestconfServiceImplTest.java | 44 +- .../impl/test/RestGetOperationTest.java | 26 +- .../impl/test/RestPostOperationTest.java | 15 +- .../impl/test/RestPutOperationTest.java | 27 +- .../restconf/impl/test/RestconfImplTest.java | 4 +- .../impl/test/URIParametersParsing.java | 7 +- .../sal/restconf/impl/test/URITest.java | 19 +- .../test/incubate/InMemoryMdsalModule.java | 8 +- .../listeners/NotificationListenerTest.java | 25 +- restconf/restconf-nb-rfc8040/pom.xml | 5 + .../restconf/nb/rfc8040/codecs/RestCodec.java | 22 +- .../StringModuleInstanceIdentifierCodec.java | 9 +- .../NormalizedNodeXmlBodyWriter.java | 6 +- .../XmlNormalizedNodeBodyReader.java | 4 +- .../patch/JsonToPatchBodyReader.java | 4 +- .../providers/patch/XmlToPatchBodyReader.java | 5 +- .../rests/services/impl/CreateStreamUtil.java | 8 +- .../impl/RestconfDataServiceImpl.java | 27 +- .../RestconfInvokeOperationsServiceImpl.java | 14 +- .../services/impl/SubscribeToStreamUtil.java | 17 +- .../rests/utils/PutDataTransactionUtil.java | 5 +- .../rests/utils/ReadDataTransactionUtil.java | 17 +- .../utils/RestconfInvokeOperationsUtil.java | 21 +- .../impl/RestconfOperationsServiceImpl.java | 10 +- .../listeners/AbstractNotificationsData.java | 4 +- .../streams/listeners/ListenerAdapter.java | 11 +- .../streams/listeners/ListenersBroker.java | 4 +- .../NotificationListenerAdapter.java | 25 +- .../mapping/RestconfMappingNodeUtil.java | 12 +- .../rfc8040/utils/parser/IdentifierCodec.java | 6 +- .../utils/parser/ParserIdentifier.java | 27 +- .../YangInstanceIdentifierDeserializer.java | 13 +- .../YangInstanceIdentifierSerializer.java | 3 +- .../XmlBodyReaderMountPointTest.java | 28 +- .../test/AbstractBodyReaderTest.java | 15 +- .../services/impl/CreateStreamUtilTest.java | 4 +- .../JSONRestconfServiceRfc8040ImplTest.java | 31 +- .../impl/RestconfDataServiceImplTest.java | 9 +- ...stconfInvokeOperationsServiceImplTest.java | 5 +- .../PlainPatchDataTransactionUtilTest.java | 5 +- .../utils/PutDataTransactionUtilTest.java | 7 +- .../nb/rfc8040/rests/utils/TestData.java | 19 +- .../impl/RestconfSchemaServiceTest.java | 4 +- .../listeners/NotificationListenerTest.java | 28 +- .../test/incubate/InMemoryMdsalModule.java | 8 +- .../utils/parser/IdentifierCodecTest.java | 4 +- .../utils/parser/ParserIdentifierTest.java | 10 +- restconf/sal-rest-connector-config/pom.xml | 2 +- .../rest/doc/maven/StaticDocGenerator.java | 11 +- .../rest/doc/impl/DefinitionGenerator.java | 5 +- .../doc/model/builder/OperationBuilder.java | 11 +- .../doc/mountpoints/MountPointSwagger.java | 15 +- .../rest/doc/impl/ApiDocServiceImplTest.java | 2 +- .../rest/doc/impl/MountPointSwaggerTest.java | 2 +- 239 files changed, 1295 insertions(+), 3340 deletions(-) create mode 100644 netconf/models/netconf-test-models/pom.xml create mode 100644 netconf/models/netconf-test-models/src/main/yang/network-topology-augment-test@2016-08-08.yang delete mode 100644 netconf/netconf-console/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang delete mode 100644 netconf/netconf-console/src/test/resources/schemas/netconf-node-optional.yang delete mode 100644 netconf/netconf-console/src/test/resources/schemas/netconf-node-topology.yang delete mode 100644 netconf/netconf-console/src/test/resources/schemas/network-topology@2013-10-21.yang delete mode 100644 netconf/netconf-console/src/test/resources/schemas/yang-ext.yang delete mode 100644 netconf/sal-netconf-connector/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang delete mode 100644 netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-optional.yang delete mode 100644 netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-topology.yang delete mode 100644 netconf/sal-netconf-connector/src/test/resources/schemas/network-topology-augment-test@2016-08-08.yang diff --git a/artifacts/pom.xml b/artifacts/pom.xml index d2fb39d8cc..9e56230753 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -14,7 +14,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 @@ -164,6 +164,13 @@ ${project.version} + + ${project.groupId} + netconf-test-models + ${project.version} + test + + org.opendaylight.netconf yanglib diff --git a/features/netconf-connector/features-netconf-connector/pom.xml b/features/netconf-connector/features-netconf-connector/pom.xml index c0ee6d4981..589a7290b0 100644 --- a/features/netconf-connector/features-netconf-connector/pom.xml +++ b/features/netconf-connector/features-netconf-connector/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent feature-repo-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf-connector/odl-message-bus/pom.xml b/features/netconf-connector/odl-message-bus/pom.xml index 1640c00421..9ced85648f 100644 --- a/features/netconf-connector/odl-message-bus/pom.xml +++ b/features/netconf-connector/odl-message-bus/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -34,7 +34,7 @@ org.opendaylight.controller odl-controller-exp-messagebus - 2.0.4 + 3.0.0 xml features diff --git a/features/netconf-connector/odl-message-bus/src/main/feature/feature.xml b/features/netconf-connector/odl-message-bus/src/main/feature/feature.xml index 1893692aaa..3af6c49e37 100644 --- a/features/netconf-connector/odl-message-bus/src/main/feature/feature.xml +++ b/features/netconf-connector/odl-message-bus/src/main/feature/feature.xml @@ -8,6 +8,6 @@ --> - odl-controller-exp-messagebus + odl-controller-exp-messagebus diff --git a/features/netconf-connector/odl-netconf-callhome-ssh/pom.xml b/features/netconf-connector/odl-netconf-callhome-ssh/pom.xml index e3293a1f42..5c49785774 100644 --- a/features/netconf-connector/odl-netconf-callhome-ssh/pom.xml +++ b/features/netconf-connector/odl-netconf-callhome-ssh/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf-connector/odl-netconf-clustered-topology/pom.xml b/features/netconf-connector/odl-netconf-clustered-topology/pom.xml index 5ba1fbd145..dd2c88445b 100644 --- a/features/netconf-connector/odl-netconf-clustered-topology/pom.xml +++ b/features/netconf-connector/odl-netconf-clustered-topology/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf-connector/odl-netconf-connector-all/pom.xml b/features/netconf-connector/odl-netconf-connector-all/pom.xml index cf2f66b978..023aab55ab 100644 --- a/features/netconf-connector/odl-netconf-connector-all/pom.xml +++ b/features/netconf-connector/odl-netconf-connector-all/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf-connector/odl-netconf-connector/pom.xml b/features/netconf-connector/odl-netconf-connector/pom.xml index a8c48e4809..b09a8ba595 100644 --- a/features/netconf-connector/odl-netconf-connector/pom.xml +++ b/features/netconf-connector/odl-netconf-connector/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -28,14 +28,14 @@ org.opendaylight.mdsal mdsal-artifacts - 6.0.5 + 7.0.0 pom import org.opendaylight.controller controller-artifacts - 2.0.4 + 3.0.0 pom import diff --git a/features/netconf-connector/odl-netconf-connector/src/main/feature/feature.xml b/features/netconf-connector/odl-netconf-connector/src/main/feature/feature.xml index 12269e342f..14d90f94d1 100644 --- a/features/netconf-connector/odl-netconf-connector/src/main/feature/feature.xml +++ b/features/netconf-connector/odl-netconf-connector/src/main/feature/feature.xml @@ -8,7 +8,7 @@ --> - odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal - odl-mdsal-broker + odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal + odl-mdsal-broker diff --git a/features/netconf-connector/odl-netconf-console/pom.xml b/features/netconf-connector/odl-netconf-console/pom.xml index df9b316274..559e1a0af4 100644 --- a/features/netconf-connector/odl-netconf-console/pom.xml +++ b/features/netconf-connector/odl-netconf-console/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf-connector/odl-netconf-topology/pom.xml b/features/netconf-connector/odl-netconf-topology/pom.xml index d253d3f83f..473b8e10dc 100644 --- a/features/netconf-connector/odl-netconf-topology/pom.xml +++ b/features/netconf-connector/odl-netconf-topology/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf-connector/pom.xml b/features/netconf-connector/pom.xml index 725dc31126..d3a9d86e2f 100644 --- a/features/netconf-connector/pom.xml +++ b/features/netconf-connector/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/features/netconf/features-netconf/pom.xml b/features/netconf/features-netconf/pom.xml index 3d343fd86c..6de0af5150 100644 --- a/features/netconf/features-netconf/pom.xml +++ b/features/netconf/features-netconf/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent feature-repo-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-aaa-netconf-plugin-no-cluster/pom.xml b/features/netconf/odl-aaa-netconf-plugin-no-cluster/pom.xml index d5500c8b37..6705b24a7a 100644 --- a/features/netconf/odl-aaa-netconf-plugin-no-cluster/pom.xml +++ b/features/netconf/odl-aaa-netconf-plugin-no-cluster/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-aaa-netconf-plugin/pom.xml b/features/netconf/odl-aaa-netconf-plugin/pom.xml index ed39a3db04..ca0b3b4122 100644 --- a/features/netconf/odl-aaa-netconf-plugin/pom.xml +++ b/features/netconf/odl-aaa-netconf-plugin/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-all/pom.xml b/features/netconf/odl-netconf-all/pom.xml index a03261716b..e6dad0387c 100644 --- a/features/netconf/odl-netconf-all/pom.xml +++ b/features/netconf/odl-netconf-all/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-api/pom.xml b/features/netconf/odl-netconf-api/pom.xml index 84485a9da2..c42020c022 100644 --- a/features/netconf/odl-netconf-api/pom.xml +++ b/features/netconf/odl-netconf-api/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -28,14 +28,14 @@ org.opendaylight.yangtools yangtools-artifacts - 5.0.6 + 6.0.0 pom import org.opendaylight.mdsal mdsal-artifacts - 6.0.5 + 7.0.0 pom import diff --git a/features/netconf/odl-netconf-api/src/main/feature/feature.xml b/features/netconf/odl-netconf-api/src/main/feature/feature.xml index c982459620..5490a25fb7 100644 --- a/features/netconf/odl-netconf-api/src/main/feature/feature.xml +++ b/features/netconf/odl-netconf-api/src/main/feature/feature.xml @@ -8,9 +8,9 @@ --> - odl-netty-4 - odl-yangtools-parser-api - odl-mdsal-model-rfc8342 - odl-mdsal-model-rfc8525 + odl-netty-4 + odl-yangtools-parser-api + odl-mdsal-model-rfc8525 + odl-mdsal-model-rfc8342 diff --git a/features/netconf/odl-netconf-client/pom.xml b/features/netconf/odl-netconf-client/pom.xml index 27714707b0..537f83d31f 100644 --- a/features/netconf/odl-netconf-client/pom.xml +++ b/features/netconf/odl-netconf-client/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -25,7 +25,7 @@ org.opendaylight.controller odl-controller-exp-netty-config - 2.0.4 + 3.0.0 xml features diff --git a/features/netconf/odl-netconf-client/src/main/feature/feature.xml b/features/netconf/odl-netconf-client/src/main/feature/feature.xml index 3a0774003f..24c41673d6 100644 --- a/features/netconf/odl-netconf-client/src/main/feature/feature.xml +++ b/features/netconf/odl-netconf-client/src/main/feature/feature.xml @@ -8,6 +8,6 @@ --> - odl-controller-exp-netty-config + odl-controller-exp-netty-config diff --git a/features/netconf/odl-netconf-impl/pom.xml b/features/netconf/odl-netconf-impl/pom.xml index cffec258eb..04cb97c8cf 100644 --- a/features/netconf/odl-netconf-impl/pom.xml +++ b/features/netconf/odl-netconf-impl/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -28,7 +28,7 @@ org.opendaylight.controller controller-artifacts - 2.0.4 + 3.0.0 pom import diff --git a/features/netconf/odl-netconf-impl/src/main/feature/feature.xml b/features/netconf/odl-netconf-impl/src/main/feature/feature.xml index a83f511f95..c333a5c8c6 100644 --- a/features/netconf/odl-netconf-impl/src/main/feature/feature.xml +++ b/features/netconf/odl-netconf-impl/src/main/feature/feature.xml @@ -8,6 +8,6 @@ --> - odl-controller-exp-netty-config + odl-controller-exp-netty-config diff --git a/features/netconf/odl-netconf-mapping-api/pom.xml b/features/netconf/odl-netconf-mapping-api/pom.xml index 33a5615cae..585cc73a69 100644 --- a/features/netconf/odl-netconf-mapping-api/pom.xml +++ b/features/netconf/odl-netconf-mapping-api/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-mdsal/pom.xml b/features/netconf/odl-netconf-mdsal/pom.xml index 5951f0a85e..2fa7078efa 100644 --- a/features/netconf/odl-netconf-mdsal/pom.xml +++ b/features/netconf/odl-netconf-mdsal/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-netty-util/pom.xml b/features/netconf/odl-netconf-netty-util/pom.xml index 9b35f9c1e5..f158eb042e 100644 --- a/features/netconf/odl-netconf-netty-util/pom.xml +++ b/features/netconf/odl-netconf-netty-util/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-netty-util/src/main/feature/feature.xml b/features/netconf/odl-netconf-netty-util/src/main/feature/feature.xml index 97b7df37b9..cec41a1326 100644 --- a/features/netconf/odl-netconf-netty-util/src/main/feature/feature.xml +++ b/features/netconf/odl-netconf-netty-util/src/main/feature/feature.xml @@ -1,6 +1,6 @@ - odl-netty-4 + odl-netty-4 diff --git a/features/netconf/odl-netconf-notifications-api/pom.xml b/features/netconf/odl-netconf-notifications-api/pom.xml index a9921c8ccf..af269ff106 100644 --- a/features/netconf/odl-netconf-notifications-api/pom.xml +++ b/features/netconf/odl-netconf-notifications-api/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-notifications-impl/pom.xml b/features/netconf/odl-netconf-notifications-impl/pom.xml index ae4836adef..af0aa7f54f 100644 --- a/features/netconf/odl-netconf-notifications-impl/pom.xml +++ b/features/netconf/odl-netconf-notifications-impl/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -28,7 +28,7 @@ org.opendaylight.mdsal mdsal-artifacts - 6.0.5 + 7.0.0 pom import diff --git a/features/netconf/odl-netconf-notifications-impl/src/main/feature/feature.xml b/features/netconf/odl-netconf-notifications-impl/src/main/feature/feature.xml index ca70fcb305..9e2627b9ba 100644 --- a/features/netconf/odl-netconf-notifications-impl/src/main/feature/feature.xml +++ b/features/netconf/odl-netconf-notifications-impl/src/main/feature/feature.xml @@ -1,6 +1,6 @@ - odl-mdsal-binding-runtime + odl-mdsal-binding-runtime diff --git a/features/netconf/odl-netconf-ssh/pom.xml b/features/netconf/odl-netconf-ssh/pom.xml index c3e7c848bb..16163b6a54 100644 --- a/features/netconf/odl-netconf-ssh/pom.xml +++ b/features/netconf/odl-netconf-ssh/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-tcp/pom.xml b/features/netconf/odl-netconf-tcp/pom.xml index 3c0159b975..bf70d40246 100644 --- a/features/netconf/odl-netconf-tcp/pom.xml +++ b/features/netconf/odl-netconf-tcp/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/netconf/odl-netconf-util/pom.xml b/features/netconf/odl-netconf-util/pom.xml index e9e75afe1b..8c59a0b96b 100644 --- a/features/netconf/odl-netconf-util/pom.xml +++ b/features/netconf/odl-netconf-util/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -32,7 +32,7 @@ org.opendaylight.yangtools odl-yangtools-codec - 5.0.6 + 6.0.0 xml features diff --git a/features/netconf/odl-netconf-util/src/main/feature/feature.xml b/features/netconf/odl-netconf-util/src/main/feature/feature.xml index 12a55a361a..df8956296f 100644 --- a/features/netconf/odl-netconf-util/src/main/feature/feature.xml +++ b/features/netconf/odl-netconf-util/src/main/feature/feature.xml @@ -11,6 +11,6 @@ mvn:org.opendaylight.netconf/netconf-util/${project.version}/cfg/config - odl-yangtools-codec + odl-yangtools-codec diff --git a/features/netconf/pom.xml b/features/netconf/pom.xml index f6d2a99760..b9031c1d3d 100644 --- a/features/netconf/pom.xml +++ b/features/netconf/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/features/pom.xml b/features/pom.xml index 3c7ef89879..7623c70cc5 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/features/restconf/features-restconf/pom.xml b/features/restconf/features-restconf/pom.xml index 0e554807ea..47711da59d 100644 --- a/features/restconf/features-restconf/pom.xml +++ b/features/restconf/features-restconf/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent feature-repo-parent - 7.0.6 + 8.0.0 diff --git a/features/restconf/odl-mdsal-apidocs/pom.xml b/features/restconf/odl-mdsal-apidocs/pom.xml index b2f8e1dc01..a9984f8191 100644 --- a/features/restconf/odl-mdsal-apidocs/pom.xml +++ b/features/restconf/odl-mdsal-apidocs/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -27,7 +27,7 @@ org.opendaylight.odlparent odl-jackson-2.10 - 7.0.6 + 8.0.0 xml features diff --git a/features/restconf/odl-mdsal-apidocs/src/main/feature/feature.xml b/features/restconf/odl-mdsal-apidocs/src/main/feature/feature.xml index f1c0e8fc2a..499a7b4a0b 100644 --- a/features/restconf/odl-mdsal-apidocs/src/main/feature/feature.xml +++ b/features/restconf/odl-mdsal-apidocs/src/main/feature/feature.xml @@ -8,6 +8,6 @@ --> - odl-jackson-2.10 + odl-jackson-2.10 diff --git a/features/restconf/odl-restconf-all/pom.xml b/features/restconf/odl-restconf-all/pom.xml index 91fb5a04c7..01bc756dd3 100644 --- a/features/restconf/odl-restconf-all/pom.xml +++ b/features/restconf/odl-restconf-all/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/restconf/odl-restconf-common/pom.xml b/features/restconf/odl-restconf-common/pom.xml index 160b1d5e91..ccc7973514 100644 --- a/features/restconf/odl-restconf-common/pom.xml +++ b/features/restconf/odl-restconf-common/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -28,21 +28,21 @@ org.opendaylight.yangtools yangtools-artifacts - 5.0.6 + 6.0.0 pom import org.opendaylight.mdsal mdsal-artifacts - 6.0.5 + 7.0.0 pom import org.opendaylight.controller controller-artifacts - 2.0.4 + 3.0.0 pom import diff --git a/features/restconf/odl-restconf-common/src/main/feature/feature.xml b/features/restconf/odl-restconf-common/src/main/feature/feature.xml index 29b5e13542..28b210a43e 100644 --- a/features/restconf/odl-restconf-common/src/main/feature/feature.xml +++ b/features/restconf/odl-restconf-common/src/main/feature/feature.xml @@ -8,9 +8,9 @@ --> - odl-karaf-feat-jetty - odl-yangtools-export - odl-mdsal-model-rfc7895 - odl-mdsal-broker + odl-karaf-feat-jetty + odl-yangtools-export + odl-mdsal-model-rfc7895 + odl-mdsal-broker diff --git a/features/restconf/odl-restconf-nb-bierman02/pom.xml b/features/restconf/odl-restconf-nb-bierman02/pom.xml index c4a240384a..2edeb829c5 100644 --- a/features/restconf/odl-restconf-nb-bierman02/pom.xml +++ b/features/restconf/odl-restconf-nb-bierman02/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -28,7 +28,7 @@ org.opendaylight.mdsal mdsal-artifacts - 6.0.5 + 7.0.0 pom import diff --git a/features/restconf/odl-restconf-nb-rfc8040/pom.xml b/features/restconf/odl-restconf-nb-rfc8040/pom.xml index 81f76f35d2..f63cf4a431 100644 --- a/features/restconf/odl-restconf-nb-rfc8040/pom.xml +++ b/features/restconf/odl-restconf-nb-rfc8040/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 @@ -28,7 +28,7 @@ org.opendaylight.controller controller-artifacts - 2.0.4 + 3.0.0 pom import diff --git a/features/restconf/odl-restconf-nb-rfc8040/src/main/feature/feature.xml b/features/restconf/odl-restconf-nb-rfc8040/src/main/feature/feature.xml index 8dda823026..855cd0c764 100644 --- a/features/restconf/odl-restconf-nb-rfc8040/src/main/feature/feature.xml +++ b/features/restconf/odl-restconf-nb-rfc8040/src/main/feature/feature.xml @@ -8,7 +8,7 @@ --> - odl-controller-exp-netty-config + odl-controller-exp-netty-config mvn:org.opendaylight.netconf/restconf-nb-rfc8040/${project.version}/cfg/config diff --git a/features/restconf/odl-restconf/pom.xml b/features/restconf/odl-restconf/pom.xml index c73ae27ecc..969b8ee515 100644 --- a/features/restconf/odl-restconf/pom.xml +++ b/features/restconf/odl-restconf/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/restconf/pom.xml b/features/restconf/pom.xml index a8a3f28250..c1662dbca5 100644 --- a/features/restconf/pom.xml +++ b/features/restconf/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/features/yanglib/features-yanglib/pom.xml b/features/yanglib/features-yanglib/pom.xml index 75e4f8f04a..958fc1db96 100644 --- a/features/yanglib/features-yanglib/pom.xml +++ b/features/yanglib/features-yanglib/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent feature-repo-parent - 7.0.6 + 8.0.0 diff --git a/features/yanglib/odl-yanglib/pom.xml b/features/yanglib/odl-yanglib/pom.xml index 7e32726653..42542477d5 100644 --- a/features/yanglib/odl-yanglib/pom.xml +++ b/features/yanglib/odl-yanglib/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent single-feature-parent - 7.0.6 + 8.0.0 diff --git a/features/yanglib/odl-yanglib/src/main/feature/feature.xml b/features/yanglib/odl-yanglib/src/main/feature/feature.xml index c0cdceac79..990a7c3ffb 100644 --- a/features/yanglib/odl-yanglib/src/main/feature/feature.xml +++ b/features/yanglib/odl-yanglib/src/main/feature/feature.xml @@ -8,6 +8,6 @@ --> - odl-karaf-feat-jetty + odl-karaf-feat-jetty diff --git a/features/yanglib/pom.xml b/features/yanglib/pom.xml index 3e839b5b24..46ecc03c32 100644 --- a/features/yanglib/pom.xml +++ b/features/yanglib/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/karaf/pom.xml b/karaf/pom.xml index aeceb4cf11..3c8cc26ff0 100644 --- a/karaf/pom.xml +++ b/karaf/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.odlparent karaf4-parent - 7.0.6 + 8.0.0 org.opendaylight.netconf diff --git a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java index f3885777fb..4b32f5e5f3 100644 --- a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java +++ b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java @@ -31,7 +31,9 @@ import org.opendaylight.netconf.api.monitoring.CapabilityListener; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.ModuleLike; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.Submodule; import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; @@ -107,7 +109,7 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ if (cap.isPresent()) { capabilities.add(cap.get()); } - for (final Module submodule : module.getSubmodules()) { + for (final Submodule submodule : module.getSubmodules()) { cap = moduleToCapability(submodule, rootSchemaSourceProviderDependency); if (cap.isPresent()) { capabilities.add(cap.get()); @@ -118,9 +120,8 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ return capabilities; } - private static Optional moduleToCapability( - final Module module, final SchemaSourceProvider rootSchemaSourceProviderDependency) { - + private static Optional moduleToCapability(final ModuleLike module, + final SchemaSourceProvider rootSchemaSourceProviderDependency) { final SourceIdentifier moduleSourceIdentifier = RevisionSourceIdentifier.create(module.getName(), module.getRevision()); diff --git a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java index 747ae2103a..443b8c64fd 100644 --- a/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java +++ b/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java @@ -11,7 +11,6 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; -import java.util.Collections; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; @@ -44,7 +43,7 @@ import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult; import org.opendaylight.yangtools.yang.data.impl.schema.SchemaOrderedNormalizedNodeWriter; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.InputSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -153,12 +152,11 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation { } final RpcDefinition rpcDefinition = rpcDefinitionOptional.get(); - final SchemaPath schemaPath = SchemaPath.create(Collections.singletonList(rpcDefinition.getQName()), true); final ContainerNode inputNode = rpcToNNode(operationElement, rpcDefinition.getInput()); final DOMRpcResult result; try { - result = rpcService.invokeRpc(schemaPath, inputNode).get(); + result = rpcService.invokeRpc(rpcDefinition.getQName(), inputNode).get(); } catch (final InterruptedException | ExecutionException e) { throw DocumentedException.wrap(e); } @@ -255,7 +253,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation { * @return parsed rpc into normalized node, or null if input schema is null */ private @Nullable ContainerNode rpcToNNode(final XmlElement element, - final @Nullable ContainerSchemaNode input) throws DocumentedException { + final @Nullable InputSchemaNode input) throws DocumentedException { final NormalizedNodeResult resultHolder = new NormalizedNodeResult(); final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder); final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext.getCurrentContext(), input); diff --git a/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpcTest.java b/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpcTest.java index d27385ea56..f169076572 100644 --- a/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpcTest.java +++ b/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpcTest.java @@ -52,18 +52,18 @@ import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext; import org.opendaylight.netconf.util.test.XmlFileLoader; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.NoOpListenerRegistration; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener; import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider; @@ -90,7 +90,7 @@ public class RuntimeRpcTest { private static final DOMRpcService RPC_SERVICE_VOID_INVOKER = new DOMRpcService() { @Override - public FluentFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { + public FluentFuture invokeRpc(final QName type, final NormalizedNode input) { return immediateFluentFuture(new DefaultDOMRpcResult(null, Collections.emptyList())); } @@ -102,7 +102,7 @@ public class RuntimeRpcTest { private static final DOMRpcService RPC_SERVICE_FAILED_INVOCATION = new DOMRpcService() { @Override - public FluentFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { + public FluentFuture invokeRpc(final QName type, final NormalizedNode input) { return immediateFailedFluentFuture(new DOMRpcException("rpc invocation not implemented yet") { private static final long serialVersionUID = 1L; }); @@ -116,14 +116,14 @@ public class RuntimeRpcTest { private final DOMRpcService rpcServiceSuccessfulInvocation = new DOMRpcService() { @Override - public FluentFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { + public FluentFuture invokeRpc(final QName type, final NormalizedNode input) { final Collection> children = ((ContainerNode) input).getValue(); - final Module module = SCHEMA_CONTEXT.findModules(type.getLastComponent().getNamespace()).stream() + final Module module = SCHEMA_CONTEXT.findModules(type.getNamespace()).stream() .findFirst().orElse(null); - final RpcDefinition rpcDefinition = getRpcDefinitionFromModule( - module, module.getNamespace(), type.getLastComponent().getLocalName()); - final ContainerSchemaNode outputSchemaNode = rpcDefinition.getOutput(); + final RpcDefinition rpcDefinition = getRpcDefinitionFromModule(module, module.getNamespace(), + type.getLocalName()); + final OutputSchemaNode outputSchemaNode = rpcDefinition.getOutput(); final ContainerNode node = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(outputSchemaNode.getQName())) .withValue(children).build(); diff --git a/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/NetconfNotificationManager.java b/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/NetconfNotificationManager.java index 3190f0b1fd..63ea9be8c7 100644 --- a/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/NetconfNotificationManager.java +++ b/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/NetconfNotificationManager.java @@ -332,6 +332,7 @@ public class NetconfNotificationManager implements NetconfNotificationCollector, } @Override + @Deprecated public void onYangLibraryChange(final YangLibraryChange yangLibraryChange) { baseRegistration.onNotification(BASE_STREAM_NAME, transformUtil.transform(yangLibraryChange, YANG_LIBRARY_CHANGE_PATH)); diff --git a/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/ops/NotificationsTransformUtil.java b/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/ops/NotificationsTransformUtil.java index 2e53553567..e04d2ec7ae 100644 --- a/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/ops/NotificationsTransformUtil.java +++ b/netconf/mdsal-netconf-notification/src/main/java/org/opendaylight/netconf/mdsal/notification/impl/ops/NotificationsTransformUtil.java @@ -15,11 +15,11 @@ import java.util.Optional; import javax.inject.Singleton; import javax.xml.stream.XMLStreamException; import javax.xml.transform.dom.DOMResult; -import org.opendaylight.binding.runtime.api.BindingRuntimeContext; -import org.opendaylight.binding.runtime.api.BindingRuntimeGenerator; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecFactory; +import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext; +import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.netconf.api.xml.XmlUtil; import org.opendaylight.netconf.notifications.NetconfNotification; import org.opendaylight.netconf.util.NetconfUtil; @@ -29,21 +29,22 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.librar import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryUpdate; import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserException; import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory; import org.w3c.dom.Document; @Singleton public final class NotificationsTransformUtil { - private final SchemaContext schemaContext; + private final EffectiveModelContext schemaContext; private final BindingNormalizedNodeSerializer serializer; public NotificationsTransformUtil(final YangParserFactory parserFactory, final BindingRuntimeGenerator generator, - final BindingDOMCodecFactory codecFactory) { + final BindingDOMCodecFactory codecFactory) throws YangParserException { final BindingRuntimeContext ctx = BindingRuntimeHelpers.createRuntimeContext(parserFactory, generator, Netconf.class, NetconfConfigChange.class, YangLibraryChange.class, YangLibraryUpdate.class); - schemaContext = ctx.getSchemaContext(); + schemaContext = ctx.getEffectiveModelContext(); verify(schemaContext.getOperations().stream() .filter(input -> input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION)) .findFirst() diff --git a/netconf/mdsal-netconf-notification/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-notification.xml b/netconf/mdsal-netconf-notification/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-notification.xml index f348e9c988..8b632cc929 100644 --- a/netconf/mdsal-netconf-notification/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-notification.xml +++ b/netconf/mdsal-netconf-notification/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-notification.xml @@ -17,7 +17,7 @@ interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener" odl:type="mapper-aggregator-registry"/> + interface="org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator"/> availNotifList = new ArrayList<>(); // add Event Source Connection status notification - availNotifList.add(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH); + availNotifList.add(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath()); // add all known notifications from netconf device for (final NotificationDefinition nd : mount.getSchemaContext().getNotifications()) { diff --git a/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMount.java b/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMount.java index f25fed1f88..ea4f4ba8b7 100644 --- a/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMount.java +++ b/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMount.java @@ -10,6 +10,7 @@ package org.opendaylight.netconf.messagebus.eventsources.netconf; import static java.util.Objects.requireNonNull; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListenableFuture; import java.time.Instant; import java.time.ZoneId; @@ -28,6 +29,7 @@ import org.opendaylight.mdsal.dom.api.DOMNotificationListener; import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.api.DOMService; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInputBuilder; @@ -41,8 +43,9 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; /** * Facade of mounted netconf device. @@ -50,26 +53,25 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; class NetconfEventSourceMount { private static final YangInstanceIdentifier STREAMS_PATH = YangInstanceIdentifier.builder().node(Netconf.QNAME) .node(Streams.QNAME).build(); - private static final SchemaPath CREATE_SUBSCRIPTION = SchemaPath - .create(true, QName.create(CreateSubscriptionInput.QNAME, "create-subscription")); + private static final QName CREATE_SUBSCRIPTION = QName.create(CreateSubscriptionInput.QNAME, "create-subscription"); - private final DOMMountPoint mountPoint; private final DOMRpcService rpcService; private final DOMNotificationService notificationService; private final DOMDataBroker dataBroker; private final Node node; private final String nodeId; private final BindingNormalizedNodeSerializer serializer; + private final DOMSchemaService schemaService; NetconfEventSourceMount(final BindingNormalizedNodeSerializer serializer, final Node node, final DOMMountPoint mountPoint) { this.serializer = requireNonNull(serializer); - this.mountPoint = mountPoint; this.node = node; this.nodeId = node.getNodeId().getValue(); this.rpcService = getService(mountPoint, DOMRpcService.class); this.notificationService = getService(mountPoint, DOMNotificationService.class); this.dataBroker = getService(mountPoint, DOMDataBroker.class); + this.schemaService = getService(mountPoint, DOMSchemaService.class); } private static T getService(final DOMMountPoint mountPoint, final Class service) { @@ -138,8 +140,8 @@ class NetconfEventSourceMount { return Collections.emptyList(); } - SchemaContext getSchemaContext() { - return mountPoint.getSchemaContext(); + EffectiveModelContext getSchemaContext() { + return schemaService.getGlobalContext(); } /** @@ -152,7 +154,8 @@ class NetconfEventSourceMount { */ ListenerRegistration registerNotificationListener(final DOMNotificationListener listener, final SchemaPath notificationPath) { - return notificationService.registerNotificationListener(listener, notificationPath); + return notificationService.registerNotificationListener(listener, + Absolute.of(ImmutableList.copyOf(notificationPath.getPathFromRoot()))); } } diff --git a/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistration.java b/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistration.java index b1a3b7b9b2..a82ce65058 100644 --- a/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistration.java +++ b/netconf/messagebus-netconf/src/main/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistration.java @@ -126,7 +126,7 @@ class StreamNotificationTopicRegistration extends NotificationTopicRegistration activateNotificationSource(); if (!isActive()) { LOG.warn("Stream {} is not active, listener for notification {} is not registered.", getStreamName(), - notificationPath.toString()); + notificationPath); return false; } diff --git a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/AbstractCodecTest.java b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/AbstractCodecTest.java index 02a8f1368e..50d9805d85 100644 --- a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/AbstractCodecTest.java +++ b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/AbstractCodecTest.java @@ -9,8 +9,8 @@ package org.opendaylight.netconf.messagebus.eventsources.netconf; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf; public abstract class AbstractCodecTest { diff --git a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/ConnectionNotificationTopicRegistrationTest.java b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/ConnectionNotificationTopicRegistrationTest.java index 0644d52d68..c9d0f3ebdc 100644 --- a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/ConnectionNotificationTopicRegistrationTest.java +++ b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/ConnectionNotificationTopicRegistrationTest.java @@ -74,14 +74,14 @@ public class ConnectionNotificationTopicRegistrationTest { final TopicId topic1 = registerTopic("topic1"); final TopicId topic2 = registerTopic("topic2"); final TopicId topic3 = registerTopic("topic3"); - final Set notificationTopicIds = - registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH); + final Set notificationTopicIds = registration.getTopicsForNotification( + ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath()); assertNotNull(notificationTopicIds); assertThat(notificationTopicIds, hasItems(topic1, topic2, topic3)); registration.unRegisterNotificationTopic(topic3); - final Set afterUnregister = - registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH); + final Set afterUnregister = registration.getTopicsForNotification( + ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath()); assertNotNull(afterUnregister); assertThat(afterUnregister, hasItems(topic1, topic2)); assertFalse(afterUnregister.contains(topic3)); @@ -89,7 +89,8 @@ public class ConnectionNotificationTopicRegistrationTest { private TopicId registerTopic(final String value) { final TopicId topic = TopicId.getDefaultInstance(value); - registration.registerNotificationTopic(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH, topic); + registration.registerNotificationTopic( + ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath(), topic); return topic; } @@ -105,8 +106,8 @@ public class ConnectionNotificationTopicRegistrationTest { verify(listener).onNotification(notificationCaptor.capture()); final DOMNotification value = notificationCaptor.getValue(); assertEquals(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH, value.getType()); - final Collection> body = value.getBody() - .getValue(); + final Collection> body = + value.getBody().getValue(); assertEquals(1, body.size()); final DOMSource source = (DOMSource) body.iterator().next().getValue(); final String statusNodeValue = source.getNode().getFirstChild().getFirstChild().getNodeValue(); diff --git a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManagerTest.java b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManagerTest.java index 6e9f45a539..f61ea9baaa 100644 --- a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManagerTest.java +++ b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceManagerTest.java @@ -36,6 +36,7 @@ import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService; import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus; @@ -47,15 +48,14 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class NetconfEventSourceManagerTest extends AbstractCodecTest { - NetconfEventSourceManager netconfEventSourceManager; - ListenerRegistration listenerRegistrationMock; - DOMMountPointService domMountPointServiceMock; - MountPointService mountPointServiceMock; - EventSourceRegistry eventSourceTopologyMock; - DataTreeModification dataTreeModificationMock; - RpcProviderService rpcProviderRegistryMock; - EventSourceRegistry eventSourceRegistry; - + private NetconfEventSourceManager netconfEventSourceManager; + private ListenerRegistration listenerRegistrationMock; + private DOMMountPointService domMountPointServiceMock; + private MountPointService mountPointServiceMock; + private EventSourceRegistry eventSourceTopologyMock; + private DataTreeModification dataTreeModificationMock; + private RpcProviderService rpcProviderRegistryMock; + private EventSourceRegistry eventSourceRegistry; @SuppressWarnings("unchecked") @Before @@ -81,6 +81,7 @@ public class NetconfEventSourceManagerTest extends AbstractCodecTest { doReturn(Optional.of(mock(DOMRpcService.class))).when(domMountPointMock).getService(DOMRpcService.class); doReturn(Optional.of(mock(DOMNotificationService.class))).when(domMountPointMock) .getService(DOMNotificationService.class); + doReturn(Optional.of(mock(DOMSchemaService.class))).when(domMountPointMock).getService(DOMSchemaService.class); DOMDataTreeReadTransaction rtx = mock(DOMDataTreeReadTransaction.class); doReturn(rtx).when(mpDataBroker).newReadOnlyTransaction(); diff --git a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMountTest.java b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMountTest.java index 1e86b0f83d..f8787fb87c 100644 --- a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMountTest.java +++ b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceMountTest.java @@ -30,6 +30,7 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf; @@ -42,7 +43,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; public class NetconfEventSourceMountTest extends AbstractCodecTest { public static final String STREAM_1 = "stream-1"; @@ -55,6 +55,8 @@ public class NetconfEventSourceMountTest extends AbstractCodecTest { @Mock DOMRpcService rpcService; @Mock + DOMSchemaService schemaService; + @Mock private DOMDataTreeReadTransaction tx; private NetconfEventSourceMount mount; @@ -65,6 +67,7 @@ public class NetconfEventSourceMountTest extends AbstractCodecTest { doReturn(Optional.of(rpcService)).when(domMountPoint).getService(DOMRpcService.class); doReturn(Optional.of(mock(DOMNotificationService.class))).when(domMountPoint) .getService(DOMNotificationService.class); + doReturn(Optional.of(schemaService)).when(domMountPoint).getService(DOMSchemaService.class); doReturn(tx).when(dataBroker).newReadOnlyTransaction(); final YangInstanceIdentifier path = YangInstanceIdentifier.builder().node(Netconf.QNAME).node(Streams.QNAME) .build(); @@ -80,8 +83,7 @@ public class NetconfEventSourceMountTest extends AbstractCodecTest { .setName(new StreamNameType(STREAM_1)) .build(); mount.invokeCreateSubscription(stream, Optional.empty()); - final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME, - "create-subscription")); + final QName type = QName.create(CreateSubscriptionInput.QNAME, "create-subscription"); ArgumentCaptor captor = ArgumentCaptor.forClass(ContainerNode.class); verify(rpcService).invokeRpc(eq(type), captor.capture()); Assert.assertEquals(STREAM_1, getStreamName(captor.getValue())); @@ -95,8 +97,7 @@ public class NetconfEventSourceMountTest extends AbstractCodecTest { .build(); final Instant date = Instant.now(); mount.invokeCreateSubscription(stream, Optional.of(date)); - final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME, - "create-subscription")); + final QName type = QName.create(CreateSubscriptionInput.QNAME, "create-subscription"); ArgumentCaptor captor = ArgumentCaptor.forClass(ContainerNode.class); verify(rpcService).invokeRpc(eq(type), captor.capture()); Assert.assertEquals(STREAM_1, getStreamName(captor.getValue())); @@ -114,8 +115,7 @@ public class NetconfEventSourceMountTest extends AbstractCodecTest { .setReplaySupport(true) .build(); mount.invokeCreateSubscription(stream, Optional.empty()); - final SchemaPath type = SchemaPath.create(true, QName.create(CreateSubscriptionInput.QNAME, - "create-subscription")); + final QName type = QName.create(CreateSubscriptionInput.QNAME, "create-subscription"); ArgumentCaptor captor = ArgumentCaptor.forClass(ContainerNode.class); verify(rpcService).invokeRpc(eq(type), captor.capture()); Assert.assertEquals(STREAM_1, getStreamName(captor.getValue())); diff --git a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceTest.java b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceTest.java index 61287c6f21..958578307b 100644 --- a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceTest.java +++ b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/NetconfEventSourceTest.java @@ -47,17 +47,14 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; public class NetconfEventSourceTest { - - - private static final SchemaPath NOTIFICATION_1_PATH = SchemaPath.create(true, QName.create("ns1", "1970-01-15", - "not1")); - private static final SchemaPath NOTIFICATION_2_PATH = SchemaPath.create(true, QName.create("ns2", "1980-02-18", - "not2")); + private static final Absolute NOTIFICATION_1_PATH = Absolute.of(QName.create("ns1", "1970-01-15", "not1")); + private static final Absolute NOTIFICATION_2_PATH = Absolute.of(QName.create("ns2", "1980-02-18", "not2")); NetconfEventSource netconfEventSource; @@ -82,9 +79,9 @@ public class NetconfEventSourceTest { doReturn(body.build()).when(matchnigNotification).getBody(); //init schema context mock Set notifications = new HashSet<>(); - notifications.add(getNotificationDefinitionMock(NOTIFICATION_1_PATH.getLastComponent())); - notifications.add(getNotificationDefinitionMock(NOTIFICATION_2_PATH.getLastComponent())); - SchemaContext schemaContext = mock(SchemaContext.class); + notifications.add(getNotificationDefinitionMock(NOTIFICATION_1_PATH.lastNodeIdentifier())); + notifications.add(getNotificationDefinitionMock(NOTIFICATION_2_PATH.lastNodeIdentifier())); + EffectiveModelContext schemaContext = mock(EffectiveModelContext.class); doReturn(notifications).when(schemaContext).getNotifications(); //init mount point mock List streams = new ArrayList<>(); @@ -101,7 +98,7 @@ public class NetconfEventSourceTest { doReturn(nodeId1.getNodeId().getValue()).when(mount).getNodeId(); Map streamMap = new HashMap<>(); - streamMap.put(NOTIFICATION_1_PATH.getLastComponent().getNamespace().toString(), "stream-1"); + streamMap.put(NOTIFICATION_1_PATH.lastNodeIdentifier().getNamespace().toString(), "stream-1"); netconfEventSource = new NetconfEventSource( streamMap, mount, diff --git a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistrationTest.java b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistrationTest.java index 1ea0410d8d..d1123f7476 100644 --- a/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistrationTest.java +++ b/netconf/messagebus-netconf/src/test/java/org/opendaylight/netconf/messagebus/eventsources/netconf/StreamNotificationTopicRegistrationTest.java @@ -42,7 +42,7 @@ public class StreamNotificationTopicRegistrationTest { private static final String STREAM_NAME = "stream-1"; private static final String PREFIX = ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH - .getLastComponent().getNamespace().toString(); + .lastNodeIdentifier().getNamespace().toString(); @Mock private NetconfEventSource source; @@ -60,8 +60,8 @@ public class StreamNotificationTopicRegistrationTest { public void setUp() throws Exception { Node node = new NodeBuilder().setNodeId(NodeId.getDefaultInstance("node-id")).build(); when(mount.getNode()).thenReturn(node); - when(mount.registerNotificationListener(source, ConnectionNotificationTopicRegistration - .EVENT_SOURCE_STATUS_PATH)) + when(mount.registerNotificationListener(source, + ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath())) .thenReturn(listenerRegistration); doReturn(immediateNullFluentFuture()).when(mount).invokeCreateSubscription(any(), any()); doReturn(immediateNullFluentFuture()).when(mount).invokeCreateSubscription(any()); @@ -113,14 +113,14 @@ public class StreamNotificationTopicRegistrationTest { final TopicId topic1 = registerTopic("topic1"); final TopicId topic2 = registerTopic("topic2"); final TopicId topic3 = registerTopic("topic3"); - final Set notificationTopicIds = - registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH); + final Set notificationTopicIds = registration.getTopicsForNotification( + ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath()); assertNotNull(notificationTopicIds); assertThat(notificationTopicIds, hasItems(topic1, topic2, topic3)); registration.unRegisterNotificationTopic(topic3); - final Set afterUnregister = - registration.getTopicsForNotification(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH); + final Set afterUnregister = registration.getTopicsForNotification( + ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath()); assertNotNull(afterUnregister); assertThat(afterUnregister, hasItems(topic1, topic2)); assertFalse(afterUnregister.contains(topic3)); @@ -128,7 +128,8 @@ public class StreamNotificationTopicRegistrationTest { private TopicId registerTopic(final String value) { final TopicId topic = TopicId.getDefaultInstance(value); - registration.registerNotificationTopic(ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH, topic); + registration.registerNotificationTopic( + ConnectionNotificationTopicRegistration.EVENT_SOURCE_STATUS_PATH.asSchemaPath(), topic); return topic; } diff --git a/netconf/models/netconf-test-models/pom.xml b/netconf/models/netconf-test-models/pom.xml new file mode 100644 index 0000000000..15743f5ea4 --- /dev/null +++ b/netconf/models/netconf-test-models/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + + org.opendaylight.netconf + netconf-parent + 1.10.0-SNAPSHOT + ../../../parent + + + org.opendaylight.netconf + netconf-test-models + 1.10.0-SNAPSHOT + bundle + ${project.artifactId} + + + + org.opendaylight.mdsal.model + ietf-topology + + + diff --git a/netconf/models/netconf-test-models/src/main/yang/network-topology-augment-test@2016-08-08.yang b/netconf/models/netconf-test-models/src/main/yang/network-topology-augment-test@2016-08-08.yang new file mode 100644 index 0000000000..409b760a7a --- /dev/null +++ b/netconf/models/netconf-test-models/src/main/yang/network-topology-augment-test@2016-08-08.yang @@ -0,0 +1,21 @@ +module network-topology-network-topology-augment-test { + namespace "urn:TBD:params:xml:ns:yang:network-topology-augment-test"; + prefix "ntat"; + + import network-topology { + prefix "nt"; + revision-date 2013-10-21; + } + + description "This module defines test model for the topology of a network with augmented node"; + revision 2016-08-08; + + augment /nt:network-topology/nt:topology/nt:node { + leaf test-id { + type uint16; + } + leaf test-name { + type string; + } + } +} diff --git a/netconf/models/pom.xml b/netconf/models/pom.xml index f96720b735..abae58096b 100644 --- a/netconf/models/pom.xml +++ b/netconf/models/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 @@ -35,5 +35,7 @@ ietf-netconf-nmda ietf-netconf-notifications ietf-netconf-with-defaults + + netconf-test-models diff --git a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/YangModuleCapability.java b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/YangModuleCapability.java index 03b94eb3b5..592ee9f08f 100644 --- a/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/YangModuleCapability.java +++ b/netconf/netconf-api/src/main/java/org/opendaylight/netconf/api/capability/YangModuleCapability.java @@ -9,7 +9,7 @@ package org.opendaylight.netconf.api.capability; import java.util.Optional; import org.opendaylight.yangtools.yang.common.Revision; -import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.ModuleLike; /** * Yang model representing capability. @@ -21,7 +21,7 @@ public final class YangModuleCapability extends BasicCapability { private final String moduleName; private final String moduleNamespace; - public YangModuleCapability(final Module module, final String moduleContent) { + public YangModuleCapability(final ModuleLike module, final String moduleContent) { super(toCapabilityURI(module)); this.content = moduleContent; this.moduleName = module.getName(); @@ -34,7 +34,7 @@ public final class YangModuleCapability extends BasicCapability { return Optional.of(content); } - private static String toCapabilityURI(final Module module) { + private static String toCapabilityURI(final ModuleLike module) { final StringBuilder sb = new StringBuilder(); sb.append(module.getNamespace()).append("?module=").append(module.getName()); diff --git a/netconf/netconf-config/pom.xml b/netconf/netconf-config/pom.xml index 6c00a55f19..4985610b7d 100644 --- a/netconf/netconf-config/pom.xml +++ b/netconf/netconf-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent bundle-parent - 7.0.6 + 8.0.0 diff --git a/netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfCommandsImplTest.java b/netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfCommandsImplTest.java index 03f7331720..8b338d539b 100644 --- a/netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfCommandsImplTest.java +++ b/netconf/netconf-console/src/test/java/org/opendaylight/netconf/console/impl/NetconfCommandsImplTest.java @@ -32,6 +32,8 @@ import org.junit.Test; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.WriteTransaction; import org.opendaylight.mdsal.binding.dom.adapter.test.ConcurrentDataBrokerTestCustomizer; +import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.netconf.console.utils.NetconfConsoleConstants; import org.opendaylight.netconf.console.utils.NetconfConsoleUtils; @@ -56,8 +58,6 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; import org.opendaylight.yangtools.yang.common.Uint16; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; public class NetconfCommandsImplTest { @@ -68,28 +68,26 @@ public class NetconfCommandsImplTest { NetconfNodeConnectionStatus.ConnectionStatus.Connected; private static final String CAP_PREFIX = "prefix"; - private static EffectiveModelContext SCHEMA_CONTEXT; + private static BindingRuntimeContext RUNTIME_CONTEXT; private DataBroker dataBroker; private NetconfCommandsImpl netconfCommands; @BeforeClass public static void beforeClass() { - SCHEMA_CONTEXT = YangParserTestUtils.parseYangResources(NetconfCommandsImplTest.class, - "/schemas/network-topology@2013-10-21.yang", "/schemas/ietf-inet-types@2013-07-15.yang", - "/schemas/yang-ext.yang", "/schemas/netconf-node-topology.yang", "/schemas/netconf-node-optional.yang"); + RUNTIME_CONTEXT = BindingRuntimeHelpers.createRuntimeContext(TopologyNetconf.class); } @AfterClass public static void afterClass() { - SCHEMA_CONTEXT = null; + RUNTIME_CONTEXT = null; } @Before public void setUp() throws Exception { ConcurrentDataBrokerTestCustomizer customizer = new ConcurrentDataBrokerTestCustomizer(true); dataBroker = customizer.createDataBroker(); - customizer.updateSchema(SCHEMA_CONTEXT); + customizer.updateSchema(RUNTIME_CONTEXT); netconfCommands = new NetconfCommandsImpl(dataBroker); } diff --git a/netconf/netconf-console/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang b/netconf/netconf-console/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang deleted file mode 100644 index 5c6f139a27..0000000000 --- a/netconf/netconf-console/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang +++ /dev/null @@ -1,457 +0,0 @@ -module ietf-inet-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types"; - prefix "inet"; - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Kessens - - - WG Chair: Juergen Schoenwaelder - - - Editor: Juergen Schoenwaelder - "; - - description - "This module contains a collection of generally useful derived - YANG data types for Internet addresses and related things. - - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 6991; see - the RFC itself for full legal notices."; - - revision 2013-07-15 { - description - "This revision adds the following new data types: - - ip-address-no-zone - - ipv4-address-no-zone - - ipv6-address-no-zone"; - reference - "RFC 6991: Common YANG Data Types"; - } - - revision 2010-09-24 { - description - "Initial revision."; - reference - "RFC 6021: Common YANG Data Types"; - } - - /*** collection of types related to protocol fields ***/ - - typedef ip-version { - type enumeration { - enum unknown { - value "0"; - description - "An unknown or unspecified version of the Internet - protocol."; - } - enum ipv4 { - value "1"; - description - "The IPv4 protocol as defined in RFC 791."; - } - enum ipv6 { - value "2"; - description - "The IPv6 protocol as defined in RFC 2460."; - } - } - description - "This value represents the version of the IP protocol. - - In the value set and its semantics, this type is equivalent - to the InetVersion textual convention of the SMIv2."; - reference - "RFC 791: Internet Protocol - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - typedef dscp { - type uint8 { - range "0..63"; - } - description - "The dscp type represents a Differentiated Services Code Point - that may be used for marking packets in a traffic stream. - In the value set and its semantics, this type is equivalent - to the Dscp textual convention of the SMIv2."; - reference - "RFC 3289: Management Information Base for the Differentiated - Services Architecture - RFC 2474: Definition of the Differentiated Services Field - (DS Field) in the IPv4 and IPv6 Headers - RFC 2780: IANA Allocation Guidelines For Values In - the Internet Protocol and Related Headers"; - } - - typedef ipv6-flow-label { - type uint32 { - range "0..1048575"; - } - description - "The ipv6-flow-label type represents the flow identifier or Flow - Label in an IPv6 packet header that may be used to - discriminate traffic flows. - - In the value set and its semantics, this type is equivalent - to the IPv6FlowLabel textual convention of the SMIv2."; - reference - "RFC 3595: Textual Conventions for IPv6 Flow Label - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"; - } - - typedef port-number { - type uint16 { - range "0..65535"; - } - description - "The port-number type represents a 16-bit port number of an - Internet transport-layer protocol such as UDP, TCP, DCCP, or - SCTP. Port numbers are assigned by IANA. A current list of - all assignments is available from . - - Note that the port number value zero is reserved by IANA. In - situations where the value zero does not make sense, it can - be excluded by subtyping the port-number type. - In the value set and its semantics, this type is equivalent - to the InetPortNumber textual convention of the SMIv2."; - reference - "RFC 768: User Datagram Protocol - RFC 793: Transmission Control Protocol - RFC 4960: Stream Control Transmission Protocol - RFC 4340: Datagram Congestion Control Protocol (DCCP) - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - /*** collection of types related to autonomous systems ***/ - - typedef as-number { - type uint32; - description - "The as-number type represents autonomous system numbers - which identify an Autonomous System (AS). An AS is a set - of routers under a single technical administration, using - an interior gateway protocol and common metrics to route - packets within the AS, and using an exterior gateway - protocol to route packets to other ASes. IANA maintains - the AS number space and has delegated large parts to the - regional registries. - - Autonomous system numbers were originally limited to 16 - bits. BGP extensions have enlarged the autonomous system - number space to 32 bits. This type therefore uses an uint32 - base type without a range restriction in order to support - a larger autonomous system number space. - - In the value set and its semantics, this type is equivalent - to the InetAutonomousSystemNumber textual convention of - the SMIv2."; - reference - "RFC 1930: Guidelines for creation, selection, and registration - of an Autonomous System (AS) - RFC 4271: A Border Gateway Protocol 4 (BGP-4) - RFC 4001: Textual Conventions for Internet Network Addresses - RFC 6793: BGP Support for Four-Octet Autonomous System (AS) - Number Space"; - } - - /*** collection of types related to IP addresses and hostnames ***/ - - typedef ip-address { - type union { - type inet:ipv4-address; - type inet:ipv6-address; - } - description - "The ip-address type represents an IP address and is IP - version neutral. The format of the textual representation - implies the IP version. This type supports scoped addresses - by allowing zone identifiers in the address format."; - reference - "RFC 4007: IPv6 Scoped Address Architecture"; - } - - typedef ipv4-address { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '(%[\p{N}\p{L}]+)?'; - } - description - "The ipv4-address type represents an IPv4 address in - dotted-quad notation. The IPv4 address may include a zone - index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format for the zone index is the numerical - format"; - } - - typedef ipv6-address { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(%[\p{N}\p{L}]+)?'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(%.+)?'; - } - description - "The ipv6-address type represents an IPv6 address in full, - mixed, shortened, and shortened-mixed notation. The IPv6 - address may include a zone index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format of IPv6 addresses uses the textual - representation defined in Section 4 of RFC 5952. The - canonical format for the zone index is the numerical - format as described in Section 11.2 of RFC 4007."; - reference - "RFC 4291: IP Version 6 Addressing Architecture - RFC 4007: IPv6 Scoped Address Architecture - RFC 5952: A Recommendation for IPv6 Address Text - Representation"; - } - - typedef ip-address-no-zone { - type union { - type inet:ipv4-address-no-zone; - type inet:ipv6-address-no-zone; - } - description - "The ip-address-no-zone type represents an IP address and is - IP version neutral. The format of the textual representation - implies the IP version. This type does not support scoped - addresses since it does not allow zone identifiers in the - address format."; - reference - "RFC 4007: IPv6 Scoped Address Architecture"; - } - - typedef ipv4-address-no-zone { - type inet:ipv4-address { - pattern '[0-9\.]*'; - } - description - "An IPv4 address without a zone index. This type, derived from - ipv4-address, may be used in situations where the zone is - known from the context and hence no zone index is needed."; - } - - typedef ipv6-address-no-zone { - type inet:ipv6-address { - pattern '[0-9a-fA-F:\.]*'; - } - description - "An IPv6 address without a zone index. This type, derived from - ipv6-address, may be used in situations where the zone is - known from the context and hence no zone index is needed."; - reference - "RFC 4291: IP Version 6 Addressing Architecture - RFC 4007: IPv6 Scoped Address Architecture - RFC 5952: A Recommendation for IPv6 Address Text - Representation"; - } - - typedef ip-prefix { - type union { - type inet:ipv4-prefix; - type inet:ipv6-prefix; - } - description - "The ip-prefix type represents an IP prefix and is IP - version neutral. The format of the textual representations - implies the IP version."; - } - - typedef ipv4-prefix { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '/(([0-9])|([1-2][0-9])|(3[0-2]))'; - } - description - "The ipv4-prefix type represents an IPv4 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal to 32. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The canonical format of an IPv4 prefix has all bits of - the IPv4 address set to zero that are not part of the - IPv4 prefix."; - } - - typedef ipv6-prefix { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(/.+)'; - } - description - "The ipv6-prefix type represents an IPv6 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal to 128. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The IPv6 address should have all bits that do not belong - to the prefix set to zero. - - The canonical format of an IPv6 prefix has all bits of - the IPv6 address set to zero that are not part of the - IPv6 prefix. Furthermore, the IPv6 address is represented - as defined in Section 4 of RFC 5952."; - reference - "RFC 5952: A Recommendation for IPv6 Address Text - Representation"; - } - - /*** collection of domain name and URI types ***/ - - typedef domain-name { - type string { - pattern - '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' - + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' - + '|\.'; - length "1..253"; - } - description - "The domain-name type represents a DNS domain name. The - name SHOULD be fully qualified whenever possible. - - Internet domain names are only loosely specified. Section - 3.5 of RFC 1034 recommends a syntax (modified in Section - 2.1 of RFC 1123). The pattern above is intended to allow - for current practice in domain name use, and some possible - future expansion. It is designed to hold various types of - domain names, including names used for A or AAAA records - (host names) and other records, such as SRV records. Note - that Internet host names have a stricter syntax (described - in RFC 952) than the DNS recommendations in RFCs 1034 and - 1123, and that systems that want to store host names in - schema nodes using the domain-name type are recommended to - adhere to this stricter standard to ensure interoperability. - - The encoding of DNS names in the DNS protocol is limited - to 255 characters. Since the encoding consists of labels - prefixed by a length bytes and there is a trailing NULL - byte, only 253 characters can appear in the textual dotted - notation. - - The description clause of schema nodes using the domain-name - type MUST describe when and how these names are resolved to - IP addresses. Note that the resolution of a domain-name value - may require to query multiple DNS records (e.g., A for IPv4 - and AAAA for IPv6). The order of the resolution process and - which DNS record takes precedence can either be defined - explicitly or may depend on the configuration of the - resolver. - - Domain-name values use the US-ASCII encoding. Their canonical - format uses lowercase US-ASCII characters. Internationalized - domain names MUST be A-labels as per RFC 5890."; - reference - "RFC 952: DoD Internet Host Table Specification - RFC 1034: Domain Names - Concepts and Facilities - RFC 1123: Requirements for Internet Hosts -- Application - and Support - RFC 2782: A DNS RR for specifying the location of services - (DNS SRV) - RFC 5890: Internationalized Domain Names in Applications - (IDNA): Definitions and Document Framework"; - } - - typedef host { - type union { - type inet:ip-address; - type inet:domain-name; - } - description - "The host type represents either an IP address or a DNS - domain name."; - } - - typedef uri { - type string; - description - "The uri type represents a Uniform Resource Identifier - (URI) as defined by STD 66. - - Objects using the uri type MUST be in US-ASCII encoding, - and MUST be normalized as described by RFC 3986 Sections - 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary - percent-encoding is removed, and all case-insensitive - characters are set to lowercase except for hexadecimal - digits, which are normalized to uppercase as described in - Section 6.2.2.1. - - The purpose of this normalization is to help provide - unique URIs. Note that this normalization is not - sufficient to provide uniqueness. Two URIs that are - textually distinct after this normalization may still be - equivalent. - - Objects using the uri type may restrict the schemes that - they permit. For example, 'data:' and 'urn:' schemes - might not be appropriate. - - A zero-length URI is not a valid URI. This can be used to - express 'URI absent' where required. - - In the value set and its semantics, this type is equivalent - to the Uri SMIv2 textual convention defined in RFC 5017."; - reference - "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax - RFC 3305: Report from the Joint W3C/IETF URI Planning Interest - Group: Uniform Resource Identifiers (URIs), URLs, - and Uniform Resource Names (URNs): Clarifications - and Recommendations - RFC 5017: MIB Textual Conventions for Uniform Resource - Identifiers (URIs)"; - } - -} diff --git a/netconf/netconf-console/src/test/resources/schemas/netconf-node-optional.yang b/netconf/netconf-console/src/test/resources/schemas/netconf-node-optional.yang deleted file mode 100644 index 9ecbe6e4b7..0000000000 --- a/netconf/netconf-console/src/test/resources/schemas/netconf-node-optional.yang +++ /dev/null @@ -1,69 +0,0 @@ -module netconf-node-optional { - namespace "urn:opendaylight:netconf-node-optional"; - prefix "netnopt"; - - import network-topology { prefix nt; revision-date 2013-10-21; } - import yang-ext { prefix ext; revision-date "2013-07-09";} - - revision "2019-06-14" { - description "Initial revision of Node Optional model"; - } - - grouping netconf-node-augmented-optional-fields { - container ignore-missing-schema-sources { - description "Allows mount point to reconnect on the 'missing schema sources' error. - WARNING - enabling the reconnection on the 'missing schema sources' error can lead - to unexpected errors at runtime."; - leaf allowed { - type boolean; - default false; - description "Allows reconnection of the mount point. Default false."; - } - leaf reconnect-time { - type uint32; - default 5000; - description "Time for reconnection - in units milliseconds. Default 5000 ms."; - } - } - } - - container netconf-node-fields-optional { - description "Allows to create node's optional value with the path mapping according to - the network-topology -> topology -> node"; - list topology { - key topology-id; - leaf topology-id { - type nt:topology-id; - description "The name of node's topology"; - } - list node { - key node-id; - leaf node-id { - type nt:node-id; - description "The identifier of a node in the topology"; - } - // Containers allow to create specific data-change-listener directly on a node's optional value. - // In the future, it'll be easy to extend the node by optional node fields in this way. Do not create - // direct leafs here, please. - container datastore-lock { - description "Allows to ignore lock/unlock node's datastare."; - leaf datastore-lock-allowed { - type boolean; - default true; - description "The operation allows the client to lock the entire configuration datastore - system of a device. - WARNING - With blocking the lock/unlock operations, the user is coming to operate - in a manner which is not supported. Concurrent access to the data store may interfere - with data consistency."; - } - } - } - } - } - - augment "/nt:network-topology/nt:topology/nt:node/" { - when "../../nt:topology-types/topology-netconf"; - ext:augment-identifier "netconf-node-augmented-optional"; - uses netconf-node-augmented-optional-fields; - } -} diff --git a/netconf/netconf-console/src/test/resources/schemas/netconf-node-topology.yang b/netconf/netconf-console/src/test/resources/schemas/netconf-node-topology.yang deleted file mode 100644 index cb1948d8f9..0000000000 --- a/netconf/netconf-console/src/test/resources/schemas/netconf-node-topology.yang +++ /dev/null @@ -1,367 +0,0 @@ -module netconf-node-topology { - namespace "urn:opendaylight:netconf-node-topology"; - prefix "nettop"; - - import network-topology { prefix nt; revision-date 2013-10-21; } - import yang-ext { prefix ext; revision-date "2013-07-09";} - import ietf-inet-types { prefix inet; revision-date "2013-07-15"; } - import netconf-node-optional {prefix nno; revision-date "2019-06-14"; } - - revision "2015-01-14" { - description "Initial revision of Topology model"; - } - - augment "/nt:network-topology/nt:topology/nt:topology-types" { - container topology-netconf { - } - } - - grouping username-password { - leaf username { - type string; - } - - leaf password { - type string; - } - } - - grouping netconf-node-credentials { - choice credentials { - config true; - case login-password { - description "Deprecated way of storing credentials, unencrypted."; - - status deprecated; - uses username-password; - } - case login-pw { - description "login-password credentials, encrypted."; - - container login-password { - uses username-password; - } - } - case login-pw-unencrypted { - description "login-password credentials, not encrypted."; - - container login-password-unencrypted { - uses username-password; - } - } - case key-auth { - description "key-based authentication, use the id for the pair thats stored in the keystore."; - - container key-based { - leaf key-id { - type string; - } - - leaf username { - type string; - } - } - } - } - } - - grouping netconf-node-connection-parameters { - - leaf host { - type inet:host; - } - - leaf port { - type inet:port-number; - } - - leaf tcp-only { - config true; - type boolean; - } - - container protocol { - config true; - leaf name { - type enumeration { - enum SSH; - enum TLS; - } - default SSH; - } - - choice specification { - case tls-case { - container tls { - leaf-list excluded-versions { - type string; - description "A list of TLS version names provided in JDK that are not supported by the - target netconf device, eg, the netopeer2 simulator does not support the - SSLv2Hello. Most of the time, this list need not be set"; - } - } - } - } - } - - leaf schemaless { - type boolean; - default false; - } - - container yang-module-capabilities { - config true; - leaf override { - type boolean; - default false; - description "Whether to override or merge this list of capabilities with capabilities from device"; - } - - leaf-list capability { - type string; - description "Set a list of capabilities to override capabilities provided in device's hello message. - Can be used for devices that do not report any yang modules in their hello message"; - } - } - - container non-module-capabilities { - config true; - leaf override { - type boolean; - default false; - description "Whether to override or merge this list of non-module based capabilities with non-module - based capabilities from device"; - } - - leaf-list capability { - type string; - description "Set a list of non-module based capabilities to override or merge non-module capabilities - provided in device's hello message. Can be used for devices that do not report or - incorrectly report non-module based capabilities in their hello message"; - } - } - - leaf reconnect-on-changed-schema { - config true; - type boolean; - default false; - description "If true, the connector would auto disconnect/reconnect when schemas are changed in the remote device. - The connector subscribes (right after connect) to base netconf notifications and listens for netconf-capability-change notification"; - } - - leaf connection-timeout-millis { - description "Specifies timeout in milliseconds after which connection must be established."; - config true; - type uint32; - default 20000; - } - - leaf default-request-timeout-millis { - description "Timeout for blocking operations within transactions."; - config true; - type uint32; - default 60000; - } - - leaf max-connection-attempts { - description "Maximum number of connection retries. Non positive value or null is interpreted as infinity."; - config true; - type uint32; - default 0; // retry forever - } - - leaf between-attempts-timeout-millis { - description "Initial timeout in milliseconds to wait between connection attempts. Will be multiplied by sleep-factor with every additional attempt"; - config true; - type uint16; - default 2000; - } - - leaf sleep-factor { - config true; - type decimal64 { - fraction-digits 1; - } - default 1.5; - } - - // Keepalive configuration - leaf keepalive-delay { - config true; - type uint32; - default 120; - description "Netconf connector sends keepalive RPCs while the session is idle, this delay specifies the delay between keepalive RPC in seconds - If a value <1 is provided, no keepalives will be sent"; - } - - leaf concurrent-rpc-limit { - config true; - type uint16; - default 0; - description "Limit of concurrent messages that can be send before reply messages are received. - If value <1 is provided, no limit will be enforced"; - } - - leaf actor-response-wait-time { - config true; - type uint16 { - range "1..max"; - } - default 5; - description "Time that slave actor will wait for response from master."; - } - - container odl-hello-message-capabilities { - config true; - leaf-list capability { - type inet:uri; - description "Certain devices are non-accepting of ODL's hello message. This allows specification of - a custom ODL hello message based on a list of supported capabilities."; - } - } - } - - grouping netconf-node-connection-status { - - leaf connection-status { - config false; - type enumeration { - enum connecting; - enum connected; - enum unable-to-connect; - } - } - - container clustered-connection-status { - config false; - list node-status { - leaf node { - type string; - } - leaf status { - type enumeration { - enum connected; - enum unavailable; - enum failed; - } - } - } - leaf netconf-master-node { - config false; - type string; - } - } - - leaf connected-message { - config false; - type string; - } - - container available-capabilities { - config false; - list available-capability { - leaf capability { - type string; - } - leaf capability-origin { - type enumeration { - enum user-defined; - enum device-advertised; - } - } - } - } - - container unavailable-capabilities { - config false; - list unavailable-capability { - leaf capability { - type string; - } - - leaf failure-reason { - type enumeration { - enum missing-source; - enum unable-to-resolve; - } - } - } - } - - container pass-through { - when "../connection-status = connected"; - description - "When the underlying node is connected, its NETCONF context - is available verbatim under this container through the - mount extension."; - } - - } - - grouping netconf-schema-storage { - leaf schema-cache-directory { - config true; - type string; - default "schema"; - description "The destination schema repository for yang files relative to the cache directory. This may be specified per netconf mount - so that the loaded yang files are stored to a distinct directory to avoid potential conflict."; - } - - container yang-library { - leaf yang-library-url { - config true; - type inet:uri; - description "Yang library to be plugged as additional source provider into the shared schema repository"; - } - - // credentials for basic http authentication - leaf username { - config true; - type string; - } - - leaf password { - config true; - type string; - } - } - } - - grouping netconf-node-fields { - - uses netconf-node-credentials; - - uses netconf-node-connection-parameters; - - uses netconf-node-connection-status; - - uses netconf-schema-storage; - uses nno:netconf-node-augmented-optional-fields ; - - } - - rpc create-device { - input { - uses netconf-node-fields; - leaf node-id { - type string; - } - } - } - - rpc delete-device { - input { - leaf node-id { - type string; - } - } - } - - augment "/nt:network-topology/nt:topology/nt:node" { - when "../../nt:topology-types/topology-netconf"; - ext:augment-identifier "netconf-node"; - - uses netconf-node-fields; - } - -} diff --git a/netconf/netconf-console/src/test/resources/schemas/network-topology@2013-10-21.yang b/netconf/netconf-console/src/test/resources/schemas/network-topology@2013-10-21.yang deleted file mode 100644 index dc5dcad708..0000000000 --- a/netconf/netconf-console/src/test/resources/schemas/network-topology@2013-10-21.yang +++ /dev/null @@ -1,339 +0,0 @@ -module network-topology { - yang-version 1; - namespace "urn:TBD:params:xml:ns:yang:network-topology"; - // replace with IANA namespace when assigned - prefix "nt"; - - import ietf-inet-types { prefix "inet"; revision-date 2013-07-15; } - - organization "TBD"; - - contact "WILL-BE-DEFINED-LATER"; - - description - "This module defines a model for the topology of a network. - Key design decisions are as follows: - A topology consists of a set of nodes and links. - Links are point-to-point and unidirectional. - Bidirectional connections need to be represented through - two separate links. - Multipoint connections, broadcast domains etc can be represented - through a hierarchy of nodes, then connecting nodes at - upper layers of the hierarchy."; - - revision 2013-10-21 { - description - "Initial revision."; - } - - typedef topology-id { - type inet:uri; - description - "An identifier for a topology."; - } - - typedef node-id { - type inet:uri; - description - "An identifier for a node in a topology. - The identifier may be opaque. - The identifier SHOULD be chosen such that the same node in a - real network topology will always be identified through the - same identifier, even if the model is instantiated in separate - datastores. An implementation MAY choose to capture semantics - in the identifier, for example to indicate the type of node - and/or the type of topology that the node is a part of."; - } - - - typedef link-id { - type inet:uri; - description - "An identifier for a link in a topology. - The identifier may be opaque. - The identifier SHOULD be chosen such that the same link in a - real network topology will always be identified through the - same identifier, even if the model is instantiated in separate - datastores. An implementation MAY choose to capture semantics - in the identifier, for example to indicate the type of link - and/or the type of topology that the link is a part of."; - } - - typedef tp-id { - type inet:uri; - description - "An identifier for termination points on a node. - The identifier may be opaque. - The identifier SHOULD be chosen such that the same TP in a - real network topology will always be identified through the - same identifier, even if the model is instantiated in separate - datastores. An implementation MAY choose to capture semantics - in the identifier, for example to indicate the type of TP - and/or the type of node and topology that the TP is a part of."; - } - - typedef tp-ref { - type leafref { - path "/network-topology/topology/node/termination-point/tp-id"; - } - description - "A type for an absolute reference to a termination point. - (This type should not be used for relative references. - In such a case, a relative path should be used instead.)"; - } - typedef topology-ref { - type leafref { - path "/network-topology/topology/topology-id"; - } - description - "A type for an absolute reference a topology instance."; - } - - typedef node-ref { - type leafref { - path "/network-topology/topology/node/node-id"; - } - description - - "A type for an absolute reference to a node instance. - (This type should not be used for relative references. - In such a case, a relative path should be used instead.)"; - } - - typedef link-ref { - type leafref { - path "/network-topology/topology/link/link-id"; - } - description - "A type for an absolute reference a link instance. - (This type should not be used for relative references. - In such a case, a relative path should be used instead.)"; - } - - grouping tp-attributes { - description - "The data objects needed to define a termination point. - (This only includes a single leaf at this point, used - to identify the termination point.) - Provided in a grouping so that in addition to the datastore, - the data can also be included in notifications."; - leaf tp-id { - type tp-id; - } - leaf-list tp-ref { - type tp-ref; - config false; - description - "The leaf list identifies any termination points that the - termination point is dependent on, or maps onto. - Those termination points will themselves be contained - in a supporting node. - This dependency information can be inferred from - the dependencies between links. For this reason, - this item is not separately configurable. Hence no - corresponding constraint needs to be articulated. - The corresponding information is simply provided by the - implementing system."; - } - } - - grouping node-attributes { - description - "The data objects needed to define a node. - The objects are provided in a grouping so that in addition to - the datastore, the data can also be included in notifications - as needed."; - - leaf node-id { - type node-id; - description - "The identifier of a node in the topology. - A node is specific to a topology to which it belongs."; - } - list supporting-node { - description - "This list defines vertical layering information for nodes. - It allows to capture for any given node, which node (or nodes) - in the corresponding underlay topology it maps onto. - A node can map to zero, one, or more nodes below it; - accordingly there can be zero, one, or more elements in the list. - If there are specific layering requirements, for example - specific to a particular type of topology that only allows - for certain layering relationships, the choice - below can be augmented with additional cases. - A list has been chosen rather than a leaf-list in order - to provide room for augmentations, e.g. for - statistics or priorization information associated with - supporting nodes."; - // This is not what was published in the initial draft, - // added topology-ref leaf and added it to the key - key "topology-ref node-ref"; - leaf topology-ref { - type topology-ref; - } - leaf node-ref { - type node-ref; - } - } - } - - grouping link-attributes { - // This is a grouping, not defined inline with the link definition itself, - // so it can be included in a notification, if needed - leaf link-id { - type link-id; - description - "The identifier of a link in the topology. - A link is specific to a topology to which it belongs."; - } - container source { - leaf source-node { - mandatory true; - type node-ref; - description - "Source node identifier, must be in same topology."; - } - leaf source-tp { - type tp-ref; - description - "Termination point within source node that terminates the link."; - - } - } - container destination { - leaf dest-node { - mandatory true; - type node-ref; - description - "Destination node identifier, must be in same topology."; - } - leaf dest-tp { - type tp-ref; - description - "Termination point within destination node that terminates the link."; - } - } - list supporting-link { - key "link-ref"; - leaf link-ref { - type link-ref; - } - } - } - - - container network-topology { - list topology { - description " - This is the model of an abstract topology. - A topology contains nodes and links. - Each topology MUST be identified by - unique topology-id for reason that a network could contain many - topologies. - "; - key "topology-id"; - leaf topology-id { - type topology-id; - description " - It is presumed that a datastore will contain many topologies. To - distinguish between topologies it is vital to have UNIQUE - topology identifiers. - "; - } - leaf server-provided { - type boolean; - config false; - description " - Indicates whether the topology is configurable by clients, - or whether it is provided by the server. This leaf is - - populated by the server implementing the model. - It is set to false for topologies that are created by a client; - it is set to true otherwise. If it is set to true, any - attempt to edit the topology MUST be rejected. - "; - } - container topology-types { - description - "This container is used to identify the type, or types - (as a topology can support several types simultaneously), - of the topology. - Topology types are the subject of several integrity constraints - that an implementing server can validate in order to - maintain integrity of the datastore. - Topology types are indicated through separate data nodes; - the set of topology types is expected to increase over time. - To add support for a new topology, an augmenting module - needs to augment this container with a new empty optional - container to indicate the new topology type. - The use of a container allows to indicate a subcategorization - of topology types. - The container SHALL NOT be augmented with any data nodes - that serve a purpose other than identifying a particular - topology type. - "; - } - list underlay-topology { - key "topology-ref"; - leaf topology-ref { - type topology-ref; - } - // a list, not a leaf-list, to allow for potential augmentation - // with properties specific to the underlay topology, - // such as statistics, preferences, or cost. - description - "Identifies the topology, or topologies, that this topology - is dependent on."; - } - - list node { - description "The list of network nodes defined for the topology."; - key "node-id"; - uses node-attributes; - must "boolean(../underlay-topology[*]/node[./supporting-nodes/node-ref])"; - // This constraint is meant to ensure that a referenced node is in fact - // a node in an underlay topology. - list termination-point { - description - - "A termination point can terminate a link. - Depending on the type of topology, a termination point could, - for example, refer to a port or an interface."; - key "tp-id"; - uses tp-attributes; - } - } - - list link { - description " - A Network Link connects a by Local (Source) node and - a Remote (Destination) Network Nodes via a set of the - nodes' termination points. - As it is possible to have several links between the same - source and destination nodes, and as a link could potentially - be re-homed between termination points, to ensure that we - would always know to distinguish between links, every link - is identified by a dedicated link identifier. - Note that a link models a point-to-point link, not a multipoint - link. - Layering dependencies on links in underlay topologies are - not represented as the layering information of nodes and of - termination points is sufficient. - "; - key "link-id"; - uses link-attributes; - must "boolean(../underlay-topology/link[./supporting-link])"; - // Constraint: any supporting link must be part of an underlay topology - must "boolean(../node[./source/source-node])"; - // Constraint: A link must have as source a node of the same topology - must "boolean(../node[./destination/dest-node])"; - // Constraint: A link must have as source a destination of the same topology - must "boolean(../node/termination-point[./source/source-tp])"; - // Constraint: The source termination point must be contained in the source node - must "boolean(../node/termination-point[./destination/dest-tp])"; - // Constraint: The destination termination point must be contained - // in the destination node - } - } - } -} diff --git a/netconf/netconf-console/src/test/resources/schemas/yang-ext.yang b/netconf/netconf-console/src/test/resources/schemas/yang-ext.yang deleted file mode 100644 index 0fbe94ddc4..0000000000 --- a/netconf/netconf-console/src/test/resources/schemas/yang-ext.yang +++ /dev/null @@ -1,79 +0,0 @@ -module yang-ext { - yang-version 1; - namespace "urn:opendaylight:yang:extension:yang-ext"; - prefix "ext"; - - contact "Anton Tkacik "; - - description - "Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - - This program and the accompanying materials are made available under the - terms of the Eclipse Public License v1.0 which accompanies this distribution, - and is available at http://www.eclipse.org/legal/epl-v10.html"; - - revision "2013-07-09" { - description ""; - } - - // Augmentation name - - extension "augment-identifier" { - description - "YANG language extension which assigns an identifier to - augmentation. Augment identifier is used to identify - specific augment statement by name. - - The identifier syntax is defined formally defined by the rule - 'identifier' in Section 12 of RFC 6020. - - All augment identifiers defined in a namespace MUST be unique. - The namespace of augment identifiers is shared by module and - its submodules."; - - /* - Discussion: - This extension allows for ease of development / debug - of YANG modules and it is suitable for code generation, - where each augment statement is nicely identified by - unique name instead of combination of augment target - and when condition. - */ - argument "identifier"; - } - - - // Context-aware RPCs - - grouping rpc-context-ref { - description - "A reference to RPC context."; - leaf context-instance { - type instance-identifier; - description "Pointer to the context. "; - } - } - - extension "rpc-context-instance" { - description - "YANG language extension which defines enclosing (parent) - schema node as referencable context for RPCs. - - The argument is identity which is used to identify RPC context - type."; - - argument "context-type"; - } - - extension "context-reference" { - argument "context-type"; - } - - extension "context-instance" { - argument "context-type"; - } - - extension "instance-target" { - argument "path"; - } -} diff --git a/netconf/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java b/netconf/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java index 9558c98257..ff68ba94b8 100644 --- a/netconf/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java +++ b/netconf/netconf-topology-impl/src/test/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImplTest.java @@ -76,6 +76,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableIt import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserException; import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl; @RunWith(MockitoJUnitRunner.StrictStubs.class) @@ -150,10 +151,12 @@ public class NetconfTopologyImplTest { final DataObjectModification newNode = mock(DataObjectModification.class); when(newNode.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE); - PathArgument pa = IdentifiableItem.of(Node.class, new NodeKey(NODE_ID)); + NodeKey key = new NodeKey(NODE_ID); + PathArgument pa = IdentifiableItem.of(Node.class, key); when(newNode.getIdentifier()).thenReturn(pa); final NodeBuilder nn = new NodeBuilder() + .withKey(key) .addAugmentation(new NetconfNodeBuilder() .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))) .setPort(new PortNumber(Uint16.valueOf(9999))) @@ -271,8 +274,15 @@ public class NetconfTopologyImplTest { } public static class TestingNetconfTopologyImpl extends NetconfTopologyImpl { - private static final BaseNetconfSchemas BASE_SCHEMAS = - new DefaultBaseNetconfSchemas(new YangParserFactoryImpl()); + private static final BaseNetconfSchemas BASE_SCHEMAS; + + static { + try { + BASE_SCHEMAS = new DefaultBaseNetconfSchemas(new YangParserFactoryImpl()); + } catch (YangParserException e) { + throw new ExceptionInInitializerError(e); + } + } public TestingNetconfTopologyImpl(final String topologyId, final NetconfClientDispatcher clientDispatcher, final EventExecutor eventExecutor, diff --git a/netconf/netconf-topology-singleton/pom.xml b/netconf/netconf-topology-singleton/pom.xml index cdfb3c6f5e..33d76043d6 100644 --- a/netconf/netconf-topology-singleton/pom.xml +++ b/netconf/netconf-topology-singleton/pom.xml @@ -24,14 +24,15 @@ ${project.artifactId} bundle + + + false + + - com.typesafe.akka - akka-actor_2.13 - - - com.typesafe.akka - akka-cluster_2.13 + org.opendaylight.controller + repackaged-akka diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMActionService.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMActionService.java index c3f61b6263..5bf202cb20 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMActionService.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMActionService.java @@ -34,7 +34,7 @@ import org.opendaylight.netconf.topology.singleton.messages.action.InvokeActionM import org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyResultResponse; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Future; @@ -70,8 +70,8 @@ public class ProxyDOMActionService implements DOMActionService { } @Override - public FluentFuture invokeAction(final SchemaPath type, - final DOMDataTreeIdentifier domDataTreeIdentifier, final ContainerNode input) { + public FluentFuture invokeAction(final Absolute type, + final DOMDataTreeIdentifier domDataTreeIdentifier, final ContainerNode input) { requireNonNull(type); requireNonNull(input); requireNonNull(domDataTreeIdentifier); @@ -84,7 +84,7 @@ public class ProxyDOMActionService implements DOMActionService { final SettableFuture settableFuture = SettableFuture.create(); - scalaFuture.onComplete(new OnComplete() { + scalaFuture.onComplete(new OnComplete<>() { @Override public void onComplete(final Throwable failure, final Object response) { if (failure != null) { diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java index 5c5fd4a77e..40041b7aca 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/ProxyDOMRpcService.java @@ -28,10 +28,10 @@ import org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessage import org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply; import org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyResultResponse; import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Future; @@ -53,7 +53,7 @@ public class ProxyDOMRpcService implements DOMRpcService { } @Override - public FluentFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { + public FluentFuture invokeRpc(final QName type, final NormalizedNode input) { LOG.trace("{}: Rpc operation invoked with schema type: {} and node: {}.", id, type, input); final NormalizedNodeMessage normalizedNodeMessage = input != null @@ -63,7 +63,7 @@ public class ProxyDOMRpcService implements DOMRpcService { final SettableFuture settableFuture = SettableFuture.create(); - scalaFuture.onComplete(new OnComplete() { + scalaFuture.onComplete(new OnComplete<>() { @Override public void onComplete(final Throwable failure, final Object response) { if (failure != null) { diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/NetconfNodeActor.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/NetconfNodeActor.java index 51a430b8b7..019f8c19e3 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/NetconfNodeActor.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/actors/NetconfNodeActor.java @@ -63,9 +63,10 @@ import org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyRe import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadTransactionRequest; import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadWriteTransactionRequest; import org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionRequest; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory; import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; @@ -167,7 +168,8 @@ public class NetconfNodeActor extends AbstractUntypedActor { } } else if (message instanceof InvokeRpcMessage) { // master final InvokeRpcMessage invokeRpcMessage = (InvokeRpcMessage) message; - invokeSlaveRpc(invokeRpcMessage.getSchemaPath(), invokeRpcMessage.getNormalizedNodeMessage(), sender()); + invokeSlaveRpc(invokeRpcMessage.getSchemaPath().lastNodeIdentifier(), + invokeRpcMessage.getNormalizedNodeMessage(), sender()); } else if (message instanceof InvokeActionMessage) { // master final InvokeActionMessage invokeActionMessage = (InvokeActionMessage) message; LOG.info("InvokeActionMessage Details : {}", invokeActionMessage.toString()); @@ -234,19 +236,19 @@ public class NetconfNodeActor extends AbstractUntypedActor { }, MoreExecutors.directExecutor()); } - private void invokeSlaveRpc(final SchemaPath schemaPath, final NormalizedNodeMessage normalizedNodeMessage, + private void invokeSlaveRpc(final QName qname, final NormalizedNodeMessage normalizedNodeMessage, final ActorRef recipient) { - LOG.debug("{}: invokeSlaveRpc for {}, input: {} on rpc service {}", id, schemaPath, normalizedNodeMessage, + LOG.debug("{}: invokeSlaveRpc for {}, input: {} on rpc service {}", id, qname, normalizedNodeMessage, deviceRpc); - final ListenableFuture rpcResult = deviceRpc.invokeRpc(schemaPath, + final ListenableFuture rpcResult = deviceRpc.invokeRpc(qname, normalizedNodeMessage != null ? normalizedNodeMessage.getNode() : null); Futures.addCallback(rpcResult, new FutureCallback() { @Override public void onSuccess(final DOMRpcResult domRpcResult) { - LOG.debug("{}: invokeSlaveRpc for {}, domRpcResult: {}", id, schemaPath, domRpcResult); + LOG.debug("{}: invokeSlaveRpc for {}, domRpcResult: {}", id, qname, domRpcResult); if (domRpcResult == null) { recipient.tell(new EmptyResultResponse(), getSender()); @@ -270,12 +272,12 @@ public class NetconfNodeActor extends AbstractUntypedActor { /** * Invoking Action on Slave Node in Odl Cluster Environment. * - * @param schemaPath {@link SchemaPath} + * @param schemaPath {@link Absolute} * @param containerNodeMessage {@link ContainerNodeMessage} * @param domDataTreeIdentifier {@link DOMDataTreeIdentifier} * @param recipient {@link ActorRef} */ - private void invokeSlaveAction(final SchemaPath schemaPath, final ContainerNodeMessage containerNodeMessage, + private void invokeSlaveAction(final Absolute schemaPath, final ContainerNodeMessage containerNodeMessage, final DOMDataTreeIdentifier domDataTreeIdentifier, final ActorRef recipient) { LOG.info("{}: invokeSlaveAction for {}, input: {}, identifier: {} on action service {}", id, schemaPath, containerNodeMessage, domDataTreeIdentifier, deviceAction); diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/SchemaPathMessage.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/SchemaPathMessage.java index 5f170036c5..a0278aef74 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/SchemaPathMessage.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/SchemaPathMessage.java @@ -8,27 +8,32 @@ package org.opendaylight.netconf.topology.singleton.messages; -import com.google.common.collect.Iterables; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.Externalizable; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; +import java.util.List; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; public class SchemaPathMessage implements Serializable { private static final long serialVersionUID = 1L; @SuppressFBWarnings("SE_BAD_FIELD") - private final SchemaPath schemaPath; + private final Absolute schemaPath; - public SchemaPathMessage(final SchemaPath schemaPath) { + public SchemaPathMessage(final QName qname) { + this(Absolute.of(qname)); + } + + public SchemaPathMessage(final Absolute schemaPath) { this.schemaPath = schemaPath; } - public SchemaPath getSchemaPath() { + public Absolute getSchemaPath() { return schemaPath; } @@ -57,14 +62,14 @@ public class SchemaPathMessage implements Serializable { @Override public void writeExternal(final ObjectOutput out) throws IOException { - final Iterable path = schemaPathMessage.getSchemaPath().getPathFromRoot(); - out.writeInt(Iterables.size(path)); + final List path = schemaPathMessage.getSchemaPath().getNodeIdentifiers(); + out.writeInt(path.size()); for (final QName qualifiedName : path) { // FIXME: switch to QName.writeTo() or a sal-clustering-commons stream out.writeObject(qualifiedName); } - out.writeBoolean(schemaPathMessage.getSchemaPath().isAbsolute()); + out.writeBoolean(true); } @Override @@ -76,7 +81,10 @@ public class SchemaPathMessage implements Serializable { paths[i] = (QName) in.readObject(); } final boolean absolute = in.readBoolean(); - schemaPathMessage = new SchemaPathMessage(SchemaPath.create(absolute, paths)); + if (!absolute) { + throw new InvalidObjectException("Non-absolute path"); + } + schemaPathMessage = new SchemaPathMessage(Absolute.of(paths)); } private Object readResolve() { diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/action/InvokeActionMessage.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/action/InvokeActionMessage.java index 4b1ccfe6e6..e415b21b0d 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/action/InvokeActionMessage.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/action/InvokeActionMessage.java @@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.netconf.topology.singleton.messages.ContainerNodeMessage; import org.opendaylight.netconf.topology.singleton.messages.SchemaPathMessage; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; /** * Message container which holds node data in {@link SchemaPathMessage}, {@link ContainerNodeMessage} and @@ -46,7 +46,7 @@ public class InvokeActionMessage implements Serializable { this.domDataTreeIdentifier = requireNonNull(domDataTreeIdentifier); } - public SchemaPath getSchemaPath() { + public Absolute getSchemaPath() { return schemaPathMessage.getSchemaPath(); } diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/rpc/InvokeRpcMessage.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/rpc/InvokeRpcMessage.java index 70e2f44cb4..1324e7e2f8 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/rpc/InvokeRpcMessage.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/messages/rpc/InvokeRpcMessage.java @@ -15,7 +15,7 @@ import java.io.Serializable; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage; import org.opendaylight.netconf.topology.singleton.messages.SchemaPathMessage; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; public class InvokeRpcMessage implements Serializable { private static final long serialVersionUID = 1L; @@ -33,11 +33,10 @@ public class InvokeRpcMessage implements Serializable { return schemaPathMessage; } - public SchemaPath getSchemaPath() { + public Absolute getSchemaPath() { return schemaPathMessage.getSchemaPath(); } - public @Nullable NormalizedNodeMessage getNormalizedNodeMessage() { return normalizedNodeMessage; } diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/AbstractBaseSchemasTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/AbstractBaseSchemasTest.java index 7e10737bae..df1cf00744 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/AbstractBaseSchemasTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/AbstractBaseSchemasTest.java @@ -11,13 +11,14 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas; import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.DefaultBaseNetconfSchemas; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserException; import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl; public abstract class AbstractBaseSchemasTest { protected static BaseNetconfSchemas BASE_SCHEMAS; @BeforeClass - public static void initBaseSchemas() { + public static void initBaseSchemas() throws YangParserException { BASE_SCHEMAS = new DefaultBaseNetconfSchemas(new YangParserFactoryImpl()); } diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java index ca23590f89..4206858604 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java @@ -57,7 +57,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.aaa.encrypt.AAAEncryptionService; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.controller.cluster.ActorSystemProvider; import org.opendaylight.controller.config.threadpool.ScheduledThreadPool; import org.opendaylight.controller.config.threadpool.ThreadPool; @@ -72,6 +71,7 @@ import org.opendaylight.mdsal.binding.api.TransactionChainListener; import org.opendaylight.mdsal.binding.api.WriteTransaction; import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMActionProviderService; @@ -153,7 +153,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource; @@ -214,8 +213,8 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { private final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(Uint16.ZERO).build(); private EffectiveModelContext deviceSchemaContext; private YangModuleInfo topModuleInfo; - private SchemaPath putTopRpcSchemaPath; - private SchemaPath getTopRpcSchemaPath; + private QName putTopRpcSchemaPath; + private QName getTopRpcSchemaPath; private BindingNormalizedNodeSerializer bindingToNormalized; private YangInstanceIdentifier yangNodeInstanceId; private final TopDOMRpcImplementation topRpcImplementation = new TopDOMRpcImplementation(); @@ -237,8 +236,8 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { deviceRpcService.onModelContextUpdated(deviceSchemaContext); - putTopRpcSchemaPath = findRpcDefinition("put-top").getPath(); - getTopRpcSchemaPath = findRpcDefinition("get-top").getPath(); + putTopRpcSchemaPath = findRpcDefinition("put-top").getQName(); + getTopRpcSchemaPath = findRpcDefinition("get-top").getQName(); deviceRpcService.getRpcProviderService().registerRpcImplementation(topRpcImplementation, DOMRpcIdentifier.create(putTopRpcSchemaPath), DOMRpcIdentifier.create(getTopRpcSchemaPath)); @@ -532,12 +531,12 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { testRpc(domRpcService, getTopRpcSchemaPath, getTopInput, result); } - private void testRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath, + private void testRpc(final DOMRpcService domRpcService, final QName qname, final NormalizedNode input, final DOMRpcResult result) throws InterruptedException, ExecutionException, TimeoutException { final FluentFuture future = result == null ? FluentFutures.immediateNullFluentFuture() : FluentFutures.immediateFluentFuture(result); - final DOMRpcResult actual = invokeRpc(domRpcService, schemaPath, input, future); + final DOMRpcResult actual = invokeRpc(domRpcService, qname, input, future); if (result == null) { assertNull(actual); return; @@ -561,10 +560,10 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { } } - private void testFailedRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath, + private void testFailedRpc(final DOMRpcService domRpcService, final QName qname, final NormalizedNode input) throws InterruptedException, TimeoutException { try { - invokeRpc(domRpcService, schemaPath, input, FluentFutures.immediateFailedFluentFuture( + invokeRpc(domRpcService, qname, input, FluentFutures.immediateFailedFluentFuture( new ClusteringRpcException("mock"))); fail("Expected exception"); } catch (ExecutionException e) { @@ -573,13 +572,13 @@ public class MountPointEndToEndTest extends AbstractBaseSchemasTest { } } - private DOMRpcResult invokeRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath, + private DOMRpcResult invokeRpc(final DOMRpcService domRpcService, final QName qname, final NormalizedNode input, final FluentFuture returnFuture) throws InterruptedException, ExecutionException, TimeoutException { topRpcImplementation.init(returnFuture); - final ListenableFuture resultFuture = domRpcService.invokeRpc(schemaPath, input); + final ListenableFuture resultFuture = domRpcService.invokeRpc(qname, input); - topRpcImplementation.verify(DOMRpcIdentifier.create(schemaPath), input); + topRpcImplementation.verify(DOMRpcIdentifier.create(qname), input); return resultFuture.get(5, TimeUnit.SECONDS); } diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java index db0c42582d..0cefc4213a 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java @@ -83,6 +83,7 @@ import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.mdsal.dom.api.DOMRpcException; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult; import org.opendaylight.netconf.dom.api.NetconfDataTreeService; @@ -113,7 +114,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory; import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException; import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; @@ -315,11 +316,11 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { slaveRef.tell(new RegisterMountPoint(ImmutableList.of(SOURCE_IDENTIFIER1), masterRef), testKit.getRef()); verify(mockMountPointBuilder, timeout(5000)).register(); - verify(mockMountPointBuilder, after(500)).addInitialSchemaContext(mockSchemaContext); - verify(mockMountPointBuilder).addService(eq(DOMDataBroker.class), any()); + verify(mockMountPointBuilder, after(500)).addService(eq(DOMDataBroker.class), any()); verify(mockMountPointBuilder).addService(eq(DOMRpcService.class), any()); verify(mockMountPointBuilder).addService(eq(DOMActionService.class), any()); verify(mockMountPointBuilder).addService(eq(DOMNotificationService.class), any()); + verify(mockMountPointBuilder).addService(eq(DOMSchemaService.class), any()); verify(mockSchemaSourceReg1).close(); verify(mockRegistry, times(2)).registerSchemaSource(any(), withSourceId(SOURCE_IDENTIFIER1)); verify(mockSchemaRepository, times(2)).createEffectiveModelContextFactory(); @@ -493,7 +494,6 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { assertTrue(slaveDomRPCService instanceof ProxyDOMRpcService); final QName testQName = QName.create("", "TestQname"); - final SchemaPath schemaPath = SchemaPath.create(true, testQName); final NormalizedNode outputNode = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(testQName)) .withChild(ImmutableNodes.leafNode(testQName, "foo")).build(); @@ -503,7 +503,7 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { doReturn(FluentFutures.immediateNullFluentFuture()).when(mockDOMRpcService).invokeRpc(any(), any()); - DOMRpcResult result = slaveDomRPCService.invokeRpc(schemaPath, outputNode).get(2, TimeUnit.SECONDS); + DOMRpcResult result = slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS); assertEquals(null, result); @@ -512,7 +512,7 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(outputNode))) .when(mockDOMRpcService).invokeRpc(any(), any()); - result = slaveDomRPCService.invokeRpc(schemaPath, outputNode).get(2, TimeUnit.SECONDS); + result = slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS); assertEquals(outputNode, result.getResult()); assertTrue(result.getErrors().isEmpty()); @@ -522,7 +522,7 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(rpcError))) .when(mockDOMRpcService).invokeRpc(any(), any()); - result = slaveDomRPCService.invokeRpc(schemaPath, outputNode).get(2, TimeUnit.SECONDS); + result = slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS); assertNull(result.getResult()); assertEquals(rpcError, result.getErrors().iterator().next()); @@ -533,7 +533,7 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { .when(mockDOMRpcService).invokeRpc(any(), any()); final DOMRpcResult resultOutputError = - slaveDomRPCService.invokeRpc(schemaPath, outputNode).get(2, TimeUnit.SECONDS); + slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS); assertEquals(outputNode, resultOutputError.getResult()); assertEquals(rpcError, resultOutputError.getErrors().iterator().next()); @@ -541,7 +541,7 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { // RPC failure. doReturn(FluentFutures.immediateFailedFluentFuture(new ClusteringRpcException("mock"))) .when(mockDOMRpcService).invokeRpc(any(), any()); - final ListenableFuture future = slaveDomRPCService.invokeRpc(schemaPath, outputNode); + final ListenableFuture future = slaveDomRPCService.invokeRpc(testQName, outputNode); final ExecutionException e = assertThrows(ExecutionException.class, () -> future.get(2, TimeUnit.SECONDS)); final Throwable cause = e.getCause(); @@ -563,7 +563,7 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { assertTrue(slaveDomActionService instanceof ProxyDOMActionService); final QName testQName = QName.create("test", "2019-08-16", "TestActionQname"); - final SchemaPath schemaPath = SchemaPath.create(true, testQName); + final Absolute schemaPath = Absolute.of(testQName); final YangInstanceIdentifier yangIIdPath = YangInstanceIdentifier .create(new YangInstanceIdentifier.NodeIdentifier(testQName)); @@ -687,7 +687,7 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { masterRef), testKit.getRef()); verify(mockMountPointBuilder, timeout(5000)).register(); - verify(mockMountPointBuilder).addInitialSchemaContext(mockSchemaContext); + verify(mockMountPointBuilder).addService(eq(DOMSchemaService.class), any()); verify(mockMountPointBuilder).addService(eq(DOMDataBroker.class), any()); verify(mockMountPointBuilder).addService(eq(NetconfDataTreeService.class), any()); verify(mockMountPointBuilder).addService(eq(DOMRpcService.class), any()); @@ -708,7 +708,6 @@ public class NetconfNodeActorTest extends AbstractBaseSchemasTest { doNothing().when(mockMountPointReg).close(); - doReturn(mockMountPointBuilder).when(mockMountPointBuilder).addInitialSchemaContext(any()); doReturn(mockMountPointBuilder).when(mockMountPointBuilder).addService(any(), any()); doReturn(mockMountPointReg).when(mockMountPointBuilder).register(); } diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeManagerTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeManagerTest.java index fa6d7c5148..de17d6f588 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeManagerTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeManagerTest.java @@ -381,7 +381,6 @@ public class NetconfNodeManagerTest extends AbstractBaseSchemasTest { doNothing().when(mockMountPointReg).close(); - doReturn(mockMountPointBuilder).when(mockMountPointBuilder).addInitialSchemaContext(any()); doReturn(mockMountPointBuilder).when(mockMountPointBuilder).addService(any(), any()); doReturn(mockMountPointReg).when(mockMountPointBuilder).register(); diff --git a/netconf/netconf-topology/pom.xml b/netconf/netconf-topology/pom.xml index 66bd55bb8f..6276378136 100644 --- a/netconf/netconf-topology/pom.xml +++ b/netconf/netconf-topology/pom.xml @@ -16,6 +16,11 @@ NETCONF topology APIs bundle + + + false + + org.opendaylight.aaa diff --git a/netconf/netconf-util/pom.xml b/netconf/netconf-util/pom.xml index e267d30773..1bede7661d 100644 --- a/netconf/netconf-util/pom.xml +++ b/netconf/netconf-util/pom.xml @@ -22,6 +22,11 @@ ${project.artifactId} bundle + + + false + + diff --git a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfUtil.java b/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfUtil.java index 2bf0856092..5184d675e2 100644 --- a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfUtil.java +++ b/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfUtil.java @@ -133,7 +133,7 @@ public final class NetconfUtil { @SuppressWarnings("checkstyle:IllegalCatch") public static void writeNormalizedNode(final NormalizedNode normalized, final DOMResult result, - final SchemaPath schemaPath, final SchemaContext context) + final SchemaPath schemaPath, final EffectiveModelContext context) throws IOException, XMLStreamException { final XMLStreamWriter writer = XML_FACTORY.createXMLStreamWriter(result); try ( @@ -159,7 +159,7 @@ public final class NetconfUtil { public static void writeNormalizedNode(final NormalizedNode normalized, final @Nullable NormalizedMetadata metadata, final DOMResult result, final SchemaPath schemaPath, - final SchemaContext context) throws IOException, XMLStreamException { + final EffectiveModelContext context) throws IOException, XMLStreamException { if (metadata == null) { writeNormalizedNode(normalized, result, schemaPath, context); return; @@ -187,7 +187,7 @@ public final class NetconfUtil { } public static void writeFilter(final YangInstanceIdentifier query, final DOMResult result, - final SchemaPath schemaPath, final SchemaContext context) throws IOException, XMLStreamException { + final SchemaPath schemaPath, final EffectiveModelContext context) throws IOException, XMLStreamException { if (query.isEmpty()) { // No query at all return; @@ -215,7 +215,7 @@ public final class NetconfUtil { // FIXME: we probably need to propagate MountPointContext here and not just the child nodes final ContainerSchemaNode dataRead = new NodeContainerProxy(NETCONF_DATA_QNAME, - mountContext.getSchemaContext().getChildNodes()); + mountContext.getEffectiveModelContext().getChildNodes()); try (XmlParserStream xmlParserStream = XmlParserStream.create(writer, codecs, dataRead)) { xmlParserStream.traverse(value); } diff --git a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java b/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java index bd9a55c7fa..760409824a 100644 --- a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java +++ b/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java @@ -22,11 +22,12 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; import org.opendaylight.yangtools.yang.model.api.MustDefinition; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; -import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UsesNode; +import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement; +import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound; /** * Simple proxy for container like schema nodes, where user provides a collection of children schema nodes. @@ -93,11 +94,13 @@ public final class NodeContainerProxy implements ContainerSchemaNode { } @Override + @Deprecated public boolean isAugmenting() { throw new UnsupportedOperationException(); } @Override + @Deprecated public boolean isAddedByUses() { throw new UnsupportedOperationException(); } @@ -113,6 +116,7 @@ public final class NodeContainerProxy implements ContainerSchemaNode { } @Override + @Deprecated public SchemaPath getPath() { throw new UnsupportedOperationException(); } @@ -143,7 +147,7 @@ public final class NodeContainerProxy implements ContainerSchemaNode { } @Override - public Optional getWhenCondition() { + public Optional getWhenCondition() { return Optional.empty(); } @@ -151,4 +155,9 @@ public final class NodeContainerProxy implements ContainerSchemaNode { public Collection getMustConstraints() { return Collections.emptySet(); } + + @Override + public ContainerEffectiveStatement asEffectiveStatement() { + throw new UnsupportedOperationException(); + } } diff --git a/netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NetconfUtilTest.java b/netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NetconfUtilTest.java index 16842040a5..e05cb26e4f 100644 --- a/netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NetconfUtilTest.java +++ b/netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NetconfUtilTest.java @@ -18,7 +18,7 @@ import org.custommonkey.xmlunit.XMLUnit; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.netconf.api.xml.XmlUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.$YangModuleInfoImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; @@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.w3c.dom.Document; @@ -55,7 +55,7 @@ public class NetconfUtilTest { @Test public void testWriteNormalizedNode() throws Exception { - final SchemaContext context = BindingRuntimeHelpers.createEffectiveModel( + final EffectiveModelContext context = BindingRuntimeHelpers.createEffectiveModel( Collections.singletonList($YangModuleInfoImpl.getInstance())); final LeafNode username = Builders.leafBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create(Session.QNAME, "username"))) diff --git a/netconf/pom.xml b/netconf/pom.xml index 450ff03416..c3378925c2 100644 --- a/netconf/pom.xml +++ b/netconf/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/netconf/sal-netconf-connector/pom.xml b/netconf/sal-netconf-connector/pom.xml index e26e3952a1..d6c1fad524 100644 --- a/netconf/sal-netconf-connector/pom.xml +++ b/netconf/sal-netconf-connector/pom.xml @@ -150,6 +150,10 @@ org.opendaylight.yangtools yang-test-util + + org.opendaylight.netconf + netconf-test-models + diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/api/MessageTransformer.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/api/MessageTransformer.java index c51eb73dd1..4f37fe6094 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/api/MessageTransformer.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/api/MessageTransformer.java @@ -11,16 +11,17 @@ import org.opendaylight.mdsal.dom.api.DOMActionResult; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; public interface MessageTransformer { DOMNotification toNotification(M message); - M toRpcRequest(SchemaPath rpc, NormalizedNode node); + M toRpcRequest(QName rpc, NormalizedNode node); - DOMRpcResult toRpcResult(M message, SchemaPath rpc); + DOMRpcResult toRpcResult(M message, QName rpc); /** * Parse action into message for request. @@ -30,7 +31,7 @@ public interface MessageTransformer { * @param payload - input of action * @return message */ - default M toActionRequest(final SchemaPath action, final DOMDataTreeIdentifier domDataTreeIdentifier, + default M toActionRequest(final Absolute action, final DOMDataTreeIdentifier domDataTreeIdentifier, final NormalizedNode payload) { throw new UnsupportedOperationException(); } @@ -42,7 +43,7 @@ public interface MessageTransformer { * @param message - message to parsing * @return {@link DOMActionResult} */ - default DOMActionResult toActionResult(final SchemaPath action, final M message) { + default DOMActionResult toActionResult(final Absolute action, final M message) { throw new UnsupportedOperationException(); } } diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/DeviceActionFactoryImpl.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/DeviceActionFactoryImpl.java index 73077849cb..9c0828a91a 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/DeviceActionFactoryImpl.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/DeviceActionFactoryImpl.java @@ -26,7 +26,7 @@ import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.osgi.service.component.annotations.Component; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +48,7 @@ public class DeviceActionFactoryImpl implements DeviceActionFactory { return new DOMActionService() { @Override - public ListenableFuture invokeAction(final SchemaPath schemaPath, + public ListenableFuture invokeAction(final Absolute schemaPath, final DOMDataTreeIdentifier dataTreeIdentifier, final ContainerNode input) { requireNonNull(schemaPath); requireNonNull(dataTreeIdentifier); diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/LibraryModulesSchemas.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/LibraryModulesSchemas.java index 80ba6b1c4a..a8616b535a 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/LibraryModulesSchemas.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/LibraryModulesSchemas.java @@ -13,7 +13,7 @@ import static java.util.Objects.requireNonNull; import static javax.xml.bind.DatatypeConverter.printBase64Binary; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DATA_NODEID; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_NODEID; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; @@ -42,7 +42,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.stream.XMLStreamException; import javax.xml.transform.dom.DOMSource; import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemas; import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc; @@ -162,7 +162,7 @@ public final class LibraryModulesSchemas implements NetconfDeviceSchemas { final DOMRpcResult moduleListNodeResult; try { moduleListNodeResult = - deviceRpc.invokeRpc(NETCONF_GET_PATH, GET_MODULES_STATE_MODULE_LIST_RPC).get(); + deviceRpc.invokeRpc(NETCONF_GET_QNAME, GET_MODULES_STATE_MODULE_LIST_RPC).get(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(deviceId + ": Interrupted while waiting for response to " diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java index d62661f8e8..53169d03ed 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java @@ -161,7 +161,7 @@ public class NetconfDevice LOG.debug("{}: Session to remote device established with {}", id, remoteSessionCapabilities); final BaseSchema baseSchema = resolveBaseSchema(remoteSessionCapabilities.isNotificationsSupported()); - final NetconfDeviceRpc initRpc = new NetconfDeviceRpc(baseSchema.getSchemaContext(), listener, + final NetconfDeviceRpc initRpc = new NetconfDeviceRpc(baseSchema.getEffectiveModelContext(), listener, new NetconfMessageTransformer(baseSchema.getMountPointContext(), false, baseSchema)); final ListenableFuture sourceResolverFuture = processingExecutor.submit( new DeviceSourcesResolver(id, baseSchema, initRpc, remoteSessionCapabilities, stateSchemasResolver)); @@ -216,7 +216,7 @@ public class NetconfDevice // Perhaps add a default schema context to support create-subscription if the model was not provided // (same as what we do for base netconf operations in transformer) final ListenableFuture rpcResultListenableFuture = deviceRpc.invokeRpc( - NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_PATH, + NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_QNAME, NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_CONTENT); Futures.addCallback(rpcResultListenableFuture, new FutureCallback() { @@ -261,7 +261,7 @@ public class NetconfDevice // salFacade.onDeviceConnected has to be called before the notification handler is initialized this.salFacade.onDeviceConnected(result, remoteSessionCapabilities, deviceRpc, this.deviceActionFactory == null ? null : this.deviceActionFactory.createDeviceAction( - this.messageTransformer, listener, result.getSchemaContext())); + this.messageTransformer, listener, result.getEffectiveModelContext())); this.notificationHandler.onRemoteSchemaUp(this.messageTransformer); LOG.info("{}: Netconf connector initialized successfully", id); @@ -322,7 +322,7 @@ public class NetconfDevice final NetconfDeviceRpc deviceRpc = new NetconfDeviceRpc(schemaContext, listener, new NetconfMessageTransformer(emptyContext, false, baseSchema)); - return Futures.transform(deviceRpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_GET_PATH, + return Futures.transform(deviceRpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_GET_QNAME, Builders.containerBuilder().withNodeIdentifier(NETCONF_GET_NODEID) .withChild(NetconfMessageTransformUtil.toFilterStructure(RFC8528_SCHEMA_MOUNTS, schemaContext)) .build()), rpcResult -> processSchemaMounts(rpcResult, emptyContext), MoreExecutors.directExecutor()); @@ -374,7 +374,7 @@ public class NetconfDevice protected NetconfDeviceRpc getDeviceSpecificRpc(final MountPointContext result, final RemoteDeviceCommunicator listener) { - return new NetconfDeviceRpc(result.getSchemaContext(), listener, + return new NetconfDeviceRpc(result.getEffectiveModelContext(), listener, new NetconfMessageTransformer(result, true, baseSchemas.getBaseSchema())); } diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemas.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemas.java index 80923a3994..9147d9a389 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemas.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemas.java @@ -14,7 +14,7 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_FILTER_NODEID; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_FILTER_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_NODEID; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_TYPE_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId; @@ -126,7 +126,7 @@ public final class NetconfStateSchemas implements NetconfDeviceSchemas { final DOMRpcResult schemasNodeResult; try { - schemasNodeResult = deviceRpc.invokeRpc(NETCONF_GET_PATH, GET_SCHEMAS_RPC).get(); + schemasNodeResult = deviceRpc.invokeRpc(NETCONF_GET_QNAME, GET_SCHEMAS_RPC).get(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(id diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacade.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacade.java index a39fd14f82..2cc942e9da 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacade.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacade.java @@ -10,7 +10,7 @@ package org.opendaylight.netconf.sal.connect.netconf.sal; import static com.google.common.base.Preconditions.checkState; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps.getSourceNode; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_NODEID; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME; import com.google.common.util.concurrent.FutureCallback; @@ -34,9 +34,9 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransform import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -200,7 +200,7 @@ public final class KeepaliveSalFacade implements RemoteDeviceHandler invokeRpc(final SchemaPath type, - final NormalizedNode input) { + public ListenableFuture invokeRpc(final QName type, final NormalizedNode input) { final ListenableFuture rpcResultFuture = deviceRpc.invokeRpc(type, input); final ResponseWaiting responseWaiting = new ResponseWaiting(responseWaitingScheduler, rpcResultFuture); responseWaiting.start(); diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationService.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationService.java index d6bef5ffa3..c55643e625 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationService.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationService.java @@ -16,7 +16,7 @@ import org.opendaylight.mdsal.dom.api.DOMNotificationListener; import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +24,7 @@ public class NetconfDeviceNotificationService implements DOMNotificationService private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceNotificationService.class); - private final Multimap listeners = HashMultimap.create(); + private final Multimap listeners = HashMultimap.create(); // Notification publish is very simple and hijacks the thread of the caller // TODO shouldnt we reuse the implementation for notification router from sal-broker-impl ? @@ -42,15 +42,15 @@ public class NetconfDeviceNotificationService implements DOMNotificationService @Override public synchronized ListenerRegistration registerNotificationListener( - final T listener, final Collection types) { - for (final SchemaPath type : types) { + final T listener, final Collection types) { + for (final Absolute type : types) { listeners.put(type, listener); } - return new AbstractListenerRegistration(listener) { + return new AbstractListenerRegistration<>(listener) { @Override protected void removeRegistration() { - for (final SchemaPath type : types) { + for (final Absolute type : types) { listeners.remove(type, listener); } } @@ -59,7 +59,7 @@ public class NetconfDeviceNotificationService implements DOMNotificationService @Override public synchronized ListenerRegistration registerNotificationListener( - final T listener, final SchemaPath... types) { + final T listener, final Absolute... types) { return registerNotificationListener(listener, Lists.newArrayList(types)); } } diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpc.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpc.java index 0c48e518cc..1d34bee1f5 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpc.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpc.java @@ -27,10 +27,10 @@ import org.opendaylight.netconf.sal.connect.api.MessageTransformer; import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.NoOpListenerRegistration; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; /** * Invokes RPC by sending netconf message via listener. Also transforms result from NetconfMessage to CompositeNode. @@ -50,9 +50,9 @@ public final class NetconfDeviceRpc implements DOMRpcService { @Override @SuppressWarnings("checkstyle:IllegalCatch") - public ListenableFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { + public ListenableFuture invokeRpc(final QName type, final NormalizedNode input) { final ListenableFuture> delegateFuture = communicator.sendRequest( - transformer.toRpcRequest(type, input), type.getLastComponent()); + transformer.toRpcRequest(type, input), type); final SettableFuture ret = SettableFuture.create(); Futures.addCallback(delegateFuture, new FutureCallback>() { @@ -79,7 +79,7 @@ public final class NetconfDeviceRpc implements DOMRpcService { @Override public ListenerRegistration registerRpcListener(final T listener) { listener.onRpcAvailable(Collections2.transform(schemaContext.getOperations(), - input -> DOMRpcIdentifier.create(input.getPath()))); + input -> DOMRpcIdentifier.create(input.getQName()))); // NOOP, no rpcs appear and disappear in this implementation return NoOpListenerRegistration.of(listener); diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java index 1c09f0cf4f..4c27db3bcb 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceSalProvider.java @@ -23,6 +23,8 @@ import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.dom.api.NetconfDataTreeService; import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.concepts.ObjectRegistration; @@ -126,7 +128,7 @@ public class NetconfDeviceSalProvider implements AutoCloseable { final DOMMountPointService.DOMMountPointBuilder mountBuilder = mountService.createMountPoint(id.getTopologyPath()); - mountBuilder.addInitialSchemaContext(initialCtx); + mountBuilder.addService(DOMSchemaService.class, FixedDOMSchemaService.of(() -> initialCtx)); if (broker != null) { mountBuilder.addService(DOMDataBroker.class, broker); diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpc.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpc.java index 8fcf325f4d..afdec81767 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpc.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpc.java @@ -26,10 +26,10 @@ import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMes import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil; import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; /** * Invokes RPC by sending netconf message via listener. Also transforms result from NetconfMessage to CompositeNode. @@ -52,7 +52,7 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService { } @Override - public ListenableFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { + public ListenableFuture invokeRpc(final QName type, final NormalizedNode input) { final MessageTransformer transformer; if (input instanceof DOMSourceAnyxmlNode) { transformer = schemalessTransformer; @@ -66,10 +66,10 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService { } private ListenableFuture handleRpc( - final @NonNull SchemaPath type, final @NonNull NormalizedNode input, + final @NonNull QName type, final @NonNull NormalizedNode input, final MessageTransformer transformer) { final ListenableFuture> delegateFuture = listener.sendRequest( - transformer.toRpcRequest(type, input), type.getLastComponent()); + transformer.toRpcRequest(type, input), type); final SettableFuture ret = SettableFuture.create(); Futures.addCallback(delegateFuture, new FutureCallback>() { @@ -89,8 +89,8 @@ public final class SchemalessNetconfDeviceRpc implements DOMRpcService { return ret; } - private static boolean isBaseRpc(final SchemaPath type) { - return NetconfMessageTransformUtil.NETCONF_URI.equals(type.getLastComponent().getNamespace()); + private static boolean isBaseRpc(final QName type) { + return NetconfMessageTransformUtil.NETCONF_URI.equals(type.getNamespace()); } @Override diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java index 7a7772871f..3539685596 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProvider.java @@ -35,7 +35,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider; @@ -105,8 +104,7 @@ public final class NetconfRemoteSchemaYangSourceProvider implements SchemaSource final ContainerNode getSchemaRequest = createGetSchemaRequest(moduleName, revision); LOG.trace("{}: Loading YANG schema source for {}:{}", id, moduleName, revision); return Futures.transform( - rpc.invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.GET_SCHEMA_QNAME), getSchemaRequest), - input -> { + rpc.invokeRpc(NetconfMessageTransformUtil.GET_SCHEMA_QNAME, getSchemaRequest), input -> { // Transform composite node to string schema representation and then to ASTSchemaSource. if (input.getErrors().isEmpty()) { final Optional schemaString = getSchemaFromRpc(id, input.getResult()); diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformer.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformer.java index 9ad2417e81..f3c3641c2a 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformer.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformer.java @@ -23,14 +23,13 @@ import org.opendaylight.netconf.sal.connect.api.MessageTransformer; import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil; import org.opendaylight.netconf.sal.connect.util.MessageCounter; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -55,29 +54,26 @@ public class BaseRpcSchemalessTransformer implements MessageTransformer payload) { + public NetconfMessage toRpcRequest(final QName rpc, final NormalizedNode payload) { // In case no input for rpc is defined, we can simply construct the payload here - final QName rpcQName = rpc.getLastComponent(); - final RpcDefinition mappedRpc = Preconditions.checkNotNull(mappedRpcs.get(rpcQName), - "Unknown rpc %s, available rpcs: %s", rpcQName, mappedRpcs.keySet()); - final DOMResult domResult = NetconfMessageTransformUtil.prepareDomResultForRpcRequest(rpcQName, counter); + final RpcDefinition mappedRpc = Preconditions.checkNotNull(mappedRpcs.get(rpc), + "Unknown rpc %s, available rpcs: %s", rpc, mappedRpcs.keySet()); + final DOMResult domResult = NetconfMessageTransformUtil.prepareDomResultForRpcRequest(rpc, counter); if (mappedRpc.getInput().getChildNodes().isEmpty()) { return new NetconfMessage(domResult.getNode().getOwnerDocument()); } - Preconditions.checkNotNull(payload, "Transforming an rpc with input: %s, payload cannot be null", rpcQName); + Preconditions.checkNotNull(payload, "Transforming an rpc with input: %s, payload cannot be null", rpc); Preconditions.checkArgument(payload instanceof ContainerNode, - "Transforming an rpc with input: %s, payload has to be a container, but was: %s", rpcQName, payload); + "Transforming an rpc with input: %s, payload has to be a container, but was: %s", rpc, payload); - // Set the path to the input of rpc for the payload stream writer - final SchemaPath inputPath = rpc.createChild(YangConstants.operationInputQName(rpcQName.getModule())); final DOMResult result = domResult; - try { - NetconfMessageTransformUtil.writeNormalizedRpc((ContainerNode) payload, result, inputPath, modelContext); + NetconfMessageTransformUtil.writeNormalizedOperationInput((ContainerNode) payload, result, Absolute.of(rpc), + modelContext); } catch (final XMLStreamException | IOException | IllegalStateException e) { - throw new IllegalStateException("Unable to serialize " + inputPath, e); + throw new IllegalStateException("Unable to serialize input of " + rpc, e); } final Document node = result.getNode().getOwnerDocument(); @@ -86,10 +82,9 @@ public class BaseRpcSchemalessTransformer implements MessageTransformer normalizedNode; - final QName rpcQName = rpc.getLastComponent(); - if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpcQName)) { + if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpc)) { final Element xmlData = NetconfMessageTransformUtil.getDataSubtree(message.getDocument()); final Document data = XmlUtil.newDocument(); data.appendChild(data.importNode(xmlData, true)); @@ -104,7 +99,7 @@ public class BaseRpcSchemalessTransformer implements MessageTransformer mappedRpcs; private final Multimap mappedNotifications; private final boolean strictParsing; - private final ImmutableMap actions; + private final ImmutableMap actions; public NetconfMessageTransformer(final MountPointContext mountContext, final boolean strictParsing, final BaseSchema baseSchema) { this.counter = new MessageCounter(); this.mountContext = requireNonNull(mountContext); - final SchemaContext schemaContext = mountContext.getSchemaContext(); + final EffectiveModelContext schemaContext = mountContext.getEffectiveModelContext(); this.contextTree = DataSchemaContextTree.from(schemaContext); this.mappedRpcs = Maps.uniqueIndex(schemaContext.getOperations(), SchemaNode::getQName); - this.actions = Maps.uniqueIndex(getActions(schemaContext), ActionDefinition::getPath); + this.actions = Maps.uniqueIndex(getActions(schemaContext), + action -> Absolute.of(ImmutableList.copyOf(action.getPath().getPathFromRoot()))); // RFC6020 normal notifications this.mappedNotifications = Multimaps.index(schemaContext.getNotifications(), @@ -129,6 +131,7 @@ public class NetconfMessageTransformer implements MessageTransformer by using only static List getActions(final SchemaContext schemaContext) { final List builder = new ArrayList<>(); findAction(schemaContext, builder); @@ -201,8 +204,10 @@ public class NetconfMessageTransformer implements MessageTransformer findNestedNotification(final NetconfMessage message, final Element element) { - final Iterator modules = mountContext.getSchemaContext() + final Iterator modules = mountContext.getEffectiveModelContext() .findModules(URI.create(element.getNamespaceURI())).iterator(); if (!modules.hasNext()) { throw new IllegalArgumentException( @@ -320,14 +325,13 @@ public class NetconfMessageTransformer implements MessageTransformer payload) { + public NetconfMessage toRpcRequest(final QName rpc, final NormalizedNode payload) { // In case no input for rpc is defined, we can simply construct the payload here - final QName rpcQName = rpc.getLastComponent(); // Determine whether a base netconf operation is being invoked // and also check if the device exposed model for base netconf. // If no, use pre built base netconf operations model - final boolean needToUseBaseCtx = mappedRpcs.get(rpcQName) == null && isBaseOrNotificationRpc(rpcQName); + final boolean needToUseBaseCtx = mappedRpcs.get(rpc) == null && isBaseOrNotificationRpc(rpc); final ImmutableMap currentMappedRpcs; if (needToUseBaseCtx) { currentMappedRpcs = baseSchema.getMappedRpcs(); @@ -335,30 +339,28 @@ public class NetconfMessageTransformer implements MessageTransformer payload) { final ActionDefinition actionDef = actions.get(action); Preconditions.checkArgument(actionDef != null, "Action does not exist: %s", action); - final ContainerSchemaNode inputDef = actionDef.getInput(); + final InputSchemaNode inputDef = actionDef.getInput(); if (inputDef.getChildNodes().isEmpty()) { return new NetconfMessage(NetconfMessageTransformUtil.prepareDomResultForActionRequest(contextTree, - domDataTreeIdentifier, action, counter, - actionDef.getQName()).getNode().getOwnerDocument()); + domDataTreeIdentifier, counter, actionDef.getQName()).getNode().getOwnerDocument()); } Preconditions.checkNotNull(payload, "Transforming an action with input: %s, payload cannot be null", action); Preconditions.checkArgument(payload instanceof ContainerNode, "Transforming an action with input: %s, payload has to be a container, but was: %s", action, payload); - // Set the path to the input of action for the node stream writer final DOMResult result = NetconfMessageTransformUtil.prepareDomResultForActionRequest(contextTree, - domDataTreeIdentifier, inputDef.getPath(), counter, actionDef.getQName()); - + domDataTreeIdentifier, counter, actionDef.getQName()); try { - NetconfMessageTransformUtil.writeNormalizedRpc((ContainerNode) payload, result, inputDef.getPath(), - mountContext.getSchemaContext()); + NetconfMessageTransformUtil.writeNormalizedOperationInput((ContainerNode) payload, result, action, + mountContext.getEffectiveModelContext()); } catch (final XMLStreamException | IOException | IllegalStateException e) { - throw new IllegalStateException("Unable to serialize " + action, e); + throw new IllegalStateException("Unable to serialize input of " + action, e); } return new NetconfMessage(result.getNode().getOwnerDocument()); @@ -402,10 +401,9 @@ public class NetconfMessageTransformer implements MessageTransformer normalizedNode; - final QName rpcQName = rpc.getLastComponent(); - if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpcQName)) { + if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpc)) { normalizedNode = Builders.containerBuilder() .withNodeIdentifier(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_NODEID) .withChild(Builders.anyXmlBuilder() @@ -418,15 +416,15 @@ public class NetconfMessageTransformer implements MessageTransformer currentMappedRpcs; - if (mappedRpcs.get(rpcQName) == null && isBaseOrNotificationRpc(rpcQName)) { + if (mappedRpcs.get(rpc) == null && isBaseOrNotificationRpc(rpc)) { currentMappedRpcs = baseSchema.getMappedRpcs(); } else { currentMappedRpcs = mappedRpcs; } - final RpcDefinition rpcDefinition = currentMappedRpcs.get(rpcQName); + final RpcDefinition rpcDefinition = currentMappedRpcs.get(rpc); Preconditions.checkArgument(rpcDefinition != null, - "Unable to parse response of %s, the rpc is unknown", rpcQName); + "Unable to parse response of %s, the rpc is unknown", rpc); // In case no input for rpc is defined, we can simply construct the payload here normalizedNode = parseResult(message, rpcDefinition); @@ -435,7 +433,7 @@ public class NetconfMessageTransformer implements MessageTransformer input) { + public NetconfMessage toRpcRequest(final QName rpc, final NormalizedNode input) { final DOMSource payload = (DOMSource) input.getValue(); wrapPayload((Document) payload.getNode()); return new NetconfMessage((Document) ((DOMSourceAnyxmlNode) input).getValue().getNode()); @@ -84,7 +83,7 @@ public class SchemalessMessageTransformer implements MessageTransformer future = rpc.invokeRpc(NETCONF_LOCK_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_LOCK_QNAME, getLockContent(datastore)); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; } public ListenableFuture lockCandidate(final FutureCallback callback) { - final ListenableFuture future = rpc.invokeRpc(NETCONF_LOCK_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_LOCK_QNAME, getLockContent(NETCONF_CANDIDATE_QNAME)); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; } public ListenableFuture lockRunning(final FutureCallback callback) { - final ListenableFuture future = rpc.invokeRpc(NETCONF_LOCK_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_LOCK_QNAME, getLockContent(NETCONF_RUNNING_QNAME)); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; @@ -117,21 +117,21 @@ public final class NetconfBaseOps { requireNonNull(callback); requireNonNull(datastore); - final ListenableFuture future = rpc.invokeRpc(NETCONF_UNLOCK_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_UNLOCK_QNAME, getUnLockContent(datastore)); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; } public ListenableFuture unlockRunning(final FutureCallback callback) { - final ListenableFuture future = rpc.invokeRpc(NETCONF_UNLOCK_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_UNLOCK_QNAME, getUnLockContent(NETCONF_RUNNING_QNAME)); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; } public ListenableFuture unlockCandidate(final FutureCallback callback) { - final ListenableFuture future = rpc.invokeRpc(NETCONF_UNLOCK_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_UNLOCK_QNAME, getUnLockContent(NETCONF_CANDIDATE_QNAME)); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; @@ -140,7 +140,7 @@ public final class NetconfBaseOps { public ListenableFuture discardChanges(final FutureCallback callback) { requireNonNull(callback); - final ListenableFuture future = rpc.invokeRpc(NETCONF_DISCARD_CHANGES_PATH, null); + final ListenableFuture future = rpc.invokeRpc(NETCONF_DISCARD_CHANGES_QNAME, null); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; } @@ -148,7 +148,7 @@ public final class NetconfBaseOps { public ListenableFuture commit(final FutureCallback callback) { requireNonNull(callback); - final ListenableFuture future = rpc.invokeRpc(NETCONF_COMMIT_PATH, COMMIT_RPC_CONTENT); + final ListenableFuture future = rpc.invokeRpc(NETCONF_COMMIT_QNAME, COMMIT_RPC_CONTENT); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; } @@ -157,7 +157,7 @@ public final class NetconfBaseOps { final QName datastore) { requireNonNull(callback); - final ListenableFuture future = rpc.invokeRpc(NETCONF_VALIDATE_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_VALIDATE_QNAME, getValidateContent(requireNonNull(datastore))); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; @@ -175,7 +175,7 @@ public final class NetconfBaseOps { final QName source, final QName target) { requireNonNull(callback); - final ListenableFuture future = rpc.invokeRpc(NETCONF_COPY_CONFIG_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_COPY_CONFIG_QNAME, getCopyConfigContent(requireNonNull(source), requireNonNull(target))); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; @@ -195,10 +195,10 @@ public final class NetconfBaseOps { final ListenableFuture future; if (isFilterPresent(filterPath)) { final DataContainerChild node = transformer.toFilterStructure(filterPath.get()); - future = rpc.invokeRpc(NETCONF_GET_CONFIG_PATH, + future = rpc.invokeRpc(NETCONF_GET_CONFIG_QNAME, NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_NODEID, getSourceNode(datastore), node)); } else { - future = rpc.invokeRpc(NETCONF_GET_CONFIG_PATH, + future = rpc.invokeRpc(NETCONF_GET_CONFIG_QNAME, NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_NODEID, getSourceNode(datastore))); } @@ -241,10 +241,10 @@ public final class NetconfBaseOps { final Optional filterPath) { requireNonNull(callback); - final ListenableFuture future = rpc.invokeRpc(NETCONF_GET_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_GET_QNAME, isFilterPresent(filterPath) ? NetconfMessageTransformUtil.wrap(NETCONF_GET_NODEID, - toFilterStructure(filterPath.get(), mountContext.getSchemaContext())) + toFilterStructure(filterPath.get(), mountContext.getEffectiveModelContext())) : NetconfMessageTransformUtil.GET_RPC_CONTENT); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); return future; @@ -284,7 +284,7 @@ public final class NetconfBaseOps { final boolean rollback) { requireNonNull(callback); - final ListenableFuture future = rpc.invokeRpc(NETCONF_EDIT_CONFIG_PATH, + final ListenableFuture future = rpc.invokeRpc(NETCONF_EDIT_CONFIG_QNAME, getEditConfigContent(requireNonNull(datastore), requireNonNull(editStructure), modifyAction, rollback)); Futures.addCallback(future, callback, MoreExecutors.directExecutor()); diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfMessageTransformUtil.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfMessageTransformUtil.java index 93af4af58d..7d47c3c056 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfMessageTransformUtil.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfMessageTransformUtil.java @@ -56,6 +56,7 @@ import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; @@ -73,9 +74,11 @@ import org.opendaylight.yangtools.yang.data.impl.schema.SchemaOrderedNormalizedN import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -225,7 +228,7 @@ public final class NetconfMessageTransformUtil { } public static DataContainerChild toFilterStructure(final YangInstanceIdentifier identifier, - final SchemaContext ctx) { + final EffectiveModelContext ctx) { final Element element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_FILTER_QNAME.getLocalName(), Optional.of(NETCONF_FILTER_QNAME.getNamespace().toString())); element.setAttributeNS(NETCONF_FILTER_QNAME.getNamespace().toString(), NETCONF_TYPE_QNAME.getLocalName(), @@ -343,7 +346,7 @@ public final class NetconfMessageTransformUtil { } public static DOMSourceAnyxmlNode createEditConfigAnyxml( - final SchemaContext ctx, final YangInstanceIdentifier dataPath, + final EffectiveModelContext ctx, final YangInstanceIdentifier dataPath, final Optional operation, final Optional> lastChildOverride) { final NormalizedNode configContent; @@ -398,7 +401,7 @@ public final class NetconfMessageTransformUtil { } } - public static DataContainerChild createEditConfigStructure(final SchemaContext ctx, + public static DataContainerChild createEditConfigStructure(final EffectiveModelContext ctx, final YangInstanceIdentifier dataPath, final Optional operation, final Optional> lastChildOverride) { return Builders.choiceBuilder().withNodeIdentifier(EDIT_CONTENT_NODEID) @@ -456,8 +459,7 @@ public final class NetconfMessageTransformUtil { } public static DOMResult prepareDomResultForActionRequest(final DataSchemaContextTree dataSchemaContextTree, - final DOMDataTreeIdentifier domDataTreeIdentifier, final SchemaPath actionSchemaPath, - final MessageCounter counter, final QName action) { + final DOMDataTreeIdentifier domDataTreeIdentifier, final MessageCounter counter, final QName action) { final Document document = XmlUtil.newDocument(); final Element rpcNS = document.createElementNS(NETCONF_RPC_QNAME.getNamespace().toString(), NETCONF_RPC_QNAME.getLocalName()); @@ -511,15 +513,19 @@ public final class NetconfMessageTransformUtil { } @SuppressWarnings("checkstyle:IllegalCatch") - public static void writeNormalizedRpc(final ContainerNode normalized, final DOMResult result, - final SchemaPath schemaPath, - final SchemaContext baseNetconfCtx) throws IOException, XMLStreamException { + public static void writeNormalizedOperationInput(final ContainerNode normalized, final DOMResult result, + final Absolute operationPath, final EffectiveModelContext baseNetconfCtx) + throws IOException, XMLStreamException { + final QName inputQName = YangConstants.operationInputQName(operationPath.lastNodeIdentifier().getModule()); + // FIXME: eliminate this conversion + final SchemaPath inputPath = operationPath.asSchemaPath().createChild(inputQName); + final XMLStreamWriter writer = NetconfUtil.XML_FACTORY.createXMLStreamWriter(result); try { try (NormalizedNodeStreamWriter normalizedNodeStreamWriter = - XMLStreamNormalizedNodeStreamWriter.create(writer, baseNetconfCtx, schemaPath)) { + XMLStreamNormalizedNodeStreamWriter.create(writer, baseNetconfCtx, inputPath)) { try (SchemaOrderedNormalizedNodeWriter normalizedNodeWriter = - new SchemaOrderedNormalizedNodeWriter(normalizedNodeStreamWriter, baseNetconfCtx, schemaPath)) { + new SchemaOrderedNormalizedNodeWriter(normalizedNodeStreamWriter, baseNetconfCtx, inputPath)) { final Collection> value = normalized.getValue(); normalizedNodeWriter.write(value); normalizedNodeWriter.flush(); diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfRpcStructureTransformer.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfRpcStructureTransformer.java index 1755659009..57e0a54714 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfRpcStructureTransformer.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfRpcStructureTransformer.java @@ -60,13 +60,13 @@ class NetconfRpcStructureTransformer implements RpcStructureTransformer { final YangInstanceIdentifier dataPath, final Optional operation) { // FIXME: propagate MountPointContext - return NetconfMessageTransformUtil.createEditConfigAnyxml(mountContext.getSchemaContext(), dataPath, operation, - data); + return NetconfMessageTransformUtil.createEditConfigAnyxml(mountContext.getEffectiveModelContext(), dataPath, + operation, data); } @Override public DataContainerChild toFilterStructure(final YangInstanceIdentifier path) { // FIXME: propagate MountPointContext - return NetconfMessageTransformUtil.toFilterStructure(path, mountContext.getSchemaContext()); + return NetconfMessageTransformUtil.toFilterStructure(path, mountContext.getEffectiveModelContext()); } } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/AbstractBaseSchemasTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/AbstractBaseSchemasTest.java index cc34b40119..bcf455ea79 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/AbstractBaseSchemasTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/AbstractBaseSchemasTest.java @@ -11,13 +11,14 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas; import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.DefaultBaseNetconfSchemas; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserException; import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl; public abstract class AbstractBaseSchemasTest { protected static BaseNetconfSchemas BASE_SCHEMAS; @BeforeClass - public static void initBaseSchemas() { + public static void initBaseSchemas() throws YangParserException { BASE_SCHEMAS = new DefaultBaseNetconfSchemas(new YangParserFactoryImpl()); } @@ -25,5 +26,4 @@ public abstract class AbstractBaseSchemasTest { public static void freeBaseSchemas() { BASE_SCHEMAS = null; } - } 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 24e7aa5fda..fca46b3943 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 @@ -70,7 +70,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory; import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException; import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; @@ -585,8 +584,8 @@ public class NetconfDeviceTest extends AbstractTestModelTest { public MessageTransformer getMessageTransformer() throws Exception { final MessageTransformer messageTransformer = mockClass(MessageTransformer.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(NOTIFICATION).when(messageTransformer).toRpcRequest(any(QName.class), any(NormalizedNode.class)); + doReturn(RPC_RESULT).when(messageTransformer).toRpcResult(any(NetconfMessage.class), any(QName.class)); doReturn(COMPOSITE_NODE).when(messageTransformer).toNotification(any(NetconfMessage.class)); return messageTransformer; } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfNestedNotificationTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfNestedNotificationTest.java index 4727e217d5..487b672cfb 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfNestedNotificationTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfNestedNotificationTest.java @@ -28,7 +28,7 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; import org.w3c.dom.Document; import org.xml.sax.SAXException; @@ -55,8 +55,8 @@ public class NetconfNestedNotificationTest extends AbstractBaseSchemasTest { assertEquals("interface-enabled", root.getNodeType().getLocalName()); assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2008-07-08T00:01:00Z").toInstant(), ((DOMEvent) domNotification).getEventInstant()); - assertEquals(domNotification.getType(), SchemaPath.create(true, INTERFACES_QNAME, INTERFACE_QNAME, - INTERFACE_ENABLED_NOTIFICATION_QNAME)); + assertEquals(Absolute.of(INTERFACES_QNAME, INTERFACE_QNAME, INTERFACE_ENABLED_NOTIFICATION_QNAME), + domNotification.getType()); } private EffectiveModelContext getNotificationSchemaContext(final Collection yangResources) { diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemasTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemasTest.java index 73ec86f233..e6c05f3bbf 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemasTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfStateSchemasTest.java @@ -16,7 +16,6 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath; import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFailedFluentFuture; import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture; @@ -124,7 +123,7 @@ public class NetconfStateSchemasTest extends AbstractBaseSchemasTest { .withChild(data) .build(); doReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcReply))).when(rpc) - .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any()); + .invokeRpc(eq(NETCONF_GET_QNAME), any()); final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext); final Set availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames(); assertEquals(numberOfLegalSchemas, availableYangSchemasQNames.size()); @@ -143,7 +142,7 @@ public class NetconfStateSchemasTest extends AbstractBaseSchemasTest { @Test public void testCreateFail() throws Exception { - when(rpc.invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any())).thenReturn( + when(rpc.invokeRpc(eq(NETCONF_GET_QNAME), any())).thenReturn( immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("not available"))); final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext); final Set availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames(); @@ -154,7 +153,7 @@ public class NetconfStateSchemasTest extends AbstractBaseSchemasTest { public void testCreateRpcError() throws Exception { final RpcError rpcError = RpcResultBuilder.newError(RpcError.ErrorType.RPC, "fail", "fail"); doReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcError))).when(rpc) - .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any()); + .invokeRpc(eq(NETCONF_GET_QNAME), any()); final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext); final Set availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames(); Assert.assertTrue(availableYangSchemasQNames.isEmpty()); @@ -169,7 +168,7 @@ public class NetconfStateSchemasTest extends AbstractBaseSchemasTest { try { when(interruptedFuture.get()).thenThrow(new InterruptedException("interrupted")); doReturn(FluentFuture.from(interruptedFuture)).when(rpc) - .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any()); + .invokeRpc(eq(NETCONF_GET_QNAME), any()); NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext); } catch (final InterruptedException | ExecutionException e) { LOG.info("Operation failed.", e); @@ -195,6 +194,5 @@ public class NetconfStateSchemasTest extends AbstractBaseSchemasTest { Assert.assertEquals(schema2, schema1); Assert.assertNotEquals(schema1, schema3); Assert.assertNotEquals(schema2, schema3); - } } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfToRpcRequestTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfToRpcRequestTest.java index fc47f360c6..aad35a667d 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfToRpcRequestTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/NetconfToRpcRequestTest.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath; import java.util.Collection; import org.junit.Before; @@ -70,7 +69,7 @@ public class NetconfToRpcRequestTest extends AbstractBaseSchemasTest { .withChild(ImmutableNodes.leafNode(STREAM_NAME, "NETCONF")) .build(); - final NetconfMessage message = messageTransformer.toRpcRequest(toPath(SUBSCRIBE_RPC_NAME), root); + final NetconfMessage message = messageTransformer.toRpcRequest(SUBSCRIBE_RPC_NAME, root); assertNotNull(message); final Document xmlDoc = message.getDocument(); @@ -96,7 +95,7 @@ public class NetconfToRpcRequestTest extends AbstractBaseSchemasTest { + "\n" )); - messageTransformer.toRpcResult(response, toPath(EDIT_CONFIG_QNAME)); + messageTransformer.toRpcResult(response, EDIT_CONFIG_QNAME); } } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeResponseWaitingTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeResponseWaitingTest.java index 30d2a3f53b..371916784a 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeResponseWaitingTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeResponseWaitingTest.java @@ -13,7 +13,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps.getSourceNode; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_NODEID; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME; import com.google.common.util.concurrent.SettableFuture; @@ -95,7 +95,7 @@ public class KeepaliveSalFacadeResponseWaitingTest { //This settable future will be used to check the invokation of keepalive RPC. Should be never invoked. final SettableFuture keepaliveSettableFuture = SettableFuture.create(); - doReturn(keepaliveSettableFuture).when(deviceRpc).invokeRpc(NETCONF_GET_CONFIG_PATH, KEEPALIVE_PAYLOAD); + doReturn(keepaliveSettableFuture).when(deviceRpc).invokeRpc(NETCONF_GET_CONFIG_QNAME, KEEPALIVE_PAYLOAD); final DOMRpcResult keepaliveResult = new DefaultDOMRpcResult(Builders.containerBuilder().withNodeIdentifier( new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME)).build()); keepaliveSettableFuture.set(keepaliveResult); @@ -111,7 +111,7 @@ public class KeepaliveSalFacadeResponseWaitingTest { verify(deviceRpc, after(2000).times(1)).invokeRpc(null, null); //verify the keepalive RPC invoke. Should be never happen. - verify(deviceRpc, after(2000).never()).invokeRpc(NETCONF_GET_CONFIG_PATH, KEEPALIVE_PAYLOAD); + verify(deviceRpc, after(2000).never()).invokeRpc(NETCONF_GET_CONFIG_QNAME, KEEPALIVE_PAYLOAD); } private final class LocalNetconfSalFacade implements RemoteDeviceHandler { diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeTest.java index 655ac624f6..d8e0e78b3f 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/KeepaliveSalFacadeTest.java @@ -37,11 +37,11 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransform import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext; import org.opendaylight.yangtools.util.concurrent.FluentFutures; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; public class KeepaliveSalFacadeTest { @@ -103,24 +103,24 @@ public class KeepaliveSalFacadeTest { new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME)).build()); doReturn(FluentFutures.immediateFluentFuture(result)) - .when(deviceRpc).invokeRpc(any(SchemaPath.class), isNull()); + .when(deviceRpc).invokeRpc(any(QName.class), isNull()); doReturn(FluentFutures.immediateFluentFuture(result)) - .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(deviceRpc).invokeRpc(any(QName.class), any(ContainerNode.class)); keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc); verify(underlyingSalFacade).onDeviceConnected( isNull(), isNull(), any(DOMRpcService.class), isNull()); - verify(deviceRpc, timeout(15000).times(5)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + verify(deviceRpc, timeout(15000).times(5)).invokeRpc(any(QName.class), any(ContainerNode.class)); } @Test public void testKeepaliveRpcFailure() { doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("illegal-state"))) - .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(deviceRpc).invokeRpc(any(QName.class), any(ContainerNode.class)); keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc); @@ -128,7 +128,7 @@ public class KeepaliveSalFacadeTest { // Should disconnect the session verify(listener, timeout(15000).times(1)).disconnect(); - verify(deviceRpc, times(1)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + verify(deviceRpc, times(1)).invokeRpc(any(QName.class), any(ContainerNode.class)); } @Test @@ -137,7 +137,7 @@ public class KeepaliveSalFacadeTest { final DOMRpcResult rpcSuccessWithError = new DefaultDOMRpcResult(mock(RpcError.class)); doReturn(FluentFutures.immediateFluentFuture(rpcSuccessWithError)) - .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(deviceRpc).invokeRpc(any(QName.class), any(ContainerNode.class)); keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc); @@ -146,7 +146,7 @@ public class KeepaliveSalFacadeTest { // Shouldn't disconnect the session verify(listener, times(0)).disconnect(); - verify(deviceRpc, timeout(15000).times(1)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + verify(deviceRpc, timeout(15000).times(1)).invokeRpc(any(QName.class), any(ContainerNode.class)); } @Test @@ -158,7 +158,7 @@ public class KeepaliveSalFacadeTest { }).when(underlyingSalFacade).onDeviceConnected(isNull(), isNull(), any(DOMRpcService.class), isNull()); doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("illegal-state"))) - .when(deviceRpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(deviceRpc).invokeRpc(any(QName.class), any(ContainerNode.class)); keepaliveSalFacade = new KeepaliveSalFacade(REMOTE_DEVICE_ID, underlyingSalFacade, executorServiceSpy, 100L, 1L); @@ -166,7 +166,7 @@ public class KeepaliveSalFacadeTest { keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc); - proxyRpc.invokeRpc(mock(SchemaPath.class), mock(ContainerNode.class)); + proxyRpc.invokeRpc(QName.create("foo", "bar"), mock(ContainerNode.class)); verify(listener, times(1)).disconnect(); } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/MountInstanceTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/MountInstanceTest.java index c59b9d8aea..ace4a1d155 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/MountInstanceTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/MountInstanceTest.java @@ -8,6 +8,7 @@ package org.opendaylight.netconf.sal.connect.netconf.sal; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -18,13 +19,14 @@ import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.netconf.dom.api.NetconfDataTreeService; import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.IetfNetconfService; @@ -78,7 +80,7 @@ public class MountInstanceTest { public void testOnTopologyDeviceConnected() { mountInstance.onTopologyDeviceConnected(SCHEMA_CONTEXT, broker, null, rpcService, notificationService, null); - verify(mountPointBuilder).addInitialSchemaContext(SCHEMA_CONTEXT); + verify(mountPointBuilder).addService(eq(DOMSchemaService.class), any()); verify(mountPointBuilder).addService(DOMDataBroker.class, broker); verify(mountPointBuilder).addService(DOMRpcService.class, rpcService); verify(mountPointBuilder).addService(DOMNotificationService.class, notificationService); @@ -88,7 +90,7 @@ public class MountInstanceTest { public void testOnTopologyDeviceConnectedWithNetconfService() { mountInstance.onTopologyDeviceConnected(SCHEMA_CONTEXT, null, netconfService, rpcService, notificationService, null); - verify(mountPointBuilder).addInitialSchemaContext(SCHEMA_CONTEXT); + verify(mountPointBuilder).addService(eq(DOMSchemaService.class), any()); verify(mountPointBuilder).addService(NetconfDataTreeService.class, netconfService); verify(mountPointBuilder).addService(DOMRpcService.class, rpcService); verify(mountPointBuilder).addService(DOMNotificationService.class, notificationService); @@ -121,7 +123,7 @@ public class MountInstanceTest { public void testPublishNotification() { mountInstance.onTopologyDeviceConnected(SCHEMA_CONTEXT, broker, null, rpcService, notificationService, null); - verify(mountPointBuilder).addInitialSchemaContext(SCHEMA_CONTEXT); + verify(mountPointBuilder).addService(eq(DOMSchemaService.class), any()); verify(mountPointBuilder).addService(DOMNotificationService.class, notificationService); mountInstance.publish(notification); verify(notificationService).publishNotification(notification); diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDataTreeServiceImplTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDataTreeServiceImplTest.java index ca2e3b7c3a..e93158e8f6 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDataTreeServiceImplTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDataTreeServiceImplTest.java @@ -18,7 +18,6 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_LOCK_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath; import com.google.common.util.concurrent.ListenableFuture; import java.net.InetSocketAddress; @@ -33,7 +32,7 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMRpcService; @@ -49,9 +48,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.re import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext; import org.opendaylight.yangtools.util.concurrent.FluentFutures; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class NetconfDataTreeServiceImplTest extends AbstractTestModelTest { @@ -75,44 +74,43 @@ public class NetconfDataTreeServiceImplTest extends AbstractTestModelTest { @Test public void lock() { netconService.lock(); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_LOCK_QNAME)), any(ContainerNode.class)); + verify(rpcService).invokeRpc(eq(NETCONF_LOCK_QNAME), any(ContainerNode.class)); } @Test public void unlock() { netconService.unlock(); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_UNLOCK_QNAME)), any(ContainerNode.class)); + verify(rpcService).invokeRpc(eq(NETCONF_UNLOCK_QNAME), any(ContainerNode.class)); } @Test public void discardChanges() { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpcService) - .invokeRpc(any(SchemaPath.class), isNull()); + .invokeRpc(any(QName.class), isNull()); netconService.discardChanges(); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_DISCARD_CHANGES_QNAME)), isNull()); + verify(rpcService).invokeRpc(eq(NETCONF_DISCARD_CHANGES_QNAME), isNull()); } @Test public void get() { netconService.get(null); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any(ContainerNode.class)); + verify(rpcService).invokeRpc(eq(NETCONF_GET_QNAME), any(ContainerNode.class)); } @Test public void getConfig() { netconService.getConfig(null); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_GET_CONFIG_QNAME)), any(ContainerNode.class)); + verify(rpcService).invokeRpc(eq(NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class)); } @Test public void merge() { netconService.merge(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode(), Optional.empty()); - verify(rpcService).invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), - captor.capture()); + verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture()); final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest( - toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.getValue()); + NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue()); Assert.assertTrue(netconfMessage.toString().contains("operation=\"merge\"")); } @@ -120,11 +118,10 @@ public class NetconfDataTreeServiceImplTest extends AbstractTestModelTest { public void replace() { netconService.replace(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode(), Optional.empty()); - verify(rpcService).invokeRpc( - eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), captor.capture()); + verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture()); final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest( - toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.getValue()); + NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue()); Assert.assertTrue(netconfMessage.toString().contains("operation=\"replace\"")); } @@ -132,33 +129,30 @@ public class NetconfDataTreeServiceImplTest extends AbstractTestModelTest { public void create() { netconService.create(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode(), Optional.empty()); - verify(rpcService).invokeRpc( - eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), captor.capture()); + verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture()); final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest( - toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.getValue()); + NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue()); Assert.assertTrue(netconfMessage.toString().contains("operation=\"create\"")); } @Test public void delete() { netconService.delete(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId().getParent()); - verify(rpcService).invokeRpc( - eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), captor.capture()); + verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture()); final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest( - toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.getValue()); + NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue()); Assert.assertTrue(netconfMessage.toString().contains("operation=\"delete\"")); } @Test public void remove() { netconService.remove(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId().getParent()); - verify(rpcService).invokeRpc( - eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), captor.capture()); + verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture()); final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest( - toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.getValue()); + NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue()); Assert.assertTrue(netconfMessage.toString().contains("operation=\"remove\"")); } @@ -166,7 +160,7 @@ public class NetconfDataTreeServiceImplTest extends AbstractTestModelTest { public void commit() { List> resultsFutures = new ArrayList<>(); netconService.commit(resultsFutures); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_COMMIT_QNAME)), any(ContainerNode.class)); + verify(rpcService).invokeRpc(eq(NETCONF_COMMIT_QNAME), any(ContainerNode.class)); } private NetconfDataTreeServiceImpl getNetconService() { diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBrokerTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBrokerTest.java index 251851d8a5..3e21a60279 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBrokerTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceDataBrokerTest.java @@ -12,7 +12,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath; import java.net.InetSocketAddress; import java.util.Arrays; @@ -24,7 +23,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; @@ -41,9 +40,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.re import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.NetconfTcp; import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext; import org.opendaylight.yangtools.util.concurrent.FluentFutures; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; @RunWith(MockitoJUnitRunner.class) public class NetconfDeviceDataBrokerTest { @@ -66,7 +65,7 @@ public class NetconfDeviceDataBrokerTest { @Before public void setUp() throws Exception { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpcService) - .invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .invokeRpc(any(QName.class), any(ContainerNode.class)); dataBroker = getDataBroker(NetconfMessageTransformUtil.NETCONF_CANDIDATE_URI.toString()); } @@ -74,14 +73,14 @@ public class NetconfDeviceDataBrokerTest { public void testNewReadOnlyTransaction() throws Exception { final DOMDataTreeReadTransaction tx = dataBroker.newReadOnlyTransaction(); tx.read(LogicalDatastoreType.OPERATIONAL, null); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any(ContainerNode.class)); + verify(rpcService).invokeRpc(eq(NETCONF_GET_QNAME), any(ContainerNode.class)); } @Test public void testNewReadWriteTransaction() throws Exception { final DOMDataTreeReadWriteTransaction tx = dataBroker.newReadWriteTransaction(); tx.read(LogicalDatastoreType.OPERATIONAL, null); - verify(rpcService).invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any(ContainerNode.class)); + verify(rpcService).invokeRpc(eq(NETCONF_GET_QNAME), any(ContainerNode.class)); } @Test diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationServiceTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationServiceTest.java index 94694b42a1..4cf00b3780 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationServiceTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceNotificationServiceTest.java @@ -22,7 +22,7 @@ import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.mdsal.dom.api.DOMNotificationListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; public class NetconfDeviceNotificationServiceTest { @@ -42,8 +42,8 @@ public class NetconfDeviceNotificationServiceTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - final SchemaPath path1 = SchemaPath.create(true, QName.create(new URI("namespace1"), "path1")); - final SchemaPath path2 = SchemaPath.create(true, QName.create(new URI("namespace2"), "path2")); + final Absolute path1 = Absolute.of(QName.create(new URI("namespace1"), "path1")); + final Absolute path2 = Absolute.of(QName.create(new URI("namespace2"), "path2")); service = new NetconfDeviceNotificationService(); service.registerNotificationListener(listener1, path1); registration = service.registerNotificationListener(listener2, path2); diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpcTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpcTest.java index 6053e13534..360a021e64 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpcTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceRpcTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener; import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; import org.opendaylight.mdsal.dom.api.DOMRpcResult; @@ -50,7 +50,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.w3c.dom.Node; public class NetconfDeviceRpcTest extends AbstractBaseSchemasTest { @@ -62,7 +61,7 @@ public class NetconfDeviceRpcTest extends AbstractBaseSchemasTest { private RemoteDeviceCommunicator communicator; private NetconfDeviceRpc rpc; - private SchemaPath path; + private QName type; private DOMRpcResult expectedReply; @BeforeClass @@ -91,9 +90,8 @@ public class NetconfDeviceRpcTest extends AbstractBaseSchemasTest { .when(communicator).sendRequest(any(NetconfMessage.class), any(QName.class)); rpc = new NetconfDeviceRpc(SCHEMA_CONTEXT, communicator, transformer); - path = SchemaPath - .create(true, QName.create("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "get-config")); - expectedReply = transformer.toRpcResult(reply, path); + type = QName.create("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "get-config"); + expectedReply = transformer.toRpcResult(reply, type); } @Test @@ -106,14 +104,14 @@ public class NetconfDeviceRpcTest extends AbstractBaseSchemasTest { when(communicatorMock.sendRequest(any(), any())).thenReturn(Futures.immediateFuture(result)); when(failingTransformer.toRpcResult(any(), any())).thenThrow(new RuntimeException("FAIL")); final NetconfDeviceRpc failingRpc = new NetconfDeviceRpc(SCHEMA_CONTEXT, communicatorMock, failingTransformer); - assertThrows(ExecutionException.class, () -> failingRpc.invokeRpc(path, mock(ContainerNode.class)).get()); - assertThrows(ExecutionException.class, () -> failingRpc.invokeRpc(path, null).get()); + assertThrows(ExecutionException.class, () -> failingRpc.invokeRpc(type, mock(ContainerNode.class)).get()); + assertThrows(ExecutionException.class, () -> failingRpc.invokeRpc(type, null).get()); } @Test public void testInvokeRpc() throws Exception { ContainerNode input = createNode("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "filter"); - final DOMRpcResult result = rpc.invokeRpc(path, input).get(); + final DOMRpcResult result = rpc.invokeRpc(type, input).get(); assertEquals(expectedReply.getResult().getIdentifier(), result.getResult().getIdentifier()); assertEquals(resolveNode(expectedReply), resolveNode(result)); } @@ -137,7 +135,7 @@ public class NetconfDeviceRpcTest extends AbstractBaseSchemasTest { final Collection operations = SCHEMA_CONTEXT.getOperations(); assertEquals(argValue.size(), operations.size()); for (RpcDefinition operation : operations) { - final DOMRpcIdentifier domRpcIdentifier = DOMRpcIdentifier.create(operation.getPath()); + final DOMRpcIdentifier domRpcIdentifier = DOMRpcIdentifier.create(operation.getQName()); assertTrue(argValue.contains(domRpcIdentifier)); } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java index cb43fe3581..ce1330897b 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceTopologyAdapterTest.java @@ -31,6 +31,8 @@ import org.opendaylight.mdsal.binding.api.TransactionChain; import org.opendaylight.mdsal.binding.api.TransactionChainListener; import org.opendaylight.mdsal.binding.api.WriteTransaction; import org.opendaylight.mdsal.binding.dom.adapter.test.ConcurrentDataBrokerTestCustomizer; +import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; @@ -38,6 +40,7 @@ import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabi import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.augment.test.rev160808.Node1; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; @@ -46,11 +49,9 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; public class NetconfDeviceTopologyAdapterTest { - private static EffectiveModelContext SCHEMA_CONTEXT; + private static BindingRuntimeContext RUNTIME_CONTEXT; private final RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22)); @@ -73,15 +74,12 @@ public class NetconfDeviceTopologyAdapterTest { @BeforeClass public static void beforeClass() { - SCHEMA_CONTEXT = YangParserTestUtils.parseYangResources(NetconfDeviceTopologyAdapterTest.class, - "/schemas/network-topology@2013-10-21.yang", "/schemas/ietf-inet-types@2013-07-15.yang", - "/schemas/yang-ext.yang", "/schemas/netconf-node-topology.yang", - "/schemas/network-topology-augment-test@2016-08-08.yang", "/schemas/netconf-node-optional.yang"); + RUNTIME_CONTEXT = BindingRuntimeHelpers.createRuntimeContext(NetconfNode.class, Node1.class); } @AfterClass public static void afterClass() { - SCHEMA_CONTEXT = null; + RUNTIME_CONTEXT = null; } @Before @@ -98,7 +96,7 @@ public class NetconfDeviceTopologyAdapterTest { ConcurrentDataBrokerTestCustomizer customizer = new ConcurrentDataBrokerTestCustomizer(true); domDataBroker = customizer.getDOMDataBroker(); dataBroker = customizer.createDataBroker(); - customizer.updateSchema(SCHEMA_CONTEXT); + customizer.updateSchema(RUNTIME_CONTEXT); transactionChain = dataBroker.createTransactionChain(new TransactionChainListener() { @Override diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpcTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpcTest.java index 40c56f783a..88a324df1a 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpcTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/SchemalessNetconfDeviceRpcTest.java @@ -33,7 +33,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,7 +61,6 @@ public class SchemalessNetconfDeviceRpcTest extends AbstractBaseSchemasTest { @Test public void testInvokeRpc() throws Exception { final QName qName = QName.create("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "get-config"); - SchemaPath type = SchemaPath.create(true, qName); DOMSource src = new DOMSource(XmlUtil.readXmlToDocument("\n" + " \n" + " \n" @@ -79,7 +77,7 @@ public class SchemalessNetconfDeviceRpcTest extends AbstractBaseSchemasTest { .withValue(src) .build(); - deviceRpc.invokeRpc(type, input); + deviceRpc.invokeRpc(qName, input); ArgumentCaptor msgCaptor = ArgumentCaptor.forClass(NetconfMessage.class); ArgumentCaptor qnameCaptor = ArgumentCaptor.forClass(QName.class); verify(listener).sendRequest(msgCaptor.capture(), qnameCaptor.capture()); diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTxTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTxTest.java index 80aa6c4de1..54c1b7d074 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTxTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/NetconfDeviceWriteOnlyTxTest.java @@ -20,7 +20,6 @@ import static org.mockito.Mockito.verify; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_FILTER_QNAME; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath; import com.google.common.util.concurrent.FluentFuture; import java.net.InetSocketAddress; @@ -43,6 +42,7 @@ import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext; import org.opendaylight.yangtools.util.concurrent.FluentFutures; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -50,7 +50,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { @@ -69,7 +68,7 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { doReturn(successFuture) .doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("Failed tx"))) .doReturn(successFuture) - .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class)); yangIId = YangInstanceIdentifier.builder().node(NetconfState.QNAME).build(); } @@ -84,13 +83,13 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { tx.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier .create(new YangInstanceIdentifier.NodeIdentifier(NETCONF_FILTER_QNAME)), emptyList); - verify(rpc, atMost(1)).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + verify(rpc, atMost(1)).invokeRpc(any(QName.class), any(ContainerNode.class)); } @Test public void testDiscardChanges() throws InterruptedException { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))) - .when(rpc).invokeRpc(any(SchemaPath.class), isNull()); + .when(rpc).invokeRpc(any(QName.class), isNull()); final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(MountPointContext.class)), false); @@ -99,13 +98,13 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { } catch (final ExecutionException e) { // verify discard changes was sent final InOrder inOrder = inOrder(rpc); - inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME), + inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME, NetconfBaseOps.getLockContent(NETCONF_CANDIDATE_QNAME)); - inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME), + inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME, NetconfMessageTransformUtil.COMMIT_RPC_CONTENT); - inOrder.verify(rpc).invokeRpc(eq(toPath(NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_QNAME)), + inOrder.verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_QNAME), isNull()); - inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME), + inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME, NetconfBaseOps.getUnLockContent(NETCONF_CANDIDATE_QNAME)); return; } @@ -119,7 +118,7 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { new DefaultDOMRpcResult(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "a", "m"))); doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))) - .doReturn(rpcErrorFuture).when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .doReturn(rpcErrorFuture).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class)); final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(MountPointContext.class)), false); @@ -136,7 +135,7 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { public void testDiscardChangesNotSentWithoutCandidate() { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))) .doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("Failed tx"))) - .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class)); final WriteRunningTx tx = new WriteRunningTx(id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchemaWithNotifications().getMountPointContext()), false); @@ -145,18 +144,18 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { tx.commit(); // verify discard changes was sent final InOrder inOrder = inOrder(rpc); - inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME), + inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME, NetconfBaseOps.getLockContent(NETCONF_RUNNING_QNAME)); - inOrder.verify(rpc).invokeRpc(eq(toPath(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), + inOrder.verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), any(ContainerNode.class)); - inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME), + inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME, NetconfBaseOps.getUnLockContent(NETCONF_RUNNING_QNAME)); } @Test public void testListenerSuccess() throws Exception { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))) - .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class)); final WriteCandidateTx tx = new WriteCandidateTx( id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchema().getMountPointContext()), false); final TxListener listener = mock(TxListener.class); @@ -172,7 +171,7 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { @Test public void testListenerCancellation() throws Exception { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))) - .when(rpc).invokeRpc(any(SchemaPath.class), isNull()); + .when(rpc).invokeRpc(any(QName.class), isNull()); final WriteCandidateTx tx = new WriteCandidateTx( id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchema().getMountPointContext()), false); final TxListener listener = mock(TxListener.class); @@ -189,7 +188,7 @@ public class NetconfDeviceWriteOnlyTxTest extends AbstractBaseSchemasTest { public void testListenerFailure() throws Exception { final IllegalStateException cause = new IllegalStateException("Failed tx"); doReturn(FluentFutures.immediateFailedFluentFuture(cause)) - .when(rpc).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class)); final WriteCandidateTx tx = new WriteCandidateTx( id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchema().getMountPointContext()), false); final TxListener listener = mock(TxListener.class); diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/ReadOnlyTxTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/ReadOnlyTxTest.java index 69cd7061d7..e0656abe42 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/ReadOnlyTxTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/ReadOnlyTxTest.java @@ -28,10 +28,10 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransform import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext; import org.opendaylight.yangtools.util.concurrent.FluentFutures; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class ReadOnlyTxTest { @@ -43,7 +43,7 @@ public class ReadOnlyTxTest { @Before public void setUp() { doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(mockedNode))).when(rpc) - .invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + .invokeRpc(any(QName.class), any(ContainerNode.class)); } @Test @@ -54,11 +54,10 @@ public class ReadOnlyTxTest { new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196))); readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); - verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath( - NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME)), any(ContainerNode.class)); + verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME), + any(ContainerNode.class)); readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty()); - verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath( - NetconfMessageTransformUtil.NETCONF_GET_QNAME)), any(ContainerNode.class)); + verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME), any(ContainerNode.class)); } @Test @@ -69,11 +68,10 @@ public class ReadOnlyTxTest { new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196))); readOnlyTx.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); - verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath( - NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME)), any(ContainerNode.class)); + verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME), + any(ContainerNode.class)); readOnlyTx.exists(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty()); - verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.toPath( - NetconfMessageTransformUtil.NETCONF_GET_QNAME)), any(ContainerNode.class)); + verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME), any(ContainerNode.class)); } @Test diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTxTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTxTest.java index aabaf2edcc..2b60be978b 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTxTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTxTest.java @@ -39,7 +39,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class WriteCandidateRunningTxTest extends AbstractTestModelTest { @@ -63,23 +62,22 @@ public class WriteCandidateRunningTxTest extends AbstractTestModelTest { getLockContent(NETCONF_LOCK_QNAME, NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME); final ContainerNode runningLock = getLockContent(NETCONF_LOCK_QNAME, NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME); - verify(rpc).invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_LOCK_QNAME), runningLock); - verify(rpc).invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_LOCK_QNAME), candidateLock); + verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME, runningLock); + verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME, candidateLock); tx.put(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getContainerId(), TxTestUtils.getContainerNode()); tx.merge(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode()); //check, if both edits are called - verify(rpc, times(2)).invokeRpc( - eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), any()); + verify(rpc, times(2)).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), any()); tx.commit().get(); //check, if unlock is called - verify(rpc).invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME), + verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME, NetconfMessageTransformUtil.COMMIT_RPC_CONTENT); final ContainerNode candidateUnlock = getLockContent(NETCONF_UNLOCK_QNAME, NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME); final ContainerNode runningUnlock = getLockContent(NETCONF_UNLOCK_QNAME, NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME); - verify(rpc).invokeRpc(SchemaPath.create(true, NETCONF_UNLOCK_QNAME), candidateUnlock); - verify(rpc).invokeRpc(SchemaPath.create(true, NETCONF_UNLOCK_QNAME), runningUnlock); + verify(rpc).invokeRpc(NETCONF_UNLOCK_QNAME, candidateUnlock); + verify(rpc).invokeRpc(NETCONF_UNLOCK_QNAME, runningUnlock); } private static ContainerNode getLockContent(final QName op, final QName datastore) { diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTxTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTxTest.java index a18a922dd7..e3f62d1587 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTxTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTxTest.java @@ -28,7 +28,6 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransform import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext; import org.opendaylight.yangtools.util.concurrent.FluentFutures; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class WriteCandidateTxTest extends AbstractTestModelTest { @@ -48,17 +47,16 @@ public class WriteCandidateTxTest extends AbstractTestModelTest { public void testSubmit() throws Exception { final WriteCandidateTx tx = new WriteCandidateTx(id, netconfOps, true); //check, if lock is called - verify(rpc).invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_LOCK_QNAME)), any()); + verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME), any()); tx.put(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getContainerId(), TxTestUtils.getContainerNode()); tx.merge(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode()); //check, if both edits are called - verify(rpc, times(2)) - .invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), any()); + verify(rpc, times(2)).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), any()); tx.commit().get(); //check, if unlock is called - verify(rpc).invokeRpc(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME), + verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME, NetconfMessageTransformUtil.COMMIT_RPC_CONTENT); - verify(rpc).invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME)), any()); + verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME), any()); } } \ No newline at end of file diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTxTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTxTest.java index 5b492ba1b5..ac6d3d9463 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTxTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTxTest.java @@ -29,7 +29,6 @@ import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransform import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.opendaylight.yangtools.rcf8528.data.util.EmptyMountPointContext; import org.opendaylight.yangtools.util.concurrent.FluentFutures; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class WriteRunningTxTest extends AbstractTestModelTest { @@ -49,17 +48,15 @@ public class WriteRunningTxTest extends AbstractTestModelTest { public void testSubmit() throws Exception { final WriteRunningTx tx = new WriteRunningTx(id, netconfOps, true); //check, if lock is called - verify(rpc).invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_LOCK_QNAME)), any()); + verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME), any()); tx.put(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getContainerId(), TxTestUtils.getContainerNode()); tx.merge(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode()); //check, if no edit-config is called before submit - verify(rpc, never()) - .invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), any()); + verify(rpc, never()).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), any()); tx.commit().get(); //check, if both edits are called - verify(rpc, times(2)) - .invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME)), any()); + verify(rpc, times(2)).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), any()); //check, if unlock is called - verify(rpc).invokeRpc(eq(SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME)), any()); + verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME), any()); } } \ No newline at end of file diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProviderTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProviderTest.java index 78d509e08a..0a58c995be 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProviderTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/NetconfRemoteSchemaYangSourceProviderTest.java @@ -36,7 +36,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAnyXmlNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; @@ -56,7 +55,7 @@ public class NetconfRemoteSchemaYangSourceProviderTest { final DOMRpcResult value = new DefaultDOMRpcResult(getNode(), Collections.emptySet()); final FluentFuture response = FluentFutures.immediateFluentFuture(value); - doReturn(response).when(service).invokeRpc(any(SchemaPath.class), any(ContainerNode.class)); + doReturn(response).when(service).invokeRpc(any(QName.class), any(ContainerNode.class)); provider = new NetconfRemoteSchemaYangSourceProvider( new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("localhost", 17830)), service); @@ -67,8 +66,7 @@ public class NetconfRemoteSchemaYangSourceProviderTest { final SourceIdentifier identifier = RevisionSourceIdentifier.create("test", Revision.of("2016-02-08")); final YangTextSchemaSource source = provider.getSource(identifier).get(); Assert.assertEquals(identifier, source.getIdentifier()); - verify(service).invokeRpc( - SchemaPath.create(true, NetconfMessageTransformUtil.GET_SCHEMA_QNAME), + verify(service).invokeRpc(NetconfMessageTransformUtil.GET_SCHEMA_QNAME, NetconfRemoteSchemaYangSourceProvider.createGetSchemaRequest(identifier.getName(), identifier.getRevision().map(Revision::toString)) ); @@ -89,5 +87,4 @@ public class NetconfRemoteSchemaYangSourceProviderTest { ImmutableAnyXmlNodeBuilder.create().withNodeIdentifier(childId).withValue(v).build(); return ImmutableContainerNodeBuilder.create().withNodeIdentifier(id).withChild(child).build(); } - } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformerTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformerTest.java index 027518e24c..fb216b96ff 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformerTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/BaseRpcSchemalessTransformerTest.java @@ -31,7 +31,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -103,7 +102,7 @@ public class BaseRpcSchemalessTransformerTest extends AbstractBaseSchemasTest { .withChild(target) .build(); final NetconfMessage msg = transformer.toRpcRequest( - SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), editConfig); + NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, editConfig); final Diff diff = XMLUnit.compareXML(EXP_RPC, XmlUtil.toString(msg.getDocument())); Assert.assertTrue(diff.toString(), diff.similar()); } @@ -117,8 +116,7 @@ public class BaseRpcSchemalessTransformerTest extends AbstractBaseSchemasTest { final Element element = (Element) doc.importNode(dataElement, true); doc.getDocumentElement().appendChild(element); final NetconfMessage msg = new NetconfMessage(doc); - final DOMRpcResult result = transformer.toRpcResult(msg, - SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME)); + final DOMRpcResult result = transformer.toRpcResult(msg, NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME); Assert.assertNotNull(result.getResult()); final ContainerNode rpcReply = (ContainerNode) result.getResult(); Assert.assertEquals(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_QNAME, rpcReply.getNodeType()); diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java index b9079fed04..4366d5cdba 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java @@ -26,9 +26,9 @@ import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTr import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.createEditConfigStructure; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toFilterStructure; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath; import static org.opendaylight.netconf.util.NetconfUtil.NETCONF_DATA_QNAME; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import java.io.IOException; @@ -49,7 +49,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers; import org.opendaylight.mdsal.dom.api.DOMActionResult; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMRpcResult; @@ -86,7 +86,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; import org.opendaylight.yangtools.yang.model.api.ActionDefinition; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; import org.w3c.dom.Node; import org.xml.sax.SAXException; @@ -108,35 +108,33 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { private static final QName SERVER_QNAME = QName.create(URN_EXAMPLE_SERVER_FARM, REVISION_EXAMPLE_SERVER_FARM, "server"); private static final QName RESET_QNAME = QName.create(SERVER_QNAME, "reset"); - private static final SchemaPath RESET_SERVER_PATH = SchemaPath.create(true, SERVER_QNAME, RESET_QNAME); + private static final Absolute RESET_SERVER_PATH = Absolute.of(SERVER_QNAME, RESET_QNAME); private static final QName APPLICATIONS_QNAME = QName.create(URN_EXAMPLE_SERVER_FARM_2, REVISION_EXAMPLE_SERVER_FARM_2, "applications"); private static final QName APPLICATION_QNAME = QName.create(APPLICATIONS_QNAME, "application"); private static final QName KILL_QNAME = QName.create(APPLICATION_QNAME, "kill"); - private static final SchemaPath KILL_SERVER_APP_PATH = - SchemaPath.create(true, SERVER_QNAME, APPLICATIONS_QNAME, APPLICATION_QNAME, KILL_QNAME); + private static final Absolute KILL_SERVER_APP_PATH = + Absolute.of(SERVER_QNAME, APPLICATIONS_QNAME, APPLICATION_QNAME, KILL_QNAME); private static final QName DEVICE_QNAME = QName.create(URN_EXAMPLE_SERVER_FARM, REVISION_EXAMPLE_SERVER_FARM, "device"); private static final QName START_QNAME = QName.create(DEVICE_QNAME, "start"); - private static final SchemaPath START_DEVICE_PATH = SchemaPath.create(true, DEVICE_QNAME, START_QNAME); + private static final Absolute START_DEVICE_PATH = Absolute.of(DEVICE_QNAME, START_QNAME); private static final QName INTERFACE_QNAME = QName.create(DEVICE_QNAME, "interface"); private static final QName ENABLE_QNAME = QName.create(INTERFACE_QNAME, "enable"); - private static final SchemaPath ENABLE_INTERFACE_PATH = - SchemaPath.create(true, DEVICE_QNAME, INTERFACE_QNAME, ENABLE_QNAME); + private static final Absolute ENABLE_INTERFACE_PATH = Absolute.of(DEVICE_QNAME, INTERFACE_QNAME, ENABLE_QNAME); private static final QName DISABLE_QNAME = QName.create(URN_EXAMPLE_AUGMENTED_ACTION, "disable"); - private static final SchemaPath DISABLE_INTERFACE_PATH = - SchemaPath.create(true, DEVICE_QNAME, INTERFACE_QNAME, DISABLE_QNAME); + private static final Absolute DISABLE_INTERFACE_PATH = Absolute.of(DEVICE_QNAME, INTERFACE_QNAME, DISABLE_QNAME); private static final QName CHECK_WITH_OUTPUT_QNAME = QName.create(URN_EXAMPLE_RPCS_ACTIONS_OUTPUTS, "check-with-output"); - private static final SchemaPath CHECK_WITH_OUTPUT_INTERFACE_PATH = - SchemaPath.create(true, DEVICE_QNAME, INTERFACE_QNAME, CHECK_WITH_OUTPUT_QNAME); + private static final Absolute CHECK_WITH_OUTPUT_INTERFACE_PATH = + Absolute.of(DEVICE_QNAME, INTERFACE_QNAME, CHECK_WITH_OUTPUT_QNAME); private static final QName CHECK_WITHOUT_OUTPUT_QNAME = QName.create(URN_EXAMPLE_RPCS_ACTIONS_OUTPUTS, "check-without-output"); - private static final SchemaPath CHECK_WITHOUT_OUTPUT_INTERFACE_PATH = - SchemaPath.create(true, DEVICE_QNAME, INTERFACE_QNAME, CHECK_WITHOUT_OUTPUT_QNAME); + private static final Absolute CHECK_WITHOUT_OUTPUT_INTERFACE_PATH = + Absolute.of(DEVICE_QNAME, INTERFACE_QNAME, CHECK_WITHOUT_OUTPUT_QNAME); private static final QName RPC_WITH_OUTPUT_QNAME = QName.create(URN_EXAMPLE_RPCS_ACTIONS_OUTPUTS, "rpc-with-output"); private static final QName RPC_WITHOUT_OUTPUT_QNAME = @@ -146,20 +144,19 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { QName.create(URN_EXAMPLE_SERVER_FARM, REVISION_EXAMPLE_SERVER_FARM, "box-out"); private static final QName BOX_IN_QNAME = QName.create(BOX_OUT_QNAME, "box-in"); private static final QName OPEN_QNAME = QName.create(BOX_IN_QNAME, "open"); - private static final SchemaPath OPEN_BOXES_PATH = - SchemaPath.create(true, BOX_OUT_QNAME, BOX_IN_QNAME, OPEN_QNAME); + private static final Absolute OPEN_BOXES_PATH = Absolute.of(BOX_OUT_QNAME, BOX_IN_QNAME, OPEN_QNAME); private static final QName FOO_QNAME = QName.create(URN_EXAMPLE_CONFLICT, "foo"); private static final QName BAR_QNAME = QName.create(URN_EXAMPLE_CONFLICT, "bar"); private static final QName XYZZY_QNAME = QName.create(URN_EXAMPLE_CONFLICT, "xyzzy"); - private static final SchemaPath XYZZY_FOO_PATH = SchemaPath.create(true, FOO_QNAME, XYZZY_QNAME); - private static final SchemaPath XYZZY_BAR_PATH = SchemaPath.create(true, BAR_QNAME, XYZZY_QNAME); + private static final Absolute XYZZY_FOO_PATH = Absolute.of(FOO_QNAME, XYZZY_QNAME); + private static final Absolute XYZZY_BAR_PATH = Absolute.of(BAR_QNAME, XYZZY_QNAME); private static final QName CONFLICT_CHOICE_QNAME = QName.create(URN_EXAMPLE_CONFLICT, "conflict-choice"); private static final QName CHOICE_CONT_QNAME = QName.create(URN_EXAMPLE_CONFLICT, "choice-cont"); private static final QName CHOICE_ACTION_QNAME = QName.create(URN_EXAMPLE_CONFLICT, "choice-action"); - private static final SchemaPath CHOICE_ACTION_PATH = - SchemaPath.create(true, CONFLICT_CHOICE_QNAME, CHOICE_CONT_QNAME, CHOICE_CONT_QNAME, CHOICE_ACTION_QNAME); + private static final Absolute CHOICE_ACTION_PATH = + Absolute.of(CONFLICT_CHOICE_QNAME, CHOICE_CONT_QNAME, CHOICE_CONT_QNAME, CHOICE_ACTION_QNAME); private static EffectiveModelContext PARTIAL_SCHEMA; private static EffectiveModelContext SCHEMA; @@ -199,7 +196,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { @Test public void testLockRequestBaseSchemaNotPresent() throws Exception { final NetconfMessageTransformer transformer = getTransformer(PARTIAL_SCHEMA); - final NetconfMessage netconfMessage = transformer.toRpcRequest(toPath(NETCONF_LOCK_QNAME), + final NetconfMessage netconfMessage = transformer.toRpcRequest(NETCONF_LOCK_QNAME, NetconfBaseOps.getLockContent(NETCONF_CANDIDATE_QNAME)); assertThat(XmlUtil.toString(netconfMessage.getDocument()), CoreMatchers.containsString(""; - transformer.toRpcResult(new NetconfMessage(XmlUtil.readXmlToDocument(result)), toPath(NETCONF_LOCK_QNAME)); + transformer.toRpcResult(new NetconfMessage(XmlUtil.readXmlToDocument(result)), NETCONF_LOCK_QNAME); } @Test @@ -232,8 +227,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { final String result = ""; DOMRpcResult domRpcResult = actionNetconfMessageTransformer - .toRpcResult(new NetconfMessage(XmlUtil.readXmlToDocument(result)), - toPath(RPC_WITH_OUTPUT_QNAME)); + .toRpcResult(new NetconfMessage(XmlUtil.readXmlToDocument(result)), RPC_WITH_OUTPUT_QNAME); assertNotNull(domRpcResult); } @@ -242,15 +236,14 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { final String result = ""; DOMRpcResult domRpcResult = actionNetconfMessageTransformer - .toRpcResult(new NetconfMessage(XmlUtil.readXmlToDocument(result)), - toPath(RPC_WITHOUT_OUTPUT_QNAME)); + .toRpcResult(new NetconfMessage(XmlUtil.readXmlToDocument(result)), RPC_WITHOUT_OUTPUT_QNAME); assertNotNull(domRpcResult); } @Test public void testDiscardChangesRequest() throws Exception { final NetconfMessage netconfMessage = - netconfMessageTransformer.toRpcRequest(toPath(NETCONF_DISCARD_CHANGES_QNAME), null); + netconfMessageTransformer.toRpcRequest(NETCONF_DISCARD_CHANGES_QNAME, null); assertThat(XmlUtil.toString(netconfMessage.getDocument()), CoreMatchers.containsString("\n" + "\n" @@ -283,7 +276,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { + "\n" + "" )); - final DOMRpcResult compositeNodeRpcResult = transformer.toRpcResult(response, toPath(GET_SCHEMA_QNAME)); + final DOMRpcResult compositeNodeRpcResult = transformer.toRpcResult(response, GET_SCHEMA_QNAME); assertTrue(compositeNodeRpcResult.getErrors().isEmpty()); assertNotNull(compositeNodeRpcResult.getResult()); final DOMSource schemaContent = ((DOMSourceAnyxmlNode) ((ContainerNode) compositeNodeRpcResult.getResult()) @@ -310,8 +303,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { + "")); final NetconfMessageTransformer transformer = getTransformer(SCHEMA); - final DOMRpcResult compositeNodeRpcResult = - transformer.toRpcResult(response, toPath(NETCONF_GET_CONFIG_QNAME)); + final DOMRpcResult compositeNodeRpcResult = transformer.toRpcResult(response, NETCONF_GET_CONFIG_QNAME); assertTrue(compositeNodeRpcResult.getErrors().isEmpty()); assertNotNull(compositeNodeRpcResult.getResult()); @@ -352,7 +344,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { final DataContainerChild source = NetconfBaseOps.getSourceNode(NETCONF_RUNNING_QNAME); - final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(toPath(NETCONF_GET_CONFIG_QNAME), + final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NETCONF_GET_CONFIG_QNAME, NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_QNAME, source, filter)); assertSimilarXml(netconfMessage, "\n" @@ -380,7 +372,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { final DataContainerChild source = NetconfBaseOps.getSourceNode(NETCONF_RUNNING_QNAME); - final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(toPath(NETCONF_GET_CONFIG_QNAME), + final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NETCONF_GET_CONFIG_QNAME, NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_QNAME, source, filter)); assertSimilarXml(netconfMessage, "\n" @@ -424,8 +416,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { final ContainerNode wrap = NetconfMessageTransformUtil.wrap(NETCONF_EDIT_CONFIG_QNAME, editConfigStructure, target); - final NetconfMessage netconfMessage = - netconfMessageTransformer.toRpcRequest(toPath(NETCONF_EDIT_CONFIG_QNAME), wrap); + final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NETCONF_EDIT_CONFIG_QNAME, wrap); assertSimilarXml(netconfMessage, "\n" + "\n" @@ -462,7 +453,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { YangInstanceIdentifier.create(toId(NetconfState.QNAME), toId(Capabilities.QNAME), toId(capability), new NodeWithValue<>(capability, "a:b:c")), SCHEMA); - final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(toPath(NETCONF_GET_QNAME), + final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NETCONF_GET_QNAME, NetconfMessageTransformUtil.wrap(NETCONF_GET_QNAME, filter)); assertSimilarXml(netconfMessage, "" @@ -488,14 +479,14 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { "" )); final DOMRpcResult compositeNodeRpcResult = - netconfMessageTransformer.toRpcResult(response, toPath(NETCONF_COMMIT_QNAME)); + netconfMessageTransformer.toRpcResult(response, NETCONF_COMMIT_QNAME); assertTrue(compositeNodeRpcResult.getErrors().isEmpty()); assertNull(compositeNodeRpcResult.getResult()); } @Test public void getActionsTest() { - Set schemaPaths = new HashSet<>(); + Set schemaPaths = new HashSet<>(); schemaPaths.add(RESET_SERVER_PATH); schemaPaths.add(START_DEVICE_PATH); schemaPaths.add(ENABLE_INTERFACE_PATH); @@ -511,7 +502,7 @@ public class NetconfMessageTransformerTest extends AbstractBaseSchemasTest { List actions = NetconfMessageTransformer.getActions(ACTION_SCHEMA); assertEquals(schemaPaths.size(), actions.size()); for (ActionDefinition actionDefinition : actions) { - SchemaPath path = actionDefinition.getPath(); + Absolute path = Absolute.of(ImmutableList.copyOf(actionDefinition.getPath().getPathFromRoot())); assertTrue(schemaPaths.remove(path)); } } diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java index 2626180d5d..43c86d24ed 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java @@ -23,7 +23,6 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -48,9 +47,9 @@ public class SchemalessMessageTransformerTest { + "\n" + "\n"; - private SchemalessMessageTransformer transformer; private static final QName TEST_RPC = QName.create("test-ns", "2016-10-13", "test-rpc"); - private static final SchemaPath SCHEMA_PATH = SchemaPath.create(true, TEST_RPC); + + private SchemalessMessageTransformer transformer; @Before public void setUp() throws Exception { @@ -62,7 +61,7 @@ public class SchemalessMessageTransformerTest { final Document payload = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/notification-payload.xml")); final NetconfMessage netconfMessage = new NetconfMessage(payload); final DOMNotification domNotification = transformer.toNotification(netconfMessage); - Assert.assertEquals(domNotification.getType().getLastComponent(), + Assert.assertEquals(domNotification.getType().lastNodeIdentifier(), SchemalessMessageTransformer.SCHEMALESS_NOTIFICATION_PAYLOAD.getNodeType()); final QName qName = QName.create("org:opendaylight:notification:test:ns:yang:user-notification", "user-visited-page"); @@ -80,7 +79,7 @@ public class SchemalessMessageTransformerTest { .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_RPC)) .withValue(new DOMSource(src)) .build(); - final NetconfMessage netconfMessage = transformer.toRpcRequest(SCHEMA_PATH, input); + final NetconfMessage netconfMessage = transformer.toRpcRequest(TEST_RPC, input); final Diff diff = XMLUnit.compareXML(XmlUtil.readXmlToDocument(EXP_REQUEST), netconfMessage.getDocument()); Assert.assertTrue(diff.toString(), diff.similar()); } @@ -89,7 +88,7 @@ public class SchemalessMessageTransformerTest { public void toRpcResult() throws Exception { final Document doc = XmlUtil.readXmlToDocument(EXP_REPLY); final NetconfMessage netconfMessage = new NetconfMessage(doc); - final DOMRpcResult result = transformer.toRpcResult(netconfMessage, SCHEMA_PATH); + final DOMRpcResult result = transformer.toRpcResult(netconfMessage, TEST_RPC); final DOMSource value = (DOMSource) result.getResult().getValue(); Assert.assertNotNull(result.getResult()); final Document domSourceDoc = (Document) value.getNode(); @@ -101,7 +100,7 @@ public class SchemalessMessageTransformerTest { public void toEmptyRpcResult() throws Exception { final Document doc = XmlUtil.readXmlToDocument(OK_REPLY); final DOMRpcResult result = transformer.toRpcResult( - new NetconfMessage(doc), SchemaPath.create(true, NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME)); + new NetconfMessage(doc), NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME); Assert.assertNull(result.getResult()); } diff --git a/netconf/sal-netconf-connector/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang b/netconf/sal-netconf-connector/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang deleted file mode 100644 index 5c6f139a27..0000000000 --- a/netconf/sal-netconf-connector/src/test/resources/schemas/ietf-inet-types@2013-07-15.yang +++ /dev/null @@ -1,457 +0,0 @@ -module ietf-inet-types { - - namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types"; - prefix "inet"; - - organization - "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; - - contact - "WG Web: - WG List: - - WG Chair: David Kessens - - - WG Chair: Juergen Schoenwaelder - - - Editor: Juergen Schoenwaelder - "; - - description - "This module contains a collection of generally useful derived - YANG data types for Internet addresses and related things. - - Copyright (c) 2013 IETF Trust and the persons identified as - authors of the code. All rights reserved. - - Redistribution and use in source and binary forms, with or - without modification, is permitted pursuant to, and subject - to the license terms contained in, the Simplified BSD License - set forth in Section 4.c of the IETF Trust's Legal Provisions - Relating to IETF Documents - (http://trustee.ietf.org/license-info). - - This version of this YANG module is part of RFC 6991; see - the RFC itself for full legal notices."; - - revision 2013-07-15 { - description - "This revision adds the following new data types: - - ip-address-no-zone - - ipv4-address-no-zone - - ipv6-address-no-zone"; - reference - "RFC 6991: Common YANG Data Types"; - } - - revision 2010-09-24 { - description - "Initial revision."; - reference - "RFC 6021: Common YANG Data Types"; - } - - /*** collection of types related to protocol fields ***/ - - typedef ip-version { - type enumeration { - enum unknown { - value "0"; - description - "An unknown or unspecified version of the Internet - protocol."; - } - enum ipv4 { - value "1"; - description - "The IPv4 protocol as defined in RFC 791."; - } - enum ipv6 { - value "2"; - description - "The IPv6 protocol as defined in RFC 2460."; - } - } - description - "This value represents the version of the IP protocol. - - In the value set and its semantics, this type is equivalent - to the InetVersion textual convention of the SMIv2."; - reference - "RFC 791: Internet Protocol - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - typedef dscp { - type uint8 { - range "0..63"; - } - description - "The dscp type represents a Differentiated Services Code Point - that may be used for marking packets in a traffic stream. - In the value set and its semantics, this type is equivalent - to the Dscp textual convention of the SMIv2."; - reference - "RFC 3289: Management Information Base for the Differentiated - Services Architecture - RFC 2474: Definition of the Differentiated Services Field - (DS Field) in the IPv4 and IPv6 Headers - RFC 2780: IANA Allocation Guidelines For Values In - the Internet Protocol and Related Headers"; - } - - typedef ipv6-flow-label { - type uint32 { - range "0..1048575"; - } - description - "The ipv6-flow-label type represents the flow identifier or Flow - Label in an IPv6 packet header that may be used to - discriminate traffic flows. - - In the value set and its semantics, this type is equivalent - to the IPv6FlowLabel textual convention of the SMIv2."; - reference - "RFC 3595: Textual Conventions for IPv6 Flow Label - RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"; - } - - typedef port-number { - type uint16 { - range "0..65535"; - } - description - "The port-number type represents a 16-bit port number of an - Internet transport-layer protocol such as UDP, TCP, DCCP, or - SCTP. Port numbers are assigned by IANA. A current list of - all assignments is available from . - - Note that the port number value zero is reserved by IANA. In - situations where the value zero does not make sense, it can - be excluded by subtyping the port-number type. - In the value set and its semantics, this type is equivalent - to the InetPortNumber textual convention of the SMIv2."; - reference - "RFC 768: User Datagram Protocol - RFC 793: Transmission Control Protocol - RFC 4960: Stream Control Transmission Protocol - RFC 4340: Datagram Congestion Control Protocol (DCCP) - RFC 4001: Textual Conventions for Internet Network Addresses"; - } - - /*** collection of types related to autonomous systems ***/ - - typedef as-number { - type uint32; - description - "The as-number type represents autonomous system numbers - which identify an Autonomous System (AS). An AS is a set - of routers under a single technical administration, using - an interior gateway protocol and common metrics to route - packets within the AS, and using an exterior gateway - protocol to route packets to other ASes. IANA maintains - the AS number space and has delegated large parts to the - regional registries. - - Autonomous system numbers were originally limited to 16 - bits. BGP extensions have enlarged the autonomous system - number space to 32 bits. This type therefore uses an uint32 - base type without a range restriction in order to support - a larger autonomous system number space. - - In the value set and its semantics, this type is equivalent - to the InetAutonomousSystemNumber textual convention of - the SMIv2."; - reference - "RFC 1930: Guidelines for creation, selection, and registration - of an Autonomous System (AS) - RFC 4271: A Border Gateway Protocol 4 (BGP-4) - RFC 4001: Textual Conventions for Internet Network Addresses - RFC 6793: BGP Support for Four-Octet Autonomous System (AS) - Number Space"; - } - - /*** collection of types related to IP addresses and hostnames ***/ - - typedef ip-address { - type union { - type inet:ipv4-address; - type inet:ipv6-address; - } - description - "The ip-address type represents an IP address and is IP - version neutral. The format of the textual representation - implies the IP version. This type supports scoped addresses - by allowing zone identifiers in the address format."; - reference - "RFC 4007: IPv6 Scoped Address Architecture"; - } - - typedef ipv4-address { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '(%[\p{N}\p{L}]+)?'; - } - description - "The ipv4-address type represents an IPv4 address in - dotted-quad notation. The IPv4 address may include a zone - index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format for the zone index is the numerical - format"; - } - - typedef ipv6-address { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(%[\p{N}\p{L}]+)?'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(%.+)?'; - } - description - "The ipv6-address type represents an IPv6 address in full, - mixed, shortened, and shortened-mixed notation. The IPv6 - address may include a zone index, separated by a % sign. - - The zone index is used to disambiguate identical address - values. For link-local addresses, the zone index will - typically be the interface index number or the name of an - interface. If the zone index is not present, the default - zone of the device will be used. - - The canonical format of IPv6 addresses uses the textual - representation defined in Section 4 of RFC 5952. The - canonical format for the zone index is the numerical - format as described in Section 11.2 of RFC 4007."; - reference - "RFC 4291: IP Version 6 Addressing Architecture - RFC 4007: IPv6 Scoped Address Architecture - RFC 5952: A Recommendation for IPv6 Address Text - Representation"; - } - - typedef ip-address-no-zone { - type union { - type inet:ipv4-address-no-zone; - type inet:ipv6-address-no-zone; - } - description - "The ip-address-no-zone type represents an IP address and is - IP version neutral. The format of the textual representation - implies the IP version. This type does not support scoped - addresses since it does not allow zone identifiers in the - address format."; - reference - "RFC 4007: IPv6 Scoped Address Architecture"; - } - - typedef ipv4-address-no-zone { - type inet:ipv4-address { - pattern '[0-9\.]*'; - } - description - "An IPv4 address without a zone index. This type, derived from - ipv4-address, may be used in situations where the zone is - known from the context and hence no zone index is needed."; - } - - typedef ipv6-address-no-zone { - type inet:ipv6-address { - pattern '[0-9a-fA-F:\.]*'; - } - description - "An IPv6 address without a zone index. This type, derived from - ipv6-address, may be used in situations where the zone is - known from the context and hence no zone index is needed."; - reference - "RFC 4291: IP Version 6 Addressing Architecture - RFC 4007: IPv6 Scoped Address Architecture - RFC 5952: A Recommendation for IPv6 Address Text - Representation"; - } - - typedef ip-prefix { - type union { - type inet:ipv4-prefix; - type inet:ipv6-prefix; - } - description - "The ip-prefix type represents an IP prefix and is IP - version neutral. The format of the textual representations - implies the IP version."; - } - - typedef ipv4-prefix { - type string { - pattern - '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' - + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' - + '/(([0-9])|([1-2][0-9])|(3[0-2]))'; - } - description - "The ipv4-prefix type represents an IPv4 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal to 32. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The canonical format of an IPv4 prefix has all bits of - the IPv4 address set to zero that are not part of the - IPv4 prefix."; - } - - typedef ipv6-prefix { - type string { - pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' - + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' - + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' - + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' - + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'; - pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' - + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' - + '(/.+)'; - } - description - "The ipv6-prefix type represents an IPv6 address prefix. - The prefix length is given by the number following the - slash character and must be less than or equal to 128. - - A prefix length value of n corresponds to an IP address - mask that has n contiguous 1-bits from the most - significant bit (MSB) and all other bits set to 0. - - The IPv6 address should have all bits that do not belong - to the prefix set to zero. - - The canonical format of an IPv6 prefix has all bits of - the IPv6 address set to zero that are not part of the - IPv6 prefix. Furthermore, the IPv6 address is represented - as defined in Section 4 of RFC 5952."; - reference - "RFC 5952: A Recommendation for IPv6 Address Text - Representation"; - } - - /*** collection of domain name and URI types ***/ - - typedef domain-name { - type string { - pattern - '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' - + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' - + '|\.'; - length "1..253"; - } - description - "The domain-name type represents a DNS domain name. The - name SHOULD be fully qualified whenever possible. - - Internet domain names are only loosely specified. Section - 3.5 of RFC 1034 recommends a syntax (modified in Section - 2.1 of RFC 1123). The pattern above is intended to allow - for current practice in domain name use, and some possible - future expansion. It is designed to hold various types of - domain names, including names used for A or AAAA records - (host names) and other records, such as SRV records. Note - that Internet host names have a stricter syntax (described - in RFC 952) than the DNS recommendations in RFCs 1034 and - 1123, and that systems that want to store host names in - schema nodes using the domain-name type are recommended to - adhere to this stricter standard to ensure interoperability. - - The encoding of DNS names in the DNS protocol is limited - to 255 characters. Since the encoding consists of labels - prefixed by a length bytes and there is a trailing NULL - byte, only 253 characters can appear in the textual dotted - notation. - - The description clause of schema nodes using the domain-name - type MUST describe when and how these names are resolved to - IP addresses. Note that the resolution of a domain-name value - may require to query multiple DNS records (e.g., A for IPv4 - and AAAA for IPv6). The order of the resolution process and - which DNS record takes precedence can either be defined - explicitly or may depend on the configuration of the - resolver. - - Domain-name values use the US-ASCII encoding. Their canonical - format uses lowercase US-ASCII characters. Internationalized - domain names MUST be A-labels as per RFC 5890."; - reference - "RFC 952: DoD Internet Host Table Specification - RFC 1034: Domain Names - Concepts and Facilities - RFC 1123: Requirements for Internet Hosts -- Application - and Support - RFC 2782: A DNS RR for specifying the location of services - (DNS SRV) - RFC 5890: Internationalized Domain Names in Applications - (IDNA): Definitions and Document Framework"; - } - - typedef host { - type union { - type inet:ip-address; - type inet:domain-name; - } - description - "The host type represents either an IP address or a DNS - domain name."; - } - - typedef uri { - type string; - description - "The uri type represents a Uniform Resource Identifier - (URI) as defined by STD 66. - - Objects using the uri type MUST be in US-ASCII encoding, - and MUST be normalized as described by RFC 3986 Sections - 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary - percent-encoding is removed, and all case-insensitive - characters are set to lowercase except for hexadecimal - digits, which are normalized to uppercase as described in - Section 6.2.2.1. - - The purpose of this normalization is to help provide - unique URIs. Note that this normalization is not - sufficient to provide uniqueness. Two URIs that are - textually distinct after this normalization may still be - equivalent. - - Objects using the uri type may restrict the schemes that - they permit. For example, 'data:' and 'urn:' schemes - might not be appropriate. - - A zero-length URI is not a valid URI. This can be used to - express 'URI absent' where required. - - In the value set and its semantics, this type is equivalent - to the Uri SMIv2 textual convention defined in RFC 5017."; - reference - "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax - RFC 3305: Report from the Joint W3C/IETF URI Planning Interest - Group: Uniform Resource Identifiers (URIs), URLs, - and Uniform Resource Names (URNs): Clarifications - and Recommendations - RFC 5017: MIB Textual Conventions for Uniform Resource - Identifiers (URIs)"; - } - -} diff --git a/netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-optional.yang b/netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-optional.yang deleted file mode 100644 index 9ecbe6e4b7..0000000000 --- a/netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-optional.yang +++ /dev/null @@ -1,69 +0,0 @@ -module netconf-node-optional { - namespace "urn:opendaylight:netconf-node-optional"; - prefix "netnopt"; - - import network-topology { prefix nt; revision-date 2013-10-21; } - import yang-ext { prefix ext; revision-date "2013-07-09";} - - revision "2019-06-14" { - description "Initial revision of Node Optional model"; - } - - grouping netconf-node-augmented-optional-fields { - container ignore-missing-schema-sources { - description "Allows mount point to reconnect on the 'missing schema sources' error. - WARNING - enabling the reconnection on the 'missing schema sources' error can lead - to unexpected errors at runtime."; - leaf allowed { - type boolean; - default false; - description "Allows reconnection of the mount point. Default false."; - } - leaf reconnect-time { - type uint32; - default 5000; - description "Time for reconnection - in units milliseconds. Default 5000 ms."; - } - } - } - - container netconf-node-fields-optional { - description "Allows to create node's optional value with the path mapping according to - the network-topology -> topology -> node"; - list topology { - key topology-id; - leaf topology-id { - type nt:topology-id; - description "The name of node's topology"; - } - list node { - key node-id; - leaf node-id { - type nt:node-id; - description "The identifier of a node in the topology"; - } - // Containers allow to create specific data-change-listener directly on a node's optional value. - // In the future, it'll be easy to extend the node by optional node fields in this way. Do not create - // direct leafs here, please. - container datastore-lock { - description "Allows to ignore lock/unlock node's datastare."; - leaf datastore-lock-allowed { - type boolean; - default true; - description "The operation allows the client to lock the entire configuration datastore - system of a device. - WARNING - With blocking the lock/unlock operations, the user is coming to operate - in a manner which is not supported. Concurrent access to the data store may interfere - with data consistency."; - } - } - } - } - } - - augment "/nt:network-topology/nt:topology/nt:node/" { - when "../../nt:topology-types/topology-netconf"; - ext:augment-identifier "netconf-node-augmented-optional"; - uses netconf-node-augmented-optional-fields; - } -} diff --git a/netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-topology.yang b/netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-topology.yang deleted file mode 100644 index cb1948d8f9..0000000000 --- a/netconf/sal-netconf-connector/src/test/resources/schemas/netconf-node-topology.yang +++ /dev/null @@ -1,367 +0,0 @@ -module netconf-node-topology { - namespace "urn:opendaylight:netconf-node-topology"; - prefix "nettop"; - - import network-topology { prefix nt; revision-date 2013-10-21; } - import yang-ext { prefix ext; revision-date "2013-07-09";} - import ietf-inet-types { prefix inet; revision-date "2013-07-15"; } - import netconf-node-optional {prefix nno; revision-date "2019-06-14"; } - - revision "2015-01-14" { - description "Initial revision of Topology model"; - } - - augment "/nt:network-topology/nt:topology/nt:topology-types" { - container topology-netconf { - } - } - - grouping username-password { - leaf username { - type string; - } - - leaf password { - type string; - } - } - - grouping netconf-node-credentials { - choice credentials { - config true; - case login-password { - description "Deprecated way of storing credentials, unencrypted."; - - status deprecated; - uses username-password; - } - case login-pw { - description "login-password credentials, encrypted."; - - container login-password { - uses username-password; - } - } - case login-pw-unencrypted { - description "login-password credentials, not encrypted."; - - container login-password-unencrypted { - uses username-password; - } - } - case key-auth { - description "key-based authentication, use the id for the pair thats stored in the keystore."; - - container key-based { - leaf key-id { - type string; - } - - leaf username { - type string; - } - } - } - } - } - - grouping netconf-node-connection-parameters { - - leaf host { - type inet:host; - } - - leaf port { - type inet:port-number; - } - - leaf tcp-only { - config true; - type boolean; - } - - container protocol { - config true; - leaf name { - type enumeration { - enum SSH; - enum TLS; - } - default SSH; - } - - choice specification { - case tls-case { - container tls { - leaf-list excluded-versions { - type string; - description "A list of TLS version names provided in JDK that are not supported by the - target netconf device, eg, the netopeer2 simulator does not support the - SSLv2Hello. Most of the time, this list need not be set"; - } - } - } - } - } - - leaf schemaless { - type boolean; - default false; - } - - container yang-module-capabilities { - config true; - leaf override { - type boolean; - default false; - description "Whether to override or merge this list of capabilities with capabilities from device"; - } - - leaf-list capability { - type string; - description "Set a list of capabilities to override capabilities provided in device's hello message. - Can be used for devices that do not report any yang modules in their hello message"; - } - } - - container non-module-capabilities { - config true; - leaf override { - type boolean; - default false; - description "Whether to override or merge this list of non-module based capabilities with non-module - based capabilities from device"; - } - - leaf-list capability { - type string; - description "Set a list of non-module based capabilities to override or merge non-module capabilities - provided in device's hello message. Can be used for devices that do not report or - incorrectly report non-module based capabilities in their hello message"; - } - } - - leaf reconnect-on-changed-schema { - config true; - type boolean; - default false; - description "If true, the connector would auto disconnect/reconnect when schemas are changed in the remote device. - The connector subscribes (right after connect) to base netconf notifications and listens for netconf-capability-change notification"; - } - - leaf connection-timeout-millis { - description "Specifies timeout in milliseconds after which connection must be established."; - config true; - type uint32; - default 20000; - } - - leaf default-request-timeout-millis { - description "Timeout for blocking operations within transactions."; - config true; - type uint32; - default 60000; - } - - leaf max-connection-attempts { - description "Maximum number of connection retries. Non positive value or null is interpreted as infinity."; - config true; - type uint32; - default 0; // retry forever - } - - leaf between-attempts-timeout-millis { - description "Initial timeout in milliseconds to wait between connection attempts. Will be multiplied by sleep-factor with every additional attempt"; - config true; - type uint16; - default 2000; - } - - leaf sleep-factor { - config true; - type decimal64 { - fraction-digits 1; - } - default 1.5; - } - - // Keepalive configuration - leaf keepalive-delay { - config true; - type uint32; - default 120; - description "Netconf connector sends keepalive RPCs while the session is idle, this delay specifies the delay between keepalive RPC in seconds - If a value <1 is provided, no keepalives will be sent"; - } - - leaf concurrent-rpc-limit { - config true; - type uint16; - default 0; - description "Limit of concurrent messages that can be send before reply messages are received. - If value <1 is provided, no limit will be enforced"; - } - - leaf actor-response-wait-time { - config true; - type uint16 { - range "1..max"; - } - default 5; - description "Time that slave actor will wait for response from master."; - } - - container odl-hello-message-capabilities { - config true; - leaf-list capability { - type inet:uri; - description "Certain devices are non-accepting of ODL's hello message. This allows specification of - a custom ODL hello message based on a list of supported capabilities."; - } - } - } - - grouping netconf-node-connection-status { - - leaf connection-status { - config false; - type enumeration { - enum connecting; - enum connected; - enum unable-to-connect; - } - } - - container clustered-connection-status { - config false; - list node-status { - leaf node { - type string; - } - leaf status { - type enumeration { - enum connected; - enum unavailable; - enum failed; - } - } - } - leaf netconf-master-node { - config false; - type string; - } - } - - leaf connected-message { - config false; - type string; - } - - container available-capabilities { - config false; - list available-capability { - leaf capability { - type string; - } - leaf capability-origin { - type enumeration { - enum user-defined; - enum device-advertised; - } - } - } - } - - container unavailable-capabilities { - config false; - list unavailable-capability { - leaf capability { - type string; - } - - leaf failure-reason { - type enumeration { - enum missing-source; - enum unable-to-resolve; - } - } - } - } - - container pass-through { - when "../connection-status = connected"; - description - "When the underlying node is connected, its NETCONF context - is available verbatim under this container through the - mount extension."; - } - - } - - grouping netconf-schema-storage { - leaf schema-cache-directory { - config true; - type string; - default "schema"; - description "The destination schema repository for yang files relative to the cache directory. This may be specified per netconf mount - so that the loaded yang files are stored to a distinct directory to avoid potential conflict."; - } - - container yang-library { - leaf yang-library-url { - config true; - type inet:uri; - description "Yang library to be plugged as additional source provider into the shared schema repository"; - } - - // credentials for basic http authentication - leaf username { - config true; - type string; - } - - leaf password { - config true; - type string; - } - } - } - - grouping netconf-node-fields { - - uses netconf-node-credentials; - - uses netconf-node-connection-parameters; - - uses netconf-node-connection-status; - - uses netconf-schema-storage; - uses nno:netconf-node-augmented-optional-fields ; - - } - - rpc create-device { - input { - uses netconf-node-fields; - leaf node-id { - type string; - } - } - } - - rpc delete-device { - input { - leaf node-id { - type string; - } - } - } - - augment "/nt:network-topology/nt:topology/nt:node" { - when "../../nt:topology-types/topology-netconf"; - ext:augment-identifier "netconf-node"; - - uses netconf-node-fields; - } - -} diff --git a/netconf/sal-netconf-connector/src/test/resources/schemas/network-topology-augment-test@2016-08-08.yang b/netconf/sal-netconf-connector/src/test/resources/schemas/network-topology-augment-test@2016-08-08.yang deleted file mode 100644 index b0f6925275..0000000000 --- a/netconf/sal-netconf-connector/src/test/resources/schemas/network-topology-augment-test@2016-08-08.yang +++ /dev/null @@ -1,26 +0,0 @@ -module network-topology-network-topology-augment-test { - - namespace "urn:TBD:params:xml:ns:yang:network-topology-augment-test"; - import yang-ext { prefix ext; revision-date "2013-07-09";} - - import network-topology{ - prefix "nt"; - revision-date 2013-10-21; - } - prefix "ntat"; - - description - "This module defines test model for the topology of a network with augmented node"; - - revision 2016-08-08; - - augment /nt:network-topology/nt:topology/nt:node { - leaf test-id { - type uint16; - } - leaf test-name { - type string; - } - } - -} diff --git a/netconf/shaded-exificient-jar/pom.xml b/netconf/shaded-exificient-jar/pom.xml index 5ffecfdb39..6fe023ad7d 100644 --- a/netconf/shaded-exificient-jar/pom.xml +++ b/netconf/shaded-exificient-jar/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent odlparent - 7.0.6 + 8.0.0 diff --git a/netconf/shaded-exificient/pom.xml b/netconf/shaded-exificient/pom.xml index 220a1fc730..8ba32c54e4 100644 --- a/netconf/shaded-exificient/pom.xml +++ b/netconf/shaded-exificient/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent bundle-parent - 7.0.6 + 8.0.0 diff --git a/netconf/shaded-sshd-jar/pom.xml b/netconf/shaded-sshd-jar/pom.xml index e80443f809..cbcd4b9a51 100644 --- a/netconf/shaded-sshd-jar/pom.xml +++ b/netconf/shaded-sshd-jar/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent odlparent - 7.0.6 + 8.0.0 @@ -38,10 +38,17 @@ org.apache.sshd sshd-netty 2.5.1 + + + org.apache.sshd + sshd-core + + net.i2p.crypto eddsa + 0.3.0 diff --git a/netconf/shaded-sshd/pom.xml b/netconf/shaded-sshd/pom.xml index e7f9e0d9b6..e6d240766b 100644 --- a/netconf/shaded-sshd/pom.xml +++ b/netconf/shaded-sshd/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent bundle-parent - 7.0.6 + 8.0.0 diff --git a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/MdsalOperationProvider.java b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/MdsalOperationProvider.java index 500258e7f5..5a27953a05 100644 --- a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/MdsalOperationProvider.java +++ b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/MdsalOperationProvider.java @@ -7,8 +7,6 @@ */ package org.opendaylight.netconf.test.tool; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; import com.google.common.collect.Sets; import com.google.common.util.concurrent.MoreExecutors; import java.util.Collections; @@ -22,7 +20,6 @@ import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMDataBroker; import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; import org.opendaylight.mdsal.dom.api.DOMSchemaService; -import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension; import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker; import org.opendaylight.mdsal.dom.spi.store.DOMStore; import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreFactory; @@ -230,12 +227,6 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory { private DOMSchemaService createSchemaService() { return new DOMSchemaService() { - - @Override - public EffectiveModelContext getSessionContext() { - return schemaContext; - } - @Override public EffectiveModelContext getGlobalContext() { return schemaContext; @@ -246,18 +237,12 @@ class MdsalOperationProvider implements NetconfOperationServiceFactory { final EffectiveModelContextListener listener) { listener.onModelContextUpdated(getGlobalContext()); return new AbstractListenerRegistration<>(listener) { - @Override protected void removeRegistration() { // No-op } }; } - - @Override - public ClassToInstanceMap getExtensions() { - return ImmutableClassToInstanceMap.of(); - } }; } } diff --git a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java index df12515093..a4a541b1a6 100644 --- a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java +++ b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java @@ -60,6 +60,8 @@ import org.opendaylight.netconf.test.tool.schemacache.SchemaSourceCache; import org.opendaylight.yangtools.yang.common.Revision; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.ModuleLike; +import org.opendaylight.yangtools.yang.model.api.Submodule; import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; @@ -336,7 +338,7 @@ public class NetconfDeviceSimulator implements Closeable { final Set capabilities = new HashSet<>(); for (final Module module : schemaContext.getModules()) { - for (final Module subModule : module.getSubmodules()) { + for (final Submodule subModule : module.getSubmodules()) { addModuleCapability(consumer, capabilities, subModule); } addModuleCapability(consumer, capabilities, module); @@ -345,7 +347,7 @@ public class NetconfDeviceSimulator implements Closeable { } private static void addModuleCapability(final SharedSchemaRepository consumer, final Set capabilities, - final Module module) { + final ModuleLike module) { final SourceIdentifier moduleSourceIdentifier = RevisionSourceIdentifier.create(module.getName(), module.getRevision()); try { diff --git a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/TesttoolParameters.java b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/TesttoolParameters.java index b8cea1bdd4..3386c0fc53 100644 --- a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/TesttoolParameters.java +++ b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/TesttoolParameters.java @@ -310,7 +310,7 @@ public class TesttoolParameters { for (final File file : files) { final Matcher matcher = YANG_FILENAME_PATTERN.matcher(file.getName()); if (!matcher.matches()) { - try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + try (BufferedReader reader = new BufferedReader(new FileReader(file, StandardCharsets.UTF_8))) { String line = reader.readLine(); while (line != null && !REVISION_DATE_PATTERN.matcher(line).find()) { line = reader.readLine(); diff --git a/netconf/tools/pom.xml b/netconf/tools/pom.xml index 54e21d0c09..cdd4d146b5 100644 --- a/netconf/tools/pom.xml +++ b/netconf/tools/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/parent/pom.xml b/parent/pom.xml index 373240e163..1c81b898aa 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.mdsal binding-parent - 6.0.5 + 7.0.0 @@ -31,15 +31,15 @@ org.opendaylight.controller - controller-artifacts - 2.0.4 + bundle-parent + 3.0.0 pom import org.opendaylight.infrautils infrautils-artifacts - 1.8.1 + 1.9.0 pom import diff --git a/pom.xml b/pom.xml index 77aee4eeea..b0d66e3a29 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/restconf/pom.xml b/restconf/pom.xml index 8cad9539d1..6c1937587a 100644 --- a/restconf/pom.xml +++ b/restconf/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationDataSchemaNode.java b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationDataSchemaNode.java index b3cc2cc1b7..1a1ddc82d6 100644 --- a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationDataSchemaNode.java +++ b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationDataSchemaNode.java @@ -9,8 +9,8 @@ package org.opendaylight.restconf.common.util; import java.util.Optional; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath; import org.opendaylight.yangtools.yang.model.api.Status; +import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound; abstract class AbstractOperationDataSchemaNode implements DataSchemaNode { @Override @@ -24,11 +24,13 @@ abstract class AbstractOperationDataSchemaNode implements DataSchemaNode { } @Override + @Deprecated public final boolean isAugmenting() { return false; } @Override + @Deprecated public final boolean isAddedByUses() { return false; } @@ -44,7 +46,7 @@ abstract class AbstractOperationDataSchemaNode implements DataSchemaNode { } @Override - public final Optional getWhenCondition() { + public final Optional getWhenCondition() { return Optional.empty(); } } diff --git a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java index 0936edbaae..bf8b7ae336 100644 --- a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java +++ b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/AbstractOperationsModule.java @@ -7,13 +7,13 @@ */ package org.opendaylight.restconf.common.util; +import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import org.opendaylight.yangtools.concepts.SemVer; import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.UnqualifiedQName; import org.opendaylight.yangtools.yang.common.YangVersion; import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.Deviation; @@ -25,6 +25,7 @@ import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.ModuleImport; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; +import org.opendaylight.yangtools.yang.model.api.Submodule; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UsesNode; import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; @@ -62,8 +63,8 @@ abstract class AbstractOperationsModule implements Module, ModuleEffectiveStatem } @Override - public final String argument() { - return getName(); + public final UnqualifiedQName argument() { + return UnqualifiedQName.of(getName()); } @Override @@ -72,7 +73,7 @@ abstract class AbstractOperationsModule implements Module, ModuleEffectiveStatem } @Override - public final Set getImports() { + public final Collection getImports() { // Yeah, not accurate, but this should not be needed return Collections.emptySet(); } @@ -83,17 +84,17 @@ abstract class AbstractOperationsModule implements Module, ModuleEffectiveStatem } @Override - public final Set> getTypeDefinitions() { + public final Collection> getTypeDefinitions() { return Collections.emptySet(); } @Override - public final Set getGroupings() { + public final Collection getGroupings() { return Collections.emptySet(); } @Override - public final Set getUses() { + public final Collection getUses() { return Collections.emptySet(); } @@ -108,7 +109,7 @@ abstract class AbstractOperationsModule implements Module, ModuleEffectiveStatem } @Override - public final Set getNotifications() { + public final Collection getNotifications() { return Collections.emptySet(); } @@ -128,37 +129,42 @@ abstract class AbstractOperationsModule implements Module, ModuleEffectiveStatem } @Override - public final Set getSubmodules() { + public final Collection getSubmodules() { return Collections.emptySet(); } @Override - public final Set getFeatures() { + public final Collection getFeatures() { return Collections.emptySet(); } @Override - public final Set getAugmentations() { + public final Collection getAugmentations() { return Collections.emptySet(); } @Override - public final Set getRpcs() { + public final Collection getRpcs() { return Collections.emptySet(); } @Override - public final Set getDeviations() { + public final Collection getDeviations() { return Collections.emptySet(); } @Override - public final Set getIdentities() { + public final Collection getIdentities() { return Collections.emptySet(); } @Override - public final List getExtensionSchemaNodes() { + public final Collection getExtensionSchemaNodes() { return Collections.emptyList(); } + + @Override + public final ModuleEffectiveStatement asEffectiveStatement() { + throw new UnsupportedOperationException(); + } } diff --git a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsContainerSchemaNode.java b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsContainerSchemaNode.java index 47ac4b0a98..0e1c98736c 100644 --- a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsContainerSchemaNode.java +++ b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsContainerSchemaNode.java @@ -27,6 +27,7 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UsesNode; +import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement; final class OperationsContainerSchemaNode extends AbstractOperationDataSchemaNode implements ContainerSchemaNode { // There is no need to intern this nor add a revision, as we are providing the corresponding context anyway @@ -45,6 +46,7 @@ final class OperationsContainerSchemaNode extends AbstractOperationDataSchemaNod } @Override + @Deprecated public SchemaPath getPath() { return PATH; } @@ -99,4 +101,9 @@ final class OperationsContainerSchemaNode extends AbstractOperationDataSchemaNod public boolean isPresenceContainer() { return false; } + + @Override + public ContainerEffectiveStatement asEffectiveStatement() { + throw new UnsupportedOperationException(); + } } diff --git a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsLeafSchemaNode.java b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsLeafSchemaNode.java index ac664fa8c5..b042a45450 100644 --- a/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsLeafSchemaNode.java +++ b/restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/util/OperationsLeafSchemaNode.java @@ -15,6 +15,7 @@ import org.opendaylight.yangtools.yang.model.api.MustDefinition; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; +import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement; import org.opendaylight.yangtools.yang.model.util.type.BaseTypes; final class OperationsLeafSchemaNode extends AbstractOperationDataSchemaNode implements LeafSchemaNode { @@ -35,6 +36,7 @@ final class OperationsLeafSchemaNode extends AbstractOperationDataSchemaNode imp } @Override + @Deprecated public SchemaPath getPath() { return OperationsContainerSchemaNode.PATH.createChild(getQName()); } @@ -49,4 +51,9 @@ final class OperationsLeafSchemaNode extends AbstractOperationDataSchemaNode imp public Collection getMustConstraints() { return Collections.emptySet(); } + + @Override + public LeafEffectiveStatement asEffectiveStatement() { + throw new UnsupportedOperationException(); + } } diff --git a/restconf/restconf-models/pom.xml b/restconf/restconf-models/pom.xml index dfe429a42b..a1bafd6cf4 100644 --- a/restconf/restconf-models/pom.xml +++ b/restconf/restconf-models/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/restconf/restconf-nb-bierman02/pom.xml b/restconf/restconf-nb-bierman02/pom.xml index c1385521c1..ecc42bbb3f 100644 --- a/restconf/restconf-nb-bierman02/pom.xml +++ b/restconf/restconf-nb-bierman02/pom.xml @@ -20,6 +20,11 @@ 1.13.0-SNAPSHOT bundle + + + false + + javax.annotation diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java index e603060614..0f308b0338 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java @@ -251,8 +251,8 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider } else { edit.setTarget(codec.deserialize(codec.serialize(path.getInstanceIdentifier()).concat(target))); edit.setTargetSchemaNode(SchemaContextUtil.findDataSchemaNode(path.getSchemaContext(), - codec.getDataContextTree().getChild(edit.getTarget()).getDataSchemaNode().getPath() - .getParent())); + codec.getDataContextTree().findChild(edit.getTarget()).orElseThrow().getDataSchemaNode() + .getPath().getParent())); } break; diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeXmlBodyWriter.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeXmlBodyWriter.java index 31682fa154..8305a7407e 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeXmlBodyWriter.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeXmlBodyWriter.java @@ -43,7 +43,6 @@ import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStr import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.xml.sax.SAXException; @@ -141,7 +140,7 @@ public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter depth) { + final EffectiveModelContext schemaContext, final SchemaPath schemaPath, final Optional depth) { final NormalizedNodeStreamWriter xmlStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, schemaContext, schemaPath); if (depth.isPresent()) { diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/StringModuleInstanceIdentifierCodec.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/StringModuleInstanceIdentifierCodec.java index 28460395a3..318ddea533 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/StringModuleInstanceIdentifierCodec.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/StringModuleInstanceIdentifierCodec.java @@ -13,6 +13,7 @@ import java.net.URI; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -28,13 +29,13 @@ public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStr private final SchemaContext context; private final String defaultPrefix; - public StringModuleInstanceIdentifierCodec(final SchemaContext context) { + public StringModuleInstanceIdentifierCodec(final EffectiveModelContext context) { this.context = requireNonNull(context); this.dataContextTree = DataSchemaContextTree.from(context); this.defaultPrefix = ""; } - StringModuleInstanceIdentifierCodec(final SchemaContext context, final @NonNull String defaultPrefix) { + StringModuleInstanceIdentifierCodec(final EffectiveModelContext context, final @NonNull String defaultPrefix) { this.context = requireNonNull(context); this.dataContextTree = DataSchemaContextTree.from(context); this.defaultPrefix = defaultPrefix; diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java index e3c4b73138..1b8435b38e 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlNormalizedNodeBodyReader.java @@ -51,7 +51,7 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; @@ -160,7 +160,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPro final NormalizedNodeResult resultHolder = new NormalizedNodeResult(); final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder); - if (schemaNode instanceof ContainerSchemaNode || schemaNode instanceof ListSchemaNode + if (schemaNode instanceof ContainerLike || schemaNode instanceof ListSchemaNode || schemaNode instanceof LeafSchemaNode) { final XmlParserStream xmlParser = XmlParserStream.create(writer, pathContext.getSchemaContext(), schemaNode); diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java index b980357d4c..a1f3b4b159 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/rest/impl/XmlToPatchBodyReader.java @@ -158,11 +158,12 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i module.getQNameModule().getRevision().map(Revision::toString).orElse(null)))); targetNode = SchemaContextUtil.findDataSchemaNode(pathContext.getSchemaContext(), - codec.getDataContextTree().getChild(targetII).getDataSchemaNode().getPath().getParent()); + codec.getDataContextTree().findChild(targetII).orElseThrow().getDataSchemaNode().getPath() + .getParent()); // move schema node schemaNode = (DataSchemaNode) SchemaContextUtil.findDataSchemaNode(pathContext.getSchemaContext(), - codec.getDataContextTree().getChild(targetII).getDataSchemaNode().getPath()); + codec.getDataContextTree().findChild(targetII).orElseThrow().getDataSchemaNode().getPath()); } if (targetNode == null) { diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java index be5256e883..8add32b987 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java @@ -48,6 +48,7 @@ import org.opendaylight.mdsal.dom.api.DOMNotificationListener; import org.opendaylight.mdsal.dom.api.DOMNotificationService; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.netconf.sal.streams.listeners.ListenerAdapter; import org.opendaylight.netconf.sal.streams.listeners.NotificationListenerAdapter; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; @@ -86,11 +87,13 @@ import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,7 +108,7 @@ public class BrokerFacade implements Closeable { private final DOMNotificationService domNotification; private final ControllerContext controllerContext; - private ThreadLocal isMounted = new ThreadLocal<>(); + private final ThreadLocal isMounted = new ThreadLocal<>(); @Inject public BrokerFacade(final @Reference DOMRpcService rpcService, final DOMDataBroker domDataBroker, @@ -248,8 +251,8 @@ public class BrokerFacade implements Closeable { * @return wrapper of status and future of PUT */ public PutResult commitConfigurationDataPut( - final SchemaContext globalSchema, final YangInstanceIdentifier path, final NormalizedNode payload, - final String insert, final String point) { + final EffectiveModelContext globalSchema, final YangInstanceIdentifier path, + final NormalizedNode payload, final String insert, final String point) { Preconditions.checkNotNull(globalSchema); Preconditions.checkNotNull(path); Preconditions.checkNotNull(payload); @@ -299,8 +302,7 @@ public class BrokerFacade implements Closeable { final Status status = readDataViaTransaction(newReadWriteTransaction, CONFIGURATION, path) != null ? Status.OK : Status.CREATED; final FluentFuture future = putDataViaTransaction( - newReadWriteTransaction, CONFIGURATION, path, payload, mountPoint.getSchemaContext(), insert, - point); + newReadWriteTransaction, CONFIGURATION, path, payload, modelContext(mountPoint), insert, point); isMounted.remove(); return new PutResult(status, future); } @@ -313,13 +315,13 @@ public class BrokerFacade implements Closeable { final DOMMountPoint mountPoint = patchContext.getInstanceIdentifierContext().getMountPoint(); // get new transaction and schema context on server or on mounted device - final SchemaContext schemaContext; + final EffectiveModelContext schemaContext; final DOMDataTreeReadWriteTransaction patchTransaction; if (mountPoint == null) { schemaContext = patchContext.getInstanceIdentifierContext().getSchemaContext(); patchTransaction = this.domDataBroker.newReadWriteTransaction(); } else { - schemaContext = mountPoint.getSchemaContext(); + schemaContext = modelContext(mountPoint); final Optional optional = mountPoint.getService(DOMDataBroker.class); @@ -466,8 +468,8 @@ public class BrokerFacade implements Closeable { // POST configuration public FluentFuture commitConfigurationDataPost( - final SchemaContext globalSchema, final YangInstanceIdentifier path, final NormalizedNode payload, - final String insert, final String point) { + final EffectiveModelContext globalSchema, final YangInstanceIdentifier path, + final NormalizedNode payload, final String insert, final String point) { isMounted.set(false); FluentFuture future = postDataViaTransaction(this.domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload, @@ -484,7 +486,7 @@ public class BrokerFacade implements Closeable { if (domDataBrokerService.isPresent()) { FluentFuture future = postDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path, - payload, mountPoint.getSchemaContext(), insert, point); + payload, modelContext(mountPoint), insert, point); isMounted.remove(); return future; } @@ -507,7 +509,7 @@ public class BrokerFacade implements Closeable { } // RPC - public ListenableFuture invokeRpc(final @NonNull SchemaPath type, + public ListenableFuture invokeRpc(final @NonNull QName type, final @NonNull NormalizedNode input) { if (this.rpcService == null) { throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE); @@ -572,9 +574,9 @@ public class BrokerFacade implements Closeable { throw new RestconfDocumentedException("Bad value used with with-defaults parameter : " + withDefa); } - final SchemaContext ctx = controllerContext.getGlobalSchema(); + final EffectiveModelContext ctx = controllerContext.getGlobalSchema(); final DataSchemaContextTree baseSchemaCtxTree = DataSchemaContextTree.from(ctx); - final DataSchemaNode baseSchemaNode = baseSchemaCtxTree.getChild(path).getDataSchemaNode(); + final DataSchemaNode baseSchemaNode = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (result instanceof ContainerNode) { final DataContainerNodeBuilder builder = Builders.containerBuilder((ContainerSchemaNode) baseSchemaNode); @@ -595,7 +597,7 @@ public class BrokerFacade implements Closeable { final YangInstanceIdentifier actualPath, final boolean trim, final List keys) { for (final DataContainerChild child : result.getValue()) { final YangInstanceIdentifier path = actualPath.node(child.getIdentifier()); - final DataSchemaNode childSchema = baseSchemaCtxTree.getChild(path).getDataSchemaNode(); + final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (child instanceof ContainerNode) { final DataContainerNodeBuilder childBuilder = Builders.containerBuilder((ContainerSchemaNode) childSchema); @@ -637,7 +639,8 @@ public class BrokerFacade implements Closeable { final List keys) { for (final MapEntryNode mapEntryNode : result.getValue()) { final YangInstanceIdentifier actualNode = path.node(mapEntryNode.getIdentifier()); - final DataSchemaNode childSchema = baseSchemaCtxTree.getChild(actualNode).getDataSchemaNode(); + final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(actualNode).orElseThrow() + .getDataSchemaNode(); final DataContainerNodeBuilder mapEntryBuilder = Builders.mapEntryBuilder((ListSchemaNode) childSchema); buildMapEntryBuilder(mapEntryBuilder, mapEntryNode, baseSchemaCtxTree, actualNode, trim, keys); @@ -650,7 +653,7 @@ public class BrokerFacade implements Closeable { final YangInstanceIdentifier actualPath, final boolean trim) { for (final DataContainerChild child : result.getValue()) { final YangInstanceIdentifier path = actualPath.node(child.getIdentifier()); - final DataSchemaNode childSchema = baseSchemaCtxTree.getChild(path).getDataSchemaNode(); + final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (child instanceof ContainerNode) { final DataContainerNodeBuilder builderChild = Builders.containerBuilder((ContainerSchemaNode) childSchema); @@ -687,8 +690,8 @@ public class BrokerFacade implements Closeable { */ private FluentFuture postDataViaTransaction( final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext, - final String insert, final String point) { + final YangInstanceIdentifier path, final NormalizedNode payload, + final EffectiveModelContext schemaContext, final String insert, final String point) { LOG.trace("POST {} via Restconf: {} with payload {}", datastore.name(), path, payload); postData(rwTransaction, datastore, path, payload, schemaContext, insert, point); return rwTransaction.commit(); @@ -699,14 +702,15 @@ public class BrokerFacade implements Closeable { */ private void postDataWithinTransaction( final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext) { + final YangInstanceIdentifier path, final NormalizedNode payload, + final EffectiveModelContext schemaContext) { LOG.trace("POST {} within Restconf Patch: {} with payload {}", datastore.name(), path, payload); postData(rwTransaction, datastore, path, payload, schemaContext, null, null); } private void postData(final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode payload, - final SchemaContext schemaContext, final String insert, final String point) { + final EffectiveModelContext schemaContext, final String insert, final String point) { if (insert == null) { makeNormalPost(rwTransaction, datastore, path, payload, schemaContext); return; @@ -859,9 +863,10 @@ public class BrokerFacade implements Closeable { } } - private static DataSchemaNode checkListAndOrderedType(final SchemaContext ctx, final YangInstanceIdentifier path) { + private static DataSchemaNode checkListAndOrderedType(final EffectiveModelContext ctx, + final YangInstanceIdentifier path) { final YangInstanceIdentifier parent = path.getParent(); - final DataSchemaContextNode node = DataSchemaContextTree.from(ctx).getChild(parent); + final DataSchemaContextNode node = DataSchemaContextTree.from(ctx).findChild(parent).orElseThrow(); final DataSchemaNode dataSchemaNode = node.getDataSchemaNode(); if (dataSchemaNode instanceof ListSchemaNode) { @@ -1008,8 +1013,8 @@ public class BrokerFacade implements Closeable { */ private FluentFuture putDataViaTransaction( final DOMDataTreeReadWriteTransaction readWriteTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext, - final String insert, final String point) { + final YangInstanceIdentifier path, final NormalizedNode payload, + final EffectiveModelContext schemaContext, final String insert, final String point) { LOG.trace("Put {} via Restconf: {} with payload {}", datastore.name(), path, payload); putData(readWriteTransaction, datastore, path, payload, schemaContext, insert, point); return readWriteTransaction.commit(); @@ -1020,15 +1025,16 @@ public class BrokerFacade implements Closeable { */ private void putDataWithinTransaction( final DOMDataTreeReadWriteTransaction writeTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext) { + final YangInstanceIdentifier path, final NormalizedNode payload, + final EffectiveModelContext schemaContext) { LOG.trace("Put {} within Restconf Patch: {} with payload {}", datastore.name(), path, payload); putData(writeTransaction, datastore, path, payload, schemaContext, null, null); } // FIXME: This is doing correct put for container and list children, not sure if this will work for choice case private void putData(final DOMDataTreeReadWriteTransaction rwTransaction, final LogicalDatastoreType datastore, - final YangInstanceIdentifier path, final NormalizedNode payload, final SchemaContext schemaContext, - final String insert, final String point) { + final YangInstanceIdentifier path, final NormalizedNode payload, + final EffectiveModelContext schemaContext, final String insert, final String point) { if (insert == null) { makePut(rwTransaction, datastore, path, payload, schemaContext); return; @@ -1231,7 +1237,7 @@ public class BrokerFacade implements Closeable { final SchemaPath path = listener.getSchemaPath(); final ListenerRegistration registration = this.domNotification - .registerNotificationListener(listener, path); + .registerNotificationListener(listener, Absolute.of(ImmutableList.copyOf(path.getPathFromRoot()))); listener.setRegistration(registration); } @@ -1271,6 +1277,12 @@ public class BrokerFacade implements Closeable { return new RestconfDocumentedException("DOM data broker service is not available for mount point " + path); } + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } + private static final class PatchStatusContextHelper { PatchStatusContext status; diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java index 261f7129df..39395458ff 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java @@ -234,7 +234,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C public Module findModuleByName(final DOMMountPoint mountPoint, final String moduleName) { Preconditions.checkArgument(moduleName != null && mountPoint != null); - final SchemaContext mountPointSchema = mountPoint.getSchemaContext(); + final SchemaContext mountPointSchema = getModelContext(mountPoint); if (mountPointSchema == null) { return null; } @@ -251,7 +251,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C public Module findModuleByNamespace(final DOMMountPoint mountPoint, final URI namespace) { Preconditions.checkArgument(namespace != null && mountPoint != null); - final SchemaContext mountPointSchema = mountPoint.getSchemaContext(); + final SchemaContext mountPointSchema = getModelContext(mountPoint); if (mountPointSchema == null) { return null; } @@ -271,7 +271,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C checkPreconditions(); Preconditions.checkArgument(name != null && revision != null && mountPoint != null); - final SchemaContext schemaContext = mountPoint.getSchemaContext(); + final SchemaContext schemaContext = getModelContext(mountPoint); return schemaContext == null ? null : schemaContext.findModule(name, revision).orElse(null); } @@ -304,7 +304,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C final QName startQName = head.getNodeType(); final SchemaContext schemaContext; if (mount != null) { - schemaContext = mount.getSchemaContext(); + schemaContext = getModelContext(mount); } else { schemaContext = this.globalSchema; } @@ -314,7 +314,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C if (!(element instanceof AugmentationIdentifier)) { final QName _nodeType = element.getNodeType(); final DataSchemaNode potentialNode = childByQName(node, _nodeType); - if (!(element instanceof NodeIdentifier && potentialNode instanceof ListSchemaNode) + if ((!(element instanceof NodeIdentifier) || !(potentialNode instanceof ListSchemaNode)) && !(potentialNode instanceof ChoiceSchemaNode)) { builder.append(convertToRestconfIdentifier(element, potentialNode, mount)); if (potentialNode instanceof DataNodeContainer) { @@ -352,7 +352,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C public Collection getAllModules(final DOMMountPoint mountPoint) { checkPreconditions(); - final SchemaContext schemaContext = mountPoint == null ? null : mountPoint.getSchemaContext(); + final SchemaContext schemaContext = mountPoint == null ? null : getModelContext(mountPoint); return schemaContext == null ? null : schemaContext.getModules(); } @@ -369,7 +369,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C public CharSequence toRestconfIdentifier(final QName qname, final DOMMountPoint mount) { final SchemaContext schema; if (mount != null) { - schema = mount.getSchemaContext(); + schema = getModelContext(mount); } else { checkPreconditions(); schema = this.globalSchema; @@ -389,7 +389,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C return null; } - return toRestconfIdentifier(mountPoint.getSchemaContext(), qname); + return toRestconfIdentifier(getModelContext(mountPoint), qname); } public Module getRestconfModule() { @@ -554,8 +554,8 @@ public final class ControllerContext implements EffectiveModelContextListener, C } if (strings.isEmpty()) { - return createContext(builder.build(), (DataSchemaNode) parentNode, - mountPoint,mountPoint != null ? mountPoint.getEffectiveModelContext() : this.globalSchema); + return createContext(builder.build(), (DataSchemaNode) parentNode, mountPoint, + mountPoint != null ? getModelContext(mountPoint) : this.globalSchema); } final String head = strings.iterator().next(); @@ -591,7 +591,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C } final DOMMountPoint mount = mountOpt.get(); - final EffectiveModelContext mountPointSchema = mount.getEffectiveModelContext(); + final EffectiveModelContext mountPointSchema = getModelContext(mount); if (mountPointSchema == null) { throw new RestconfDocumentedException("Mount point does not contain any schema with modules.", ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT); @@ -630,7 +630,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT); } } else { - final EffectiveModelContext schemaContext = mountPoint.getEffectiveModelContext(); + final EffectiveModelContext schemaContext = getModelContext(mountPoint); if (schemaContext != null) { module = schemaContext.findModules(moduleName).stream().findFirst().orElse(null); } else { @@ -654,7 +654,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C } if (rpc != null) { return new InstanceIdentifierContext<>(builder.build(), rpc, mountPoint, - mountPoint != null ? mountPoint.getEffectiveModelContext() : this.globalSchema); + mountPoint != null ? getModelContext(mountPoint) : this.globalSchema); } } @@ -733,7 +733,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C } return createContext(builder.build(), targetNode, mountPoint, - mountPoint != null ? mountPoint.getEffectiveModelContext() : this.globalSchema); + mountPoint != null ? getModelContext(mountPoint) : this.globalSchema); } private static InstanceIdentifierContext createContext(final YangInstanceIdentifier instance, @@ -796,7 +796,7 @@ public final class ControllerContext implements EffectiveModelContextListener, C Preconditions.checkNotNull(uriValue); Preconditions.checkArgument(node instanceof LeafSchemaNode); - final SchemaContext schemaContext = mountPoint == null ? this.globalSchema : mountPoint.getSchemaContext(); + final SchemaContext schemaContext = mountPoint == null ? this.globalSchema : getModelContext(mountPoint); final String urlDecoded = urlPathArgDecode(uriValue); TypeDefinition typedef = ((LeafSchemaNode) node).getType(); final TypeDefinition baseType = RestUtil.resolveBaseTypeFrom(typedef); @@ -1014,4 +1014,10 @@ public final class ControllerContext implements EffectiveModelContextListener, C } return operation.isMixin(); } + + private static EffectiveModelContext getModelContext(DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } } diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizationOperation.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizationOperation.java index f411678ad0..19ccfe24e3 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizationOperation.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizationOperation.java @@ -29,13 +29,14 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema; abstract class DataNormalizationOperation implements Identifiable { @@ -50,7 +51,7 @@ abstract class DataNormalizationOperation implements Ide this.identifier = identifier; } - static DataNormalizationOperation from(final SchemaContext ctx) { + static DataNormalizationOperation from(final EffectiveModelContext ctx) { return new ContainerNormalization(ctx); } @@ -185,7 +186,7 @@ abstract class DataNormalizationOperation implements Ide } private static final class ContainerNormalization extends DataContainerNormalizationOperation { - ContainerNormalization(final ContainerSchemaNode schema) { + ContainerNormalization(final ContainerLike schema) { super(new NodeIdentifier(schema.getQName()), schema); } } diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizer.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizer.java index 3e815ed20d..753b515477 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizer.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/DataNormalizer.java @@ -13,12 +13,12 @@ import com.google.common.collect.ImmutableList; import java.util.Iterator; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; class DataNormalizer { private final DataNormalizationOperation operation; - DataNormalizer(final SchemaContext ctx) { + DataNormalizer(final EffectiveModelContext ctx) { operation = DataNormalizationOperation.from(ctx); } diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java index 1f3710bd6f..6b3cff2378 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestconfImpl.java @@ -60,6 +60,7 @@ import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.netconf.sal.rest.api.Draft02; import org.opendaylight.netconf.sal.rest.api.RestconfService; @@ -199,6 +200,7 @@ public final class RestconfImpl implements RestconfService { } @Override + @Deprecated public NormalizedNodeContext getModules(final UriInfo uriInfo) { final MapNode allModuleMap = makeModuleMapNode(controllerContext.getAllModules()); @@ -221,6 +223,7 @@ public final class RestconfImpl implements RestconfService { * Valid only for mount point. */ @Override + @Deprecated public NormalizedNodeContext getModules(final String identifier, final UriInfo uriInfo) { Preconditions.checkNotNull(identifier); if (!identifier.contains(ControllerContext.MOUNT)) { @@ -251,6 +254,7 @@ public final class RestconfImpl implements RestconfService { } @Override + @Deprecated public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) { Preconditions.checkNotNull(identifier); final Entry nameRev = getModuleNameAndRevision(identifier); @@ -263,7 +267,7 @@ public final class RestconfImpl implements RestconfService { mountPoint = mountPointIdentifier.getMountPoint(); module = this.controllerContext.findModuleByNameAndRevision(mountPoint, nameRev.getKey(), nameRev.getValue()); - schemaContext = mountPoint.getEffectiveModelContext(); + schemaContext = modelContext(mountPoint); } else { module = this.controllerContext.findModuleByNameAndRevision(nameRev.getKey(), nameRev.getValue()); schemaContext = this.controllerContext.getGlobalSchema(); @@ -289,6 +293,7 @@ public final class RestconfImpl implements RestconfService { } @Override + @Deprecated public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) { final EffectiveModelContext schemaContext = this.controllerContext.getGlobalSchema(); final Set availableStreams = Notificator.getStreamNames(); @@ -318,11 +323,13 @@ public final class RestconfImpl implements RestconfService { } @Override + @Deprecated public NormalizedNodeContext getOperations(final UriInfo uriInfo) { return OperationsResourceUtils.contextForModelContext(controllerContext.getGlobalSchema(), null); } @Override + @Deprecated public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) { if (!identifier.contains(ControllerContext.MOUNT)) { final String errMsg = "URI has bad format. If operations behind mount point should be showed, URI has to " @@ -334,7 +341,7 @@ public final class RestconfImpl implements RestconfService { final InstanceIdentifierContext mountPointIdentifier = this.controllerContext.toMountPointIdentifier(identifier); final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint(); - return OperationsResourceUtils.contextForModelContext(mountPoint.getSchemaContext(), mountPoint); + return OperationsResourceUtils.contextForModelContext(modelContext(mountPoint), mountPoint); } private Module getRestconfModule() { @@ -400,8 +407,8 @@ public final class RestconfImpl implements RestconfService { LOG.debug("Error: Rpc service is missing."); throw new RestconfDocumentedException("Rpc service is missing."); } - schemaContext = mountPoint.getEffectiveModelContext(); - response = mountRpcServices.get().invokeRpc(schema.getPath(), input); + schemaContext = modelContext(mountPoint); + response = mountRpcServices.get().invokeRpc(schema.getQName(), input); } else { final URI namespace = schema.getQName().getNamespace(); if (namespace.toString().equals(SAL_REMOTE_NAMESPACE)) { @@ -415,7 +422,7 @@ public final class RestconfImpl implements RestconfService { throw new RestconfDocumentedException(msg, ErrorType.RPC, ErrorTag.OPERATION_NOT_SUPPORTED); } } else { - response = this.broker.invokeRpc(schema.getPath(), input); + response = this.broker.invokeRpc(schema.getQName(), input); } schemaContext = this.controllerContext.getGlobalSchema(); } @@ -450,7 +457,7 @@ public final class RestconfImpl implements RestconfService { // mounted RPC call - look up mount instance. final InstanceIdentifierContext mountPointId = this.controllerContext.toMountPointIdentifier(identifier); mountPoint = mountPointId.getMountPoint(); - schemaContext = mountPoint.getEffectiveModelContext(); + schemaContext = modelContext(mountPoint); final int startOfRemoteRpcName = identifier.lastIndexOf(ControllerContext.MOUNT) + ControllerContext.MOUNT.length() + 1; final String remoteRpcName = identifier.substring(startOfRemoteRpcName); @@ -472,7 +479,7 @@ public final class RestconfImpl implements RestconfService { if (mountPoint == null) { rpc = this.controllerContext.getRpcDefinition(identifierDecoded); } else { - rpc = findRpc(mountPoint.getSchemaContext(), identifierDecoded); + rpc = findRpc(modelContext(mountPoint), identifierDecoded); } if (rpc == null) { @@ -493,9 +500,9 @@ public final class RestconfImpl implements RestconfService { if (!mountRpcServices.isPresent()) { throw new RestconfDocumentedException("Rpc service is missing."); } - response = mountRpcServices.get().invokeRpc(rpc.getPath(), input); + response = mountRpcServices.get().invokeRpc(rpc.getQName(), input); } else { - response = this.broker.invokeRpc(rpc.getPath(), input); + response = this.broker.invokeRpc(rpc.getQName(), input); } final NormalizedNode result = checkRpcResponse(response).getResult(); @@ -1539,4 +1546,10 @@ public final class RestconfImpl implements RestconfService { return Futures.immediateFuture(new DefaultDOMRpcResult(output)); } + + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } } diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/AbstractNotificationsData.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/AbstractNotificationsData.java index 02f537066e..df88d98e77 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/AbstractNotificationsData.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/AbstractNotificationsData.java @@ -29,7 +29,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter; import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,7 +75,7 @@ abstract class AbstractNotificationsData { * schema path of data * @return {@link DOMResult} */ - protected DOMResult writeNormalizedNode(final NormalizedNode normalized, final SchemaContext context, + protected DOMResult writeNormalizedNode(final NormalizedNode normalized, final EffectiveModelContext context, final SchemaPath schemaPath) throws IOException, XMLStreamException { final Document doc = UntrustedXML.newDocumentBuilder().newDocument(); final DOMResult result = new DOMResult(doc); diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java index 5d61cb52a3..8afc8dedae 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/ListenerAdapter.java @@ -33,8 +33,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -141,7 +141,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster * @return Data in printable form. */ private String prepareXml(final Collection candidates) { - final SchemaContext schemaContext = controllerContext.getGlobalSchema(); + final EffectiveModelContext schemaContext = controllerContext.getGlobalSchema(); final DataSchemaContextTree dataContextTree = DataSchemaContextTree.from(schemaContext); final Document doc = createDocument(); final Element notificationElement = basePartDoc(doc); @@ -168,7 +168,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster private void addValuesToDataChangedNotificationEventElement(final Document doc, final Element dataChangedNotificationEventElement, final Collection dataTreeCandidates, - final SchemaContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { + final EffectiveModelContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { for (DataTreeCandidate dataTreeCandidate : dataTreeCandidates) { DataTreeCandidateNode candidateNode = dataTreeCandidate.getRootNode(); @@ -190,7 +190,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster private void addNodeToDataChangeNotificationEventElement(final Document doc, final Element dataChangedNotificationEventElement, final DataTreeCandidateNode candidateNode, - final YangInstanceIdentifier parentYiid, final SchemaContext schemaContext, + final YangInstanceIdentifier parentYiid, final EffectiveModelContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { Optional> optionalNormalizedNode = Optional.empty(); @@ -308,7 +308,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster private Node createCreatedChangedDataChangeEventElement(final Document doc, final YangInstanceIdentifier eventPath, final NormalizedNode normalized, final Operation operation, - final SchemaContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { + final EffectiveModelContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { final Element dataChangeEventElement = doc.createElement(DATA_CHANGE_EVENT); final Element pathElement = doc.createElement(PATH); addPathAsValueToElement(eventPath, pathElement); @@ -321,9 +321,10 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster try { SchemaPath nodePath; if (normalized instanceof MapEntryNode || normalized instanceof UnkeyedListEntryNode) { - nodePath = dataSchemaContextTree.getChild(eventPath).getDataSchemaNode().getPath(); + nodePath = dataSchemaContextTree.findChild(eventPath).orElseThrow().getDataSchemaNode().getPath(); } else { - nodePath = dataSchemaContextTree.getChild(eventPath).getDataSchemaNode().getPath().getParent(); + nodePath = dataSchemaContextTree.findChild(eventPath).orElseThrow().getDataSchemaNode().getPath() + .getParent(); } final DOMResult domResult = writeNormalizedNode(normalized, schemaContext, nodePath); final Node result = doc.importNode(domResult.getNode().getFirstChild(), true); diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java index 2f1da2b09c..2ea58c064e 100644 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java @@ -28,7 +28,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWrit import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -87,7 +87,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem return; } - final SchemaContext schemaContext = controllerContext.getGlobalSchema(); + final EffectiveModelContext schemaContext = controllerContext.getGlobalSchema(); final String xml = prepareXml(schemaContext, notification); if (checkFilter(xml)) { prepareAndPostData(outputType.equals("JSON") ? prepareJson(schemaContext, notification) : xml); @@ -130,7 +130,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem * @return json as {@link String} */ @VisibleForTesting - String prepareJson(final SchemaContext schemaContext, final DOMNotification notification) { + String prepareJson(final EffectiveModelContext schemaContext, final DOMNotification notification) { final JsonParser jsonParser = new JsonParser(); final JsonObject json = new JsonObject(); json.add("ietf-restconf:notification", jsonParser.parse(writeBodyToString(schemaContext, notification))); @@ -138,11 +138,12 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem return json.toString(); } - private static String writeBodyToString(final SchemaContext schemaContext, final DOMNotification notification) { + private static String writeBodyToString(final EffectiveModelContext schemaContext, + final DOMNotification notification) { final Writer writer = new StringWriter(); final NormalizedNodeStreamWriter jsonStream = JSONNormalizedNodeStreamWriter.createExclusiveWriter( JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext), - notification.getType(), null, JsonWriterFactory.createJsonWriter(writer)); + notification.getType().asSchemaPath(), null, JsonWriterFactory.createJsonWriter(writer)); final NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(jsonStream); try { nodeWriter.write(notification.getBody()); @@ -153,7 +154,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem return writer.toString(); } - private String prepareXml(final SchemaContext schemaContext, final DOMNotification notification) { + private String prepareXml(final EffectiveModelContext schemaContext, final DOMNotification notification) { final Document doc = createDocument(); final Element notificationElement = basePartDoc(doc); @@ -166,7 +167,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem } private void addValuesToNotificationEventElement(final Document doc, final Element element, - final SchemaContext schemaContext, final DOMNotification notification) { + final EffectiveModelContext schemaContext, final DOMNotification notification) { try { final DOMResult domResult = writeNormalizedNode(notification.getBody(), schemaContext, this.path); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java index 3cb8c8798a..a8ce9ea972 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/md/sal/rest/common/TestRestconfUtils.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.rest.common; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doCallRealMethod; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -30,6 +30,7 @@ import org.opendaylight.controller.sal.rest.impl.test.providers.TestJsonBodyWrit import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; @@ -40,7 +41,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; @@ -70,8 +71,8 @@ public final class TestRestconfUtils { final DOMMountPointService mockMountService = mock(DOMMountPointService.class); if (mountInstance != null) { - doReturn(schemaContext).when(mountInstance).getEffectiveModelContext(); - doCallRealMethod().when(mountInstance).getSchemaContext(); + doReturn(Optional.of(FixedDOMSchemaService.of(() -> schemaContext))).when(mountInstance) + .getService(eq(DOMSchemaService.class)); doReturn(Optional.ofNullable(mountInstance)).when(mockMountService).getMountPoint( any(YangInstanceIdentifier.class)); } @@ -156,7 +157,7 @@ public final class TestRestconfUtils { final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder); final XmlParserStream xmlParser = XmlParserStream.create(writer, iiContext.getSchemaContext(), schemaNode); - if (schemaNode instanceof ContainerSchemaNode || schemaNode instanceof ListSchemaNode) { + if (schemaNode instanceof ContainerLike || schemaNode instanceof ListSchemaNode) { xmlParser.traverse(new DOMSource(doc.getDocumentElement())); return resultHolder.getResult(); } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java index 57c6ef2943..677ef51eca 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java @@ -14,6 +14,7 @@ import static org.mockito.Mockito.when; import java.lang.reflect.Field; import java.net.URI; import java.util.Collections; +import java.util.Optional; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; @@ -21,6 +22,7 @@ import javax.ws.rs.core.Request; import javax.ws.rs.core.UriInfo; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.netconf.sal.rest.api.RestconfConstants; import org.opendaylight.netconf.sal.rest.impl.AbstractIdentifierAwareJaxRsProvider; import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; @@ -112,6 +114,12 @@ public abstract class AbstractBodyReaderTest { protected static void checkPatchContextMountPoint(final PatchContext patchContext) { checkPatchContext(patchContext); assertNotNull(patchContext.getInstanceIdentifierContext().getMountPoint()); - assertNotNull(patchContext.getInstanceIdentifierContext().getMountPoint().getSchemaContext()); } + + protected static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } + } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java index 96d661515c..befa969030 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java @@ -133,14 +133,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest { checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null); } - protected void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, + protected void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, final NormalizedNodeContext nnContext, final QName qualifiedName) { - YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier - .of(dataSchemaNode.getQName()); - final DOMMountPoint mountPoint = nnContext - .getInstanceIdentifierContext().getMountPoint(); - final DataSchemaNode mountDataSchemaNode = mountPoint.getSchemaContext().getDataChildByName( + YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName()); + final DOMMountPoint mountPoint = nnContext.getInstanceIdentifierContext().getMountPoint(); + final DataSchemaNode mountDataSchemaNode = modelContext(mountPoint).getDataChildByName( dataSchemaNode.getQName()); assertNotNull(mountDataSchemaNode); if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) { diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java index 3e720c131c..6f54a773d9 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java @@ -137,28 +137,20 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest { } protected void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, - final NormalizedNodeContext nnContext, final QName qualifiedName) { - YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier - .of(dataSchemaNode.getQName()); - final DOMMountPoint mountPoint = nnContext - .getInstanceIdentifierContext().getMountPoint(); - final DataSchemaNode mountDataSchemaNode = mountPoint - .getSchemaContext().getDataChildByName( - dataSchemaNode.getQName()); + final DataSchemaNode dataSchemaNode, final NormalizedNodeContext nnContext, final QName qualifiedName) { + YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName()); + final DOMMountPoint mountPoint = nnContext.getInstanceIdentifierContext().getMountPoint(); + final DataSchemaNode mountDataSchemaNode = + modelContext(mountPoint).getDataChildByName(dataSchemaNode.getQName()); assertNotNull(mountDataSchemaNode); if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) { - final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode) - .getDataChildByName(qualifiedName); - dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent) - .node(child.getQName()).build(); - assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode() - .equals(child)); + final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(qualifiedName); + dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build(); + assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child)); } else { assertTrue(mountDataSchemaNode.equals(dataSchemaNode)); } - assertNotNull(NormalizedNodes.findNode(nnContext.getData(), - dataNodeIdent)); + assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent)); } /** diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java index 037b8fb5ef..1f44c65fd2 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyWriter.java @@ -52,8 +52,7 @@ public class TestXmlBodyWriter extends AbstractBodyReaderTest { final NormalizedNodeContext nnContext = TestRestconfUtils .loadNormalizedContextFromXmlFile(pathToInputFile, uri, controllerContext); final OutputStream output = new ByteArrayOutputStream(); - this.xmlBodyWriter.writeTo(nnContext, null, null, null, this.mediaType, null, - output); + this.xmlBodyWriter.writeTo(nnContext, null, null, null, this.mediaType, null, output); assertTrue(output.toString().contains("lf-test")); } } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java index 7b76453c7e..206158341a 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/input/to/cnsn/test/RestPutListDataTest.java @@ -52,7 +52,6 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class RestPutListDataTest { private static EffectiveModelContext schemaContextTestModule; @@ -74,8 +73,8 @@ public class RestPutListDataTest { brokerFacade = mock(BrokerFacade.class); restconfImpl = RestconfImpl.newInstance(brokerFacade, controllerContext); final PutResult result = mock(PutResult.class); - when(brokerFacade.commitConfigurationDataPut(any(SchemaContext.class), any(YangInstanceIdentifier.class), - any(NormalizedNode.class), Mockito.anyString(), Mockito.anyString())) + when(brokerFacade.commitConfigurationDataPut(any(EffectiveModelContext.class), + any(YangInstanceIdentifier.class), any(NormalizedNode.class), Mockito.anyString(), Mockito.anyString())) .thenReturn(result); when(result.getFutureOfPutData()).thenReturn(mock(FluentFuture.class)); when(result.getStatus()).thenReturn(Status.OK); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java index c9dd5c5ad6..2005834bdb 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/xml/test/NnToXmlWithDataFromSeveralModulesTest.java @@ -94,12 +94,8 @@ public class NnToXmlWithDataFromSeveralModulesTest extends private static NormalizedNodeContext prepareNormalizedNodeContext() { final String rev = "2014-01-17"; - final DataSchemaNode schemaContNode = schemaContext; - - assertTrue(schemaContNode instanceof ContainerSchemaNode); - final DataContainerNodeBuilder dataContSchemaContNode = Builders - .containerBuilder((ContainerSchemaNode) schemaContNode); + .containerBuilder(schemaContext); final DataContainerNodeBuilder modul1 = buildContBuilderMod1( "module:one", rev, "cont_m1", "contB_m1", "lf1_m1", @@ -112,8 +108,7 @@ public class NnToXmlWithDataFromSeveralModulesTest extends dataContSchemaContNode.withChild(modul2.build()); final NormalizedNodeContext testNormalizedNodeContext = new NormalizedNodeContext( - new InstanceIdentifierContext<>(null, - schemaContNode, null, schemaContext), + new InstanceIdentifierContext<>(null, schemaContext, null, schemaContext), dataContSchemaContNode.build()); return testNormalizedNodeContext; diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java index 9d612e2870..1cd850ea32 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java @@ -28,6 +28,7 @@ import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediate import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateTrueFluentFuture; import com.google.common.collect.ImmutableClassToInstanceMap; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.ListenableFuture; @@ -77,8 +78,9 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; /** * Unit tests for BrokerFacade. @@ -106,7 +108,6 @@ public class BrokerFacadeTest { private final NormalizedNode dummyNode = createDummyNode("test:module", "2014-01-09", "interfaces"); private final FluentFuture>> dummyNodeInFuture = wrapDummyNode(this.dummyNode); private final QName qname = TestUtils.buildQName("interfaces","test:module", "2014-01-09"); - private final SchemaPath type = SchemaPath.create(true, this.qname); private final YangInstanceIdentifier instanceID = YangInstanceIdentifier.builder().node(this.qname).build(); private ControllerContext controllerContext; @@ -185,9 +186,9 @@ public class BrokerFacadeTest { @Test public void testInvokeRpc() throws Exception { final DOMRpcResult expResult = mock(DOMRpcResult.class); - doReturn(immediateFluentFuture(expResult)).when(this.mockRpcService).invokeRpc(this.type, this.dummyNode); + doReturn(immediateFluentFuture(expResult)).when(this.mockRpcService).invokeRpc(this.qname, this.dummyNode); - final ListenableFuture actualFuture = this.brokerFacade.invokeRpc(this.type, + final ListenableFuture actualFuture = this.brokerFacade.invokeRpc(this.qname, this.dummyNode); assertNotNull("Future is null", actualFuture); final DOMRpcResult actualResult = actualFuture.get(); @@ -201,7 +202,7 @@ public class BrokerFacadeTest { doReturn(immediateFluentFuture(Optional.of(mock(NormalizedNode.class)))).when(this.rwTransaction) .read(LogicalDatastoreType.CONFIGURATION, this.instanceID); - final PutResult result = this.brokerFacade.commitConfigurationDataPut(mock(SchemaContext.class), + final PutResult result = this.brokerFacade.commitConfigurationDataPut(mock(EffectiveModelContext.class), this.instanceID, this.dummyNode, null, null); assertSame("commitConfigurationDataPut", CommitInfo.emptyFluentFuture(), result.getFutureOfPutData()); @@ -220,7 +221,8 @@ public class BrokerFacadeTest { doReturn(CommitInfo.emptyFluentFuture()).when(this.rwTransaction).commit(); final FluentFuture actualFuture = this.brokerFacade - .commitConfigurationDataPost(mock(SchemaContext.class), this.instanceID, this.dummyNode, null, null); + .commitConfigurationDataPost(mock(EffectiveModelContext.class), this.instanceID, this.dummyNode, null, + null); assertSame("commitConfigurationDataPost", CommitInfo.emptyFluentFuture(), actualFuture); @@ -237,8 +239,8 @@ public class BrokerFacadeTest { .thenReturn(immediateTrueFluentFuture()); try { // Schema context is only necessary for ensuring parent structure - this.brokerFacade.commitConfigurationDataPost((SchemaContext) null, this.instanceID, this.dummyNode, null, - null); + this.brokerFacade.commitConfigurationDataPost((EffectiveModelContext) null, this.instanceID, this.dummyNode, + null, null); } catch (final RestconfDocumentedException e) { assertEquals("getErrorTag", RestconfError.ErrorTag.DATA_EXISTS, e.getErrors().get(0).getErrorTag()); throw e; @@ -337,7 +339,8 @@ public class BrokerFacadeTest { // mock registration final ListenerRegistration registration = mock(ListenerRegistration.class); - when(this.domNotification.registerNotificationListener(listener, listener.getSchemaPath())) + when(this.domNotification.registerNotificationListener(listener, + Absolute.of(ImmutableList.copyOf(listener.getSchemaPath().getPathFromRoot())))) .thenReturn(registration); // test to register listener for the first time @@ -349,7 +352,8 @@ public class BrokerFacadeTest { assertEquals("Registration was not successful", true, listener.isListening()); // registrations should be invoked only once - verify(this.domNotification, times(1)).registerNotificationListener(listener, listener.getSchemaPath()); + verify(this.domNotification, times(1)).registerNotificationListener(listener, + Absolute.of(ImmutableList.copyOf(listener.getSchemaPath().getPathFromRoot()))); final DOMTransactionChain transactionChain = mock(DOMTransactionChain.class); final DOMDataTreeWriteTransaction wTx = mock(DOMDataTreeWriteTransaction.class); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug8072Test.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug8072Test.java index 6bb6f607aa..7e226c9b40 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug8072Test.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/Bug8072Test.java @@ -14,17 +14,19 @@ import static org.mockito.Mockito.mock; import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; public class Bug8072Test { @@ -40,10 +42,11 @@ public class Bug8072Test { private final ControllerContext controllerContext; public Bug8072Test() throws FileNotFoundException { - final SchemaContext mountPointContext = TestUtils.loadSchemaContext("/full-versions/test-module"); + final EffectiveModelContext mountPointContext = TestUtils.loadSchemaContext("/full-versions/test-module"); final DOMMountPoint mountInstance = mock(DOMMountPoint.class); controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mountInstance); - doReturn(mountPointContext).when(mountInstance).getEffectiveModelContext(); + doReturn(Optional.of(FixedDOMSchemaService.of(() -> mountPointContext))).when(mountInstance) + .getService(DOMSchemaService.class); } @BeforeClass diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java index ec681f3e62..d0ecee442d 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java @@ -61,6 +61,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; @@ -68,7 +69,6 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; @@ -129,7 +129,7 @@ public class InvokeRpcMethodTest { assertNotNull(rpcModule); final QName rpcQName = QName.create(rpcModule.getQNameModule(), "rpc-test"); final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input"); - ContainerSchemaNode rpcInputSchemaNode = null; + ContainerLike rpcInputSchemaNode = null; for (final RpcDefinition rpc : rpcModule.getRpcs()) { if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName); @@ -162,10 +162,9 @@ public class InvokeRpcMethodTest { @Test public void testInvokeRpcWithNoPayloadRpc_FailNoErrors() { final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"); - final SchemaPath type = SchemaPath.create(true, qname); doReturn(immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("testExeption"))) - .when(brokerFacade).invokeRpc(eq(type), any()); + .when(brokerFacade).invokeRpc(eq(qname), any()); try { this.restconfImpl.invokeRpc("toaster:cancel-toast", null, uriInfo); @@ -207,8 +206,7 @@ public class InvokeRpcMethodTest { "app-tag", null, null)); final DOMRpcResult result = new DefaultDOMRpcResult(rpcErrors); - final SchemaPath path = SchemaPath.create(true, - QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast")); + final QName path = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"); doReturn(immediateFluentFuture(result)).when(brokerFacade).invokeRpc(eq(path), any()); try { @@ -228,9 +226,8 @@ public class InvokeRpcMethodTest { final DOMRpcResult expResult = new DefaultDOMRpcResult(resultObj); final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"); - final SchemaPath path = SchemaPath.create(true, qname); - doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(path), any()); + doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(qname), any()); final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:cancel-toast", null, uriInfo); assertNotNull(output); @@ -246,8 +243,7 @@ public class InvokeRpcMethodTest { final DOMRpcResult expResult = new DefaultDOMRpcResult(resultObj); final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"); - final SchemaPath path = SchemaPath.create(true, qname); - doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(path), any()); + doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(qname), any()); WebApplicationException exceptionToBeThrown = null; try { @@ -275,8 +271,7 @@ public class InvokeRpcMethodTest { @Ignore public void testInvokeRpcMethodWithInput() { final DOMRpcResult expResult = mock(DOMRpcResult.class); - final SchemaPath path = SchemaPath.create(true, - QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)make-toast")); + final QName path = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)make-toast"); final Module rpcModule = schemaContext.findModules("toaster").iterator().next(); assertNotNull(rpcModule); @@ -284,7 +279,7 @@ public class InvokeRpcMethodTest { final QName rpcInputQName = QName.create(rpcModule.getQNameModule(),"input"); RpcDefinition rpcDef = null; - ContainerSchemaNode rpcInputSchemaNode = null; + ContainerLike rpcInputSchemaNode = null; for (final RpcDefinition rpc : rpcModule.getRpcs()) { if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName); @@ -331,7 +326,7 @@ public class InvokeRpcMethodTest { final QName rpcOutputQName = QName.create(rpcModule.getQNameModule(),"output"); RpcDefinition rpcDef = null; - ContainerSchemaNode rpcOutputSchemaNode = null; + ContainerLike rpcOutputSchemaNode = null; for (final RpcDefinition rpc : rpcModule.getRpcs()) { if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { rpcOutputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcOutputQName); @@ -354,7 +349,7 @@ public class InvokeRpcMethodTest { final DOMRpcResult result = new DefaultDOMRpcResult(container); - doReturn(immediateFluentFuture(result)).when(brokerFacade).invokeRpc(eq(rpcDef.getPath()), any()); + doReturn(immediateFluentFuture(result)).when(brokerFacade).invokeRpc(eq(rpcDef.getQName()), any()); final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:testOutput", null, uriInfo); assertNotNull(output); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java index 3379024a2d..e1571aa58c 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/JSONRestconfServiceImplTest.java @@ -17,7 +17,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.notNull; import static org.mockito.ArgumentMatchers.same; -import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -46,7 +45,9 @@ import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMRpcException; import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade; import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; import org.opendaylight.netconf.sal.restconf.impl.JSONRestconfServiceImpl; @@ -71,8 +72,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; /** @@ -122,11 +121,11 @@ public class JSONRestconfServiceImplTest { @Before public void setup() throws FileNotFoundException { - final SchemaContext mountPointSchemaContext = TestUtils.loadSchemaContext("/full-versions/test-module"); + final EffectiveModelContext mountPointSchemaContext = TestUtils.loadSchemaContext("/full-versions/test-module"); final ControllerContext controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mockMountPoint); - doCallRealMethod().when(mockMountPoint).getSchemaContext(); - doReturn(mountPointSchemaContext).when(mockMountPoint).getEffectiveModelContext(); + doReturn(java.util.Optional.of(FixedDOMSchemaService.of(() -> mountPointSchemaContext))).when(mockMountPoint) + .getService(eq(DOMSchemaService.class)); service = new JSONRestconfServiceImpl(controllerContext, RestconfImpl.newInstance(brokerFacade, controllerContext)); @@ -141,7 +140,7 @@ public class JSONRestconfServiceImplTest { @Test public void testPut() throws Exception { final PutResult result = mock(PutResult.class); - when(brokerFacade.commitConfigurationDataPut(notNull(SchemaContext.class), + when(brokerFacade.commitConfigurationDataPut(notNull(EffectiveModelContext.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), isNull(), isNull())) .thenReturn(result); doReturn(CommitInfo.emptyFluentFuture()).when(result).getFutureOfPutData(); @@ -153,7 +152,7 @@ public class JSONRestconfServiceImplTest { final ArgumentCaptor capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class); final ArgumentCaptor capturedNode = ArgumentCaptor.forClass(NormalizedNode.class); - verify(brokerFacade).commitConfigurationDataPut(notNull(SchemaContext.class), capturedPath.capture(), + verify(brokerFacade).commitConfigurationDataPut(notNull(EffectiveModelContext.class), capturedPath.capture(), capturedNode.capture(), isNull(), isNull()); verifyPath(capturedPath.getValue(), INTERFACES_QNAME, INTERFACE_QNAME, @@ -206,7 +205,7 @@ public class JSONRestconfServiceImplTest { doReturn(immediateFailedFluentFuture(new TransactionCommitFailedException("mock"))).when(result) .getFutureOfPutData(); when(result.getStatus()).thenReturn(Status.OK); - when(brokerFacade.commitConfigurationDataPut(notNull(SchemaContext.class), + when(brokerFacade.commitConfigurationDataPut(notNull(EffectiveModelContext.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), Mockito.anyString(), Mockito.anyString())).thenReturn(result); @@ -220,7 +219,7 @@ public class JSONRestconfServiceImplTest { @Test public void testPost() throws Exception { doReturn(CommitInfo.emptyFluentFuture()).when(brokerFacade).commitConfigurationDataPost( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), + any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), isNull(), isNull()); final String uriPath = null; @@ -231,7 +230,7 @@ public class JSONRestconfServiceImplTest { final ArgumentCaptor capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class); final ArgumentCaptor capturedNode = ArgumentCaptor.forClass(NormalizedNode.class); - verify(brokerFacade).commitConfigurationDataPost(notNull(SchemaContext.class), capturedPath.capture(), + verify(brokerFacade).commitConfigurationDataPost(notNull(EffectiveModelContext.class), capturedPath.capture(), capturedNode.capture(), isNull(), isNull()); verifyPath(capturedPath.getValue(), INTERFACES_QNAME); @@ -288,7 +287,7 @@ public class JSONRestconfServiceImplTest { @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" }) public void testPostFailure() throws Throwable { doReturn(immediateFailedFluentFuture(new TransactionCommitFailedException("mock"))).when(brokerFacade) - .commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class), + .commitConfigurationDataPost(any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), isNull(), isNull()); final String uriPath = null; @@ -418,10 +417,9 @@ public class JSONRestconfServiceImplTest { @SuppressWarnings("rawtypes") @Test public void testInvokeRpcWithInput() throws Exception { - final SchemaPath path = SchemaPath.create(true, MAKE_TOAST_QNAME); - final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode)null); - doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(path), any(NormalizedNode.class)); + doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(MAKE_TOAST_QNAME), + any(NormalizedNode.class)); final String uriPath = "toaster:make-toast"; final String input = loadData("/full-versions/make-toast-rpc-input.json"); @@ -431,7 +429,7 @@ public class JSONRestconfServiceImplTest { assertEquals("Output present", false, output.isPresent()); final ArgumentCaptor capturedNode = ArgumentCaptor.forClass(NormalizedNode.class); - verify(brokerFacade).invokeRpc(eq(path), capturedNode.capture()); + verify(brokerFacade).invokeRpc(eq(MAKE_TOAST_QNAME), capturedNode.capture()); assertTrue("Expected ContainerNode. Actual " + capturedNode.getValue().getClass(), capturedNode.getValue() instanceof ContainerNode); @@ -442,10 +440,8 @@ public class JSONRestconfServiceImplTest { @Test public void testInvokeRpcWithNoInput() throws Exception { - final SchemaPath path = SchemaPath.create(true, CANCEL_TOAST_QNAME); - final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode)null); - doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(any(SchemaPath.class), any()); + doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(any(QName.class), any()); final String uriPath = "toaster:cancel-toast"; @@ -453,18 +449,16 @@ public class JSONRestconfServiceImplTest { assertEquals("Output present", false, output.isPresent()); - verify(brokerFacade).invokeRpc(eq(path), any()); + verify(brokerFacade).invokeRpc(eq(CANCEL_TOAST_QNAME), any()); } @Test public void testInvokeRpcWithOutput() throws Exception { - final SchemaPath path = SchemaPath.create(true, TEST_OUTPUT_QNAME); - final NormalizedNode outputNode = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_OUTPUT_QNAME)) .withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build(); final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode); - doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(any(SchemaPath.class), any()); + doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(any(QName.class), any()); final String uriPath = "toaster:testOutput"; @@ -474,13 +468,13 @@ public class JSONRestconfServiceImplTest { assertNotNull("Returned null response", output.get()); assertThat("Missing \"textOut\"", output.get(), containsString("\"textOut\":\"foo\"")); - verify(brokerFacade).invokeRpc(eq(path), any()); + verify(brokerFacade).invokeRpc(eq(TEST_OUTPUT_QNAME), any()); } @Test(expected = OperationFailedException.class) public void testInvokeRpcFailure() throws Exception { final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption"); - doReturn(immediateFailedFluentFuture(exception)).when(brokerFacade).invokeRpc(any(SchemaPath.class), + doReturn(immediateFailedFluentFuture(exception)).when(brokerFacade).invokeRpc(any(QName.class), any(NormalizedNode.class)); final String uriPath = "toaster:cancel-toast"; diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java index e09f6c2bdb..2714f33425 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -42,6 +43,8 @@ import org.junit.Ignore; import org.junit.Test; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader; import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter; import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter; @@ -170,7 +173,8 @@ public class RestGetOperationTest extends JerseyTest { public void getDataWithUrlMountPoint() throws Exception { when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), isNull())).thenReturn(prepareCnDataForMountPointTest(false)); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); + when(mountInstance.getService(DOMSchemaService.class)) + .thenReturn(Optional.of(FixedDOMSchemaService.of(schemaContextTestModule))); String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/cont1"; assertEquals(200, get(uri, MediaType.APPLICATION_XML)); @@ -192,8 +196,8 @@ public class RestGetOperationTest extends JerseyTest { final YangInstanceIdentifier awaitedInstanceIdentifier = prepareInstanceIdentifierForList(); when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), eq(awaitedInstanceIdentifier), isNull())).thenReturn(prepareCnDataForSlashesBehindMountPointTest()); - - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); + when(mountInstance.getService(DOMSchemaService.class)) + .thenReturn(Optional.of(FixedDOMSchemaService.of(schemaContextTestModule))); final String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/" + "test-module:cont/lst1/GigabitEthernet0%2F0%2F0%2F0"; @@ -221,8 +225,8 @@ public class RestGetOperationTest extends JerseyTest { public void getDataMountPointIntoHighestElement() throws Exception { when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), isNull())).thenReturn(prepareCnDataForMountPointTest(true)); - - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); + when(mountInstance.getService(DOMSchemaService.class)) + .thenReturn(Optional.of(FixedDOMSchemaService.of(schemaContextTestModule))); final String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont"; assertEquals(200, get(uri, MediaType.APPLICATION_XML)); @@ -369,7 +373,7 @@ public class RestGetOperationTest extends JerseyTest { public void getOperationsBehindMountPointTest() throws Exception { setControllerContext(schemaContextModules); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); + mockMountPoint(); final String uri = "/operations/ietf-interfaces:interfaces/interface/0/yang-ext:mount/"; @@ -403,7 +407,7 @@ public class RestGetOperationTest extends JerseyTest { public void getModulesBehindMountPoint() throws Exception { setControllerContext(schemaContextModules); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); + mockMountPoint(); final String uri = "/modules/ietf-interfaces:interfaces/interface/0/yang-ext:mount/"; @@ -431,7 +435,7 @@ public class RestGetOperationTest extends JerseyTest { public void getModuleBehindMountPoint() throws Exception { setControllerContext(schemaContextModules); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextBehindMountPoint); + mockMountPoint(); final String uri = "/modules/module/ietf-interfaces:interfaces/interface/0/yang-ext:mount/" + "module1-behind-mount-point/2014-02-03"; @@ -456,8 +460,6 @@ public class RestGetOperationTest extends JerseyTest { assertEquals("module1-behind-mount-point", module.getLocalName()); assertEquals("2014-02-03", module.getRevision().get().toString()); assertEquals("module:1:behind:mount:point", module.getNamespace().toString()); - - } private static void validateModulesResponseXml(final Response response, final SchemaContext schemaContext) { @@ -744,4 +746,8 @@ public class RestGetOperationTest extends JerseyTest { } } + private void mockMountPoint() { + when(mountInstance.getService(DOMSchemaService.class)) + .thenReturn(Optional.of(FixedDOMSchemaService.of(schemaContextBehindMountPoint))); + } } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java index 599875a1ee..19eeda240a 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.text.ParseException; +import java.util.Optional; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; @@ -35,6 +36,8 @@ import org.mockito.ArgumentCaptor; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.rest.api.Draft02; import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader; import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter; @@ -47,7 +50,6 @@ import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class RestPostOperationTest extends JerseyTest { @@ -105,7 +107,8 @@ public class RestPostOperationTest extends JerseyTest { when(brokerFacade.commitConfigurationDataPost(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null)).thenReturn(mock(FluentFuture.class)); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); + when(mountInstance.getService(DOMSchemaService.class)) + .thenReturn(Optional.of(FixedDOMSchemaService.of(schemaContextTestModule))); String uri = "/config/ietf-interfaces:interfaces/interface/0/"; assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData4)); @@ -120,7 +123,7 @@ public class RestPostOperationTest extends JerseyTest { @Ignore //jenkins has problem with JerseyTest // - we expecting problems with singletons ControllerContext as schemaContext holder public void createConfigurationDataTest() throws UnsupportedEncodingException, ParseException { - when(brokerFacade.commitConfigurationDataPost((SchemaContext) null, any(YangInstanceIdentifier.class), + when(brokerFacade.commitConfigurationDataPost((EffectiveModelContext) null, any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null)) .thenReturn(mock(FluentFuture.class)); @@ -142,8 +145,8 @@ public class RestPostOperationTest extends JerseyTest { // FIXME : NEVER test a nr. of call some service in complex test suite // verify(brokerFacade, times(2)) verify(brokerFacade, times(1)) - .commitConfigurationDataPost((SchemaContext) null, instanceIdCaptor.capture(), compNodeCaptor.capture(), - null, null); + .commitConfigurationDataPost((EffectiveModelContext) null, instanceIdCaptor.capture(), + compNodeCaptor.capture(), null, null); // identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces," + // "(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)block]"; assertEquals(identifier, ImmutableList.copyOf(instanceIdCaptor.getValue().getPathArguments()).toString()); @@ -152,7 +155,7 @@ public class RestPostOperationTest extends JerseyTest { @Test public void createConfigurationDataNullTest() throws UnsupportedEncodingException { doReturn(CommitInfo.emptyFluentFuture()).when(brokerFacade).commitConfigurationDataPost( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), isNull(), + any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), isNull(), isNull()); //FIXME : find who is set schemaContext diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java index 4737efd573..8c04e50f09 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; +import java.util.Optional; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; @@ -34,6 +35,8 @@ import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.common.api.OptimisticLockFailedException; import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader; import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter; import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter; @@ -47,7 +50,6 @@ import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; //TODO UNSTABLE TESTS - FIX ME @@ -139,7 +141,7 @@ public class RestPutOperationTest extends JerseyTest { doReturn(CommitInfo.emptyFluentFuture()).when(result).getFutureOfPutData(); when(result.getStatus()).thenReturn(Status.OK); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); + mockMountPoint(); String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont"; assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2)); @@ -156,7 +158,7 @@ public class RestPutOperationTest extends JerseyTest { doReturn(CommitInfo.emptyFluentFuture()).when(result).getFutureOfPutData(); when(result.getStatus()).thenReturn(Status.OK); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); + mockMountPoint(); final String uri = "/config/ietf-interfaces:interfaces/yang-ext:mount"; assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData3)); @@ -168,12 +170,13 @@ public class RestPutOperationTest extends JerseyTest { final String uri = "/config/ietf-interfaces:interfaces/interface/eth0"; doThrow(OptimisticLockFailedException.class).when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null); + any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, + null); assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); doThrow(OptimisticLockFailedException.class).doReturn(mock(PutResult.class)).when(brokerFacade) - .commitConfigurationDataPut(any(SchemaContext.class), any(YangInstanceIdentifier.class), + .commitConfigurationDataPut(any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null); assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); @@ -186,7 +189,8 @@ public class RestPutOperationTest extends JerseyTest { doThrow(TransactionCommitFailedException.class) .when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null); + any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), + null, null); assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); } @@ -195,14 +199,21 @@ public class RestPutOperationTest extends JerseyTest { return target(uri).request(mediaType).put(Entity.entity(data, mediaType)).getStatus(); } + private void mockMountPoint() { + when(mountInstance.getService(DOMSchemaService.class)) + .thenReturn(Optional.of(FixedDOMSchemaService.of(schemaContextTestModule))); + } + private void mockCommitConfigurationDataPutMethod(final boolean noErrors) { final PutResult putResMock = mock(PutResult.class); if (noErrors) { doReturn(putResMock).when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null); + any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), + null, null); } else { doThrow(RestconfDocumentedException.class).when(brokerFacade).commitConfigurationDataPut( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null); + any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), + null, null); } } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java index c1b9e63d15..cc127d5e40 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplTest.java @@ -165,10 +165,10 @@ public class RestconfImplTest { final DOMRpcService rpcService = mock(DOMRpcService.class); doReturn(Optional.of(rpcService)).when(mount).getService(DOMRpcService.class); doReturn(immediateFluentFuture(mock(DOMRpcResult.class))).when(rpcService) - .invokeRpc(any(SchemaPath.class), any(NormalizedNode.class)); + .invokeRpc(any(QName.class), any(NormalizedNode.class)); this.restconfImpl.invokeRpc("randomId", ctx, uriInfo); this.restconfImpl.invokeRpc("ietf-netconf", ctx, uriInfo); - verify(rpcService, times(2)).invokeRpc(any(SchemaPath.class), any()); + verify(rpcService, times(2)).invokeRpc(any(QName.class), any()); } /** diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java index efbebda005..8b70e1f64c 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URIParametersParsing.java @@ -44,9 +44,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.api.InputSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; @@ -117,7 +118,7 @@ public class URIParametersParsing { final QName rpcInputQName = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote", "2014-01-14", "input"); final RpcDefinition rpcDef = Mockito.mock(RpcDefinition.class); - ContainerSchemaNode rpcInputSchemaNode = null; + ContainerLike rpcInputSchemaNode = null; for (final RpcDefinition rpc : rpcSalRemoteModule.getRpcs()) { if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName); @@ -168,7 +169,7 @@ public class URIParametersParsing { container.withChild(augmentationBuilder.build()); - when(rpcDef.getInput()).thenReturn(rpcInputSchemaNode); + when(rpcDef.getInput()).thenReturn((InputSchemaNode) rpcInputSchemaNode); when(rpcDef.getPath()).thenReturn(SchemaPath.create(true, rpcQName)); when(rpcDef.getQName()).thenReturn(rpcQName); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java index 39e7373cd3..1904e7f28e 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/URITest.java @@ -9,12 +9,13 @@ package org.opendaylight.controller.sal.restconf.impl.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import java.io.FileNotFoundException; +import java.util.Optional; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Rule; @@ -22,6 +23,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; @@ -135,7 +138,7 @@ public class URITest { @Test public void testMountPointWithExternModul() throws FileNotFoundException, ReactorException { - initMountService(true); + initSchemaService(); final InstanceIdentifierContext instanceIdentifier = controllerContext .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class/student/name"); assertEquals( @@ -148,7 +151,7 @@ public class URITest { @Test public void testMountPointWithoutExternModul() throws FileNotFoundException, ReactorException { - initMountService(true); + initSchemaService(); final InstanceIdentifierContext instanceIdentifier = controllerContext .toInstanceIdentifier("simple-nodes:users/yang-ext:mount/"); assertTrue(Iterables.isEmpty(instanceIdentifier.getInstanceIdentifier().getPathArguments())); @@ -156,17 +159,13 @@ public class URITest { @Test public void testMountPointWithoutMountPointSchema() throws FileNotFoundException, ReactorException { - initMountService(false); this.exception.expect(RestconfDocumentedException.class); controllerContext.toInstanceIdentifier("simple-nodes:users/yang-ext:mount/test-interface2:class"); } - public void initMountService(final boolean withSchema) throws FileNotFoundException, ReactorException { - if (withSchema) { - when(mountInstance.getSchemaContext()).thenReturn(mountSchemaContext); - } else { - when(mountInstance.getSchemaContext()).thenReturn(null); - } + public void initSchemaService() { + doReturn(Optional.of(FixedDOMSchemaService.of(mountSchemaContext))).when(mountInstance) + .getService(DOMSchemaService.class); } } diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/incubate/InMemoryMdsalModule.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/incubate/InMemoryMdsalModule.java index 18f1287a79..cabdc6ce77 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/incubate/InMemoryMdsalModule.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/incubate/InMemoryMdsalModule.java @@ -25,7 +25,7 @@ import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter; import org.opendaylight.mdsal.dom.broker.DOMRpcRouter; import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry; import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider; /** * Guice Module which binds the mdsal (not controller) {@link DataBroker} & Co. @@ -85,10 +85,10 @@ public class InMemoryMdsalModule extends AbstractModule { } @Provides - @Singleton SchemaContextProvider getSchemaContextProvider() { + @Singleton EffectiveModelContextProvider getSchemaContextProvider() { DOMSchemaService schemaService = dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService(); - if (schemaService instanceof SchemaContextProvider) { - return (SchemaContextProvider) schemaService; + if (schemaService instanceof EffectiveModelContextProvider) { + return (EffectiveModelContextProvider) schemaService; } throw new IllegalStateException( "The schema service isn't a SchemaContextProvider, it's a " + schemaService.getClass()); diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerTest.java index b642129fb8..b30991be77 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerTest.java @@ -47,6 +47,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; public class NotificationListenerTest { private static final QNameModule MODULE = QNameModule.create(URI.create("notifi:mod"), Revision.of("2016-11-23")); @@ -68,12 +69,12 @@ public class NotificationListenerTest { @Test public void notifi_leafTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-leaf")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-leaf")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf")); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), leaf); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), leaf); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -88,13 +89,13 @@ public class NotificationListenerTest { @Test public void notifi_cont_leafTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-cont")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-cont")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf")); final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), leaf); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), cont); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), cont); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -110,7 +111,7 @@ public class NotificationListenerTest { @Test public void notifi_list_Test() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-list")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-list")); final DOMNotification notificationData = mock(DOMNotification.class); @@ -118,7 +119,7 @@ public class NotificationListenerTest { final MapEntryNode entry = mockMapEntry(QName.create(MODULE, "lst"), leaf); final MapNode list = mockList(QName.create(MODULE, "lst"), entry); final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), list); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), cont); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), cont); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -134,12 +135,12 @@ public class NotificationListenerTest { @Test public void notifi_grpTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-grp")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-grp")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf")); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), leaf); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), leaf); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -153,13 +154,13 @@ public class NotificationListenerTest { @Test public void notifi_augmTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-augm")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-augm")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf-augm")); final AugmentationNode augm = mockAugm(leaf); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), augm); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), augm); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -226,10 +227,10 @@ public class NotificationListenerTest { return child; } - private String prepareJson(final DOMNotification notificationData, final SchemaPath schemaPathNotifi) + private String prepareJson(final DOMNotification notificationData, final Absolute schemaPathNotifi) throws Exception { final List paths = new ArrayList<>(); - paths.add(schemaPathNotifi); + paths.add(schemaPathNotifi.asSchemaPath()); final List listNotifi = Notificator.createNotificationListener(paths, "stream-name", NotificationOutputType.JSON.toString(), controllerContext); diff --git a/restconf/restconf-nb-rfc8040/pom.xml b/restconf/restconf-nb-rfc8040/pom.xml index fb27221d52..d9657782ad 100644 --- a/restconf/restconf-nb-rfc8040/pom.xml +++ b/restconf/restconf-nb-rfc8040/pom.xml @@ -22,6 +22,11 @@ 1.13.0-SNAPSHOT bundle + + + false + + javax.annotation diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/RestCodec.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/RestCodec.java index 12b7332f67..75e859410f 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/RestCodec.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/RestCodec.java @@ -18,8 +18,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.Set; +import org.checkerframework.checker.nullness.qual.Nullable; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.restconf.common.util.IdentityValuesDTO; import org.opendaylight.restconf.common.util.IdentityValuesDTO.IdentityValue; import org.opendaylight.restconf.common.util.IdentityValuesDTO.Predicate; @@ -41,6 +44,7 @@ import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; @@ -62,7 +66,7 @@ public final class RestCodec { // FIXME: IllegalArgumentCodec is not quite accurate public static IllegalArgumentCodec from(final TypeDefinition typeDefinition, - final DOMMountPoint mountPoint, final SchemaContext schemaContext) { + final DOMMountPoint mountPoint, final EffectiveModelContext schemaContext) { return new ObjectCodec(typeDefinition, mountPoint, schemaContext); } @@ -77,10 +81,10 @@ public final class RestCodec { private final TypeDefinition type; - private final SchemaContext schemaContext; + private final EffectiveModelContext schemaContext; private ObjectCodec(final TypeDefinition typeDefinition, final DOMMountPoint mountPoint, - final SchemaContext schemaContext) { + final EffectiveModelContext schemaContext) { this.schemaContext = schemaContext; this.type = RestUtil.resolveBaseTypeFrom(typeDefinition); if (this.type instanceof IdentityrefTypeDefinition) { @@ -348,7 +352,7 @@ public final class RestCodec { final URI validNamespace = resolveValidNamespace(namespace, mountPoint, schemaContext); Module module = null; if (mountPoint != null) { - module = mountPoint.getSchemaContext().findModules(validNamespace).iterator().next(); + module = modelContext(mountPoint).findModules(validNamespace).iterator().next(); } else { module = schemaContext.findModules(validNamespace).iterator().next(); } @@ -363,7 +367,7 @@ public final class RestCodec { final SchemaContext schemaContext) { URI validNamespace; if (mountPoint != null) { - validNamespace = findFirstModuleByName(mountPoint.getSchemaContext(), namespace); + validNamespace = findFirstModuleByName(modelContext(mountPoint), namespace); } else { validNamespace = findFirstModuleByName(schemaContext, namespace); } @@ -419,7 +423,7 @@ public final class RestCodec { final Iterable choiceNodes = Iterables.filter(container.getChildNodes(), ChoiceSchemaNode.class); final Iterable> map = Iterables.transform(choiceNodes, - choice -> choice.getCases()); + @Nullable ChoiceSchemaNode::getCases); for (final CaseSchemaNode caze : Iterables.concat(map)) { collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name); } @@ -430,4 +434,10 @@ public final class RestCodec { || node instanceof ContainerSchemaNode || node instanceof ListSchemaNode || node instanceof AnyxmlSchemaNode; } + + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/StringModuleInstanceIdentifierCodec.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/StringModuleInstanceIdentifierCodec.java index 091e4fc5df..c026f7dbc3 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/StringModuleInstanceIdentifierCodec.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/StringModuleInstanceIdentifierCodec.java @@ -13,22 +13,23 @@ import java.net.URI; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; public final class StringModuleInstanceIdentifierCodec extends AbstractModuleStringInstanceIdentifierCodec { private final DataSchemaContextTree dataContextTree; - private final SchemaContext context; + private final EffectiveModelContext context; private final String defaultPrefix; - public StringModuleInstanceIdentifierCodec(final SchemaContext context) { + public StringModuleInstanceIdentifierCodec(final EffectiveModelContext context) { this.context = requireNonNull(context); this.dataContextTree = DataSchemaContextTree.from(context); this.defaultPrefix = ""; } - public StringModuleInstanceIdentifierCodec(final SchemaContext context, final @NonNull String defaultPrefix) { + public StringModuleInstanceIdentifierCodec(final EffectiveModelContext context, + final @NonNull String defaultPrefix) { this.context = requireNonNull(context); this.dataContextTree = DataSchemaContextTree.from(context); this.defaultPrefix = defaultPrefix; diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeXmlBodyWriter.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeXmlBodyWriter.java index a89caa90c9..4198de95f8 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeXmlBodyWriter.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeXmlBodyWriter.java @@ -41,8 +41,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStre import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.ActionDefinition; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @Provider @@ -111,7 +111,7 @@ public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter pathContext, final NormalizedNode data, final Integer depth, final List> fields) throws IOException { final RestconfNormalizedNodeWriter nnWriter; - final SchemaContext schemaCtx = pathContext.getSchemaContext(); + final EffectiveModelContext schemaCtx = pathContext.getSchemaContext(); if (pathContext.getSchemaNode() instanceof RpcDefinition) { /* @@ -153,7 +153,7 @@ public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter> fields) { final NormalizedNodeStreamWriter xmlStreamWriter = XMLStreamNormalizedNodeStreamWriter .create(xmlWriter, schemaContext, schemaPath); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyReader.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyReader.java index 5b779de950..4403c1cb7f 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyReader.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlNormalizedNodeBodyReader.java @@ -48,7 +48,7 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; @@ -134,7 +134,7 @@ public class XmlNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyReade final NormalizedNodeResult resultHolder = new NormalizedNodeResult(); final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder); - if (schemaNode instanceof ContainerSchemaNode || schemaNode instanceof ListSchemaNode + if (schemaNode instanceof ContainerLike || schemaNode instanceof ListSchemaNode || schemaNode instanceof LeafSchemaNode) { final XmlParserStream xmlParser = XmlParserStream.create(writer, pathContext.getSchemaContext(), schemaNode); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java index 14fd87ce2f..7af23cf7db 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonToPatchBodyReader.java @@ -233,8 +233,8 @@ public class JsonToPatchBodyReader extends AbstractToPatchBodyReader { } else { edit.setTarget(codec.deserialize(codec.serialize(path.getInstanceIdentifier()).concat(target))); edit.setTargetSchemaNode(SchemaContextUtil.findDataSchemaNode(path.getSchemaContext(), - codec.getDataContextTree().getChild(edit.getTarget()).getDataSchemaNode().getPath() - .getParent())); + codec.getDataContextTree().findChild(edit.getTarget()).orElseThrow().getDataSchemaNode() + .getPath().getParent())); } break; diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java index 322000d7e6..49b4222e2f 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlToPatchBodyReader.java @@ -130,11 +130,12 @@ public class XmlToPatchBodyReader extends AbstractToPatchBodyReader { module.getQNameModule().getRevision().map(Revision::toString).orElse(null)))); targetNode = SchemaContextUtil.findDataSchemaNode(pathContext.getSchemaContext(), - codec.getDataContextTree().getChild(targetII).getDataSchemaNode().getPath().getParent()); + codec.getDataContextTree().findChild(targetII).orElseThrow().getDataSchemaNode() + .getPath().getParent()); // move schema node schemaNode = (DataSchemaNode) SchemaContextUtil.findDataSchemaNode(pathContext.getSchemaContext(), - codec.getDataContextTree().getChild(targetII).getDataSchemaNode().getPath()); + codec.getDataContextTree().findChild(targetII).orElseThrow().getDataSchemaNode().getPath()); } if (targetNode == null) { diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java index f11a226bae..d3dc392da0 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java @@ -9,6 +9,7 @@ package org.opendaylight.restconf.nb.rfc8040.rests.services.impl; import static java.util.Objects.requireNonNull; +import com.google.common.collect.ImmutableList; import java.util.Optional; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMRpcResult; @@ -36,7 +37,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,7 +128,7 @@ final class CreateStreamUtil { * @return Parsed stream name. */ private static String prepareDataChangeNotifiStreamName(final YangInstanceIdentifier path, - final SchemaContext schemaContext, final ContainerNode data) { + final EffectiveModelContext schemaContext, final ContainerNode data) { LogicalDatastoreType datastoreType = parseEnum( data, LogicalDatastoreType.class, RestconfStreamsConstants.DATASTORE_PARAM_NAME); datastoreType = datastoreType == null ? LogicalDatastoreType.CONFIGURATION : datastoreType; @@ -218,7 +219,8 @@ final class CreateStreamUtil { final Optional listenerForStreamName = ListenersBroker.getInstance() .getNotificationListenerFor(streamName); return listenerForStreamName.orElseGet(() -> ListenersBroker.getInstance().registerNotificationListener( - notificationDefinition.getPath(), streamName, outputType)); + Absolute.of(ImmutableList.copyOf(notificationDefinition.getPath().getPathFromRoot())), streamName, + outputType)); } private static String parseNotificationStreamName(final NotificationDefinition notificationDefinition, diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java index b45f69882e..a2becd5c7f 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImpl.java @@ -17,6 +17,7 @@ import static org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsCo import static org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants.STREAM_PATH; import static org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants.STREAM_PATH_PART; +import com.google.common.collect.ImmutableList; import java.net.URI; import java.time.Clock; import java.time.LocalDateTime; @@ -33,6 +34,7 @@ import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMActionResult; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.context.WriterParameters; @@ -76,7 +78,7 @@ import org.opendaylight.yangtools.yang.model.api.ActionDefinition; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -231,10 +233,10 @@ public class RestconfDataServiceImpl implements RestconfDataService { final URI uri = streamUtils.prepareUriByStreamName(uriInfo, listener.getStreamName()); final NormalizedNode mapToStreams = RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring( - listener.getSchemaPath().getLastComponent(), schemaContext.getNotifications(), null, + listener.getSchemaPath().lastNodeIdentifier(), schemaContext.getNotifications(), null, listener.getOutputType(), uri, SubscribeToStreamUtil.getMonitoringModule(schemaContext), exist); writeDataToDS(schemaContext, - listener.getSchemaPath().getLastComponent().getLocalName(), strategy, exist, mapToStreams); + listener.getSchemaPath().lastNodeIdentifier().getLocalName(), strategy, exist, mapToStreams); } private static boolean checkExist(final EffectiveModelContext schemaContext, final RestconfStrategy strategy) { @@ -273,8 +275,7 @@ public class RestconfDataServiceImpl implements RestconfDataService { final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint(); final EffectiveModelContext ref = mountPoint == null - ? this.schemaContextHandler.get() - : mountPoint.getEffectiveModelContext(); + ? this.schemaContextHandler.get() : modelContext(mountPoint); final RestconfStrategy strategy = getRestconfStrategy(mountPoint); return PutDataTransactionUtil.putData(payload, ref, strategy, checkedParms.insert, checkedParms.point); @@ -390,15 +391,14 @@ public class RestconfDataServiceImpl implements RestconfDataService { final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint(); final EffectiveModelContext ref = mountPoint == null - ? this.schemaContextHandler.get() - : mountPoint.getEffectiveModelContext(); + ? this.schemaContextHandler.get() : modelContext(mountPoint); final RestconfStrategy strategy = getRestconfStrategy(mountPoint); return PlainPatchDataTransactionUtil.patchData(payload, strategy, ref); } private EffectiveModelContext getSchemaContext(final DOMMountPoint mountPoint) { - return mountPoint == null ? schemaContextHandler.get() : mountPoint.getEffectiveModelContext(); + return mountPoint == null ? schemaContextHandler.get() : modelContext(mountPoint); } // FIXME: why is this synchronized? @@ -423,7 +423,8 @@ public class RestconfDataServiceImpl implements RestconfDataService { public Response invokeAction(final NormalizedNodeContext payload) { final InstanceIdentifierContext context = payload.getInstanceIdentifierContext(); final DOMMountPoint mountPoint = context.getMountPoint(); - final SchemaPath schemaPath = context.getSchemaNode().getPath(); + final Absolute schemaPath = Absolute.of(ImmutableList.copyOf(context.getSchemaNode().getPath() + .getPathFromRoot())); final YangInstanceIdentifier yangIIdContext = context.getInstanceIdentifier(); final NormalizedNode data = payload.getData(); @@ -437,7 +438,7 @@ public class RestconfDataServiceImpl implements RestconfDataService { if (mountPoint != null) { response = RestconfInvokeOperationsUtil.invokeActionViaMountPoint(mountPoint, (ContainerNode) data, schemaPath, yangIIdContext); - schemaContextRef = mountPoint.getEffectiveModelContext(); + schemaContextRef = modelContext(mountPoint); } else { response = RestconfInvokeOperationsUtil.invokeAction((ContainerNode) data, schemaPath, this.actionServiceHandler, yangIIdContext); @@ -462,4 +463,10 @@ public class RestconfDataServiceImpl implements RestconfDataService { return Response.status(200).entity(new NormalizedNodeContext(new InstanceIdentifierContext<>(yangIIdContext, resultNodeSchema, mountPoint, schemaContextRef), resultData)).build(); } + + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java index e63e0fbac1..725404041b 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImpl.java @@ -8,12 +8,14 @@ package org.opendaylight.restconf.nb.rfc8040.rests.services.impl; import java.net.URI; +import java.util.Optional; import javax.ws.rs.Path; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; @@ -24,11 +26,11 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService; import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfInvokeOperationsUtil; import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; /** * Implementation of {@link RestconfInvokeOperationsService}. @@ -61,7 +63,7 @@ public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperat public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { final EffectiveModelContext refSchemaCtx = this.schemaContextHandler.get(); - final SchemaPath schemaPath = payload.getInstanceIdentifierContext().getSchemaNode().getPath(); + final QName schemaPath = payload.getInstanceIdentifierContext().getSchemaNode().getQName(); final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint(); final URI namespace = payload.getInstanceIdentifierContext().getSchemaNode().getQName().getNamespace(); @@ -82,7 +84,7 @@ public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperat schemaContextRef = this.schemaContextHandler.get(); } else { response = RestconfInvokeOperationsUtil.invokeRpcViaMountPoint(mountPoint, payload.getData(), schemaPath); - schemaContextRef = mountPoint.getEffectiveModelContext(); + schemaContextRef = modelContext(mountPoint); } final DOMRpcResult result = RestconfInvokeOperationsUtil.checkResponse(response); @@ -101,4 +103,10 @@ public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperat schemaContextRef), resultData); } } + + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/SubscribeToStreamUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/SubscribeToStreamUtil.java index 9f1207f454..04433f3ee0 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/SubscribeToStreamUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/SubscribeToStreamUtil.java @@ -45,8 +45,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -145,7 +144,7 @@ abstract class SubscribeToStreamUtil { final DOMTransactionChain transactionChain = handlersHolder.getTransactionChainHandler().get(); final DOMDataTreeReadWriteTransaction writeTransaction = transactionChain.newReadWriteTransaction(); - final SchemaContext schemaContext = handlersHolder.getSchemaHandler().get(); + final EffectiveModelContext schemaContext = handlersHolder.getSchemaHandler().get(); final boolean exist = checkExist(schemaContext, writeTransaction); final URI uri = prepareUriByStreamName(uriInfo, streamName); @@ -160,11 +159,11 @@ abstract class SubscribeToStreamUtil { handlersHolder.getTransactionChainHandler(), handlersHolder.getSchemaHandler()); final NormalizedNode mapToStreams = RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring( - notificationListenerAdapter.get().getSchemaPath().getLastComponent(), + notificationListenerAdapter.get().getSchemaPath().lastNodeIdentifier(), schemaContext.getNotifications(), notificationQueryParams.getStart(), notificationListenerAdapter.get().getOutputType(), uri, getMonitoringModule(schemaContext), exist); writeDataToDS(schemaContext, - notificationListenerAdapter.get().getSchemaPath().getLastComponent().getLocalName(), writeTransaction, + notificationListenerAdapter.get().getSchemaPath().lastNodeIdentifier().getLocalName(), writeTransaction, exist, mapToStreams); submitData(writeTransaction); transactionChain.close(); @@ -231,11 +230,11 @@ abstract class SubscribeToStreamUtil { return uri; } - static Module getMonitoringModule(final SchemaContext schemaContext) { + static Module getMonitoringModule(final EffectiveModelContext schemaContext) { return schemaContext.findModule(MonitoringModule.MODULE_QNAME).orElse(null); } - private static void writeDataToDS(final SchemaContext schemaContext, final String name, + private static void writeDataToDS(final EffectiveModelContext schemaContext, final String name, final DOMDataTreeReadWriteTransaction readWriteTransaction, final boolean exist, final NormalizedNode mapToStreams) { String pathId; @@ -298,7 +297,7 @@ abstract class SubscribeToStreamUtil { listener.setRegistration(registration); } - private static boolean checkExist(final SchemaContext schemaContext, + private static boolean checkExist(final EffectiveModelContext schemaContext, final DOMDataTreeReadOperations readWriteTransaction) { try { return readWriteTransaction.exists(LogicalDatastoreType.OPERATIONAL, @@ -314,7 +313,7 @@ abstract class SubscribeToStreamUtil { return; } - final SchemaPath path = listener.getSchemaPath(); + final Absolute path = listener.getSchemaPath(); final ListenerRegistration registration = notificationServiceHandler.get().registerNotificationListener(listener, path); listener.setRegistration(registration); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtil.java index 4d996ef9bd..3ec3f487a5 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtil.java @@ -403,9 +403,10 @@ public final class PutDataTransactionUtil { return strategy.commit(); } - public static DataSchemaNode checkListAndOrderedType(final SchemaContext ctx, final YangInstanceIdentifier path) { + public static DataSchemaNode checkListAndOrderedType(final EffectiveModelContext ctx, + final YangInstanceIdentifier path) { final YangInstanceIdentifier parent = path.getParent(); - final DataSchemaContextNode node = DataSchemaContextTree.from(ctx).getChild(parent); + final DataSchemaContextNode node = DataSchemaContextTree.from(ctx).findChild(parent).orElseThrow(); final DataSchemaNode dataSchemaNode = node.getDataSchemaNode(); if (dataSchemaNode instanceof ListSchemaNode) { diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java index d75898dbe9..5558a714b0 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java @@ -64,10 +64,10 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNo import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; /** * Util class for read data from data store via transaction. @@ -189,7 +189,7 @@ public final class ReadDataTransactionUtil { public static @Nullable NormalizedNode readData(final @NonNull String valueOfContent, final @NonNull YangInstanceIdentifier path, final @NonNull RestconfStrategy strategy, - final String withDefa, final SchemaContext ctx) { + final String withDefa, final EffectiveModelContext ctx) { switch (valueOfContent) { case RestconfDataServiceConstant.ReadData.CONFIG: if (withDefa == null) { @@ -250,7 +250,7 @@ public final class ReadDataTransactionUtil { } private static NormalizedNode prepareDataByParamWithDef(final NormalizedNode result, - final YangInstanceIdentifier path, final String withDefa, final SchemaContext ctx) { + final YangInstanceIdentifier path, final String withDefa, final EffectiveModelContext ctx) { boolean trim; switch (withDefa) { case "trim": @@ -264,7 +264,7 @@ public final class ReadDataTransactionUtil { } final DataSchemaContextTree baseSchemaCtxTree = DataSchemaContextTree.from(ctx); - final DataSchemaNode baseSchemaNode = baseSchemaCtxTree.getChild(path).getDataSchemaNode(); + final DataSchemaNode baseSchemaNode = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (result instanceof ContainerNode) { final DataContainerNodeBuilder builder = Builders.containerBuilder((ContainerSchemaNode) baseSchemaNode); @@ -285,7 +285,7 @@ public final class ReadDataTransactionUtil { final YangInstanceIdentifier actualPath, final boolean trim, final List keys) { for (final DataContainerChild child : result.getValue()) { final YangInstanceIdentifier path = actualPath.node(child.getIdentifier()); - final DataSchemaNode childSchema = baseSchemaCtxTree.getChild(path).getDataSchemaNode(); + final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (child instanceof ContainerNode) { final DataContainerNodeBuilder childBuilder = Builders.containerBuilder((ContainerSchemaNode) childSchema); @@ -327,7 +327,8 @@ public final class ReadDataTransactionUtil { final List keys) { for (final MapEntryNode mapEntryNode : result.getValue()) { final YangInstanceIdentifier actualNode = path.node(mapEntryNode.getIdentifier()); - final DataSchemaNode childSchema = baseSchemaCtxTree.getChild(actualNode).getDataSchemaNode(); + final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(actualNode).orElseThrow() + .getDataSchemaNode(); final DataContainerNodeBuilder mapEntryBuilder = Builders.mapEntryBuilder((ListSchemaNode) childSchema); buildMapEntryBuilder(mapEntryBuilder, mapEntryNode, baseSchemaCtxTree, actualNode, trim, keys); @@ -340,7 +341,7 @@ public final class ReadDataTransactionUtil { final YangInstanceIdentifier actualPath, final boolean trim) { for (final DataContainerChild child : result.getValue()) { final YangInstanceIdentifier path = actualPath.node(child.getIdentifier()); - final DataSchemaNode childSchema = baseSchemaCtxTree.getChild(path).getDataSchemaNode(); + final DataSchemaNode childSchema = baseSchemaCtxTree.findChild(path).orElseThrow().getDataSchemaNode(); if (child instanceof ContainerNode) { final DataContainerNodeBuilder builderChild = Builders.containerBuilder((ContainerSchemaNode) childSchema); @@ -405,7 +406,7 @@ public final class ReadDataTransactionUtil { * @return {@link NormalizedNode} */ private static @Nullable NormalizedNode readAllData(final @NonNull RestconfStrategy strategy, - final YangInstanceIdentifier path, final String withDefa, final SchemaContext ctx) { + final YangInstanceIdentifier path, final String withDefa, final EffectiveModelContext ctx) { // PREPARE STATE DATA NODE final NormalizedNode stateDataNode = readDataViaTransaction( strategy, LogicalDatastoreType.OPERATIONAL, path, false); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfInvokeOperationsUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfInvokeOperationsUtil.java index c2e1f80801..8bef7a3f46 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfInvokeOperationsUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/RestconfInvokeOperationsUtil.java @@ -24,12 +24,13 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag; import org.opendaylight.restconf.common.errors.RestconfError.ErrorType; import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +56,7 @@ public final class RestconfInvokeOperationsUtil { * @return {@link DOMRpcResult} */ public static DOMRpcResult invokeRpcViaMountPoint(final DOMMountPoint mountPoint, final NormalizedNode data, - final SchemaPath schemaPath) { + final QName schemaPath) { final Optional mountPointService = mountPoint.getService(DOMRpcService.class); if (mountPointService.isPresent()) { return prepareResult(mountPointService.get().invokeRpc(schemaPath, nonnullInput(schemaPath, data))); @@ -70,25 +71,25 @@ public final class RestconfInvokeOperationsUtil { * * @param data * input data - * @param schemaPath - * schema path of data + * @param rpc + * RPC type * @param rpcServiceHandler * rpc service handler to invoke rpc * @return {@link DOMRpcResult} */ - public static DOMRpcResult invokeRpc(final NormalizedNode data, final SchemaPath schemaPath, + public static DOMRpcResult invokeRpc(final NormalizedNode data, final QName rpc, final RpcServiceHandler rpcServiceHandler) { final DOMRpcService rpcService = rpcServiceHandler.get(); if (rpcService == null) { throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE); } - return prepareResult(rpcService.invokeRpc(schemaPath, nonnullInput(schemaPath, data))); + return prepareResult(rpcService.invokeRpc(rpc, nonnullInput(rpc, data))); } - private static @NonNull NormalizedNode nonnullInput(final SchemaPath type, final NormalizedNode input) { + private static @NonNull NormalizedNode nonnullInput(final QName type, final NormalizedNode input) { return input != null ? input - : ImmutableNodes.containerNode(YangConstants.operationInputQName(type.getLastComponent().getModule())); + : ImmutableNodes.containerNode(YangConstants.operationInputQName(type.getModule())); } /** @@ -133,7 +134,7 @@ public final class RestconfInvokeOperationsUtil { * @return {@link DOMActionResult} */ public static DOMActionResult invokeActionViaMountPoint(final DOMMountPoint mountPoint, final ContainerNode data, - final SchemaPath schemaPath, final YangInstanceIdentifier yangIId) { + final Absolute schemaPath, final YangInstanceIdentifier yangIId) { final Optional mountPointService = mountPoint.getService(DOMActionService.class); if (!mountPointService.isPresent()) { throw new RestconfDocumentedException("DomAction service is missing."); @@ -152,7 +153,7 @@ public final class RestconfInvokeOperationsUtil { * action service handler to invoke action * @return {@link DOMActionResult} */ - public static DOMActionResult invokeAction(final ContainerNode data, final SchemaPath schemaPath, + public static DOMActionResult invokeAction(final ContainerNode data, final Absolute schemaPath, final ActionServiceHandler actionServiceHandler, final YangInstanceIdentifier yangIId) { return prepareActionResult( actionServiceHandler.get().invokeAction(schemaPath, prepareDataTreeId(yangIId), data)); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceImpl.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceImpl.java index bfb3436a05..15abbb204f 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceImpl.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfOperationsServiceImpl.java @@ -11,6 +11,7 @@ import java.util.Optional; import javax.ws.rs.Path; import javax.ws.rs.core.UriInfo; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; @@ -22,6 +23,7 @@ import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfOperationsService; import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants; import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,6 +83,12 @@ public class RestconfOperationsServiceImpl implements RestconfOperationsService final InstanceIdentifierContext mountPointIdentifier = ParserIdentifier.toInstanceIdentifier(identifier, schemaContextHandler.get(), Optional.of(this.domMountPointServiceHandler.get())); final DOMMountPoint mountPoint = mountPointIdentifier.getMountPoint(); - return OperationsResourceUtils.contextForModelContext(mountPoint.getSchemaContext(), mountPoint); + return OperationsResourceUtils.contextForModelContext(modelContext(mountPoint), mountPoint); + } + + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/AbstractNotificationsData.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/AbstractNotificationsData.java index d2c2322c4e..45dde3f2da 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/AbstractNotificationsData.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/AbstractNotificationsData.java @@ -37,7 +37,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter; import org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -127,7 +127,7 @@ abstract class AbstractNotificationsData { * schema path of data * @return {@link DOMResult} */ - protected DOMResult writeNormalizedNode(final NormalizedNode normalized, final SchemaContext context, + protected DOMResult writeNormalizedNode(final NormalizedNode normalized, final EffectiveModelContext context, final SchemaPath schemaPath) throws IOException, XMLStreamException { final Document doc = UntrustedXML.newDocumentBuilder().newDocument(); final DOMResult result = new DOMResult(doc); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenerAdapter.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenerAdapter.java index d9d6eb3533..655e48bc39 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenerAdapter.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenerAdapter.java @@ -35,6 +35,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -132,7 +133,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster * @return Data in printable form. */ private String prepareXml(final Collection dataTreeCandidates) { - final SchemaContext schemaContext = schemaHandler.get(); + final EffectiveModelContext schemaContext = schemaHandler.get(); final DataSchemaContextTree dataContextTree = DataSchemaContextTree.from(schemaContext); final Document doc = createDocument(); final Element notificationElement = basePartDoc(doc); @@ -151,7 +152,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster */ private void addValuesToDataChangedNotificationEventElement(final Document doc, final Element dataChangedNotificationEventElement, final Collection dataTreeCandidates, - final SchemaContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { + final EffectiveModelContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { for (DataTreeCandidate dataTreeCandidate : dataTreeCandidates) { DataTreeCandidateNode candidateNode = dataTreeCandidate.getRootNode(); @@ -172,7 +173,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster private void addNodeToDataChangeNotificationEventElement(final Document doc, final Element dataChangedNotificationEventElement, final DataTreeCandidateNode candidateNode, - final YangInstanceIdentifier parentYiid, final SchemaContext schemaContext, + final YangInstanceIdentifier parentYiid, final EffectiveModelContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { Optional> optionalNormalizedNode = Optional.empty(); @@ -288,7 +289,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster } private Node createCreatedChangedDataChangeEventElement(final Document doc, final YangInstanceIdentifier eventPath, - final NormalizedNode normalized, final Operation operation, final SchemaContext schemaContext, + final NormalizedNode normalized, final Operation operation, final EffectiveModelContext schemaContext, final DataSchemaContextTree dataSchemaContextTree) { final Element dataChangeEventElement = doc.createElement(DATA_CHANGE_EVENT); final Element pathElement = doc.createElement(PATH); @@ -300,7 +301,7 @@ public class ListenerAdapter extends AbstractCommonSubscriber implements Cluster dataChangeEventElement.appendChild(operationElement); try { - SchemaPath nodePath; + final SchemaPath nodePath; final Optional> childrenSchemaNode = dataSchemaContextTree.findChild(eventPath); checkState(childrenSchemaNode.isPresent()); if (normalized instanceof MapEntryNode || normalized instanceof UnkeyedListEntryNode) { diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenersBroker.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenersBroker.java index 299eef3256..d1dadcf22e 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenersBroker.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/ListenersBroker.java @@ -24,7 +24,7 @@ import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants; import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -164,7 +164,7 @@ public final class ListenersBroker { * @param outputType Specific type of output for notifications - XML or JSON. * @return Created or existing notification listener adapter. */ - public NotificationListenerAdapter registerNotificationListener(final SchemaPath schemaPath, + public NotificationListenerAdapter registerNotificationListener(final Absolute schemaPath, final String streamName, final NotificationOutputType outputType) { requireNonNull(schemaPath); requireNonNull(streamName); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerAdapter.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerAdapter.java index 8d95aca788..c1cbdd98f8 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerAdapter.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerAdapter.java @@ -28,8 +28,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWrit import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier; import org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter; import org.opendaylight.yangtools.yang.data.codec.gson.JsonWriterFactory; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -44,7 +44,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem private static final Logger LOG = LoggerFactory.getLogger(NotificationListenerAdapter.class); private final String streamName; - private final SchemaPath path; + private final Absolute path; private final String outputType; /** @@ -54,8 +54,8 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem * @param streamName Name of the stream. * @param outputType Type of output on notification (JSON or XML). */ - NotificationListenerAdapter(final SchemaPath path, final String streamName, final String outputType) { - setLocalNameOfPath(path.getLastComponent().getLocalName()); + NotificationListenerAdapter(final Absolute path, final String streamName, final String outputType) { + setLocalNameOfPath(path.lastNodeIdentifier().getLocalName()); this.outputType = requireNonNull(outputType); this.path = requireNonNull(path); @@ -80,7 +80,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem return; } - final SchemaContext schemaContext = schemaHandler.get(); + final EffectiveModelContext schemaContext = schemaHandler.get(); final String xml = prepareXml(schemaContext, notification); if (checkFilter(xml)) { post(outputType.equals("JSON") ? prepareJson(schemaContext, notification) : xml); @@ -102,7 +102,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem * * @return The configured schema path that points to observing YANG notification schema node. */ - public SchemaPath getSchemaPath() { + public Absolute getSchemaPath() { return this.path; } @@ -112,7 +112,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem * @return Transformed notification data in JSON format. */ @VisibleForTesting - String prepareJson(final SchemaContext schemaContext, final DOMNotification notification) { + String prepareJson(final EffectiveModelContext schemaContext, final DOMNotification notification) { final JsonParser jsonParser = new JsonParser(); final JsonObject json = new JsonObject(); json.add("ietf-restconf:notification", jsonParser.parse(writeBodyToString(schemaContext, notification))); @@ -120,7 +120,8 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem return json.toString(); } - private static String writeBodyToString(final SchemaContext schemaContext, final DOMNotification notification) { + private static String writeBodyToString(final EffectiveModelContext schemaContext, + final DOMNotification notification) { final Writer writer = new StringWriter(); final NormalizedNodeStreamWriter jsonStream = JSONNormalizedNodeStreamWriter.createExclusiveWriter( JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext), @@ -140,7 +141,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem * * @return Transformed notification data in XML format. */ - private String prepareXml(final SchemaContext schemaContext, final DOMNotification notification) { + private String prepareXml(final EffectiveModelContext schemaContext, final DOMNotification notification) { final Document doc = createDocument(); final Element notificationElement = basePartDoc(doc); @@ -153,9 +154,9 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem } private void addValuesToNotificationEventElement(final Document doc, final Element element, - final SchemaContext schemaContext, final DOMNotification notification) { + final EffectiveModelContext schemaContext, final DOMNotification notification) { try { - final DOMResult domResult = writeNormalizedNode(notification.getBody(), schemaContext, this.path); + final DOMResult domResult = writeNormalizedNode(notification.getBody(), schemaContext, path.asSchemaPath()); final Node result = doc.importNode(domResult.getNode().getFirstChild(), true); final Element dataElement = doc.createElement("notification"); dataElement.appendChild(result); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtil.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtil.java index 21a40ab50d..d328790528 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtil.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/mapping/RestconfMappingNodeUtil.java @@ -50,9 +50,11 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.ModuleLike; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.opendaylight.yangtools.yang.model.api.Submodule; /** * Util class for mapping nodes. @@ -116,7 +118,7 @@ public final class RestconfMappingNodeUtil { * schema context */ private static void fillMapByModules(final CollectionNodeBuilder mapBuilder, - final DataSchemaNode moduleSch, final boolean isSubmodule, final Module module, + final DataSchemaNode moduleSch, final boolean isSubmodule, final ModuleLike module, final Module ietfYangLibraryModule, final SchemaContext context) { final DataContainerNodeBuilder mapEntryBuilder = Builders.mapEntryBuilder((ListSchemaNode) moduleSch); @@ -164,14 +166,14 @@ public final class RestconfMappingNodeUtil { * @param context * schema context */ - private static void addSubmodules(final Module module, + private static void addSubmodules(final ModuleLike module, final DataContainerNodeBuilder mapEntryBuilder, final Module ietfYangLibraryModule, final SchemaContext context) { final DataSchemaNode listSubm = findSchemaInListOfModulesSchema( IetfYangLibrary.SPECIFIC_MODULE_SUBMODULE_LIST_QNAME, ietfYangLibraryModule); final CollectionNodeBuilder mapBuilder = Builders.orderedMapBuilder((ListSchemaNode) listSubm); - for (final Module submodule : module.getSubmodules()) { + for (final Submodule submodule : module.getSubmodules()) { fillMapByModules(mapBuilder, listSubm, true, submodule, ietfYangLibraryModule, context); } mapEntryBuilder.withChild(mapBuilder.build()); @@ -189,7 +191,7 @@ public final class RestconfMappingNodeUtil { * @param context * schema context */ - private static void addDeviationList(final Module module, + private static void addDeviationList(final ModuleLike module, final DataContainerNodeBuilder mapEntryBuilder, final Module ietfYangLibraryModule, final SchemaContext context) { final DataSchemaNode deviationsSchema = findSchemaInListOfModulesSchema( @@ -245,7 +247,7 @@ public final class RestconfMappingNodeUtil { * @param ietfYangLibraryModule * ietf-yang-library module */ - private static void addCommonLeafs(final Module module, + private static void addCommonLeafs(final ModuleLike module, final DataContainerNodeBuilder mapEntryBuilder, final Module ietfYangLibraryModule) { addChildOfModuleBySpecificModuleInternal(IetfYangLibrary.SPECIFIC_MODULE_NAME_LEAF_QNAME, mapEntryBuilder, diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodec.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodec.java index 3d67b9bb59..df7d5e3b25 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodec.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodec.java @@ -8,7 +8,7 @@ package org.opendaylight.restconf.nb.rfc8040.utils.parser; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; /** * Codec for identifier to serialize {@link YangInstanceIdentifier} to @@ -22,11 +22,11 @@ public final class IdentifierCodec { throw new UnsupportedOperationException("Util class."); } - public static String serialize(final YangInstanceIdentifier data, final SchemaContext schemaContext) { + public static String serialize(final YangInstanceIdentifier data, final EffectiveModelContext schemaContext) { return YangInstanceIdentifierSerializer.create(schemaContext, data); } - public static YangInstanceIdentifier deserialize(final String data, final SchemaContext schemaContext) { + public static YangInstanceIdentifier deserialize(final String data, final EffectiveModelContext schemaContext) { if (data == null) { return YangInstanceIdentifier.builder().build(); } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifier.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifier.java index e3145cbfef..e8cbdde7b7 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifier.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifier.java @@ -7,6 +7,7 @@ */ package org.opendaylight.restconf.nb.rfc8040.utils.parser; +import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Verify.verifyNotNull; import com.google.common.annotations.VisibleForTesting; @@ -23,6 +24,7 @@ import java.util.Optional; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMMountPointService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; @@ -93,7 +95,7 @@ public final class ParserIdentifier { .orElseThrow(() -> new RestconfDocumentedException("Mount point does not exist.", ErrorType.PROTOCOL, ErrorTag.DATA_MISSING)); - final EffectiveModelContext mountSchemaContext = mountPoint.getEffectiveModelContext(); + final EffectiveModelContext mountSchemaContext = coerceModelContext(mountPoint); final String pathId = pathsIt.next().replaceFirst("/", ""); return createIIdContext(mountSchemaContext, pathId, mountPoint); } @@ -115,7 +117,8 @@ public final class ParserIdentifier { schemaContext); } - private static SchemaNode getPathSchema(final SchemaContext schemaContext, final YangInstanceIdentifier urlPath) { + private static SchemaNode getPathSchema(final EffectiveModelContext schemaContext, + final YangInstanceIdentifier urlPath) { // First things first: an empty path means data invocation on SchemaContext if (urlPath.isEmpty()) { return schemaContext; @@ -168,7 +171,7 @@ public final class ParserIdentifier { * @return Yang instance identifier serialized to String */ public static String stringFromYangInstanceIdentifier(final YangInstanceIdentifier instanceIdentifier, - final SchemaContext schemaContext) { + final EffectiveModelContext schemaContext) { return IdentifierCodec.serialize(instanceIdentifier, schemaContext); } @@ -261,9 +264,9 @@ public final class ParserIdentifier { Optional.of(domMountPointService)); final String moduleName = validateAndGetModulName(componentIter); final Revision revision = validateAndGetRevision(componentIter); - final Module module = point.getMountPoint().getSchemaContext().findModule(moduleName, revision) - .orElse(null); - return new SchemaExportContext(point.getMountPoint().getSchemaContext(), module, sourceProvider); + final EffectiveModelContext context = coerceModelContext(point.getMountPoint()); + final Module module = context.findModule(moduleName, revision).orElse(null); + return new SchemaExportContext(context, module, sourceProvider); } } @@ -307,4 +310,16 @@ public final class ParserIdentifier { return name; } + + private static EffectiveModelContext coerceModelContext(final DOMMountPoint mountPoint) { + final EffectiveModelContext context = modelContext(mountPoint); + checkState(context != null, "Mount point %s does not have a model context", mountPoint); + return context; + } + + private static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java index 2b9bbc778b..b0f797cf19 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierDeserializer.java @@ -31,9 +31,10 @@ import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; import org.opendaylight.yangtools.yang.model.api.ActionDefinition; import org.opendaylight.yangtools.yang.model.api.ActionNodeContainer; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; @@ -63,13 +64,13 @@ public final class YangInstanceIdentifierDeserializer { // percent encoded radix for parsing integers private static final int PERCENT_ENCODED_RADIX = 16; - private final SchemaContext schemaContext; + private final EffectiveModelContext schemaContext; private final String data; private DataSchemaContextNode current; private int offset; - private YangInstanceIdentifierDeserializer(final SchemaContext schemaContext, final String data) { + private YangInstanceIdentifierDeserializer(final EffectiveModelContext schemaContext, final String data) { this.schemaContext = requireNonNull(schemaContext); this.data = requireNonNull(data); current = DataSchemaContextTree.from(schemaContext).getRoot(); @@ -82,7 +83,7 @@ public final class YangInstanceIdentifierDeserializer { * @param data path to data, in URL string form * @return {@link Iterable} of {@link PathArgument} */ - public static Iterable create(final SchemaContext schemaContext, final String data) { + public static Iterable create(final EffectiveModelContext schemaContext, final String data) { return new YangInstanceIdentifierDeserializer(schemaContext, data).parse(); } @@ -333,8 +334,8 @@ public final class YangInstanceIdentifierDeserializer { private QName getQNameOfDataSchemaNode(final String nodeName) { final DataSchemaNode dataSchemaNode = current.getDataSchemaNode(); - if (dataSchemaNode instanceof ContainerSchemaNode) { - return getQNameOfDataSchemaNode((ContainerSchemaNode) dataSchemaNode, nodeName); + if (dataSchemaNode instanceof ContainerLike) { + return getQNameOfDataSchemaNode((ContainerLike) dataSchemaNode, nodeName); } else if (dataSchemaNode instanceof ListSchemaNode) { return getQNameOfDataSchemaNode((ListSchemaNode) dataSchemaNode, nodeName); } diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java index c3623bed48..3c489ba6d5 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/YangInstanceIdentifierSerializer.java @@ -24,6 +24,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithV import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode; import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -50,7 +51,7 @@ public final class YangInstanceIdentifierSerializer { * path to data * @return {@link String} */ - public static String create(final SchemaContext schemaContext, final YangInstanceIdentifier data) { + public static String create(final EffectiveModelContext schemaContext, final YangInstanceIdentifier data) { final DataSchemaContextNode current = DataSchemaContextTree.from(schemaContext).getRoot(); final MainVarsWrapper variables = new MainVarsWrapper(current); final StringBuilder path = new StringBuilder(); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java index 60097ecd8e..d8121fbe97 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/XmlBodyReaderMountPointTest.java @@ -144,34 +144,26 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest { assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString())); } - private void checkExpectValueNormalizeNodeContext( - final DataSchemaNode dataSchemaNode, + private static void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, final NormalizedNodeContext nnContext) { checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null); } - private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, + private static void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode, final NormalizedNodeContext nnContext, final QName qualifiedName) { - YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier - .of(dataSchemaNode.getQName()); - final DOMMountPoint mountPoint = nnContext - .getInstanceIdentifierContext().getMountPoint(); - final DataSchemaNode mountDataSchemaNode = mountPoint - .getSchemaContext().getDataChildByName( - dataSchemaNode.getQName()); + YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName()); + final DOMMountPoint mountPoint = nnContext.getInstanceIdentifierContext().getMountPoint(); + final DataSchemaNode mountDataSchemaNode = modelContext(mountPoint) + .getDataChildByName(dataSchemaNode.getQName()); assertNotNull(mountDataSchemaNode); if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) { - final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode) - .getDataChildByName(qualifiedName); - dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent) - .node(child.getQName()).build(); - assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode() - .equals(child)); + final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(qualifiedName); + dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build(); + assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child)); } else { assertTrue(mountDataSchemaNode.equals(dataSchemaNode)); } - assertNotNull(NormalizedNodes.findNode(nnContext.getData(), - dataNodeIdent)); + assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent)); } /** diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java index b08e74378c..b1257c274f 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java @@ -9,7 +9,6 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.test; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -23,6 +22,8 @@ import javax.ws.rs.core.Request; import javax.ws.rs.core.UriInfo; import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMMountPointService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.restconf.common.context.NormalizedNodeContext; import org.opendaylight.restconf.common.patch.PatchContext; import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; @@ -49,8 +50,8 @@ public abstract class AbstractBodyReaderTest { final DOMMountPointService mountPointService = mock(DOMMountPointService.class); final DOMMountPoint mountPoint = mock(DOMMountPoint.class); doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class)); - doReturn(schemaContext).when(mountPoint).getEffectiveModelContext(); - doCallRealMethod().when(mountPoint).getSchemaContext(); + doReturn(Optional.of(FixedDOMSchemaService.of(schemaContext))).when(mountPoint) + .getService(DOMSchemaService.class); mountPointServiceHandler = new DOMMountPointServiceHandler(mountPointService); } @@ -114,6 +115,12 @@ public abstract class AbstractBodyReaderTest { protected static void checkPatchContextMountPoint(final PatchContext patchContext) { checkPatchContext(patchContext); assertNotNull(patchContext.getInstanceIdentifierContext().getMountPoint()); - assertNotNull(patchContext.getInstanceIdentifierContext().getMountPoint().getSchemaContext()); } + + protected static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) { + return mountPoint.getService(DOMSchemaService.class) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); + } + } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtilTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtilTest.java index b6d3efc3c7..edd27c49c6 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtilTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtilTest.java @@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; @@ -81,7 +81,7 @@ public class CreateStreamUtilTest { final Module rpcModule = schema.findModules("sal-remote").iterator().next(); final QName rpcQName = QName.create(rpcModule.getQNameModule(), rpcName); final QName rpcInputQName = QName.create(rpcModule.getQNameModule(), inputOutput); - ContainerSchemaNode rpcInputSchemaNode = null; + ContainerLike rpcInputSchemaNode = null; for (final RpcDefinition rpc : rpcModule.getRpcs()) { if (rpcQName.isEqualWithoutRevision(rpc.getQName())) { rpcInputSchemaNode = SchemaNodeUtils.getRpcDataSchema(rpc, rpcInputQName); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java index 35165f33f5..e6286e90ed 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/JSONRestconfServiceRfc8040ImplTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.notNull; -import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -59,6 +58,7 @@ import org.opendaylight.mdsal.dom.api.DOMRpcService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.api.DOMTransactionChain; import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.restconf.nb.rfc8040.TestUtils; import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler; import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler; @@ -85,8 +85,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; /** * Unit tests for JSONRestconfServiceDraft18. @@ -466,10 +464,9 @@ public class JSONRestconfServiceRfc8040ImplTest { @Test public void testInvokeRpcWithInput() throws IOException, OperationFailedException { - final SchemaPath path = SchemaPath.create(true, MAKE_TOAST_QNAME); - final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode)null); - doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), any(NormalizedNode.class)); + doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(MAKE_TOAST_QNAME), + any(NormalizedNode.class)); final String uriPath = "toaster:make-toast"; final String input = loadData("/full-versions/make-toast-rpc-input.json"); @@ -479,7 +476,7 @@ public class JSONRestconfServiceRfc8040ImplTest { assertEquals("Output present", false, output.isPresent()); final ArgumentCaptor> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class); - verify(mockRpcService).invokeRpc(eq(path), capturedNode.capture()); + verify(mockRpcService).invokeRpc(eq(MAKE_TOAST_QNAME), capturedNode.capture()); assertTrue("Expected ContainerNode. Actual " + capturedNode.getValue().getClass(), capturedNode.getValue() instanceof ContainerNode); @@ -490,10 +487,8 @@ public class JSONRestconfServiceRfc8040ImplTest { @Test public void testInvokeRpcWithNoInput() throws OperationFailedException { - final SchemaPath path = SchemaPath.create(true, CANCEL_TOAST_QNAME); - final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode)null); - doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), any()); + doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(CANCEL_TOAST_QNAME), any()); final String uriPath = "toaster:cancel-toast"; @@ -501,18 +496,16 @@ public class JSONRestconfServiceRfc8040ImplTest { assertEquals("Output present", false, output.isPresent()); - verify(mockRpcService).invokeRpc(eq(path), any()); + verify(mockRpcService).invokeRpc(eq(CANCEL_TOAST_QNAME), any()); } @Test public void testInvokeRpcWithOutput() throws OperationFailedException { - final SchemaPath path = SchemaPath.create(true, TEST_OUTPUT_QNAME); - final NormalizedNode outputNode = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_OUTPUT_QNAME)) .withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build(); final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode); - doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), any()); + doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(TEST_OUTPUT_QNAME), any()); final String uriPath = "toaster:testOutput"; @@ -523,12 +516,12 @@ public class JSONRestconfServiceRfc8040ImplTest { assertThat("Output element is missing namespace", output.get(), containsString("\"toaster:output\"")); assertThat("Missing \"textOut\"", output.get(), containsString("\"textOut\":\"foo\"")); - verify(mockRpcService).invokeRpc(eq(path), any()); + verify(mockRpcService).invokeRpc(eq(TEST_OUTPUT_QNAME), any()); } public void testInvokeRpcFailure() { final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption"); - doReturn(immediateFailedFluentFuture(exception)).when(mockRpcService).invokeRpc(any(SchemaPath.class), + doReturn(immediateFailedFluentFuture(exception)).when(mockRpcService).invokeRpc(any(QName.class), any(NormalizedNode.class)); assertThrows(OperationFailedException.class, @@ -568,10 +561,10 @@ public class JSONRestconfServiceRfc8040ImplTest { } DOMMountPoint setupTestMountPoint() throws FileNotFoundException { - final SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module"); + final EffectiveModelContext schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module"); final DOMMountPoint mockMountPoint = mock(DOMMountPoint.class); - doReturn(schemaContextTestModule).when(mockMountPoint).getEffectiveModelContext(); - doCallRealMethod().when(mockMountPoint).getSchemaContext(); + doReturn(Optional.of(FixedDOMSchemaService.of(schemaContextTestModule))).when(mockMountPoint) + .getService(DOMSchemaService.class); doReturn(Optional.of(mockDOMDataBroker)).when(mockMountPoint).getService(DOMDataBroker.class); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java index 9a7f4288bd..080e8ba219 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataServiceImplTest.java @@ -13,7 +13,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.opendaylight.restconf.common.patch.PatchEditOperation.CREATE; @@ -51,6 +50,7 @@ import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.api.DOMTransactionChain; import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.dom.api.NetconfDataTreeService; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.context.NormalizedNodeContext; @@ -192,7 +192,8 @@ public class RestconfDataServiceImplTest { this.contextRef = YangParserTestUtils.parseYangFiles(TestRestconfUtils.loadFiles(PATH_FOR_NEW_SCHEMA_CONTEXT)); - this.schemaNode = DataSchemaContextTree.from(this.contextRef).getChild(this.iidBase).getDataSchemaNode(); + this.schemaNode = DataSchemaContextTree.from(this.contextRef).findChild(this.iidBase).orElseThrow( + ).getDataSchemaNode(); doReturn(CommitInfo.emptyFluentFuture()).when(this.write).commit(); doReturn(CommitInfo.emptyFluentFuture()).when(this.readWrite).commit(); @@ -215,8 +216,8 @@ public class RestconfDataServiceImplTest { this.actionServiceHandler, configuration); doReturn(Optional.of(this.mountPoint)).when(this.mountPointService) .getMountPoint(any(YangInstanceIdentifier.class)); - doCallRealMethod().when(this.mountPoint).getSchemaContext(); - doReturn(this.contextRef).when(this.mountPoint).getEffectiveModelContext(); + doReturn(Optional.of(FixedDOMSchemaService.of(this.contextRef))).when(this.mountPoint) + .getService(DOMSchemaService.class); doReturn(Optional.of(this.mountDataBroker)).when(this.mountPoint).getService(DOMDataBroker.class); doReturn(this.mountTransactionChain).when(this.mountDataBroker) .createTransactionChain(any(DOMTransactionChainListener.class)); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImplTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImplTest.java index 7319142152..94b037d68c 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImplTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfInvokeOperationsServiceImplTest.java @@ -111,13 +111,12 @@ public class RestconfInvokeOperationsServiceImplTest { final InstanceIdentifierContext context = mock(InstanceIdentifierContext.class); final RpcDefinition schemaNode = mock(RpcDefinition.class); final QName qname = QName.create("invoke:rpc:module", "2013-12-03", "rpcTest"); - final SchemaPath schemaPath = SchemaPath.create(true, qname); - when(schemaNode.getPath()).thenReturn(schemaPath); + when(schemaNode.getPath()).thenReturn(SchemaPath.create(true, qname)); when(schemaNode.getQName()).thenReturn(qname); doReturn(schemaNode).when(context).getSchemaNode(); final NormalizedNode data = mock(NormalizedNode.class); final DOMRpcResult domRpcResult = mock(DOMRpcResult.class); - doReturn(immediateFluentFuture(domRpcResult)).when(this.rpcService).invokeRpc(schemaPath, data); + doReturn(immediateFluentFuture(domRpcResult)).when(this.rpcService).invokeRpc(qname, data); doReturn(result).when(domRpcResult).getResult(); return new NormalizedNodeContext(context, data); } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtilTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtilTest.java index 297832bb61..23554fd88d 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtilTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PlainPatchDataTransactionUtilTest.java @@ -93,13 +93,14 @@ public class PlainPatchDataTransactionUtilTest { .node(qnPlayer) .node(qnGap) .build(); - this.schemaNodeForGap = DataSchemaContextTree.from(this.schema).getChild(this.iidGap).getDataSchemaNode(); + this.schemaNodeForGap = DataSchemaContextTree.from(this.schema).findChild(this.iidGap).orElseThrow() + .getDataSchemaNode(); this.iidJukebox = YangInstanceIdentifier.builder() .node(qnJukebox) .build(); this.schemaNodeForJukebox = DataSchemaContextTree.from(this.schema) - .getChild(this.iidJukebox).getDataSchemaNode(); + .findChild(this.iidJukebox).orElseThrow().getDataSchemaNode(); this.leafGap = Builders.leafBuilder() .withNodeIdentifier(new NodeIdentifier(qnGap)) diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtilTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtilTest.java index 32a75c2856..4ae553b5a5 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtilTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/PutDataTransactionUtilTest.java @@ -95,24 +95,25 @@ public class PutDataTransactionUtilTest { final NodeIdentifierWithPredicates nodeWithKey2 = NodeIdentifierWithPredicates.of(listQname, listKeyQname, "name of band 2"); + final DataSchemaContextTree tree = DataSchemaContextTree.from(this.schema); this.iid = YangInstanceIdentifier.builder() .node(baseQName) .node(containerQname) .node(leafQname) .build(); - this.schemaNode = DataSchemaContextTree.from(this.schema).getChild(this.iid).getDataSchemaNode(); + this.schemaNode = tree.findChild(this.iid).orElseThrow().getDataSchemaNode(); this.iid2 = YangInstanceIdentifier.builder() .node(baseQName) .build(); - this.schemaNode2 = DataSchemaContextTree.from(this.schema).getChild(this.iid2).getDataSchemaNode(); + this.schemaNode2 = tree.findChild(this.iid2).orElseThrow().getDataSchemaNode(); this.iid3 = YangInstanceIdentifier.builder() .node(baseQName) .node(listQname) .node(nodeWithKey) .build(); - this.schemaNode3 = DataSchemaContextTree.from(this.schema).getChild(this.iid3).getDataSchemaNode(); + this.schemaNode3 = tree.findChild(this.iid3).orElseThrow().getDataSchemaNode(); this.buildLeaf = Builders.leafBuilder() .withNodeIdentifier(new NodeIdentifier(leafQname)) diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/TestData.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/TestData.java index 8f98a5dc53..722d999fd5 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/TestData.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/TestData.java @@ -21,7 +21,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode; import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; class TestData { @@ -39,8 +38,8 @@ class TestData { final LeafNode contentLeaf; final LeafNode contentLeaf2; final MapEntryNode checkData; - final SchemaPath rpc; - final SchemaPath errorRpc; + final QName rpc; + final QName errorRpc; final ContainerNode input; final ContainerNode output; final LeafSetNode leafSetNode1; @@ -161,24 +160,22 @@ class TestData { unkeyedListNode2 = Builders.unkeyedListBuilder().withNodeIdentifier( new YangInstanceIdentifier.NodeIdentifier(listQname)).withChild(unkeyedListEntryNode2).build(); - final QName rpcQname = QName.create("ns", "2015-02-28", "test-rpc"); - final QName errorRpcQname = QName.create(rpcQname, "error-rpc"); - rpc = SchemaPath.create(true, rpcQname); - errorRpc = SchemaPath.create(true, errorRpcQname); + rpc = QName.create("ns", "2015-02-28", "test-rpc"); + errorRpc = QName.create(rpc, "error-rpc"); final LeafNode contentLeafNode = Builders.leafBuilder() - .withNodeIdentifier(new NodeIdentifier(QName.create(rpcQname, "content"))) + .withNodeIdentifier(new NodeIdentifier(QName.create(rpc, "content"))) .withValue("test") .build(); input = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(QName.create(rpcQname, "input"))) + .withNodeIdentifier(new NodeIdentifier(QName.create(rpc, "input"))) .withChild(contentLeafNode) .build(); final LeafNode resultLeafNode = Builders.leafBuilder() - .withNodeIdentifier(new NodeIdentifier(QName.create(rpcQname, "content"))) + .withNodeIdentifier(new NodeIdentifier(QName.create(rpc, "content"))) .withValue("operation result") .build(); output = Builders.containerBuilder() - .withNodeIdentifier(new NodeIdentifier(QName.create(rpcQname, "output"))) + .withNodeIdentifier(new NodeIdentifier(QName.create(rpc, "output"))) .withChild(resultLeafNode) .build(); } diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java index 56cddb13de..5023df4c85 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/services/simple/impl/RestconfSchemaServiceTest.java @@ -23,8 +23,10 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.mdsal.dom.api.DOMMountPointService; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider; import org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; import org.opendaylight.restconf.common.schema.SchemaExportContext; @@ -93,7 +95,7 @@ public class RestconfSchemaServiceTest { // create and register mount points mountPointService .createMountPoint(YangInstanceIdentifier.of(QName.create("mount:point:1", "2016-01-01", "cont"))) - .addInitialSchemaContext(SCHEMA_CONTEXT_BEHIND_MOUNT_POINT) + .addService(DOMSchemaService.class, FixedDOMSchemaService.of(SCHEMA_CONTEXT_BEHIND_MOUNT_POINT)) .register(); mountPointService .createMountPoint(YangInstanceIdentifier.of(QName.create("mount:point:2", "2016-01-01", "cont"))) diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java index 90e349cd20..a964815b67 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/listeners/NotificationListenerTest.java @@ -40,14 +40,14 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class NotificationListenerTest { private static final QNameModule MODULE = QNameModule.create(URI.create("notifi:mod"), Revision.of("2016-11-23")); - private static SchemaContext SCHEMA_CONTEXT; + private static EffectiveModelContext SCHEMA_CONTEXT; @BeforeClass public static void beforeClass() throws Exception { @@ -61,12 +61,12 @@ public class NotificationListenerTest { @Test public void notifi_leafTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-leaf")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-leaf")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf")); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), leaf); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), leaf); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -81,13 +81,13 @@ public class NotificationListenerTest { @Test public void notifi_cont_leafTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-cont")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-cont")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf")); final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), leaf); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), cont); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), cont); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -103,7 +103,7 @@ public class NotificationListenerTest { @Test public void notifi_list_Test() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-list")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-list")); final DOMNotification notificationData = mock(DOMNotification.class); @@ -111,7 +111,7 @@ public class NotificationListenerTest { final MapEntryNode entry = mockMapEntry(QName.create(MODULE, "lst"), leaf); final MapNode list = mockList(QName.create(MODULE, "lst"), entry); final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), list); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), cont); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), cont); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -127,12 +127,12 @@ public class NotificationListenerTest { @Test public void notifi_grpTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-grp")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-grp")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf")); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), leaf); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), leaf); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -146,13 +146,13 @@ public class NotificationListenerTest { @Test public void notifi_augmTest() throws Exception { - final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-augm")); + final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-augm")); final DOMNotification notificationData = mock(DOMNotification.class); final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf-augm")); final AugmentationNode augm = mockAugm(leaf); - final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), augm); + final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), augm); when(notificationData.getType()).thenReturn(schemaPathNotifi); when(notificationData.getBody()).thenReturn(notifiBody); @@ -216,7 +216,7 @@ public class NotificationListenerTest { return child; } - private static String prepareJson(final DOMNotification notificationData, final SchemaPath schemaPathNotifi) { + private static String prepareJson(final DOMNotification notificationData, final Absolute schemaPathNotifi) { final NotificationListenerAdapter notifiAdapter = ListenersBroker.getInstance().registerNotificationListener( schemaPathNotifi, "stream-name", NotificationOutputType.JSON); return requireNonNull(notifiAdapter.prepareJson(SCHEMA_CONTEXT, notificationData)); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/test/incubate/InMemoryMdsalModule.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/test/incubate/InMemoryMdsalModule.java index 3a23203c78..9099443b20 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/test/incubate/InMemoryMdsalModule.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/test/incubate/InMemoryMdsalModule.java @@ -25,7 +25,7 @@ import org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl; import org.opendaylight.mdsal.dom.broker.DOMNotificationRouter; import org.opendaylight.mdsal.dom.broker.DOMRpcRouter; import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry; -import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider; /** * Copy paste from org.opendaylight.controller.sal.restconf.impl.test.incubate.InMemoryMdsalModule. @@ -73,10 +73,10 @@ public class InMemoryMdsalModule extends AbstractModule { } @Provides - @Singleton SchemaContextProvider getSchemaContextProvider() { + @Singleton EffectiveModelContextProvider getSchemaContextProvider() { DOMSchemaService schemaService = dataBrokerTest.getDataBrokerTestCustomizer().getSchemaService(); - if (schemaService instanceof SchemaContextProvider) { - return (SchemaContextProvider) schemaService; + if (schemaService instanceof EffectiveModelContextProvider) { + return (EffectiveModelContextProvider) schemaService; } throw new IllegalStateException( "The schema service isn't a SchemaContextProvider, it's a " + schemaService.getClass()); diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodecTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodecTest.java index f4fc263f86..9483581f21 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodecTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/IdentifierCodecTest.java @@ -16,7 +16,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; /** @@ -28,7 +28,7 @@ public class IdentifierCodecTest { "list-test:top/list1=%2C%27" + '"' + "%3A" + '"' + "%20%2F,,foo/list2=a,b/result"; private static final String URI_WITH_INT_VAL_LEAF_LIST = "list-test:top/Y=4"; - private SchemaContext schemaContext; + private EffectiveModelContext schemaContext; @Before public void init() throws FileNotFoundException { diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java index 885571ac82..1cbf78067c 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifierTest.java @@ -28,6 +28,7 @@ import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider; import org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.restconf.common.context.InstanceIdentifierContext; import org.opendaylight.restconf.common.errors.RestconfDocumentedException; import org.opendaylight.restconf.common.errors.RestconfError; @@ -129,12 +130,11 @@ public class ParserIdentifierTest { .build(); mountPoint = mountPointService.createMountPoint(mountPointId) - .addInitialSchemaContext(SCHEMA_CONTEXT_ON_MOUNT_POINT) + .addService(DOMSchemaService.class, FixedDOMSchemaService.of(SCHEMA_CONTEXT_ON_MOUNT_POINT)) .register() .getInstance(); // register mount point with null schema context - when(this.mockMountPoint.getEffectiveModelContext()).thenReturn(null); when(this.mockMountPointService.getMountPoint(YangInstanceIdentifier.empty())) .thenReturn(Optional.of(this.mockMountPoint)); } @@ -562,13 +562,9 @@ public class ParserIdentifierTest { sourceProvider)); } - /** - * Negative test of of getting SchemaExportContext when SchemaContext behind mount - * point is null. Test is expected to fail with NullPointerException. - */ @Test public void toSchemaExportContextFromIdentifierNullSchemaContextBehindMountPointNegativeTest() { - assertThrows(NullPointerException.class, () -> ParserIdentifier.toSchemaExportContextFromIdentifier( + assertThrows(IllegalStateException.class, () -> ParserIdentifier.toSchemaExportContextFromIdentifier( SCHEMA_CONTEXT, "/" + RestconfConstants.MOUNT + "/" + TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION, this.mockMountPointService, sourceProvider)); } diff --git a/restconf/sal-rest-connector-config/pom.xml b/restconf/sal-rest-connector-config/pom.xml index 38ebc45ea2..11e6b5377d 100644 --- a/restconf/sal-rest-connector-config/pom.xml +++ b/restconf/sal-rest-connector-config/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.odlparent odlparent-lite - 7.0.6 + 8.0.0 diff --git a/restconf/sal-rest-docgen-maven/src/main/java/org/opendaylight/netconf/sal/rest/doc/maven/StaticDocGenerator.java b/restconf/sal-rest-docgen-maven/src/main/java/org/opendaylight/netconf/sal/rest/doc/maven/StaticDocGenerator.java index 8dc3ecb071..a1f49d31b5 100644 --- a/restconf/sal-rest-docgen-maven/src/main/java/org/opendaylight/netconf/sal/rest/doc/maven/StaticDocGenerator.java +++ b/restconf/sal-rest-docgen-maven/src/main/java/org/opendaylight/netconf/sal/rest/doc/maven/StaticDocGenerator.java @@ -14,13 +14,13 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.function.Function; import javax.ws.rs.core.UriInfo; import org.apache.maven.project.MavenProject; import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl; @@ -33,6 +33,7 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang2sources.spi.BasicCodeGenerator; import org.opendaylight.yangtools.yang2sources.spi.MavenProjectAware; +import org.opendaylight.yangtools.yang2sources.spi.ModuleResourceResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +54,7 @@ public class StaticDocGenerator extends BaseYangSwaggerGeneratorDraft02 @Override @SuppressFBWarnings("DM_DEFAULT_ENCODING") public Collection generateSources(final EffectiveModelContext context, final File outputBaseDir, - final Set currentModules, final Function> moduleResourcePathResolver) + final Set currentModules, final ModuleResourceResolver moduleResourcePathResolver) throws IOException { final List result = new ArrayList<>(); @@ -81,7 +82,8 @@ public class StaticDocGenerator extends BaseYangSwaggerGeneratorDraft02 LOG.info("File {} already exists.", resourcesJsFile); } - try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(resourcesJsFile))) { + try (BufferedWriter bufferedWriter = + new BufferedWriter(new FileWriter(resourcesJsFile, StandardCharsets.UTF_8))) { final ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); @@ -112,7 +114,8 @@ public class StaticDocGenerator extends BaseYangSwaggerGeneratorDraft02 final File resourceFile = new File(resourcesDir, name + "(" + revision + ").json"); - try (BufferedWriter resourceFileWriter = new BufferedWriter(new FileWriter(resourceFile))) { + try (BufferedWriter resourceFileWriter = + new BufferedWriter(new FileWriter(resourceFile, StandardCharsets.UTF_8))) { resourceFileWriter.write(json); } diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java index b54cf0b47b..a73e754c54 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java @@ -41,6 +41,7 @@ import org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode; import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; +import org.opendaylight.yangtools.yang.model.api.ContainerLike; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -271,7 +272,7 @@ public class DefinitionGenerator { definitionNames, schemaContext, oaversion); } - private void processOperationInputOutput(final ContainerSchemaNode container, final String operationName, + private void processOperationInputOutput(final ContainerLike container, final String operationName, final String parentName, final boolean isInput, final ObjectNode definitions, final DefinitionNames definitionNames, final SchemaContext schemaContext, final OAversion oaversion) @@ -876,7 +877,7 @@ public class DefinitionGenerator { private boolean isHexadecimalOrOctal(RangeRestrictedTypeDefinition typeDef) { final Optional optDefaultValue = typeDef.getDefaultValue(); if (optDefaultValue.isPresent()) { - final String defaultValue = ((String)optDefaultValue.get()); + final String defaultValue = (String)optDefaultValue.get(); return defaultValue.startsWith("0") || defaultValue.startsWith("-0"); } return false; diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java index 7476e0662f..d5ee84fd2f 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java @@ -26,9 +26,10 @@ import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl.OAversion; import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl.URIType; import org.opendaylight.netconf.sal.rest.doc.impl.DefinitionNames; import org.opendaylight.netconf.sal.rest.doc.util.JsonUtil; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; +import org.opendaylight.yangtools.yang.model.api.InputSchemaNode; import org.opendaylight.yangtools.yang.model.api.OperationDefinition; +import org.opendaylight.yangtools.yang.model.api.OutputSchemaNode; public final class OperationBuilder { public static final String BODY = "body"; @@ -203,8 +204,8 @@ public final class OperationBuilder { final String operName = operDef.getQName().getLocalName(); final String inputName = operName + INPUT_SUFFIX; - final ContainerSchemaNode input = operDef.getInput(); - final ContainerSchemaNode output = operDef.getOutput(); + final InputSchemaNode input = operDef.getInput(); + final OutputSchemaNode output = operDef.getOutput(); if (!input.getChildNodes().isEmpty()) { final String discriminator = definitionNames.getDiscriminator(input); final String clearDefName = parentName + "_" + operName + INPUT_SUFFIX; @@ -330,13 +331,13 @@ public final class OperationBuilder { private static String buildSummaryValue(final String httpMethod, final String moduleName, final Optional deviceName, final String nodeName) { - return httpMethod + SUMMARY_SEPARATOR + (deviceName.map(s -> s + SUMMARY_SEPARATOR).orElse("")) + return httpMethod + SUMMARY_SEPARATOR + deviceName.map(s -> s + SUMMARY_SEPARATOR).orElse("") + moduleName + SUMMARY_SEPARATOR + nodeName; } public static ArrayNode buildTagsValue(final Optional deviceName, final String moduleName) { final ArrayNode tagsValue = JsonNodeFactory.instance.arrayNode(); - tagsValue.add((deviceName.map(s -> "mounted " + s).orElse("controller")) + " " + moduleName); + tagsValue.add(deviceName.map(s -> "mounted " + s).orElse("controller") + " " + moduleName); return tagsValue; } diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java index d02b54abdd..91005b007d 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java @@ -31,7 +31,6 @@ import java.util.concurrent.atomic.AtomicLong; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; import org.opendaylight.mdsal.dom.api.DOMMountPointListener; import org.opendaylight.mdsal.dom.api.DOMMountPointService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; @@ -44,6 +43,7 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.SwaggerObject; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; @@ -123,19 +123,16 @@ public class MountPointSwagger implements DOMMountPointListener, AutoCloseable { return instanceId; } - private SchemaContext getSchemaContext(final YangInstanceIdentifier id) { + private EffectiveModelContext getSchemaContext(final YangInstanceIdentifier id) { if (id == null) { return null; } checkState(mountService != null); - final Optional mountPoint = this.mountService.getMountPoint(id); - if (mountPoint.isEmpty()) { - return null; - } - - final SchemaContext context = mountPoint.get().getSchemaContext(); - return context; + return this.mountService.getMountPoint(id) + .flatMap(mountPoint -> mountPoint.getService(DOMSchemaService.class)) + .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext())) + .orElse(null); } public CommonApiObject getMountPointApi(final UriInfo uriInfo, final Long id, final String module, diff --git a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocServiceImplTest.java b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocServiceImplTest.java index 55f78552ab..ca239954d3 100644 --- a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocServiceImplTest.java +++ b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/ApiDocServiceImplTest.java @@ -51,7 +51,7 @@ public class ApiDocServiceImplTest { final DOMSchemaService schemaService = this.helper.createMockSchemaService(context); final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getSchemaContext()).thenReturn(context); + when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); final DOMMountPointService service = mock(DOMMountPointService.class); when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); diff --git a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java index 6c0f65c213..7639871fb5 100644 --- a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java +++ b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/MountPointSwaggerTest.java @@ -60,7 +60,7 @@ public class MountPointSwaggerTest { final DOMSchemaService schemaService = this.helper.createMockSchemaService(context); final DOMMountPoint mountPoint = mock(DOMMountPoint.class); - when(mountPoint.getSchemaContext()).thenReturn(context); + when(mountPoint.getService(DOMSchemaService.class)).thenReturn(Optional.of(schemaService)); final DOMMountPointService service = mock(DOMMountPointService.class); when(service.getMountPoint(INSTANCE_ID)).thenReturn(Optional.of(mountPoint)); -- 2.36.6