c6a9d11e550db5c4eceb705ca84c385e8383131c
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18
19 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test;
20
21
22 import static org.junit.Assert.assertNotEquals;
23 import static org.junit.Assert.assertNotNull;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
31 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointNodeStateListenerImpl;
32 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher;
33 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.NetconfNodeMock;
34 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test.mock.NetconfNodeStateServiceMock;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
37
38 public class TestMountpointNodeStateListenerImpl {
39
40     NetconfNodeStateServiceMock netconfNodeStateServiceMock = new NetconfNodeStateServiceMock();
41     MountpointNodeStateListenerImpl nodeStateListener =
42             new MountpointNodeStateListenerImpl(netconfNodeStateServiceMock);
43     MountpointStatePublisher mountpointStatePublisher;
44     NetconfNodeMock netconfNodeMock = new NetconfNodeMock();
45     NetconfNode netconfNode = netconfNodeMock.getNetconfNode();
46     NodeId nNodeId = new NodeId("nSky");
47     VESCollectorService vesCollectorService;
48
49     @Before
50     public void initialize() {
51         DeviceManagerServiceProvider serviceProvider = mock(DeviceManagerServiceProvider.class);
52         vesCollectorService = mock(VESCollectorService.class);
53         NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class);
54         when(netconfNetworkElementService.getServiceProvider()).thenReturn(serviceProvider);
55         when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService);
56         mountpointStatePublisher = new MountpointStatePublisher(vesCollectorService);
57         nodeStateListener.start(mountpointStatePublisher);
58     }
59
60     @Test
61     public void testOnCreated() {
62         assertNotNull(nNodeId);
63         assertNotNull(netconfNode);
64         nodeStateListener.onCreated(nNodeId, netconfNode);
65         assertNotEquals(mountpointStatePublisher.getStateObjects().size(), 0);
66     }
67
68     @Test
69     public void testOnStateChange() {
70         nodeStateListener.onStateChange(nNodeId, netconfNode);
71         assertNotEquals(mountpointStatePublisher.getStateObjects().size(), 0);
72     }
73
74     @Test
75     public void testOnRemoved() {
76         nodeStateListener.onRemoved(nNodeId);
77     }
78
79 }