2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test;
24 import static org.mockito.Mockito.when;
25 import java.math.BigDecimal;
26 import org.eclipse.jdt.annotation.Nullable;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.mockito.Mock;
30 import org.mockito.junit.MockitoJUnitRunner;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanRegistrationToVESpnfRegistrationMapper;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.netconf.node.augmented.optional.fields.IgnoreMissingSchemaSources;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.NonModuleCapabilities;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.OdlHelloMessageCapabilities;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.YangModuleCapabilities;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.ClusteredConnectionStatus;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.PassThrough;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilities;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.schema.storage.YangLibrary;
52 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
53 import org.opendaylight.yangtools.yang.common.Uint16;
54 import org.opendaylight.yangtools.yang.common.Uint32;
56 @RunWith(MockitoJUnitRunner.class)
57 public class TestORanRegistrationToVESpnfRegistration {
60 NetconfAccessor netconfAccessor;
62 VESCollectorService vesCollectorService;
64 VESCollectorCfgService vesCfgService;
66 private final int SEQUENCE_NO = 10;
70 String dateTimeString = "2020-02-05T12:30:45.283Z";
71 String name = "Slot-0";
73 when(netconfAccessor.getNodeId()).thenReturn(new NodeId("nSky"));
74 when(netconfAccessor.getNetconfNode()).thenReturn(new TestNetconfNode());
75 when(vesCollectorService.getConfig()).thenReturn(vesCfgService);
76 when(vesCfgService.getReportingEntityName()).thenReturn("SDN-R");
77 Component testComponent = ComponentHelper.get(name, dateTimeString);
79 ORanRegistrationToVESpnfRegistrationMapper mapper = new ORanRegistrationToVESpnfRegistrationMapper(netconfAccessor, vesCollectorService, testComponent);
80 mapper.mapCommonEventHeader(SEQUENCE_NO);
81 mapper.mapPNFRegistrationFields();
84 public class TestNetconfNode implements NetconfNode {
87 public @Nullable Credentials getCredentials() {
92 public @Nullable Host getHost() {
93 return new Host(new IpAddress(new Ipv4Address("10.10.10.10")));
97 public @Nullable PortNumber getPort() {
98 // TODO Auto-generated method stub
103 public @Nullable Boolean isTcpOnly() {
104 // TODO Auto-generated method stub
109 public @Nullable Protocol getProtocol() {
110 // TODO Auto-generated method stub
115 public @Nullable Boolean isSchemaless() {
116 // TODO Auto-generated method stub
121 public @Nullable YangModuleCapabilities getYangModuleCapabilities() {
122 // TODO Auto-generated method stub
127 public @Nullable NonModuleCapabilities getNonModuleCapabilities() {
128 // TODO Auto-generated method stub
133 public @Nullable Boolean isReconnectOnChangedSchema() {
134 // TODO Auto-generated method stub
139 public @Nullable Uint32 getConnectionTimeoutMillis() {
140 // TODO Auto-generated method stub
145 public @Nullable Uint32 getDefaultRequestTimeoutMillis() {
146 // TODO Auto-generated method stub
151 public @Nullable Uint32 getMaxConnectionAttempts() {
152 // TODO Auto-generated method stub
157 public @Nullable Uint16 getBetweenAttemptsTimeoutMillis() {
158 // TODO Auto-generated method stub
163 public @Nullable BigDecimal getSleepFactor() {
164 // TODO Auto-generated method stub
169 public @Nullable Uint32 getKeepaliveDelay() {
170 // TODO Auto-generated method stub
175 public @Nullable Uint16 getConcurrentRpcLimit() {
176 // TODO Auto-generated method stub
181 public @Nullable Uint16 getActorResponseWaitTime() {
182 // TODO Auto-generated method stub
187 public @Nullable OdlHelloMessageCapabilities getOdlHelloMessageCapabilities() {
188 // TODO Auto-generated method stub
193 public @Nullable ConnectionStatus getConnectionStatus() {
194 // TODO Auto-generated method stub
199 public @Nullable ClusteredConnectionStatus getClusteredConnectionStatus() {
200 // TODO Auto-generated method stub
205 public @Nullable String getConnectedMessage() {
206 // TODO Auto-generated method stub
211 public @Nullable AvailableCapabilities getAvailableCapabilities() {
212 // TODO Auto-generated method stub
217 public @Nullable UnavailableCapabilities getUnavailableCapabilities() {
218 // TODO Auto-generated method stub
223 public @Nullable PassThrough getPassThrough() {
224 // TODO Auto-generated method stub
229 public @Nullable String getSchemaCacheDirectory() {
230 // TODO Auto-generated method stub
235 public @Nullable YangLibrary getYangLibrary() {
236 // TODO Auto-generated method stub
241 public @Nullable IgnoreMissingSchemaSources getIgnoreMissingSchemaSources() {
242 // TODO Auto-generated method stub