diff options
Diffstat (limited to 'sdnr/wt/mountpoint-state-provider/provider/src/test/java')
16 files changed, 1196 insertions, 0 deletions
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 new file mode 100644 index 000000000..87bd85fa3 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/GeneralConfigTest.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import org.junit.After; +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 com.google.common.io.Files; + +public class GeneralConfigTest { + + 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"; + + 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"); + GeneralConfig cfg = new GeneralConfig(globalCfg); + assertEquals("onap-dmap:3904", cfg.getHostPort()); + assertEquals(false, cfg.getEnabled()); + assertEquals("unauthenticated.SDNR_MOUNTPOINT_STATE_INFO", cfg.getTopic()); + assertEquals("application/json", cfg.getContenttype()); + assertEquals("20000", cfg.getTimeout()); + assertEquals("10000", cfg.getLimit()); + assertEquals("100", cfg.getMaxBatchSize()); + assertEquals("250", cfg.getMaxAgeMs()); + assertEquals("50", cfg.getMessageSentThreadOccurrence()); + 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"); + 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 new file mode 100644 index 000000000..078109500 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeConnectListenerImpl.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * ============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; + +import static org.junit.Assert.assertNotEquals; + +import java.util.Optional; +import org.junit.Test; +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.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.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(); + 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); + + @Test + public void testOnEnterConnected() { + nodeConnectListener.onEnterConnected(accessor); + assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + } + + @Test + public void testOnLeaveConnected() { + nodeConnectListener.onLeaveConnected(nNodeId, Optional.of(netconfNode)); + assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + } + + @Test + public void testClose() throws Exception { + //assertEquals(MountpointStatePublisher.stateObjects.size(), 0); + nodeConnectListener.close(); + } + +} 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 new file mode 100644 index 000000000..2423aa8d4 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * ============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; + + +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +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.test.mock.NetconfNodeMock; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.odlapi.DataBrokerMountpointMock; +import org.opendaylight.mdsal.binding.api.DataBroker; +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(); + NetconfNodeMock netconfNodeMock = new NetconfNodeMock(); + NetconfNode netconfNode = netconfNodeMock.getNetconfNode(); + NodeId nNodeId = new NodeId("nSky"); + DataBroker netconfNodeDataBroker = new DataBrokerMountpointMock(); + + @Test + public void testOnCreated() { + assertNotNull(nNodeId); + assertNotNull(netconfNode); + nodeStateListener.onCreated(nNodeId, netconfNode); + assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + } + + @Test + public void testOnStateChange() { + nodeStateListener.onStateChange(nNodeId, netconfNode); + assertNotEquals(MountpointStatePublisher.stateObjects.size(), 0); + } + + @Test + public void testOnRemoved() { + nodeStateListener.onRemoved(nNodeId); + } + +} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java new file mode 100644 index 000000000..efcd86582 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java @@ -0,0 +1,124 @@ +package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test; +/******************************************************************************* + * ============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========================================================================== + ******************************************************************************/ + +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStateProviderImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestMountpointStateProviderImpl { + + private static Path KARAF_ETC = Paths.get("etc"); + private static MountpointStateProviderImpl mountpointStateProvider; + + private static final Logger LOG = LoggerFactory.getLogger(TestMountpointStateProviderImpl.class); + + + + @BeforeClass + public static void before() throws InterruptedException, IOException { + + System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName()); + // Call System property to get the classpath value + Path etc = KARAF_ETC; + delete(etc); + + System.out.println("Create empty:" + etc.toString()); + Files.createDirectories(etc); + + // Create mocks + + // start using blueprint interface + try { + mountpointStateProvider = new MountpointStateProviderImpl(); + + //mountpointStateProvider.init(); // Can't be tested as this invokes a thread. Mockito doesn't help either + } catch (Exception e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + fail("Not initialized" +sw.toString()); + } + System.out.println("Initialization status: " + mountpointStateProvider.isInitializationOk()); + System.out.println("Initialization done"); + } + + @AfterClass + public static void after() throws InterruptedException, IOException { + + System.out.println("Start shutdown"); + // close using blueprint interface + try { + mountpointStateProvider.close(); + } catch (Exception e) { + System.out.println(e); + } + delete(KARAF_ETC); + + } + + @Test + public void test1() { + System.out.println("Test1: slave mountpoint"); + System.out.println("Initialization status: " + mountpointStateProvider.isInitializationOk()); + System.out.println("Test2: Done"); + } + + // ********************* Private + + private static void delete(Path etc) throws IOException { + if (Files.exists(etc)) { + System.out.println("Found and remove:" + etc.toString()); + delete(etc.toFile()); + } + } + + private static void delete(File f) throws IOException { + if (f.isDirectory()) { + for (File c : f.listFiles()) { + delete(c); + } + } + if (!f.delete()) { + throw new FileNotFoundException("Failed to delete file: " + f); + } + } +/* @Test + public void testInit() { + + } + + @Test + public void testOnConfigChanged() { + //fail("Not yet implemented"); + }*/ + +} 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 new file mode 100644 index 000000000..b9eb9ba30 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStatePublisher.java @@ -0,0 +1,143 @@ +package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test; +/******************************************************************************* + * ============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========================================================================== + ******************************************************************************/ + +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.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.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"; + public Thread publisher; + + @Before + public void testMountpointStatePublisherData() { + String testJsonData = "{\"NodeId\":\"69322972e178_50001\",\"NetConfNodeState\":\"Connecting\",\"TimeStamp\":\"2019-11-12T12:45:08.604Z\"}"; + JSONObject jsonObj = new JSONObject(testJsonData); + MountpointStatePublisher.stateObjects.add(jsonObj); + } + + @Test + public void testMountpointStatePublisherConfiguration() throws InterruptedException { + ConfigurationFileRepresentation configFileRepresentation = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE); + GeneralConfig cfg = new GeneralConfig(configFileRepresentation); + + MountpointStatePublisher pub = new MountpointStatePublisherMock(cfg); + pub.createPublisher(null); + pub.publishMessage(pub.createPublisher(null), "Test DMaaP Message"); + + } + + public class MountpointStatePublisherMock extends MountpointStatePublisher { + + public MountpointStatePublisherMock(Configuration config) { + super(config); + } + + @Override + public MRBatchingPublisher createPublisher(Properties publisherProperties) { + + return new MRBatchingPublisher() { + + @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<message> 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<message> 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; + } + + }; + } + } + +} 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 new file mode 100644 index 000000000..8a4f20b29 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfAccessorMock.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * ============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; + +import com.google.common.util.concurrent.ListenableFuture; +import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput; +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.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.common.RpcResult; + +/** + */ +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) { + this.nNodeId = nNodeId; + this.netconfNode = netconfNode; + this.mountpoint = mountpoint; + this.netconfNodeDataBroker = netconfNodeDataBroker; + } + + @Override + public NodeId getNodeId() { + return nNodeId; + } + + @Override + public NetconfNode getNetconfNode() { + return netconfNode; + } + + @Override + public Capabilities getCapabilites() { + return null; + } + + @Override + public DataBroker getDataBroker() { + return netconfNodeDataBroker; + } + + @Override + public MountPoint getMountpoint() { + return mountpoint; + } + + @Override + public TransactionUtils getTransactionUtils() { + return null; + } + + @Override + public <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener( + @NonNull T listener) { + return null; + } + + @Override + public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(String streamName) { + return null; + } + +} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfNodeMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfNodeMock.java new file mode 100644 index 000000000..297674945 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/NetconfNodeMock.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; +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.NetconfNodeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus; + +public class NetconfNodeMock { + + public NetconfNode getNetconfNode() { + + NetconfNodeBuilder nNodeBuilder = new NetconfNodeBuilder(); + nNodeBuilder.setAvailableCapabilities(null); + nNodeBuilder.setConnectionStatus(ConnectionStatus.Connected); + nNodeBuilder.setHost(new Host(new IpAddress(new Ipv4Address("1.2.3.4")))); + nNodeBuilder.setPort(new PortNumber(2230)); + // build + NetconfNode nNode = nNodeBuilder.build(); + return nNode; + } + +} diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/ClusterSingletonServiceProviderMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/ClusterSingletonServiceProviderMock.java new file mode 100644 index 000000000..b9d55ff27 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/ClusterSingletonServiceProviderMock.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * ============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.mdsal.singleton.common.api.ClusterSingletonService; +import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; +import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; + +public class ClusterSingletonServiceProviderMock implements ClusterSingletonServiceProvider { + + @Override + public void close() throws Exception { + + } + + @Override + public ClusterSingletonServiceRegistration registerClusterSingletonService(ClusterSingletonService 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/DataBrokerMountpointMock.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerMountpointMock.java new file mode 100644 index 000000000..b85d66809 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerMountpointMock.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * ============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 <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener( + DataTreeIdentifier<T> 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 <T extends DataObject, L extends org.opendaylight.mdsal.binding.api.DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener( + org.opendaylight.mdsal.binding.api.@NonNull DataTreeIdentifier<T> 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 new file mode 100644 index 000000000..c8b03e4a0 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/DataBrokerNetconfMock.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * ============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 <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener( + DataTreeIdentifier<T> 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 <T extends DataObject, L extends org.opendaylight.mdsal.binding.api.DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener( + org.opendaylight.mdsal.binding.api.@NonNull DataTreeIdentifier<T> 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 new file mode 100644 index 000000000..3194189d8 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMock.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * ============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<Topology> 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 <T extends BindingService> Optional<T> getService(Class<T> 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<T>)res; + } + + public void setDatabrokerAbsent( boolean state) { + this.databrokerAbsent = state; + } + + public <T extends NotificationService&ReadOnlyTransaction>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 new file mode 100644 index 000000000..03e70b56f --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointMockNew.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * ============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 <T extends BindingService> @NonNull Optional<T> getService(@NonNull Class<T> 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 new file mode 100644 index 000000000..59f742f4a --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/MountPointServiceMock.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * ============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<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint) { + + Optional<MountPoint> optional = Optional.of(mountpoint); + return optional; + } + + @Override + public <T extends MountPointListener> ListenerRegistration<T> 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 new file mode 100644 index 000000000..b9db050c3 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/NotificationPublishServiceMock.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * ============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 new file mode 100644 index 000000000..0f08ec07f --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcConsumerRegistryMock.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============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 extends RpcService> T getRpcService(Class<T> 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 new file mode 100644 index 000000000..8a72bb630 --- /dev/null +++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/mock/odlapi/RpcProviderRegistryMock.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * ============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 extends RpcService> T getRpcService(Class<T> serviceInterface) { + return null; + } + + @Override + public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener( + L listener) { + return null; + } + + + @Override + public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> serviceInterface, + T implementation) throws IllegalStateException { + return null; + } + + @Override + public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> serviceInterface, T implementation) + throws IllegalStateException { + System.out.println("Register class "+serviceInterface); + return null; + } + +} |