diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2020-02-14 12:30:46 +0100 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2020-02-14 15:44:43 +0000 |
commit | 53f1c13a96a6ee7a12b7bc3642e6a63d54cd07f3 (patch) | |
tree | 1fdc19db345ad7660c2400b839947fb5b4917ada /sdnr/wt/devicemanager-onf | |
parent | 1c924ae13ed9a0fc9b6afd4d16b8becdf8d0b44c (diff) |
Add Unit test cases
Add Unit tests to provide Code coverage for compliance
Issue-ID: SDNC-1073
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: Ic35016d270cc32c6f42e665cafc3b7ea6407ea15
Diffstat (limited to 'sdnr/wt/devicemanager-onf')
18 files changed, 1991 insertions, 733 deletions
diff --git a/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang b/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang index 11a3e83ef..2a943658b 100644 --- a/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang +++ b/sdnr/wt/devicemanager-onf/model/src/main/yang/devicemanager-onf.yang @@ -1,15 +1,37 @@ module devicemanager-onf { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-onf"; - prefix "devicemanager-onf"; - description - "DeviceManager Open Network Foundation Api Module"; + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-onf"; + prefix devicemanager-onf; + + organization + "highstreet technologies GmbH"; + contact + "Web: <https://highstreet-technologies.com> + O-RAN: <https://wiki.o-ran-sc.org/display/OAM/Operations+and+Maintenance"; + + description + "DeviceManager Open Network Foundation Api Module + + Copyright 2019 highstreet technologies GmbH Intellectual Property. + All rights reserved. - revision "2019-12-09" { - description - "Initial revision"; - } + 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."; + + revision 2019-12-09 { + description + "Initial revision"; + reference + "https://jira.onap.org/browse/SDNC-877"; + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/pom.xml b/sdnr/wt/devicemanager-onf/provider/pom.xml index 031c20416..63db46fe1 100644 --- a/sdnr/wt/devicemanager-onf/provider/pom.xml +++ b/sdnr/wt/devicemanager-onf/provider/pom.xml @@ -107,28 +107,6 @@ </excludes> </configuration> </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>generateDTOs</id> - <phase>generate-sources</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>bash</executable> - <arguments> - <argument>${basedir}/../../data-provider/provider/src/main/resources/es-init.sh</argument> - <argument>initfile</argument> - <argument>-f</argument> - <argument>${project.build.directory}/EsInit.script</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> </project> diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java deleted file mode 100644 index 056247941..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java +++ /dev/null @@ -1,88 +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.devicemanager.onf.impl; - -import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DeviceManagerOnfImpl implements AutoCloseable { - - private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOnfImpl.class); - private static final String APPLICATION_NAME = "DeviceManagerOnf"; - private static final String CONFIGURATIONFILE = "etc/devicemanager-onf.properties"; - - - private NetconfNetworkElementService netconfNetworkElementService; - - private HtDatabaseClient htDatabaseClient; - private Boolean devicemanagerInitializationOk = false; - private FactoryRegistration<ONFCoreNetworkElementFactory> resORan; - - // Blueprint begin - public DeviceManagerOnfImpl() { - LOG.info("Creating provider for {}", APPLICATION_NAME); - resORan = null; - } - - public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { - this.netconfNetworkElementService = netconfNetworkElementService; - } - - public void init() throws Exception { - - LOG.info("Session Initiated start {}", APPLICATION_NAME); - - resORan = netconfNetworkElementService.registerNetworkElementFactory(new ONFCoreNetworkElementFactory()); - - - netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); - this.devicemanagerInitializationOk = true; - - LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk); - } - // Blueprint end - - @Override - public void close() throws Exception { - LOG.info("closing ..."); - close(htDatabaseClient); - close(resORan); - LOG.info("closing done"); - } - - /** - * Used to close all Services, that should support AutoCloseable Pattern - * - * @param toClose - * @throws Exception - */ - private void close(AutoCloseable... toCloseList) { - for (AutoCloseable element : toCloseList) { - if (element != null) { - try { - element.close(); - } catch (Exception e) { - LOG.warn("Fail during close: ", e); - } - } - } - } -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java deleted file mode 100644 index e2371de74..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElement.java +++ /dev/null @@ -1,168 +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.devicemanager.onf.impl; - -import java.util.List; -import java.util.Optional; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.mdsal.binding.api.MountPoint; -import org.opendaylight.mdsal.binding.api.NotificationService; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfirmedCommit; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; -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.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - */ -public class OnfNetworkElement implements NetworkElement { - - private static final Logger log = LoggerFactory.getLogger(OnfNetworkElement.class); - - private final NetconfAccessor netconfAccessor; - - private final DataProvider databaseService; - - private @NonNull final OnfListener ranListener; - - private ListenerRegistration<NotificationListener> ranListenerRegistrationResult; - - OnfNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { - log.info("Create {}",OnfNetworkElement.class.getSimpleName()); - this.netconfAccessor = netconfAccess; - this.databaseService = databaseService; - - this.ranListenerRegistrationResult = null; - this.ranListener = new OnfListener(); - - } - - public void initialReadFromNetworkElement() { - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.ORAN; - } - - private void doRegisterNotificationListener(MountPoint mountPoint) { - log.info("Begin register listener for Mountpoint {}", mountPoint.getIdentifier().toString()); - final Optional<NotificationService> optionalNotificationService = mountPoint - .getService(NotificationService.class); - final NotificationService notificationService = optionalNotificationService.get(); - // notificationService.registerNotificationListener(microwaveEventListener); - ranListenerRegistrationResult = notificationService.registerNotificationListener(ranListener); - log.info("End registration listener for Mountpoint {} Listener: {} Result: {}", - mountPoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistrationResult); - } - - private class OnfListener implements IetfNetconfNotificationsListener { - - @Override - public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) { - log.info("onNetconfConfirmedCommit ", notification); - } - - @Override - public void onNetconfSessionStart(NetconfSessionStart notification) { - log.info("onNetconfSessionStart ", notification); - } - - @Override - public void onNetconfSessionEnd(NetconfSessionEnd notification) { - log.info("onNetconfSessionEnd ", notification); - } - - @Override - public void onNetconfCapabilityChange(NetconfCapabilityChange notification) { - log.info("onNetconfCapabilityChange ", notification); - } - - @Override - public void onNetconfConfigChange(NetconfConfigChange notification) { - log.info("onNetconfConfigChange (1) {}", notification); - StringBuffer sb = new StringBuffer(); - List<Edit> editList = notification.nonnullEdit(); - for (Edit edit : editList) { - if (sb.length() > 0) { - sb.append(", "); - } - sb.append(edit); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - - InstanceIdentifier<?> target = edit.getTarget(); - if (target != null) { - eventlogBuilder.setObjectId(target.toString()); - log.info("TARGET: {} {} {}", target.getClass(), target.getTargetType()); - for (PathArgument pa : target.getPathArguments()) { - log.info("PathArgument {}", pa); - } - } - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()); - eventlogBuilder.setNewValue(String.valueOf(edit.getOperation())); - databaseService.writeEventLog(eventlogBuilder.build()); - } - log.info("onNetconfConfigChange (2) {}", sb); - } - } - - @Override - public void register() { - } - - @Override - public void deregister() { - } - - - @Override - public NodeId getNodeId() { - return netconfAccessor.getNodeId(); - } - - @Override - public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { - return Optional.empty(); - } - - @Override - public void warmstart() { - } - - @Override - public Optional<NetconfAccessor> getAcessor() { - return Optional.of(netconfAccessor); - } - -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java deleted file mode 100644 index e086c0ca0..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/OnfNetworkElementFactory.java +++ /dev/null @@ -1,43 +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.devicemanager.onf.impl; - -import java.util.Optional; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class OnfNetworkElementFactory implements NetworkElementFactory { - - private static final Logger log = LoggerFactory.getLogger(OnfNetworkElementFactory.class); - - @Override - public Optional<NetworkElement> create(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) { - if (acessor.getCapabilites().isSupportingNamespace(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement.QNAME)) { - log.info("Create device {} ",OnfNetworkElement.class.getName()); - return Optional.of(new OnfNetworkElement(acessor, serviceProvider.getDataProvider())); - } else { - return Optional.empty(); - } - } -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java index 0eb1982b2..80df3ce5f 100644 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java +++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java @@ -90,20 +90,21 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor /** * @return the capabilities */ - public Capabilities getCapabilities() { - return capabilities; - } + /* + * public Capabilities getCapabilities() { return capabilities; } + */ /** * Update devicetype and let all other field empty * @param deviceType that should be updated * @return NetworkElementConnectionEntity with related parameter */ - public static NetworkElementConnectionEntity getNetworkConnectionDeviceTpe(NetworkElementDeviceType deviceType) { - NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); - eb.setDeviceType(deviceType); - return eb.build(); - } + /* + * public static NetworkElementConnectionEntity + * getNetworkConnectionDeviceTpe(NetworkElementDeviceType deviceType) { + * NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); + * eb.setDeviceType(deviceType); return eb.build(); } + */ /** * Provide device specific data @@ -111,39 +112,38 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor * @param nNode data * @return NetworkElementConnectionEntity specific information */ - public static NetworkElementConnectionEntity getNetworkConnection(String nodeId, @Nonnull NetconfNode nNode) { - - NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); - // -- basics - eb.setId(nodeId).setNodeId(nodeId).setDeviceType(NetworkElementDeviceType.Unknown).setIsRequired(false); - - // -- connection status - ConnectionLogStatus status = InternalConnectionStatus.statusFromNodeStatus(nNode.getConnectionStatus()); - eb.setStatus(status); - - // -- capabilites - Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode); - Capabilities unAvailableCapabilities = Capabilities.getUnavailableCapabilities(nNode); - eb.setCoreModelCapability(availableCapabilities.getRevisionForNamespace(NetworkElement.QNAME)); - - NodeDetailsBuilder nodeDetails = new NodeDetailsBuilder() - .setAvailableCapabilities(availableCapabilities.getCapabilities()) - .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); - eb.setNodeDetails(nodeDetails.build()); - // -- host information - Host host = nNode.getHost(); - PortNumber portNumber = nNode.getPort(); - if (host != null && portNumber != null) { - eb.setHost(host.stringValue()).setPort(portNumber.getValue().longValue()); - } - - Credentials credentials = nNode.getCredentials(); - if (credentials instanceof LoginPassword) { - LoginPassword loginPassword = (LoginPassword) credentials; - eb.setUsername(loginPassword.getUsername()).setPassword(loginPassword.getPassword()); - } - return eb.build(); - } + /* + * public static NetworkElementConnectionEntity getNetworkConnection(String + * nodeId, @Nonnull NetconfNode nNode) { + * + * NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder(); + * // -- basics + * eb.setId(nodeId).setNodeId(nodeId).setDeviceType(NetworkElementDeviceType. + * Unknown).setIsRequired(false); + * + * // -- connection status ConnectionLogStatus status = + * InternalConnectionStatus.statusFromNodeStatus(nNode.getConnectionStatus()); + * eb.setStatus(status); + * + * // -- capabilites Capabilities availableCapabilities = + * Capabilities.getAvailableCapabilities(nNode); Capabilities + * unAvailableCapabilities = Capabilities.getUnavailableCapabilities(nNode); + * eb.setCoreModelCapability(availableCapabilities.getRevisionForNamespace( + * NetworkElement.QNAME)); + * + * NodeDetailsBuilder nodeDetails = new NodeDetailsBuilder() + * .setAvailableCapabilities(availableCapabilities.getCapabilities()) + * .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); + * eb.setNodeDetails(nodeDetails.build()); // -- host information Host host = + * nNode.getHost(); PortNumber portNumber = nNode.getPort(); if (host != null && + * portNumber != null) { + * eb.setHost(host.stringValue()).setPort(portNumber.getValue().longValue()); } + * + * Credentials credentials = nNode.getCredentials(); if (credentials instanceof + * LoginPassword) { LoginPassword loginPassword = (LoginPassword) credentials; + * eb.setUsername(loginPassword.getUsername()).setPassword(loginPassword. + * getPassword()); } return eb.build(); } + */ @Override diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java deleted file mode 100644 index ef2636ca8..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementEmpty.java +++ /dev/null @@ -1,170 +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.devicemanager.onf.ne; - -import java.util.Optional; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ONFCoreNetworkElementRepresentation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.PerformanceDataLtp; -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.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author herbert - * - */ -public class ONFCoreNetworkElementEmpty implements ONFCoreNetworkElementRepresentation { - - private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementEmpty.class); - - private final NetconfAccessor acessor; - private final String mountPointNodeName; - private final NodeId nodeId; - - public ONFCoreNetworkElementEmpty(NetconfAccessor acessor, String mountPointNodeName) { - LOG.info("Create {}",ONFCoreNetworkElementEmpty.class.getSimpleName()); - this.mountPointNodeName = mountPointNodeName; - this.nodeId = new NodeId(mountPointNodeName); - this.acessor = acessor; - } - - @Override - public void initialReadFromNetworkElement() { - } - - @Override - public String getMountPointNodeName() { - return mountPointNodeName; - } - - @Override - public String getMountpoint() { - return mountPointNodeName; - } - - @Override - public void resetPMIterator() { - } - - @Override - public boolean hasNext() { - return false; - } - - @Override - public void next() { - } - - @Override - public String pmStatusToString() { - return this.getClass().getSimpleName(); - } - - @Override - public int removeAllCurrentProblemsOfNode() { - return 0; - } - - @Override - public void doRegisterEventListener(MountPoint mointPoint) { - //Do nothing - } - - @Override - public void prepareCheck() { - //Do nothing here - } - - @Override - public boolean checkIfConnectionToMediatorIsOk() { - return true; - } - - @Override - public boolean checkIfConnectionToNeIsOk() { - return true; - } - - @Override - public InventoryInformationDcae getInventoryInformation() { - return InventoryInformationDcae.getDefault(); - } - - @Override - public InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) { - return InventoryInformationDcae.getDefault(); - } - - @Override - public DataBroker getDataBroker() { - return null; - } - - @Override - public Optional<NetworkElement> getOptionalNetworkElement() { - return Optional.empty(); - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.Unknown; - } - - @Override - public void register() { - } - - @Override - public void deregister() { - } - - @Override - public NodeId getNodeId() { - return nodeId; - } - - @Override - public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { - return Optional.empty(); - } - - @Override - public void warmstart() { - } - - @Override - public Optional<NetconfAccessor> getAcessor() { - return Optional.of(acessor); - } - - @Override - public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() { - return Optional.empty(); - } - -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java deleted file mode 100644 index 4326fec32..000000000 --- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/InternalSeverity.java +++ /dev/null @@ -1,191 +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========================================================================== - ******************************************************************************/ -/** - * @author herbert - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util; - - -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType; - -public enum InternalSeverity { - - NonAlarmed, - Warning, - Minor, - Major, - Critical; - - public boolean isNoAlarmIndication() { - return this == NonAlarmed; - } - - public String getValueAsString() { - return this.name(); - } - - @Override - public String toString() { - return this.name(); - } - - public String toNetconfString() { - switch (this) { - case NonAlarmed: - return "non-alarmed"; - case Warning: - return "warning"; - case Minor: - return "minor"; - case Major: - return "major"; - case Critical: - return "critical"; - } - return "not-specified"; - } - - public SeverityType toDataProviderSeverityType() { - switch (this) { - case NonAlarmed: - return SeverityType.NonAlarmed; - case Warning: - return SeverityType.Warning; - case Minor: - return SeverityType.Minor; - case Major: - return SeverityType.Major; - case Critical: - return SeverityType.Critical; - } - return null; //Should never happen - } - - /** - * convert ONF 1.2 Severity - * @param severity as input - * @return String with related output - */ - public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType severity ) { - switch( severity ) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - return null; - } - - /** - * convert ONF 1.2.1.1 Severity - * @param severity as input - * @return String with related output - */ - public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType severity ) { - switch( severity ) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - return null; - } - - /** - * convert ONF 1.2.1.1p Severity - * @param severity as input - * @return String with related output - */ - public static InternalSeverity valueOf(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType severity ) { - switch( severity ) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - return null; - } - - - - /** - * convert a text string into Severity - * @param severityString with textes: warning minor major critical non[-]alarmed. (Capital or lowercase) - * @return related enum. Unknown oe illegal are converted to NonAlarm - */ - public static @Nullable InternalSeverity valueOfString(String severityString) { - - switch( severityString.toLowerCase().trim() ) { - case "warning": - return InternalSeverity.Warning; - case "minor": - return InternalSeverity.Minor; - case "major": - return InternalSeverity.Major; - case "critical": - return InternalSeverity.Critical; - } - return InternalSeverity.NonAlarmed; - - } - - /** - * Convert to InternalSeverity - * @param severity to be converted - * @return InternalSeverity, null converted to NonAlarmed - */ - public static InternalSeverity valueOf(@org.eclipse.jdt.annotation.Nullable SeverityType severity) { - if (severity != null) { - switch (severity) { - case NonAlarmed: - return InternalSeverity.NonAlarmed; - case Warning: - return InternalSeverity.Warning; - case Minor: - return InternalSeverity.Minor; - case Major: - return InternalSeverity.Major; - case Critical: - return InternalSeverity.Critical; - } - } - return InternalSeverity.NonAlarmed; - } - - -} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java new file mode 100644 index 000000000..f55ef4afc --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ifpac.equipment.test; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.WrapperPTPModelRev170208; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.ExtendedEquipment; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.Equipment; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.EquipmentBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ContainedHolderBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThing; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.equipment.g.ManufacturedThingBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentInstance; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentInstanceBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.EquipmentTypeBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerProperties; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.manufactured.thing.g.ManufacturerPropertiesBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestExtendedEquipment { + + UniversalId id = new UniversalId("1234567"); + private static final String NODEID = "NODE1"; + private static final Logger LOG = LoggerFactory.getLogger(TestExtendedEquipment.class); + + @Test + public void test() { + final @NonNull List<ContainedHolder> holder = Arrays.asList(new ContainedHolderBuilder().setUuid(id).build()); + final @NonNull ManufacturerProperties manufacturerProps = new ManufacturerPropertiesBuilder() + .setManufacturerIdentifier("NOK") + .setManufacturerName("Nokia").build(); + + final @NonNull EquipmentType eqptType = new EquipmentTypeBuilder() + .setDescription("5G RAN Equipment") + .setModelIdentifier("NOK-987-1T") + .setPartTypeIdentifier("ABCDEF") + .setTypeName("12345") + .setVersion("5T9V4567") + .build(); + + final @NonNull EquipmentInstance eqptInstance = new EquipmentInstanceBuilder() + .setAssetInstanceIdentifier("NOK1234-ABCD") + .setManufactureDate("2020-02-11") + .setSerialNumber("123456ABCD").build(); + + final @NonNull ManufacturedThing manufacturedThing = new ManufacturedThingBuilder() + .setManufacturerProperties(manufacturerProps) + .setEquipmentType(eqptType) + .setEquipmentInstance(eqptInstance).build(); + + Equipment equipment = new EquipmentBuilder().setUuid(id).setContainedHolder(holder).setManufacturedThing(manufacturedThing).build(); + + ExtendedEquipment extEqpt = new ExtendedEquipment(NODEID, "1234567890", equipment, "/var/opt", 3); + assertEquals(extEqpt.getNodeId(), NODEID); + assertEquals(extEqpt.getParentUuid(), "1234567890"); + assertEquals(extEqpt.getEquipment(), equipment); + LOG.info(extEqpt.toString()); + extEqpt.getCreateInventoryInput(); + + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java new file mode 100644 index 000000000..c5107364f --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ifpac.equipment.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.NetworkElementCoreData; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.ONFCoreNetworkElement12Equipment; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.equipment.WrapperEquipmentPacRev170402; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +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.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.EquipmentPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.equipment.pac.EquipmentCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestONFCoreNetworkElement12Equipment { + + NetconfAccessor netconfAccessor; + Capabilities capabilities; + NetworkElementCoreData coreData; + FaultData faultData; + TransactionUtils transactionUtils; + EquipmentCurrentProblems eqptCurrProblems; + DataBroker dataBroker; + UniversalId uid = new UniversalId("ID"); + + + @Before + public void init() throws Exception { + netconfAccessor = mock(NetconfAccessor.class); + capabilities = mock(Capabilities.class); + coreData = mock(NetworkElementCoreData.class); + faultData = mock(FaultData.class); + eqptCurrProblems = mock(EquipmentCurrentProblems.class); + dataBroker = mock(DataBroker.class); + transactionUtils = mock(TransactionUtils.class); + + final Class<EquipmentPac> clazzPac = EquipmentPac.class; + final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class; + final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class; + Constructor<EquipmentPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); + InstanceIdentifier<EquipmentCurrentProblems> interfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + when(netconfAccessor.getCapabilites()).thenReturn(capabilities); + when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils); + when(netconfAccessor.getDataBroker()).thenReturn(dataBroker); + when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, interfaceIID)).thenReturn(eqptCurrProblems); + } + + @Test + public void test() { + when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(true); + ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities); + onfCoreEqpt.addProblemsofNode(faultData); + onfCoreEqpt.addProblemsofNodeObject("ABCD"); + onfCoreEqpt.getInventoryInformation(Arrays.asList("TESTINV")); + onfCoreEqpt.getEquipmentAll(); + onfCoreEqpt.getEquipmentData(); + onfCoreEqpt.getEquipmentPac(); + onfCoreEqpt.readNetworkElementEquipment(); + + } + + @Test + public void test1() { + when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(false); + ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java new file mode 100644 index 000000000..5d14e7d26 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.Helper; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; + +public class TestHelper { + + @Test + public void test() { + + assertEquals(GranularityPeriodType.Period24Hours, Helper.nnGetGranularityPeriodType(GranularityPeriodType.Period24Hours)); + assertEquals(GranularityPeriodType.Unknown, Helper.nnGetGranularityPeriodType(null)); + + assertEquals(new LayerProtocolName("TDM"), Helper.nnGetLayerProtocolName(LayerProtocolName.getDefaultInstance("TDM"))); + assertEquals(new LayerProtocolName("default"), Helper.nnGetLayerProtocolName(null)); + + assertEquals("TEST", Helper.nnGetString("TEST")); + assertEquals("", Helper.nnGetString(null)); + + assertEquals(new UniversalId("ABC"), Helper.nnGetUniversalId(new UniversalId("ABC"))); + assertEquals(new UniversalId("Default"), Helper.nnGetUniversalId(null)); + + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java new file mode 100644 index 000000000..7ac2944dd --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java @@ -0,0 +1,293 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +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.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.LpBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.ethernet.container.pac.EthernetContainerHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.tdm.container.pac.TdmContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.mw.air._interface.pac.AirInterfaceConfigurationBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.current.problems.g.CurrentProblemList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.current.problems.g.CurrentProblemListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.performance.g.CurrentPerformanceDataList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestWrapperMicrowaveModelRev170324 { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + FaultData resultList; + UniversalId uid; + TransactionUtils transactionUtils; + DataBroker dataBroker; + + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID; + @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems; + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID; + @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems; + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + resultList = mock(FaultData.class); + transactionUtils = mock(TransactionUtils.class); + dataBroker = mock(DataBroker.class); + + uid = new UniversalId("ABCD"); + + mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceCurrentProblems.class).build(); + List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build()); + airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + + mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerCurrentProblems.class).build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList + = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemListBuilder() + .setProblemName("Link Negotiation Unsuccessful") + .setProblemSeverity(SeverityType.Critical) + .setSequenceNumber(1) + .setTimeStamp(null) + .build()); + ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build(); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + when(accessor.getDataBroker()).thenReturn(dataBroker); + + } + + @Test + public void testMWAirInterfaceWithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAirInterface, null, uid, resultList); + } + + @Test + public void testMWAirInterfaceWithoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAirInterface, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.EthernetContainer12, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithNoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.EthernetContainer12, null, uid, resultList); + } + + @Test + public void testTdmContainer12WithProblems() throws Exception { + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMContainer, null, uid, resultList); + + } + + @Test + public void testMwHybridMwStructureWithProblems() throws Exception { + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwHybridMwStructurePac.class, uid, resultList); + + } + + @Test + public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception { + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwAirInterfaceDiversityPac.class, uid, resultList); + + } + + @Test + public void testMwPureEthernetStructureWithProblems() throws Exception { + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwPureEthernetStructurePac.class, uid, resultList); + + } + + @Test + public void testNullStructureWithProblems() throws Exception { + + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, null, uid, resultList); + + } + + @Test + public void testgetLtpHistoricalPerformanceData() { + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceConfiguration.class).build(); + + AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration); + + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + PerformanceData performanceData = new PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build()); + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder() + .setHistoricalPerformanceDataList(airHistPMList).build(); + when(accessor.getTransactionUtils().readData( + accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData); + + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build()); + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID)) + .thenReturn(ethContainerHistoricalPerformanceData); + + Lp lp = new LpBuilder().setUuid(uid).build(); + WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider); + + wrapperMicrowaveModelRev170324.getLtpHistoricalPerformanceData(ONFLayerProtocolName.Ethernet, lp); + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java new file mode 100644 index 000000000..ee0f727dd --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java @@ -0,0 +1,290 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.LpBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceConfigurationBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.air._interface.pac.AirInterfaceCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.ethernet.container.pac.EthernetContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.mw.tdm.container.pac.TdmContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.current.problems.g.CurrentProblemList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.current.problems.g.CurrentProblemListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.performance.g.CurrentPerformanceDataList; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestWrapperMicrowaveModelRev180907 { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + FaultData resultList; + UniversalId uid; + TransactionUtils transactionUtils; + + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID; + @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems; + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID; + @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems; + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + resultList = mock(FaultData.class); + transactionUtils = mock(TransactionUtils.class); + + uid = new UniversalId("ABCD"); + + mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceCurrentProblems.class).build(); + List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build()); + airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + + mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerCurrentProblems.class).build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList + = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemListBuilder() + .setProblemName("Link Negotiation Unsuccessful") + .setProblemSeverity(SeverityType.Critical) + .setSequenceNumber(1) + .setTimeStamp(null) + .build()); + ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build(); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + + } + + @Test + public void testMWAirInterfaceWithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAirInterface, null, uid, resultList); + } + + @Test + public void testMWAirInterfaceWithoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAirInterface, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.EthernetContainer12, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithNoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.EthernetContainer12, null, uid, resultList); + } + + @Test + public void testTdmContainer12WithProblems() throws Exception { + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMContainer, null, uid, resultList); + + } + + @Test + public void testMwHybridMwStructureWithProblems() throws Exception { + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwHybridMwStructurePac.class, uid, resultList); + + } + + @Test + public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception { + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwAirInterfaceDiversityPac.class, uid, resultList); + + } + + @Test + public void testMwPureEthernetStructureWithProblems() throws Exception { + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwPureEthernetStructurePac.class, uid, resultList); + + } + + @Test + public void testNullStructureWithProblems() throws Exception { + + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, null, uid, resultList); + + } + + @Test + public void testgetLtpHistoricalPerformanceData() { + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceConfiguration.class).build(); + + AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration); + + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + PerformanceData performanceData = new PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build()); + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder() + .setHistoricalPerformanceDataList(airHistPMList).build(); + when(accessor.getTransactionUtils().readData( + accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData); + + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build()); + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID)) + .thenReturn(ethContainerHistoricalPerformanceData); + + Lp lp = new LpBuilder().setUuid(uid).build();; + WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider); + + wrapperMicrowaveModelRev180907.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAirInterface, lp); + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java new file mode 100644 index 000000000..074948ba1 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java @@ -0,0 +1,295 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ifpac.microwave.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.util.ONFLayerProtocolName; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; +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.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.LpBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performance.type.g.PerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfaceDiversityPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwAirInterfacePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwEthernetContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwHybridMwStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwPureEthernetStructurePacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPac; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.MwTdmContainerPacKey; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.SeverityType; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.diversity.pac.AirInterfaceDiversityCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfiguration; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceConfigurationBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformances; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.air._interface.pac.AirInterfaceHistoricalPerformancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.ethernet.container.pac.EthernetContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.hybrid.mw.structure.pac.HybridMwStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.pure.ethernet.structure.pac.PureEthernetStructureCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblems; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.mw.tdm.container.pac.TdmContainerCurrentProblemsBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.current.problems.g.CurrentProblemList; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.current.problems.g.CurrentProblemListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.performance.g.CurrentPerformanceDataList; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +@SuppressWarnings("deprecation") +public class TestWrapperMicrowaveModelRev181010 { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + FaultData resultList; + UniversalId uid; + TransactionUtils transactionUtils; + DataBroker dataBroker; + + InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID; + @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems; + + InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID; + @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems; + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + resultList = mock(FaultData.class); + transactionUtils = mock(TransactionUtils.class); + dataBroker = mock(DataBroker.class); + + uid = new UniversalId("ABCD"); + + mwAirInterfaceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceCurrentProblems.class).build(); + List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build()); + airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + + mwEthInterfaceIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerCurrentProblems.class).build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList + = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemListBuilder() + .setProblemName("Link Negotiation Unsuccessful") + .setProblemSeverity(SeverityType.Critical) + .setSequenceNumber(1) + .setTimeStamp(null) + .build()); + ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build(); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + when(accessor.getDataBroker()).thenReturn(dataBroker); + + } + + @Test + public void testMWAirInterfaceWithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAirInterface, null, uid, resultList); + } + + @Test + public void testMWAirInterfaceWithoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAirInterface, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.EthernetContainer12, null, uid, resultList); + } + + @Test + public void testEthernetContainer12WithNoProblems() { + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.EthernetContainer12, null, uid, resultList); + } + + @Test + public void testTdmContainer12WithProblems() throws Exception { + final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class; + final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class; + final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class; + + Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new() + InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMContainer, null, uid, resultList); + + } + + @Test + public void testMwHybridMwStructureWithProblems() throws Exception { + final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class; + final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class; + + InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwHybridMwStructurePac.class, uid, resultList); + + } + + @Test + public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception { + final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class; + final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class; + + InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwAirInterfaceDiversityPac.class, uid, resultList); + + } + + @Test + public void testMwPureEthernetStructureWithProblems() throws Exception { + final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class; + final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class; + + InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier + .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build(); + + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemList> + currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build()); + PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems); + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, MwPureEthernetStructurePac.class, uid, resultList); + + } + + @Test + public void testNullStructureWithProblems() throws Exception { + + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.Structure, null, uid, resultList); + + } + + @Test + public void testgetLtpHistoricalPerformanceData() { + InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceConfiguration.class).build(); + + AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().build(); + when(accessor.getTransactionUtils().readData(dataBroker, + LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration); + + InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier + .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid)) + .child(AirInterfaceHistoricalPerformances.class).build(); + + PerformanceData performanceData = new PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build()); + AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder() + .setHistoricalPerformanceDataList(airHistPMList).build(); + when(accessor.getTransactionUtils().readData( + accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData); + + InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier + .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid)) + .child(EthernetContainerHistoricalPerformances.class).build(); + + org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceDataBuilder().build(); + List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList = + Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build()); + EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID)) + .thenReturn(ethContainerHistoricalPerformanceData); + + Lp lp = new LpBuilder().setUuid(uid).build(); + WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider); + + wrapperMicrowaveModelRev181010.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAirInterface, lp); + } +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java new file mode 100644 index 000000000..55db66a1a --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ifpac.test; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.WrapperPTPModelRev170208; +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.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.InstanceListKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsList; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.instance.list.PortDsListBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentity; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ptp.dataset.rev170208.port.ds.entry.PortIdentityBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; + +import static org.mockito.Mockito.*; + +public class TestWrapperPTPModelRev170208 { + + private static final String NODEID = "node1"; + NetconfAccessor netconfAccessor; + Capabilities capabilities; + TransactionUtils transactionUtils; + DataBroker dataBroker; + + @Before + public void init() { + netconfAccessor = mock(NetconfAccessor.class); + capabilities = mock(Capabilities.class); + dataBroker = mock(DataBroker.class); + transactionUtils = mock(TransactionUtils.class); + + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + when(netconfAccessor.getCapabilites()).thenReturn(capabilities); + when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils); + when(netconfAccessor.getDataBroker()).thenReturn(dataBroker); + + PortIdentity portIdentity = new PortIdentityBuilder().setPortNumber(10).build(); + List<PortDsList> portDsList = Arrays.asList(new PortDsListBuilder().setPortIdentity(portIdentity).build()); + InstanceList instanceList = new InstanceListBuilder().setPortDsList(portDsList).build(); + InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier + .builder(InstanceList.class, new InstanceListKey(1)).build(); + when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + PTPINSTANCES_IID)).thenReturn(instanceList); + } + + @Test + public void test() { + + when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false); + + WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor); + } + + @Test + public void test1() { + + when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true); + + WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor); + } + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java new file mode 100644 index 000000000..6713a7821 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.impl.test; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev170324; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev180907; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.WrapperMicrowaveModelRev181010; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.ONFCoreNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.QName; + +public class TestONFCoreNetworkElementFactory { + + static NetconfAccessor accessor; + static DeviceManagerServiceProvider serviceProvider; + static Capabilities capabilities; + static DataBroker dataBroker; + static NodeId nNodeId; + QName qCapability; + + @BeforeClass + public static void init() throws InterruptedException, IOException { + capabilities = mock(Capabilities.class); + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + dataBroker = mock(DataBroker.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + //when(serviceProvider.getDataProvider()).thenReturn(dataProvider); + nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + + + } + + @Test + public void testCreateMWModelRev170324() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false); + ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + } + + @Test + public void testCreateMWModelRev180907() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false); + ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(); + assertTrue(factory.create(accessor, serviceProvider).isPresent()); + } + + @Test + public void testCreateMWModelRev181010() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(true); + ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(); + assertTrue(factory.create(accessor, serviceProvider).isPresent()); + } + + @After + public void cleanUp() throws Exception { + + } +} + diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java new file mode 100644 index 000000000..a09d6fcfc --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java @@ -0,0 +1,295 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ne.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; + +import org.eclipse.jdt.annotation.Nullable; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestONFCoreNetworkElement12Basic { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + Capabilities capabilities; + TransactionUtils transactionUtils; + NetworkElement optionalNe; + OnfMicrowaveModel onfMicrowaveModel; + FaultService faultService; + EquipmentService equipmentService; + + protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier + .builder(NetworkElement.class).build(); + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + capabilities = mock(Capabilities.class); + transactionUtils = mock(TransactionUtils.class); + onfMicrowaveModel = mock(OnfMicrowaveModel.class); + faultService = mock(FaultService.class); + equipmentService = mock(EquipmentService.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getEquipmentService()).thenReturn(equipmentService); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + + } + + @Test + public void test() { + optionalNe = new NetworkElement() { + + @Override + public @Nullable List<Label> getLabel() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Extension> getExtension() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable OperationalState getOperationalState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable LifecycleState getLifecycleState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeState getAdministrativeState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeControl getAdministrativeControl() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Name> getName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable UniversalId getUuid() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<LocalId> getLocalId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public <E$$ extends Augmentation<NetworkElement>> @Nullable E$$ augmentation(Class<E$$> augmentationType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Ltp> getLtp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Fd> getFd() { + // TODO Auto-generated method stub + return null; + } + }; + + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID)).thenReturn(optionalNe); + + ONFCoreNetworkElement12Basic onfCoreNetworkElement12Basic = new ONFCoreNetworkElement12Basic(accessor, + serviceProvider); + onfCoreNetworkElement12Basic.prepareCheck(); + + /* + * EventlogEntity eventlogEntity = new EventlogEntity() { + * + * @Override public @Nullable String getId() { // TODO Auto-generated method + * stub return null; } + * + * @Override public @Nullable DateAndTime getTimestamp() { // TODO + * Auto-generated method stub return null; } + * + * @Override public @Nullable String getObjectId() { // TODO Auto-generated + * method stub return "ABCD"; } + * + * @Override public @Nullable String getNodeId() { // TODO Auto-generated method + * stub return null; } + * + * @Override public @Nullable Integer getCounter() { // TODO Auto-generated + * method stub return null; } + * + * @Override public @Nullable SourceType getSourceType() { // TODO + * Auto-generated method stub return null; } + * + * @Override public @Nullable String getNewValue() { // TODO Auto-generated + * method stub return null; } + * + * @Override public @Nullable String getAttributeName() { // TODO Auto-generated + * method stub return + * "/network-element/extension[value-name=\"top-level-equipment\"]/value"; // + * "/equipment-pac/equipment-current-problems"; } + * + * @Override public Class<? extends DataContainer> getImplementedInterface() { + * // TODO Auto-generated method stub return null; } }; + * + * onfCoreNetworkElement12Basic.notificationActor(eventlogEntity); + */ + + } + + + @Test + public void test1() + { + when (accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null); + + ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = + new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, + onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck(); + + EventlogEntity eventlogEntity = new EventlogEntity() { + + @Override + public @Nullable String getId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable DateAndTime getTimestamp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getObjectId() { + // TODO Auto-generated method stub + return "ABCD"; + } + + @Override + public @Nullable String getNodeId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Integer getCounter() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable SourceType getSourceType() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getNewValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getAttributeName() { + // TODO Auto-generated method stub + return "/equipment-pac/equipment-current-problems"; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + }; + + onfCoreNetworkElement12MW.notificationActor(eventlogEntity); + } + + +} diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java new file mode 100644 index 000000000..63b31b717 --- /dev/null +++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java @@ -0,0 +1,319 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 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.devicemanager.onf.ne.test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Optional; + +import org.eclipse.jdt.annotation.Nullable; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ifpac.microwave.OnfMicrowaveModel; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Basic; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne.ONFCoreNetworkElement12Microwave; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeControl; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.AdministrativeState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LifecycleState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.OperationalState; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.global._class.g.LocalId; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.label.g.Label; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.name.g.Name; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Fd; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.network.element.Ltp; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.Augmentation; +import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestONFCoreNetworkElement12Microwave { + + NetconfAccessor accessor; + DeviceManagerServiceProvider serviceProvider; + Capabilities capabilities; + TransactionUtils transactionUtils; + NetworkElement optionalNe; + OnfMicrowaveModel onfMicrowaveModel; + FaultService faultService; + EquipmentService equipmentService; + + protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier + .builder(NetworkElement.class).build(); + + @Before + public void init() { + accessor = mock(NetconfAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + capabilities = mock(Capabilities.class); + transactionUtils = mock(TransactionUtils.class); + onfMicrowaveModel = mock(OnfMicrowaveModel.class); + faultService = mock(FaultService.class); + equipmentService = mock(EquipmentService.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getEquipmentService()).thenReturn(equipmentService); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME)).thenReturn(true); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + + } + + @Test + public void test() { + optionalNe = new NetworkElement() { + + @Override + public @Nullable List<Label> getLabel() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Extension> getExtension() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable OperationalState getOperationalState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable LifecycleState getLifecycleState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeState getAdministrativeState() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable AdministrativeControl getAdministrativeControl() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Name> getName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable UniversalId getUuid() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<LocalId> getLocalId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public <E$$ extends Augmentation<NetworkElement>> @Nullable E$$ augmentation(Class<E$$> augmentationType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Ltp> getLtp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable List<Fd> getFd() { + // TODO Auto-generated method stub + return null; + } + }; + + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + NETWORKELEMENT_IID)).thenReturn(optionalNe); + + ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = new ONFCoreNetworkElement12Microwave(accessor, + serviceProvider, onfMicrowaveModel); + onfCoreNetworkElement12MW.prepareCheck(); + + EventlogEntity eventlogEntity = new EventlogEntity() { + + @Override + public @Nullable String getId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable DateAndTime getTimestamp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getObjectId() { + // TODO Auto-generated method stub + return "ABCD"; + } + + @Override + public @Nullable String getNodeId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Integer getCounter() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable SourceType getSourceType() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getNewValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getAttributeName() { + // TODO Auto-generated method stub + return "/network-element/extension[value-name=\"top-level-equipment\"]/value"; // "/equipment-pac/equipment-current-problems"; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + }; + + onfCoreNetworkElement12MW.notificationActor(eventlogEntity); + + } + + + @Test + public void test1() + { + when (accessor.getTransactionUtils().readData(accessor.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null); + + ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = + new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, + onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck(); + + EventlogEntity eventlogEntity = new EventlogEntity() { + + @Override + public @Nullable String getId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable DateAndTime getTimestamp() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getObjectId() { + // TODO Auto-generated method stub + return "ABCD"; + } + + @Override + public @Nullable String getNodeId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Integer getCounter() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable SourceType getSourceType() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getNewValue() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable String getAttributeName() { + // TODO Auto-generated method stub + return "/equipment-pac/equipment-current-problems"; + } + + @Override + public Class<? extends DataContainer> getImplementedInterface() { + // TODO Auto-generated method stub + return null; + } + }; + + onfCoreNetworkElement12MW.notificationActor(eventlogEntity); + } + + +} |