ebf4cb8941e3892634a849565beb125c310a5024
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
7  * ================================================================================
8  * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
9  * ================================================================================
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *     http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ============LICENSE_END=======================================================
22  *
23  */
24 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test;
25
26
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.when;
29 import org.json.JSONObject;
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
37 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage;
38 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStatePublisher;
39
40 public class TestMountpointStatePublisher {
41
42     MountpointStatePublisher mountpointStatePublisher;
43     VESCollectorService vesCollectorService;
44     VESCollectorCfgService vesCfg;
45     VESMessage vesMsg;
46     JSONObject testJsonData;
47
48     @Before
49     public void testMountpointStatePublisherData() {
50         testJsonData = new JSONObject();
51         testJsonData.put("NodeId", "69322972e178_50001");
52         testJsonData.put("NetConfNodeState", "Connecting");
53         testJsonData.put("TimeStamp", java.time.Clock.systemUTC().instant());
54
55
56         DeviceManagerServiceProvider serviceProvider = mock(DeviceManagerServiceProvider.class);
57         vesCollectorService = mock(VESCollectorService.class);
58         vesCfg = mock(VESCollectorCfgService.class);
59         NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class);
60         when(netconfNetworkElementService.getServiceProvider()).thenReturn(serviceProvider);
61         when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService);
62         when(vesCollectorService.getConfig()).thenReturn(vesCfg);
63         when(vesCfg.getReportingEntityName()).thenReturn("ONAP SDN-R");
64         when(vesCollectorService.publishVESMessage(vesMsg)).thenReturn(true);
65
66         mountpointStatePublisher = new MountpointStatePublisher(vesCollectorService);
67         mountpointStatePublisher.addToPublish(testJsonData);
68         mountpointStatePublisher.getStateObjects().add(testJsonData);
69     }
70
71     @Test
72     public void testMountpointStatePublisherConfiguration() throws InterruptedException {
73         Thread t = new Thread(mountpointStatePublisher);
74         t.start();
75         Thread.sleep(7000);
76     }
77
78     @After
79     public void close() {
80         mountpointStatePublisher.stop();
81     }
82 }