From 64d46cf2ef7e4441b46420bb6ca1c6863cc12ba6 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Thu, 30 Jul 2020 09:06:20 +0200 Subject: Update mountpoint-state-provider Update mountpoint-state-provider for ODL Sodium support and some refactoring Issue-ID: CCSDK-2575 Signed-off-by: Ravi Pendurty Change-Id: I5a44e8d2e2b4359d66374ccf7669fbbde45ee582 Signed-off-by: Ravi Pendurty --- sdnr/wt/mountpoint-state-provider/feature/pom.xml | 11 -- .../wt/mountpoint-state-provider/installer/pom.xml | 11 -- .../impl/GeneralConfig.java | 2 +- .../impl/MountpointNodeConnectListenerImpl.java | 30 ++++- .../impl/MountpointNodeStateListenerImpl.java | 25 +++- .../impl/MountpointStateProviderImpl.java | 58 +++++---- .../impl/MountpointStatePublisher.java | 129 ------------------ .../impl/MountpointStatePublisherMain.java | 144 +++++++++++++++++++++ .../test/GeneralConfigTest.java | 17 +-- .../TestMountpointNodeConnectListenerImpl.java | 66 ++++++++-- .../test/TestMountpointNodeStateListenerImpl.java | 60 +++++++-- .../test/TestMountpointStatePublisher.java | 43 +++--- .../test/mock/NetconfAccessorMock.java | 11 +- .../test/mock/NetconfNodeStateServiceMock.java | 59 +++++++++ .../test/mock/odlapi/DataBrokerMountpointMock.java | 106 --------------- .../test/mock/odlapi/DataBrokerNetconfMock.java | 110 ---------------- .../test/mock/odlapi/MountPointMock.java | 91 ------------- .../test/mock/odlapi/MountPointMockNew.java | 38 ------ .../test/mock/odlapi/MountPointServiceMock.java | 55 -------- .../odlapi/NotificationPublishServiceMock.java | 49 ------- .../test/mock/odlapi/RpcConsumerRegistryMock.java | 39 ------ .../test/mock/odlapi/RpcProviderRegistryMock.java | 60 --------- 22 files changed, 424 insertions(+), 790 deletions(-) delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java create mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisherMain.java create mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfNodeStateServiceMock.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerMountpointMock.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerNetconfMock.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMock.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMockNew.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointServiceMock.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/NotificationPublishServiceMock.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcConsumerRegistryMock.java delete mode 100644 sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcProviderRegistryMock.java diff --git a/sdnr/wt/mountpoint-state-provider/feature/pom.xml b/sdnr/wt/mountpoint-state-provider/feature/pom.xml index 65881d4fd..e55ad77a5 100644 --- a/sdnr/wt/mountpoint-state-provider/feature/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/feature/pom.xml @@ -40,17 +40,6 @@ ccsdk-features :: ${project.artifactId} - - - - org.opendaylight.controller - mdsal-artifacts - ${odl.controller.mdsal.version} - pom - import - - - ${project.groupId} diff --git a/sdnr/wt/mountpoint-state-provider/installer/pom.xml b/sdnr/wt/mountpoint-state-provider/installer/pom.xml index 5c86f3b05..831a705d8 100755 --- a/sdnr/wt/mountpoint-state-provider/installer/pom.xml +++ b/sdnr/wt/mountpoint-state-provider/installer/pom.xml @@ -45,17 +45,6 @@ false - - - - org.opendaylight.controller - mdsal-artifacts - ${odl.controller.mdsal.version} - pom - import - - - org.onap.ccsdk.features.sdnr.wt diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/GeneralConfig.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/GeneralConfig.java index 675ac8a2f..21ca9dae7 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/GeneralConfig.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/GeneralConfig.java @@ -38,7 +38,7 @@ public class GeneralConfig implements Configuration { private static final String DEFAULT_VALUE_PUBLISHER_TRANSPORTTYPE = "HTTPNOAUTH"; public static final String PROPERTY_KEY_PUBLISHER_HOST_PORT = "host"; - private static final String DEFAULT_VALUE_PUBLISHER_HOST_PORT = "onap-dmap:3904"; + private static final String DEFAULT_VALUE_PUBLISHER_HOST_PORT = "onap-dmaap:3904"; public static final String PROPERTY_KEY_PUBLISHER_TOPIC = "topic"; private static final String DEFAULT_VALUE_PUBLISHER_TOPIC = "unauthenticated.SDNR_MOUNTPOINT_STATE_INFO"; diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java index 48cb76ead..f9b7b1e6a 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java @@ -18,25 +18,38 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; +import java.util.Objects; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; - +import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class MountpointNodeConnectListenerImpl implements NetconfNodeConnectListener { +public class MountpointNodeConnectListenerImpl implements NetconfNodeConnectListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(MountpointNodeConnectListenerImpl.class); + private NetconfNodeStateService netconfNodeStateService; + private MountpointStatePublisherMain mountpointStatePublisher; + private ListenerRegistration registeredNodeConnectListener; + + public MountpointNodeConnectListenerImpl(NetconfNodeStateService netconfNodeStateService) { + this.netconfNodeStateService = netconfNodeStateService; + } + + public void start(MountpointStatePublisherMain mountpointStatePublisher) { + this.mountpointStatePublisher = mountpointStatePublisher; + registeredNodeConnectListener = netconfNodeStateService.registerNetconfNodeConnectListener(this); + } @Override public void onEnterConnected(@NonNull NetconfAccessor accessor) { NodeId nNodeId = accessor.getNodeId(); NetconfNode netconfNode = accessor.getNetconfNode(); - //, MountPoint mountpoint, DataBroker netconfNodeDataBroker; LOG.debug("In onEnterConnected of MountpointNodeConnectListenerImpl - nNodeId = " + nNodeId.getValue() + " IP Address = " + netconfNode.getHost().getIpAddress().getIpv4Address().getValue()); @@ -46,7 +59,7 @@ public class MountpointNodeConnectListenerImpl implements NetconfNodeConnectList obj.put("NetConfNodeState", netconfNode.getConnectionStatus().toString()); obj.put("TimeStamp", java.time.Clock.systemUTC().instant()); - MountpointStatePublisher.stateObjects.add(obj); + mountpointStatePublisher.addToPublish(obj); } @Override @@ -59,13 +72,18 @@ public class MountpointNodeConnectListenerImpl implements NetconfNodeConnectList obj.put("NetConfNodeState", "Unmounted"); obj.put("TimeStamp", java.time.Clock.systemUTC().instant()); - MountpointStatePublisher.stateObjects.add(obj); + mountpointStatePublisher.addToPublish(obj); + } + + public void stop() throws Exception { + this.close(); } @Override public void close() throws Exception { - LOG.debug("In close of MountpointNodeConnectListenerImpl"); + if (!Objects.isNull(registeredNodeConnectListener)) + registeredNodeConnectListener.close(); } } diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java index 36ec16298..bbfd87961 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java @@ -20,14 +20,28 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; import org.json.JSONObject; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(MountpointNodeStateListenerImpl.class); + private NetconfNodeStateService netconfNodeStateService; + private MountpointStatePublisherMain mountpointStatePublisher; + private ListenerRegistration registeredNodeStateListener; + + public MountpointNodeStateListenerImpl(NetconfNodeStateService netconfNodeStateService) { + this.netconfNodeStateService = netconfNodeStateService; + } + + public void start(MountpointStatePublisherMain mountpointStatePublisher) { + this.mountpointStatePublisher = mountpointStatePublisher; + registeredNodeStateListener = netconfNodeStateService.registerNetconfNodeStateListener(this); + } @Override public void onCreated(NodeId nNodeId, NetconfNode netconfNode) { @@ -39,7 +53,7 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener obj.put("NetConfNodeState", netconfNode.getConnectionStatus().toString()); obj.put("TimeStamp", java.time.Clock.systemUTC().instant()); - MountpointStatePublisher.stateObjects.add(obj); + mountpointStatePublisher.addToPublish(obj); } @Override @@ -52,7 +66,7 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener obj.put("NetConfNodeState", netconfNode.getConnectionStatus().toString()); obj.put("TimeStamp", java.time.Clock.systemUTC().instant()); - MountpointStatePublisher.stateObjects.add(obj); + mountpointStatePublisher.addToPublish(obj); } @Override @@ -64,11 +78,16 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener obj.put("NetConfNodeState", "Removed"); obj.put("TimeStamp", java.time.Clock.systemUTC().instant()); - MountpointStatePublisher.stateObjects.add(obj); + mountpointStatePublisher.addToPublish(obj); + } + + public void stop() throws Exception { + this.close(); } @Override public void close() throws Exception { + registeredNodeStateListener.close(); } } diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateProviderImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateProviderImpl.java index cb5cbe3e2..e31032393 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateProviderImpl.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateProviderImpl.java @@ -32,7 +32,6 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateS import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@SuppressWarnings("deprecation") public class MountpointStateProviderImpl implements AutoCloseable, IConfigChangedListener { private static final Logger LOG = LoggerFactory.getLogger(MountpointStateProviderImpl.class); @@ -40,16 +39,17 @@ public class MountpointStateProviderImpl implements AutoCloseable, IConfigChange private static final String CONFIGURATIONFILE = "etc/mountpoint-state-provider.properties"; private NetconfNodeStateService netconfNodeStateService; - private GeneralConfig generalConfig; private boolean dmaapEnabled = false; - private Thread mountpointStatePublisher = null; - MountpointNodeConnectListenerImpl nodeConnectListener = new MountpointNodeConnectListenerImpl(); - MountpointNodeStateListenerImpl nodeStateListener = new MountpointNodeStateListenerImpl(); + private MountpointNodeConnectListenerImpl nodeConnectListener; + private MountpointNodeStateListenerImpl nodeStateListener; + private MountpointStatePublisherMain mountpointStatePublisher; public MountpointStateProviderImpl() { LOG.info("Creating provider class for {}", APPLICATION_NAME); + nodeConnectListener = null; + nodeStateListener = null; } public void setNetconfNodeStateService(NetconfNodeStateService netconfNodeStateService) { @@ -62,12 +62,12 @@ public class MountpointStateProviderImpl implements AutoCloseable, IConfigChange new ConfigurationFileRepresentation(CONFIGURATIONFILE); configFileRepresentation.registerConfigChangedListener(this); + nodeConnectListener = new MountpointNodeConnectListenerImpl(netconfNodeStateService); + nodeStateListener = new MountpointNodeStateListenerImpl(netconfNodeStateService); + generalConfig = new GeneralConfig(configFileRepresentation); if (generalConfig.getEnabled()) { //dmaapEnabled - mountpointStatePublisher = new Thread(new MountpointStatePublisher(generalConfig)); - mountpointStatePublisher.start(); - netconfNodeStateService.registerNetconfNodeConnectListener(nodeConnectListener); - netconfNodeStateService.registerNetconfNodeStateListener(nodeStateListener); + startPublishing(); } } @@ -85,35 +85,45 @@ public class MountpointStateProviderImpl implements AutoCloseable, IConfigChange LOG.info("Service configuration state changed. Enabled: {}", generalConfig.getEnabled()); boolean dmaapEnabledNewVal = generalConfig.getEnabled(); - // DMaap disabled earlier (or during bundle startup) but enabled later, start Consumer(s) + // DMaap disabled earlier (or during bundle startup) but enabled later, start publisher(s) if (!dmaapEnabled && dmaapEnabledNewVal) { LOG.info("DMaaP is enabled, starting Publisher"); - mountpointStatePublisher = new Thread(new MountpointStatePublisher(generalConfig)); - mountpointStatePublisher.start(); - netconfNodeStateService.registerNetconfNodeConnectListener(nodeConnectListener); - netconfNodeStateService.registerNetconfNodeStateListener(nodeStateListener); + startPublishing(); } else if (dmaapEnabled && !dmaapEnabledNewVal) { - // DMaap enabled earlier (or during bundle startup) but disabled later, stop consumer(s) + // DMaap enabled earlier (or during bundle startup) but disabled later, stop publisher(s) LOG.info("DMaaP is disabled, stop publisher"); - try { - MountpointStatePublisher.stopPublisher(); - } catch (IOException | InterruptedException e) { - LOG.error("Exception while stopping publisher ", e); - } + stopPublishing(); } dmaapEnabled = dmaapEnabledNewVal; } + public void startPublishing() { + mountpointStatePublisher = new MountpointStatePublisherMain(generalConfig); + mountpointStatePublisher.start(); + + nodeConnectListener.start(mountpointStatePublisher); + nodeStateListener.start(mountpointStatePublisher); + } + + public void stopPublishing() { + try { + nodeConnectListener.stop(); + nodeStateListener.stop(); + mountpointStatePublisher.stop(); + } catch (Exception e) { + LOG.error("Exception while stopping publisher ", e); + } + } + @Override public void close() throws Exception { LOG.info("{} closing ...", this.getClass().getName()); - //close(updateService, configService, mwtnService); issue#1 try { - MountpointStatePublisher.stopPublisher(); + mountpointStatePublisher.stop(); } catch (IOException | InterruptedException e) { LOG.error("Exception while stopping publisher ", e); } - //close(updateService, mwtnService); + close(nodeConnectListener, nodeStateListener); LOG.info("{} closing done", APPLICATION_NAME); } @@ -123,7 +133,6 @@ public class MountpointStateProviderImpl implements AutoCloseable, IConfigChange * @param toClose * @throws Exception */ - @SuppressWarnings("unused") private void close(AutoCloseable... toCloseList) throws Exception { for (AutoCloseable element : toCloseList) { if (element != null) { @@ -131,5 +140,4 @@ public class MountpointStateProviderImpl implements AutoCloseable, IConfigChange } } } - } diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java deleted file mode 100644 index 7f9fb2370..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END======================================================= - * - */ - -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import org.json.JSONObject; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; -import org.onap.dmaap.mr.client.MRBatchingPublisher; -import org.onap.dmaap.mr.client.MRClientFactory; -import org.onap.dmaap.mr.client.response.MRPublisherResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class MountpointStatePublisher implements Runnable { - - private static final Logger LOG = LoggerFactory.getLogger(MountpointStatePublisher.class); - public static final List stateObjects = new LinkedList(); - static MRBatchingPublisher pub; - Properties publisherProperties = new Properties(); - static boolean closePublisher = false; //Set this to true in the "Close" method of MountpointStateProviderImpl - private int fetchPause = 5000; // Default pause between fetch - 5 seconds - - - public MountpointStatePublisher(Configuration config) { - initialize(config); - } - - public void initialize(Configuration config) { - LOG.info("In initializePublisher method of MountpointStatePublisher"); - GeneralConfig generalCfg = (GeneralConfig) config; - - publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_TRANSPORTTYPE, generalCfg.getTransportType()); - publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_HOST_PORT, generalCfg.getHostPort()); - publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_CONTENTTYPE, generalCfg.getContenttype()); - publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_TOPIC, generalCfg.getTopic()); - publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_MAXBATCHSIZE, generalCfg.getMaxBatchSize()); - publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_MAXAGEMS, generalCfg.getMaxAgeMs()); - publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_MESSAGESENTTHREADOCCURANCE, - generalCfg.getMessageSentThreadOccurrence()); - - createPublisher(publisherProperties); - } - - public MRBatchingPublisher createPublisher(Properties publisherProperties) { - - try { - pub = MRClientFactory.createBatchingPublisher(publisherProperties, false); - return pub; - } catch (IOException e) { - LOG.info("Exception while creating a publisher", e); - - } - return null; - } - - public void publishMessage(MRBatchingPublisher pub, String msg) { - LOG.info("Publishing message {} - ", msg); - try { - pub.send(msg); - } catch (IOException e) { - LOG.info("Exception while publishing a mesage ", e); - } - } - - public MRBatchingPublisher getPublisher() { - return pub; - } - - public void run() { - - while (!closePublisher) { - try { - if (stateObjects.size() > 0) { - JSONObject obj = ((LinkedList) stateObjects).removeFirst(); - publishMessage(getPublisher(), obj.toString()); - } else { - pauseThread(); - } - } catch (Exception ex) { - LOG.error("Exception while publishing message, ignoring and continuing ... ", ex); - } - - MRPublisherResponse res = pub.sendBatchWithResponse(); // As per dmaap-client code understanding, this need not be called but for some reason the messages are not pushed unless this is called - LOG.debug("Response message = {} ", res.toString()); - } - } - - private void pauseThread() throws InterruptedException { - if (fetchPause > 0) { - LOG.debug("No data yet to publish. Pausing {} ms before retry ", fetchPause); - Thread.sleep(fetchPause); - } else { - LOG.debug("No data yet to publish. No fetch pause specified - retrying immediately"); - } - } - - public static void stopPublisher() throws IOException, InterruptedException { - closePublisher = true; - pub.close(100, TimeUnit.MILLISECONDS); // Send any remaining messages and close - } -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisherMain.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisherMain.java new file mode 100644 index 000000000..8d6e2d4a3 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisherMain.java @@ -0,0 +1,144 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END======================================================= + * + */ +package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.TimeUnit; +import org.json.JSONObject; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; +import org.onap.dmaap.mr.client.MRBatchingPublisher; +import org.onap.dmaap.mr.client.MRClientFactory; +import org.onap.dmaap.mr.client.response.MRPublisherResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MountpointStatePublisherMain { + + private static final Logger LOG = LoggerFactory.getLogger(MountpointStatePublisherMain.class); + private Thread thread = null; + private MRBatchingPublisher pub = null; + private List stateObjects = new LinkedList(); + private Properties publisherProperties = new Properties(); + private boolean closePublisher = false; + private int publishPause = 5000; // Default pause between fetch - 5 seconds + + public MountpointStatePublisherMain(Configuration config) { + initialize(config); + } + + public void initialize(Configuration config) { + LOG.info("In initializePublisher method of MountpointStatePublisher"); + GeneralConfig generalCfg = (GeneralConfig) config; + + publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_TRANSPORTTYPE, generalCfg.getTransportType()); + publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_HOST_PORT, generalCfg.getHostPort()); + publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_CONTENTTYPE, generalCfg.getContenttype()); + publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_TOPIC, generalCfg.getTopic()); + publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_MAXBATCHSIZE, generalCfg.getMaxBatchSize()); + publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_MAXAGEMS, generalCfg.getMaxAgeMs()); + publisherProperties.put(GeneralConfig.PROPERTY_KEY_PUBLISHER_MESSAGESENTTHREADOCCURANCE, + generalCfg.getMessageSentThreadOccurrence()); + + createPublisher(publisherProperties); + } + + public MRBatchingPublisher createPublisher(Properties publisherProperties) { + + try { + pub = MRClientFactory.createBatchingPublisher(publisherProperties, false); + return pub; + } catch (IOException e) { + LOG.info("Exception while creating a publisher", e); + } + return null; + } + + public void publishMessage(MRBatchingPublisher pub, String msg) { + LOG.info("Publishing message {} - ", msg); + try { + pub.send(msg); + } catch (IOException e) { + LOG.info("Exception while publishing a mesage ", e); + } + } + + public MRBatchingPublisher getPublisher() { + return pub; + } + + public void start() { + thread = new Thread(new MountpointStatePublisher()); + thread.start(); + } + + public void stop() throws IOException, InterruptedException { + closePublisher = true; + getPublisher().close(100, TimeUnit.MILLISECONDS); // Send any remaining messages and close) + } + + private void pauseThread() throws InterruptedException { + if (publishPause > 0) { + LOG.debug("No data yet to publish. Pausing {} ms before retry ", publishPause); + Thread.sleep(publishPause); + } else { + LOG.debug("No data yet to publish. No fetch pause specified - retrying immediately"); + } + } + + public void addToPublish(JSONObject publishObj) { + getStateObjects().add(publishObj); + } + + public List getStateObjects() { + return stateObjects; + } + + public class MountpointStatePublisher implements Runnable { + + @Override + public void run() { + while (!closePublisher) { + try { + if (getStateObjects().size() > 0) { + JSONObject obj = ((LinkedList) getStateObjects()).removeFirst(); + publishMessage(getPublisher(), obj.toString()); + } else { + pauseThread(); + } + } catch (Exception ex) { + LOG.error("Exception while publishing message, ignoring and continuing ... ", ex); + } + + MRPublisherResponse res = pub.sendBatchWithResponse(); // As per dmaap-client code understanding, this need not be called but for some reason the messages are not pushed unless this is called + LOG.debug("Response message = {} ", res.toString()); + } + + } + + } + +} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/GeneralConfigTest.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/GeneralConfigTest.java index c95dbf56c..c921e7bcb 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/GeneralConfigTest.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/GeneralConfigTest.java @@ -44,14 +44,14 @@ public class GeneralConfigTest { + "maxAgeMs=250\n" + "MessageSentThreadOccurance=50\n"; // @formatter:on - + private final String fileName = "test.properties"; private ConfigurationFileRepresentation globalCfg; @Test - public void test() { - try { - Files.asCharSink(new File("test.properties"), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); - globalCfg = new ConfigurationFileRepresentation("test.properties"); + public void test() throws IOException { + + Files.asCharSink(new File(fileName), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + globalCfg = new ConfigurationFileRepresentation(fileName); GeneralConfig cfg = new GeneralConfig(globalCfg); assertEquals("onap-dmap:3904", cfg.getHostPort()); assertEquals(false, cfg.getEnabled()); @@ -65,15 +65,12 @@ public class GeneralConfigTest { assertEquals("HTTPNOAUTH", cfg.getTransportType()); assertEquals("general", cfg.getSectionName()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + } @After public void cleanUp() { - File file = new File("test.properties"); + File file = new File(fileName); if (file.exists()) { System.out.println("File exists, Deleting it"); file.delete(); diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeConnectListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeConnectListenerImpl.java index 8cc7f206f..2466683fd 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeConnectListenerImpl.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeConnectListenerImpl.java @@ -19,41 +19,73 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test; import static org.junit.Assert.assertNotEquals; - +import com.google.common.io.Files; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Optional; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.GeneralConfig; import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointNodeConnectListenerImpl; -import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisherMain; import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.NetconfAccessorMock; import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.NetconfNodeMock; -import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi.DataBrokerMountpointMock; -import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi.MountPointMockNew; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.NetconfNodeStateServiceMock; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.MountPoint; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; public class TestMountpointNodeConnectListenerImpl { - MountpointNodeConnectListenerImpl nodeConnectListener = new MountpointNodeConnectListenerImpl(); + // @formatter:off + private static final String TESTCONFIG_CONTENT = + "[general]\n" + + "dmaapEnabled=false\n" + + "TransportType=HTTPNOAUTH\n" + + "host=onap-dmap:3904\n" + + "topic=unauthenticated.SDNR_MOUNTPOINT_STATE_INFO\n" + + "contenttype=application/json\n" + + "timeout=20000\n" + + "limit=10000\n" + + "maxBatchSize=100\n" + + "maxAgeMs=250\n" + + "MessageSentThreadOccurance=50\n"; + // @formatter:on + private final String fileName = "test1.properties"; + private ConfigurationFileRepresentation globalCfg; + + + NetconfNodeStateServiceMock netconfNodeStateServiceMock = new NetconfNodeStateServiceMock(); + MountpointNodeConnectListenerImpl nodeConnectListener = + new MountpointNodeConnectListenerImpl(netconfNodeStateServiceMock); + MountpointStatePublisherMain mountpointStatePublisher; NetconfNodeMock netconfNodeMock = new NetconfNodeMock(); NetconfNode netconfNode = netconfNodeMock.getNetconfNode(); NodeId nNodeId = new NodeId("nSky"); - DataBroker netconfNodeDataBroker = new DataBrokerMountpointMock(); - MountPoint mountpoint = new MountPointMockNew(); - NetconfAccessor accessor = new NetconfAccessorMock(nNodeId, netconfNode, mountpoint, netconfNodeDataBroker); + NetconfAccessor accessor = new NetconfAccessorMock(nNodeId, netconfNode); + + @Before + public void initialize() throws IOException { + Files.asCharSink(new File(fileName), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + globalCfg = new ConfigurationFileRepresentation(fileName); + GeneralConfig cfg = new GeneralConfig(globalCfg); + mountpointStatePublisher = new MountpointStatePublisherMain(cfg); + nodeConnectListener.start(mountpointStatePublisher); + } @Test public void testOnEnterConnected() { nodeConnectListener.onEnterConnected(accessor); - assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + assertNotEquals(mountpointStatePublisher.getStateObjects().size(), 0); } @Test public void testOnLeaveConnected() { nodeConnectListener.onLeaveConnected(nNodeId, Optional.of(netconfNode)); - assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + assertNotEquals(mountpointStatePublisher.getStateObjects().size(), 0); } @Test @@ -62,4 +94,14 @@ public class TestMountpointNodeConnectListenerImpl { nodeConnectListener.close(); } + @After + public void after() { + File file = new File(fileName); + if (file.exists()) { + System.out.println("File exists, Deleting it"); + file.delete(); + } + + } + } diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java index 2ee93b0a3..8d95a4c53 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java @@ -21,36 +21,70 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; - +import com.google.common.io.Files; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.GeneralConfig; import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointNodeStateListenerImpl; -import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisherMain; import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.NetconfNodeMock; -import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi.DataBrokerMountpointMock; -import org.opendaylight.mdsal.binding.api.DataBroker; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.NetconfNodeStateServiceMock; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; public class TestMountpointNodeStateListenerImpl { - MountpointNodeStateListenerImpl nodeStateListener = new MountpointNodeStateListenerImpl(); + // @formatter:off + private static final String TESTCONFIG_CONTENT = + "[general]\n" + + "dmaapEnabled=false\n" + + "TransportType=HTTPNOAUTH\n" + + "host=onap-dmap:3904\n" + + "topic=unauthenticated.SDNR_MOUNTPOINT_STATE_INFO\n" + + "contenttype=application/json\n" + + "timeout=20000\n" + + "limit=10000\n" + + "maxBatchSize=100\n" + + "maxAgeMs=250\n" + + "MessageSentThreadOccurance=50\n"; + // @formatter:on + private final String fileName = "test2.properties"; + private ConfigurationFileRepresentation globalCfg; + + NetconfNodeStateServiceMock netconfNodeStateServiceMock = new NetconfNodeStateServiceMock(); + MountpointNodeStateListenerImpl nodeStateListener = + new MountpointNodeStateListenerImpl(netconfNodeStateServiceMock); + MountpointStatePublisherMain mountpointStatePublisher; NetconfNodeMock netconfNodeMock = new NetconfNodeMock(); NetconfNode netconfNode = netconfNodeMock.getNetconfNode(); NodeId nNodeId = new NodeId("nSky"); - DataBroker netconfNodeDataBroker = new DataBrokerMountpointMock(); + + @Before + public void initialize() throws IOException { + Files.asCharSink(new File(fileName), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + globalCfg = new ConfigurationFileRepresentation(fileName); + GeneralConfig cfg = new GeneralConfig(globalCfg); + mountpointStatePublisher = new MountpointStatePublisherMain(cfg); + nodeStateListener.start(mountpointStatePublisher); + } @Test public void testOnCreated() { assertNotNull(nNodeId); assertNotNull(netconfNode); nodeStateListener.onCreated(nNodeId, netconfNode); - assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + assertNotEquals(mountpointStatePublisher.getStateObjects().size(), 0); } @Test public void testOnStateChange() { nodeStateListener.onStateChange(nNodeId, netconfNode); - assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + assertNotEquals(mountpointStatePublisher.getStateObjects().size(), 0); } @Test @@ -58,4 +92,14 @@ public class TestMountpointNodeStateListenerImpl { nodeStateListener.onRemoved(nNodeId); } + @After + public void after() { + File file = new File(fileName); + if (file.exists()) { + System.out.println("File exists, Deleting it"); + file.delete(); + } + + } + } diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java index dcb62f253..5fc1c5e15 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java @@ -21,37 +21,45 @@ * ============LICENSE_END======================================================= * */ - package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test; + +import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Properties; import java.util.concurrent.TimeUnit; - import org.json.JSONObject; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.GeneralConfig; -import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisherMain; import org.onap.dmaap.mr.client.MRBatchingPublisher; import org.onap.dmaap.mr.client.response.MRPublisherResponse; import org.slf4j.Logger; public class TestMountpointStatePublisher { - private static final String CONFIGURATIONTESTFILE = "test.properties"; + private static final String CONFIGURATIONTESTFILE = "test3.properties"; public Thread publisher; + MountpointStatePublisherMain mountpointStatePublisher; + ConfigurationFileRepresentation configFileRepresentation; + GeneralConfig cfg; @Before public void testMountpointStatePublisherData() { String testJsonData = "{\"NodeId\":\"69322972e178_50001\",\"NetConfNodeState\":\"Connecting\",\"TimeStamp\":\"2019-11-12T12:45:08.604Z\"}"; + configFileRepresentation = + new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE); + cfg = new GeneralConfig(configFileRepresentation); JSONObject jsonObj = new JSONObject(testJsonData); - MountpointStatePublisher.stateObjects.add(jsonObj); + mountpointStatePublisher = new MountpointStatePublisherMain(cfg); + mountpointStatePublisher.getStateObjects().add(jsonObj); } @Test @@ -60,13 +68,13 @@ public class TestMountpointStatePublisher { new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE); GeneralConfig cfg = new GeneralConfig(configFileRepresentation); - MountpointStatePublisher pub = new MountpointStatePublisherMock(cfg); + MountpointStatePublisherMain pub = new MountpointStatePublisherMock(cfg); pub.createPublisher(null); pub.publishMessage(pub.createPublisher(null), "Test DMaaP Message"); } - public class MountpointStatePublisherMock extends MountpointStatePublisher { + public class MountpointStatePublisherMock extends MountpointStatePublisherMain { public MountpointStatePublisherMock(Configuration config) { super(config); @@ -79,69 +87,58 @@ public class TestMountpointStatePublisher { @Override public int send(String msg) throws IOException { - // TODO Auto-generated method stub System.out.println("Message to send - " + msg); return 0; } @Override public int send(String partition, String msg) throws IOException { - // TODO Auto-generated method stub return 0; } @Override public int send(message msg) throws IOException { - // TODO Auto-generated method stub return 0; } @Override public int send(Collection msgs) throws IOException { - // TODO Auto-generated method stub return 0; } @Override public void close() { - // TODO Auto-generated method stub } @Override public void logTo(Logger log) { - // TODO Auto-generated method stub } @Override public void setApiCredentials(String apiKey, String apiSecret) { - // TODO Auto-generated method stub } @Override public void clearApiCredentials() { - // TODO Auto-generated method stub } @Override public int getPendingMessageCount() { - // TODO Auto-generated method stub return 0; } @Override public List close(long timeout, TimeUnit timeoutUnits) throws IOException, InterruptedException { - // TODO Auto-generated method stub return null; } @Override public MRPublisherResponse sendBatchWithResponse() { - // TODO Auto-generated method stub return null; } @@ -149,4 +146,14 @@ public class TestMountpointStatePublisher { } } + @After + public void after() { + File file = new File(CONFIGURATIONTESTFILE); + if (file.exists()) { + System.out.println("File exists, Deleting it"); + file.delete(); + } + + } + } diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfAccessorMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfAccessorMock.java index 69c24d834..328e9a344 100644 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfAccessorMock.java +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfAccessorMock.java @@ -37,15 +37,10 @@ public class NetconfAccessorMock implements NetconfAccessor { private final NodeId nNodeId; private final NetconfNode netconfNode; - private final MountPoint mountpoint; - private final DataBroker netconfNodeDataBroker; - public NetconfAccessorMock(NodeId nNodeId, NetconfNode netconfNode, MountPoint mountpoint, - DataBroker netconfNodeDataBroker) { + public NetconfAccessorMock(NodeId nNodeId, NetconfNode netconfNode) { this.nNodeId = nNodeId; this.netconfNode = netconfNode; - this.mountpoint = mountpoint; - this.netconfNodeDataBroker = netconfNodeDataBroker; } @Override @@ -65,12 +60,12 @@ public class NetconfAccessorMock implements NetconfAccessor { @Override public DataBroker getDataBroker() { - return netconfNodeDataBroker; + return null; } @Override public MountPoint getMountpoint() { - return mountpoint; + return null; } @Override diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfNodeStateServiceMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfNodeStateServiceMock.java new file mode 100644 index 000000000..9d6e69d53 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfNodeStateServiceMock.java @@ -0,0 +1,59 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. + * All rights reserved. + * ================================================================================ + * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END======================================================= + * + */ + +package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock; + +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener; +import org.opendaylight.yangtools.concepts.ListenerRegistration; + +public class NetconfNodeStateServiceMock implements NetconfNodeStateService { + + @Override + public void close() { + + } + + @Override + public @NonNull ListenerRegistration registerNetconfNodeConnectListener( + @NonNull L netconfNodeConnectListener) { + return null; + } + + @Override + public @NonNull ListenerRegistration registerNetconfNodeStateListener( + @NonNull L netconfNodeStateListener) { + return null; + } + + @Override + public @NonNull ListenerRegistration registerVesNotifications( + @NonNull L netconfNodeStateListener) { + return null; + } + +} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerMountpointMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerMountpointMock.java deleted file mode 100644 index 271701fc2..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerMountpointMock.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.binding.api.BindingService; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.ReadTransaction; -import org.opendaylight.mdsal.binding.api.TransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class DataBrokerMountpointMock implements DataBroker, BindingService { - - ReadOnlyTransaction readOnlyTransaction; - - public void setReadOnlyTransaction(ReadOnlyTransaction readOnlyTransaction) { - this.readOnlyTransaction = readOnlyTransaction; - } - - public > ListenerRegistration registerDataTreeChangeListener( - DataTreeIdentifier arg0, L arg1) { - return null; - } - - public BindingTransactionChain createTransactionChain(TransactionChainListener listener) { - return null; - } - - public ReadOnlyTransaction newReadOnlyTransaction1() { - return readOnlyTransaction; - } - - public ReadWriteTransaction newReadWriteTransaction1() { - return null; - } - - public org.opendaylight.mdsal.binding.api.@NonNull WriteTransaction newWriteOnlyTransaction1() { - return null; - } - - @Override - public @NonNull ReadTransaction newReadOnlyTransaction() { - // TODO Auto-generated method stub - return null; - } - - @Override - public org.opendaylight.mdsal.binding.api.@NonNull ReadWriteTransaction newReadWriteTransaction() { - // TODO Auto-generated method stub - return null; - } - - @Override - public org.opendaylight.mdsal.binding.api.@NonNull WriteTransaction newWriteOnlyTransaction() { - // TODO Auto-generated method stub - return null; - } - - @Override - public > @NonNull ListenerRegistration registerDataTreeChangeListener( - org.opendaylight.mdsal.binding.api.@NonNull DataTreeIdentifier treeId, @NonNull L listener) { - // TODO Auto-generated method stub - return null; - } - - @Override - public @NonNull TransactionChain createTransactionChain( - org.opendaylight.mdsal.binding.api.@NonNull TransactionChainListener listener) { - // TODO Auto-generated method stub - return null; - } - - - -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerNetconfMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerNetconfMock.java deleted file mode 100644 index 65ca779a3..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerNetconfMock.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.mdsal.binding.api.ReadTransaction; -import org.opendaylight.mdsal.binding.api.TransactionChain; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class DataBrokerNetconfMock implements DataBroker { - - - ReadOnlyTransaction readOnlyTransaction; - - public void setReadOnlyTransaction(ReadOnlyTransaction readOnlyTransaction) { - this.readOnlyTransaction = readOnlyTransaction; - } - - //@Override - public > ListenerRegistration registerDataTreeChangeListener( - DataTreeIdentifier arg0, L arg1) { - return null; - } - - //@Override - public BindingTransactionChain createTransactionChain(TransactionChainListener listener) { - return null; - } - - //@Override - public ReadOnlyTransaction newReadOnlyTransaction1() { - return readOnlyTransaction; - } - - //@Override - public ReadWriteTransaction newReadWriteTransaction1() { - return null; - } - - //@Override - public WriteTransaction newWriteOnlyTransaction1() { - return null; - } - - @Override - public @NonNull ReadTransaction newReadOnlyTransaction() { - // TODO Auto-generated method stub - return null; - } - - @Override - public org.opendaylight.mdsal.binding.api.@NonNull ReadWriteTransaction newReadWriteTransaction() { - // TODO Auto-generated method stub - return null; - } - - @Override - public org.opendaylight.mdsal.binding.api.@NonNull WriteTransaction newWriteOnlyTransaction() { - // TODO Auto-generated method stub - return null; - } - - @Override - public > @NonNull ListenerRegistration registerDataTreeChangeListener( - org.opendaylight.mdsal.binding.api.@NonNull DataTreeIdentifier treeId, @NonNull L listener) { - // TODO Auto-generated method stub - return null; - } - - @Override - public @NonNull TransactionChain createTransactionChain( - org.opendaylight.mdsal.binding.api.@NonNull TransactionChainListener listener) { - // TODO Auto-generated method stub - return null; - } - - -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMock.java deleted file mode 100644 index cab9747e9..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMock.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import com.google.common.base.Optional; -import org.opendaylight.controller.md.sal.binding.api.BindingService; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf; -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.TopologyId; -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.TopologyKey; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class MountPointMock implements MountPoint { - - private boolean databrokerAbsent = true; - private final DataBrokerMountpointMock dataBroker = new DataBrokerMountpointMock(); - private final RpcConsumerRegistryMock rpcConsumerRegistry = new RpcConsumerRegistryMock(); - private NotificationService setReadOnlyTransaction; - - private static final InstanceIdentifier NETCONF_TOPO_IID = - InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, - new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))); - - @Override - public InstanceIdentifier getIdentifier() { - return NETCONF_TOPO_IID; - } - - @SuppressWarnings("unchecked") - @Override - public Optional getService(Class service) { - - System.out.println("Requested mountpoint service: " + service.getSimpleName() + " databrokerAbsent state: " - + databrokerAbsent); - - Optional res; - if (service.isInstance(dataBroker)) { - System.out.println("Delivering databroker"); - res = databrokerAbsent ? Optional.absent() : Optional.of(dataBroker); - } else if (service.isInstance(rpcConsumerRegistry)) { - System.out.println("Delivering RpcConsumerRegistryMock"); - res = Optional.of(rpcConsumerRegistry); - } else if (service.isInstance(setReadOnlyTransaction)) { - System.out.println("Delivering notificationService"); - res = Optional.of(setReadOnlyTransaction); - } else { - System.out.println("Delivering no service"); - res = Optional.absent(); - } - return (Optional) res; - } - - public void setDatabrokerAbsent(boolean state) { - this.databrokerAbsent = state; - } - - public void setReadOnlyTransaction(T readOnlyTransaction) { - this.setReadOnlyTransaction = readOnlyTransaction; - dataBroker.setReadOnlyTransaction(readOnlyTransaction); - } - - -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMockNew.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMockNew.java deleted file mode 100644 index f8035e82e..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMockNew.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import java.util.Optional; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.mdsal.binding.api.BindingService; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class MountPointMockNew implements MountPoint { - - @Override - public @NonNull InstanceIdentifier getIdentifier() { - return null; - } - - @Override - public @NonNull Optional getService(@NonNull Class service) { - return null; - } - -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointServiceMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointServiceMock.java deleted file mode 100644 index 8802e812b..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointServiceMock.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import com.google.common.base.Optional; -import org.opendaylight.controller.md.sal.binding.api.MountPoint; -import org.opendaylight.controller.md.sal.binding.api.MountPointService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class MountPointServiceMock implements MountPointService { - - private final MountPointMock mountpoint; - - public MountPointServiceMock(MountPointMock mountpoint) { - this.mountpoint = mountpoint; - } - - @Override - public Optional getMountPoint(InstanceIdentifier mountPoint) { - - Optional optional = Optional.of(mountpoint); - return optional; - } - - @Override - public ListenerRegistration registerListener(InstanceIdentifier path, - T listener) { - return null; - } - -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/NotificationPublishServiceMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/NotificationPublishServiceMock.java deleted file mode 100644 index 79ba90ae2..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/NotificationPublishServiceMock.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.yangtools.yang.binding.Notification; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class NotificationPublishServiceMock implements NotificationPublishService { - - @Override - public ListenableFuture offerNotification(Notification notification) { - return null; - } - - @Override - public ListenableFuture offerNotification(Notification notification, int timeout, TimeUnit unit) - throws InterruptedException { - return null; - } - - @Override - public void putNotification(Notification notification) throws InterruptedException {} - -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcConsumerRegistryMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcConsumerRegistryMock.java deleted file mode 100644 index 963c9023b..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcConsumerRegistryMock.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; -import org.opendaylight.yangtools.yang.binding.RpcService; - -/** - * @author herbert - * - */ -@SuppressWarnings("deprecation") -public class RpcConsumerRegistryMock implements RpcConsumerRegistry { - - @Override - public T getRpcService(Class serviceInterface) { - return null; - } - -} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcProviderRegistryMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcProviderRegistryMock.java deleted file mode 100644 index 1a8ed90d6..000000000 --- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcProviderRegistryMock.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi; - -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; - -@SuppressWarnings("deprecation") -public class RpcProviderRegistryMock implements RpcProviderRegistry { - - @Override - public T getRpcService(Class serviceInterface) { - return null; - } - - @Override - public >> ListenerRegistration registerRouteChangeListener( - L listener) { - return null; - } - - - @Override - public RoutedRpcRegistration addRoutedRpcImplementation(Class serviceInterface, - T implementation) throws IllegalStateException { - return null; - } - - @Override - public RpcRegistration addRpcImplementation(Class serviceInterface, T implementation) - throws IllegalStateException { - System.out.println("Register class " + serviceInterface); - return null; - } - -} -- cgit 1.2.3-korg