aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/netconfnode-state-service/provider/src/main
diff options
context:
space:
mode:
authorhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2021-02-17 16:32:31 +0100
committerhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2021-02-17 16:43:41 +0100
commit5cf15b27796b68b3edbfc1e59f258dee1e10b2b9 (patch)
tree4645675dd73b142bd96748ee232419724a1b38a4 /sdnr/wt/netconfnode-state-service/provider/src/main
parentf9486b50bbf6f92a4549203c1ede21ba912989c0 (diff)
Increase coverage of netconfnode-state-service
Add junit tests to provider Issue-ID: CCSDK-3171 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com> Change-Id: I3c32859f1e30b9d715d74d9125f3603805ea7808 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/netconfnode-state-service/provider/src/main')
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java8
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingNotificationsImpl.java36
2 files changed, 31 insertions, 13 deletions
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
index 5ff6caf56..189845831 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
@@ -80,10 +80,10 @@ public class NetconfAccessorImpl implements NetconfAccessor {
this(new NodeId(nodeId), netconfNode, netconfCommunicatorManager, domContext);
}
- protected NetconfAccessorImpl(NetconfAccessorImpl accessor) {
- this.nodeId = accessor.nodeId;
- this.netconfNode = accessor.netconfNode;
- this.capabilities = accessor.capabilities;
+ public NetconfAccessorImpl(NetconfAccessorImpl accessor) {
+ this.nodeId = accessor.getNodeId();
+ this.netconfNode = accessor.getNetconfNode();
+ this.capabilities = accessor.getCapabilites();
this.netconfCommunicatorManager = accessor.netconfCommunicatorManager;
this.domContext = accessor.domContext;
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingNotificationsImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingNotificationsImpl.java
index 6716581a2..46ff07b2c 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingNotificationsImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/binding/NetconfBindingNotificationsImpl.java
@@ -23,9 +23,11 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.bind
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.common.YangHelper;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl;
@@ -57,12 +59,14 @@ public class NetconfBindingNotificationsImpl extends NetconfBindingAccessorImpl
}
@Override
- public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(@NonNull String streamName) {
+ public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(
+ @NonNull String streamName) {
String failMessage = "";
final Optional<RpcConsumerRegistry> optionalRpcConsumerService =
getMountpoint().getService(RpcConsumerRegistry.class);
if (optionalRpcConsumerService.isPresent()) {
- final NotificationsService rpcService = optionalRpcConsumerService.get().getRpcService(NotificationsService.class);
+ final NotificationsService rpcService =
+ optionalRpcConsumerService.get().getRpcService(NotificationsService.class);
final CreateSubscriptionInputBuilder createSubscriptionInputBuilder = new CreateSubscriptionInputBuilder();
createSubscriptionInputBuilder.setStream(new StreamNameType(streamName));
@@ -72,6 +76,7 @@ public class NetconfBindingNotificationsImpl extends NetconfBindingAccessorImpl
if (createSubscriptionInput == null) {
failMessage = "createSubscriptionInput is null for mountpoint " + getNodeId();
} else {
+ // Regular case, return value
return rpcService.createSubscription(createSubscriptionInput);
}
} catch (NullPointerException e) {
@@ -80,6 +85,7 @@ public class NetconfBindingNotificationsImpl extends NetconfBindingAccessorImpl
} else {
failMessage = "No RpcConsumerRegistry avaialble.";
}
+ //Be here only in case of problem and return failed indication
log.warn(failMessage);
RpcResultBuilder<CreateSubscriptionOutput> result = RpcResultBuilder.failed();
result.withError(ErrorType.APPLICATION, failMessage);
@@ -91,9 +97,17 @@ public class NetconfBindingNotificationsImpl extends NetconfBindingAccessorImpl
@Override
public void registerNotificationsStream(List<Stream> streamList) {
for (Stream stream : streamList) {
- log.info("Stream Name = {}, Stream Description = {}", stream.getName().getValue(), stream.getDescription());
- if (!(stream.getName().getValue().equals(NetconfNotifications.DefaultNotificationsStream))) // Since this stream is already registered
- registerNotificationsStream(stream.getName().getValue());
+ @Nullable
+ StreamNameType streamName = stream.getName();
+ if (streamName != null) {
+ String streamNameValue = stream.getName().getValue();
+ log.info("Stream Name = {}, Stream Description = {}", streamNameValue, stream.getDescription());
+ if (!(streamNameValue.equals(NetconfNotifications.DefaultNotificationsStream)))
+ // Register any not default stream. Default stream is already registered
+ registerNotificationsStream(streamNameValue);
+ } else {
+ log.warn("Ignore a stream without name");
+ }
}
}
@@ -116,10 +130,14 @@ public class NetconfBindingNotificationsImpl extends NetconfBindingAccessorImpl
final Class<Netconf> netconfClazz = Netconf.class;
InstanceIdentifier<Netconf> streamsIID = InstanceIdentifier.builder(netconfClazz).build();
- Netconf res = getTransactionUtils().readData(getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, streamsIID);
- Streams streams = res.getStreams();
- return YangHelper.getList(streams.getStream());
+ Netconf res = getTransactionUtils().readData(getDataBroker(), LogicalDatastoreType.OPERATIONAL, streamsIID);
+ if (res != null) {
+ Streams streams = res.getStreams();
+ if (streams != null) {
+ return YangHelper.getList(streams.nonnullStream());
+ }
+ }
+ return Collections.emptyList();
}
@Override