diff options
author | 2021-04-19 12:46:16 +0200 | |
---|---|---|
committer | 2021-04-20 08:01:27 +0200 | |
commit | 05fe114a5969727c32cd9f1051cd7b9fde0344d5 (patch) | |
tree | 4cb505cd98ddb5b9c6f188f9febe93b07cf743db /sdnr/wt/devicemanager-oran/provider/src/test | |
parent | 6ae7e8a1bae83d407b22d8b066dd0bcca730e1bb (diff) |
Reorganization of devicemanager directory structure
Organized into core, onap and o-ran-sc directories
Issue-ID: CCSDK-3242
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I3c23710f990a2d96ba01104c97315fc8c6b1921b
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-oran/provider/src/test')
12 files changed, 0 insertions, 1535 deletions
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/ComponentHelper.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/ComponentHelper.java deleted file mode 100644 index 7b8380442..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/ComponentHelper.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.oran.test; - -import java.util.Arrays; -import java.util.List; -import java.util.Scanner; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import org.json.JSONArray; -import org.json.JSONObject; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Fan; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Port; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Sensor; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.AdminState; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.OperState; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.SensorStatus; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.SensorValue; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.SensorValueType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.ComponentBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.SensorData; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.SensorDataBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.State; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.component.StateBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; - -public class ComponentHelper { - - public static Component get(String name, String dateTimeString) { - DateAndTime dateTime = new DateAndTime(dateTimeString); - Uuid uuid = new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB"); - - ComponentBuilder componentBuilder = new ComponentBuilder(); - componentBuilder.setParent("Shelf").setName("Slot-0").setParentRelPos(0); - componentBuilder.setUuid(uuid); - componentBuilder.setContainsChild(Arrays.asList("Card-01A", "Card-01B")); - componentBuilder.setDescription("ORAN Network Element NO-456"); - componentBuilder.setXmlClass(TestHardwareClass.class); - componentBuilder.setMfgName("Nokia"); - componentBuilder.setMfgDate(dateTime); - return componentBuilder.build(); - } - - public static List<Component> getComponentList(String resourceName) { - try (Scanner scanner = new Scanner(ComponentHelper.class.getResourceAsStream(resourceName), "UTF-8")) { - String jsonString = scanner.useDelimiter("\\A").next(); - JSONObject jsonHardware = new JSONObject(jsonString).getJSONObject("hardware"); - JSONArray jsonComponentArray = jsonHardware.getJSONArray("component"); - return IntStream.range(0, jsonComponentArray.length()) - .mapToObj(idx -> ComponentHelper.get(jsonComponentArray.getJSONObject(idx))) - .collect(Collectors.toList()); - } - } - - public static Component get(JSONObject jsonComponent) { - ComponentBuilder componentBuilder = new ComponentBuilder(); - componentBuilder.setName(getString(jsonComponent, "name")); - componentBuilder.setParent(getString(jsonComponent, "parent")); - componentBuilder.setParentRelPos(getInteger(jsonComponent, "parent-rel-pos")); - componentBuilder.setAlias(getString(jsonComponent, "alias")); - componentBuilder.setXmlClass(getXmlClass(jsonComponent, "class")); - componentBuilder.setState(getState(jsonComponent, "state")); - componentBuilder.setDescription(getString(jsonComponent, "description")); - componentBuilder.setContainsChild(getStringArray(jsonComponent, "contains-child")); - componentBuilder.setSensorData(getSensorData(jsonComponent, "sensor-data")); - componentBuilder.setFirmwareRev(getString(jsonComponent, "firmware-rev")); - componentBuilder.setSerialNum(getString(jsonComponent, "serial-num")); - componentBuilder.setSoftwareRev(getString(jsonComponent, "software-rev")); - return componentBuilder.build(); - } - - // Private - - private static State getState(JSONObject jsonComponent, String key) { - if (jsonComponent.has(key)) { - JSONObject jsonState = jsonComponent.getJSONObject(key); - StateBuilder stateBuilder = new StateBuilder(); - stateBuilder.setOperState(getString(jsonState, "oper-state", value -> OperState.forName(value)).get()); - stateBuilder.setAdminState(getString(jsonState, "admin-state", value -> AdminState.forName(value)).get()); - return stateBuilder.build(); - } - return null; - } - - private static SensorData getSensorData(JSONObject jsonComponent, String key) { - if (jsonComponent.has(key)) { - JSONObject jsonSonsor = jsonComponent.getJSONObject(key); - SensorDataBuilder sensorBuilder = new SensorDataBuilder(); - sensorBuilder.setValueTimestamp(getString(jsonSonsor, "value-timestamp", value -> new DateAndTime(value))); - sensorBuilder.setValue(getInteger(jsonSonsor, "value", value -> new SensorValue(value))); - sensorBuilder - .setValueType(getString(jsonSonsor, "value-type", value -> SensorValueType.forName(value).get())); - sensorBuilder - .setOperStatus(getString(jsonSonsor, "oper-status", value -> SensorStatus.forName(value).get())); - return sensorBuilder.build(); - } - return null; - } - - // Get data types - private static Class<? extends HardwareClass> getXmlClass(JSONObject jsonComponent, String key) { - return getString(jsonComponent, key, value -> { - switch (value) { - case "iana-hardware:sensor": - return Sensor.class; - case "iana-hardware:port": - return Port.class; - case "iana-hardware:fan": - return Fan.class; - default: - return HardwareClass.class; - } - }); - } - - private static String getString(JSONObject jsonObject, String key) { - return getString(jsonObject, key, value -> value); - } - - private static Integer getInteger(JSONObject jsonObject, String key) { - return getInteger(jsonObject, key, value -> value); - } - - private interface ConvertString<T> { - T convert(String value); - } - - private static <T> T getString(JSONObject jsonObject, String key, ConvertString<T> convert) { - if (jsonObject.has(key)) { - String value = jsonObject.getString(key); - return convert.convert(value); - } - return null; - } - - private interface ConvertInteger<T> { - T convert(int value); - } - - private static <T> T getInteger(JSONObject jsonObject, String key, ConvertInteger<T> convert) { - if (jsonObject.has(key)) { - int value = jsonObject.getInt(key); - return convert.convert(value); - } - return null; - } - - private static List<String> getStringArray(JSONObject jsonComponent, String key) { - if (jsonComponent.has(key)) { - JSONArray stringArray = jsonComponent.getJSONArray(key); - return IntStream.range(0, stringArray.length()).mapToObj(idx -> stringArray.getString(idx)) - .collect(Collectors.toList()); - } - return null; - } - -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestAlarmNotif.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestAlarmNotif.java deleted file mode 100644 index 365b3a226..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestAlarmNotif.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.oran.test; - -import java.util.Map; -import org.eclipse.jdt.annotation.Nullable; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.AlarmNotif; -import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.alarm.AffectedObjects; -import org.opendaylight.yang.gen.v1.urn.o.ran.fm._1._0.rev190204.alarm.AffectedObjectsKey; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.common.Uint16; - -public class TestAlarmNotif implements AlarmNotif { - - private static final Uint16 FAULT_ID = Uint16.valueOf(123); - - @Override - public <A extends Augmentation<AlarmNotif>> @Nullable A augmentation(Class<A> augmentationType) { - return null; - } - - @Override - public @Nullable Uint16 getFaultId() { - return FAULT_ID; - } - - @Override - public @Nullable String getFaultSource() { - return "ORAN-RU-FH"; - } - - @Override - public @Nullable Map<AffectedObjectsKey, AffectedObjects> getAffectedObjects() { - return null; - } - - @Override - public @Nullable FaultSeverity getFaultSeverity() { - return FaultSeverity.CRITICAL; - } - - @Override - public @Nullable Boolean isIsCleared() { - return true; - } - - @Override - public @Nullable String getFaultText() { - return "CPRI Port Down"; - } - - @Override - public @Nullable DateAndTime getEventTime() { - return new DateAndTime("2021-03-23T18:19:42.326144Z"); - } - -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java deleted file mode 100644 index 7b05342c4..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============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.oran.test; - -import static org.mockito.Mockito.mock; -import java.io.IOException; -import org.junit.Before; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.DeviceManagerORanImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; - -public class TestDeviceManagerORanImpl { - DeviceManagerORanImpl devMgrOran; - - @Before - public void init() throws InterruptedException, IOException { - } - - // @Test - public void test() throws Exception { - devMgrOran = new DeviceManagerORanImpl(); - NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class); - - try { - devMgrOran.setNetconfNetworkElementService(netconfNetworkElementService); - devMgrOran.init(); - } catch (Exception e) { - throw e; - } - } - - //@After - public void cleanUp() throws Exception { - devMgrOran.close(); - } -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java deleted file mode 100644 index c8a000bde..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * ============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.oran.test; - -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; - -public interface TestHardwareClass extends HardwareClass { - -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java deleted file mode 100644 index dd5fa7fae..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * ============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.oran.test; - -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.time.Instant; -import java.util.Arrays; -import java.util.List; -import org.eclipse.jdt.annotation.NonNull; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanChangeNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; -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.netconf.config.change.Edit; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.EditBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; - -@RunWith(MockitoJUnitRunner.class) -public class TestORanChangeNotificationListener { - - private static final String NODEID = "node1"; - - @Mock - NetconfBindingAccessor netconfAccessor; - @Mock - DataProvider databaseService; - @Mock - VESCollectorService vesCollectorService; - @Mock - VESCollectorCfgService vesCfgService; - @Mock - NotificationProxyParser notifProxyParser; - @Mock - static NetconfConfigChange change; - - @Test - public void test() { - - when(vesCollectorService.getConfig()).thenReturn(vesCfgService); - when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - when(vesCfgService.isVESCollectorEnabled()).thenReturn(true); - - ORanChangeNotificationListener notifListener = - new ORanChangeNotificationListener(netconfAccessor, databaseService, vesCollectorService, notifProxyParser); - - Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() { - - @Override - public int compareTo(PathArgument arg0) { - return 0; - } - - @Override - public Class<? extends DataObject> getType() { - return DataObject.class; - } - }); - InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments); - NetconfConfigChange confChangeNotification = createNotification(EditOperationType.Create, target); - when(notifProxyParser.getTime(confChangeNotification)).thenReturn(Instant.now()); - notifListener.onNetconfConfigChange(confChangeNotification); - EventlogEntity event = new EventlogBuilder().setNodeId(NODEID) - .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build(); - verify(databaseService).writeEventLog(event); - - } - - /** - * @param type - * @return - */ - private static NetconfConfigChange createNotification(EditOperationType type, InstanceIdentifier<?> target) { - @SuppressWarnings("null") - final @NonNull List<Edit> edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build()); - when(change.nonnullEdit()).thenReturn(edits); - return change; - } -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java deleted file mode 100644 index b536460a0..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * ============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.oran.test; - -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanFaultNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; - -@RunWith(MockitoJUnitRunner.class) -public class TestORanFaultNotificationListener { - - @Mock - NetconfBindingAccessor bindingAccessor; - @Mock - DataProvider dataProvider; - @Mock - VESCollectorService vesCollectorService; - @Mock - VESCollectorCfgService vesCfgService; - - @Test - public void test() { - when(bindingAccessor.getNodeId()).thenReturn(new NodeId("nSky")); - when(vesCollectorService.getConfig()).thenReturn(vesCfgService); - when(vesCfgService.isVESCollectorEnabled()).thenReturn(true); - - ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener(bindingAccessor, dataProvider, vesCollectorService); - faultListener.onAlarmNotif(new TestAlarmNotif()); - verify(dataProvider).updateFaultCurrent(new FaultcurrentBuilder().setCounter(0) - .setNodeId("nSky") - .setId("123") - .setProblem("CPRI Port Down") - .setSeverity(SeverityType.Critical) - .setObjectId("ORAN-RU-FH") - .setTimestamp(new DateAndTime("2021-03-23T18:19:42.326144Z")) - .build()); - } -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java deleted file mode 100644 index 2ca59d916..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * ============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.oran.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.util.Optional; -import org.junit.BeforeClass; -import org.junit.Test; -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.oran.impl.ORanNetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -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.NetconfBindingAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; -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 TestORanNetworkElement { - - private static final QName OneCell = - QName.create("urn:onf:otcc:wireless:yang:radio-access:commscope-onecell", "2020-06-22", "onecell").intern(); - private static String NODEIDSTRING = "nSky"; - private static NodeId nodeId = new NodeId(NODEIDSTRING); - private static NodeId nNodeId = new NodeId("nSky"); - - private static NetconfAccessor accessor; - private static DeviceManagerServiceProvider serviceProvider; - private static Capabilities capabilities; - private static TransactionUtils transactionUtils; - private static NetconfBindingAccessor bindingCommunicator; - private static VESCollectorService vesCollectorService; - private static NotificationProxyParser notificationProxyParser; - private static VESCollectorCfgService vesCfgService; - - @BeforeClass - public static void init() throws InterruptedException, IOException { - capabilities = mock(Capabilities.class); - accessor = mock(NetconfAccessor.class); - serviceProvider = mock(DeviceManagerServiceProvider.class); - transactionUtils = mock(TransactionUtils.class); - bindingCommunicator = mock(NetconfBindingAccessor.class); - vesCollectorService = mock(VESCollectorService.class); - notificationProxyParser = mock(NotificationProxyParser.class); - vesCfgService = mock(VESCollectorCfgService.class); - - when(accessor.getCapabilites()).thenReturn(capabilities); - when(accessor.getNodeId()).thenReturn(nNodeId); - when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator)); - when(bindingCommunicator.getTransactionUtils()).thenReturn(transactionUtils); - when(bindingCommunicator.getNodeId()).thenReturn(nodeId); - when(vesCollectorService.getNotificationProxyParser()).thenReturn(notificationProxyParser); - - DataProvider dataProvider = mock(DataProvider.class); - when(serviceProvider.getDataProvider()).thenReturn(dataProvider); - when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService); - when(vesCollectorService.getConfig()).thenReturn(vesCfgService); - when(vesCfgService.isVESCollectorEnabled()).thenReturn(true); - - } - - @Test - public void test() { - - NodeId nodeId = new NodeId(NODEIDSTRING); - when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); - when(bindingCommunicator.getNodeId()).thenReturn(nodeId); - - Optional<NetworkElement> oRanNe; - when(capabilities.isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); - when(capabilities.isSupportingNamespace(OneCell)).thenReturn(false); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); - oRanNe = factory.create(accessor, serviceProvider); - assertTrue(factory.create(accessor, serviceProvider).isPresent()); - oRanNe.get().register(); - oRanNe.get().deregister(); - oRanNe.get().getAcessor(); - oRanNe.get().getDeviceType(); - assertEquals(oRanNe.get().getNodeId().getValue(), "nSky"); - } - - } diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java deleted file mode 100644 index 0e257e345..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ============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.oran.test; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.util.Optional; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory; -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.NetconfBindingAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; - -public class TestORanNetworkElementFactory { - - private static String NODEIDSTRING = "nSky"; - - private static NetconfBindingAccessor accessor; - private static DeviceManagerServiceProvider serviceProvider; - private static Capabilities capabilities; - - // @BeforeClass - public static void init() throws InterruptedException, IOException { - NetconfBindingAccessor bindingCommunicator = mock(NetconfBindingAccessor.class); - NodeId nodeId = new NodeId(NODEIDSTRING); - when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); - when(bindingCommunicator.getNodeId()).thenReturn(nodeId); - - capabilities = mock(Capabilities.class); - accessor = mock(NetconfBindingAccessor.class); - serviceProvider = mock(DeviceManagerServiceProvider.class); - - when(accessor.getCapabilites()).thenReturn(capabilities); - when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator)); - when(serviceProvider.getDataProvider()).thenReturn(null); - - - } - - //@Test - public void testCreateORANHWComponent() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); - assertTrue((factory.create(accessor, serviceProvider)).isPresent()); - } - - //@Test - public void testCreateNone() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); - assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); - } - - //@After - public void cleanUp() throws Exception { - - } -} - diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanRegistrationToVESpnfRegistration.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanRegistrationToVESpnfRegistration.java deleted file mode 100644 index 781d333fe..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanRegistrationToVESpnfRegistration.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.oran.test; - -import static org.mockito.Mockito.when; -import java.math.BigDecimal; -import org.eclipse.jdt.annotation.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanRegistrationToVESpnfRegistrationMapper; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.netconf.node.augmented.optional.fields.IgnoreMissingSchemaSources; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.NonModuleCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.OdlHelloMessageCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.YangModuleCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.ClusteredConnectionStatus; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.PassThrough; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials; -import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.schema.storage.YangLibrary; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.common.Uint16; -import org.opendaylight.yangtools.yang.common.Uint32; - -@RunWith(MockitoJUnitRunner.class) -public class TestORanRegistrationToVESpnfRegistration { - - @Mock - NetconfAccessor netconfAccessor; - @Mock - VESCollectorService vesCollectorService; - @Mock - VESCollectorCfgService vesCfgService; - - private final int SEQUENCE_NO = 10; - - @Test - public void test() { - String dateTimeString = "2020-02-05T12:30:45.283Z"; - String name = "Slot-0"; - - when(netconfAccessor.getNodeId()).thenReturn(new NodeId("nSky")); - when(netconfAccessor.getNetconfNode()).thenReturn(new TestNetconfNode()); - when(vesCollectorService.getConfig()).thenReturn(vesCfgService); - when(vesCfgService.getReportingEntityName()).thenReturn("SDN-R"); - Component testComponent = ComponentHelper.get(name, dateTimeString); - - ORanRegistrationToVESpnfRegistrationMapper mapper = new ORanRegistrationToVESpnfRegistrationMapper(netconfAccessor, vesCollectorService, testComponent); - mapper.mapCommonEventHeader(SEQUENCE_NO); - mapper.mapPNFRegistrationFields(); - } - - public class TestNetconfNode implements NetconfNode { - - @Override - public @Nullable Credentials getCredentials() { - return null; - } - - @Override - public @Nullable Host getHost() { - return new Host(new IpAddress(new Ipv4Address("10.10.10.10"))); - } - - @Override - public @Nullable PortNumber getPort() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Boolean isTcpOnly() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Protocol getProtocol() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Boolean isSchemaless() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable YangModuleCapabilities getYangModuleCapabilities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable NonModuleCapabilities getNonModuleCapabilities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Boolean isReconnectOnChangedSchema() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Uint32 getConnectionTimeoutMillis() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Uint32 getDefaultRequestTimeoutMillis() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Uint32 getMaxConnectionAttempts() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Uint16 getBetweenAttemptsTimeoutMillis() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable BigDecimal getSleepFactor() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Uint32 getKeepaliveDelay() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Uint16 getConcurrentRpcLimit() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Uint16 getActorResponseWaitTime() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable OdlHelloMessageCapabilities getOdlHelloMessageCapabilities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable ConnectionStatus getConnectionStatus() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable ClusteredConnectionStatus getClusteredConnectionStatus() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable String getConnectedMessage() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable AvailableCapabilities getAvailableCapabilities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable UnavailableCapabilities getUnavailableCapabilities() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable PassThrough getPassThrough() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable String getSchemaCacheDirectory() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable YangLibrary getYangLibrary() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable IgnoreMissingSchemaSources getIgnoreMissingSchemaSources() { - // TODO Auto-generated method stub - return null; - } - - } - -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java deleted file mode 100644 index 531b2f939..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * ============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.oran.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import java.io.IOException; -import java.util.List; -import java.util.Optional; -import java.util.function.IntConsumer; -import java.util.stream.IntStream; -import org.eclipse.jdt.annotation.Nullable; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanToInternalDataModel; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.common.Uint32; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestORanToInternalDataModel { - - private static final Logger LOG = LoggerFactory.getLogger(TestORanToInternalDataModel.class); - - NodeId nodeId = new NodeId("ORan-1000"); - - @Test - public void testInventory() { - String dateTimeString = "2020-02-05T12:30:45.283Z"; - String name = "Slot-0"; - - Component testComponent = ComponentHelper.get(name, dateTimeString); - Optional<Inventory> oInventory = ORanToInternalDataModel.getInternalEquipment(nodeId, testComponent, 0); - - assertTrue(oInventory.isPresent()); - Inventory inventory = oInventory.get(); - assertEquals(name, inventory.getUuid()); - assertEquals(dateTimeString, inventory.getDate()); - assertEquals(nodeId.getValue(), inventory.getNodeId()); - } - - @Test - public void testInventoryList() throws IOException, ClassNotFoundException { - List<Component> componentList = ComponentHelper.getComponentList("/Device-ietf-hardware-Output.json"); - List<Inventory> inventoryList = ORanToInternalDataModel.getInventoryList(nodeId, componentList); - //componentList.forEach(System.out::println); - assertEquals("All elements", 27, inventoryList.size()); - assertEquals("Fully parseable", componentList.size(), inventoryList.size()); - assertEquals("Treelevel always there", 0, - inventoryList.stream().filter(inventory -> inventory.getTreeLevel() == null).count()); - listAsTree(inventoryList); - } - - private void listAsTree(List<Inventory> inventoryList) { - //Walk through complete list and print parameters - IntConsumer action = level -> IntStream.range(0, inventoryList.size()) - .filter(idx -> inventoryList.get(idx).getTreeLevel().intValue() == level) - .forEach(idx2 -> printElements(idx2, level, inventoryList.get(idx2))); - //Walk trough 10 levels - IntStream.range(0, 10) - .forEach(action); - } - - private void printElements(int idx2, int level, Inventory inventory) { - System.out.println(level + ": " + inventory.getParentUuid() + " " - + inventory.getUuid()); - } - - @SuppressWarnings("unused") - private boolean compareLevel(int idx, List<Component> componentList, List<Inventory> inventoryList) { - @Nullable - Integer relPos = componentList.get(idx).getParentRelPos(); - @Nullable - Uint32 treeLevel = inventoryList.get(idx).getTreeLevel(); - LOG.warn("Treelevel relPos: {} treeLevel: {}", relPos, treeLevel); - if (relPos != null && treeLevel != null) { - return relPos == treeLevel.intValue(); - } - return false; - } -} diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/resources/Device-ietf-hardware-Output.json b/sdnr/wt/devicemanager-oran/provider/src/test/resources/Device-ietf-hardware-Output.json deleted file mode 100644 index b5728fe1e..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/resources/Device-ietf-hardware-Output.json +++ /dev/null @@ -1,442 +0,0 @@ -{ - "hardware": { - "component": [ - { - "name": "chassis-temperature-exhaust", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-temperature-exhaust", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 30, - "value-type": "celsius", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "chassis", - "parent-rel-pos": 0 - }, - { - "name": "slot0-logical0-rrh", - "state": { - "oper-state": "enabled", - "admin-state": "unlocked" - }, - "model-name": "FTLX1475D3BTL-E7", - "mfg-name": "FINISAR CORP.", - "alias": "Slot0-A-rrh", - "class": "iana-hardware:port", - "contains-child": [ - "slot0-logical0-rrh-temperature" - ], - "parent": "slot0-logical0", - "o-ran-hardware:o-ran-name": "slot0-logical0-rrh", - "serial-num": "AYR3GA9", - "parent-rel-pos": 1 - }, - { - "name": "slot2-logical2", - "state": { - "oper-state": "disabled", - "admin-state": "unlocked" - }, - "alias": "Slot3-B", - "class": "iana-hardware:module", - "parent": "slot2", - "description": "SLOT3-B", - "parent-rel-pos": 3 - }, - { - "name": "chassis-temperature-inlet", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-temperature-inlet", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 29, - "value-type": "celsius", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "chassis", - "parent-rel-pos": 1 - }, - { - "name": "chassis-fan2", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan2", - "class": "iana-hardware:fan", - "contains-child": [ - "chassis-fan2-speed" - ], - "parent": "chassis", - "parent-rel-pos": 4 - }, - { - "name": "slot0-logical0-bbu-temperature", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "Slot0-A-bbu-temperature", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 37, - "value-type": "celsius", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "slot0-logical0-bbu", - "parent-rel-pos": 0 - }, - { - "name": "chassis-fan3", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan3", - "class": "iana-hardware:fan", - "contains-child": [ - "chassis-fan3-speed" - ], - "parent": "chassis", - "parent-rel-pos": 5 - }, - { - "name": "chassis-fan0", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan0", - "class": "iana-hardware:fan", - "contains-child": [ - "chassis-fan0-speed" - ], - "parent": "chassis", - "parent-rel-pos": 2 - }, - { - "name": "slot0-logical1", - "state": { - "oper-state": "disabled", - "admin-state": "unlocked" - }, - "alias": "Slot0-B", - "class": "iana-hardware:module", - "parent": "slot0", - "description": "SLOT0-B", - "parent-rel-pos": 2 - }, - { - "name": "chassis-fan1", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan1", - "class": "iana-hardware:fan", - "contains-child": [ - "chassis-fan1-speed" - ], - "parent": "chassis", - "parent-rel-pos": 3 - }, - { - "name": "slot0-logical0", - "state": { - "oper-state": "enabled", - "admin-state": "unlocked" - }, - "alias": "Slot0-A", - "class": "iana-hardware:module", - "contains-child": [ - "slot0-logical0-rrh", - "slot0-logical0-bbu" - ], - "parent": "slot0", - "description": "SLOT0-AZ", - "parent-rel-pos": 1 - }, - { - "name": "slot0-logical2", - "state": { - "oper-state": "disabled", - "admin-state": "unlocked" - }, - "alias": "Slot0-C", - "class": "iana-hardware:module", - "parent": "slot0", - "description": "SLOT0-C", - "parent-rel-pos": 3 - }, - { - "name": "chassis-fan1-speed", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan1-speed", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 4100, - "value-type": "rpm", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "chassis-fan1", - "parent-rel-pos": 0 - }, - { - "name": "slot2-logical1", - "state": { - "oper-state": "disabled", - "admin-state": "unlocked" - }, - "alias": "Slot3-A", - "class": "iana-hardware:module", - "parent": "slot2", - "description": "SLOT3-A", - "parent-rel-pos": 2 - }, - { - "name": "slot2-logical0", - "state": { - "oper-state": "disabled", - "admin-state": "unlocked" - }, - "alias": "Slot2-C", - "class": "iana-hardware:module", - "parent": "slot2", - "description": "SLOT2-C", - "parent-rel-pos": 1 - }, - { - "name": "cpu-temperature", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "cpu-temperature", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 30, - "value-type": "celsius", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "cpu", - "parent-rel-pos": 0 - }, - { - "name": "chassis", - "state": { - "oper-state": "enabled", - "admin-state": "unlocked" - }, - "model-name": "ProteusCPRI Compact", - "mfg-name": "ISCO", - "alias": "chassis", - "class": "iana-hardware:chassis", - "contains-child": [ - "chassis-temperature-inlet", - "cpu", - "chassis-fan0", - "chassis-temperature-exhaust", - "slot0", - "slot2", - "chassis-fan3", - "chassis-fan2", - "chassis-fan1" - ], - "serial-num": "10283", - "description": "HighStreet-ONAP40", - "software-rev": "3.8.1 (2020-10-30 11:47:59)" - }, - { - "name": "slot0-logical0-bbu", - "state": { - "oper-state": "enabled", - "admin-state": "unlocked" - }, - "model-name": "FTLX1475D3BTL-E7", - "mfg-name": "FINISAR CORP.", - "alias": "Slot0-A-bbu", - "class": "iana-hardware:port", - "contains-child": [ - "slot0-logical0-bbu-temperature" - ], - "parent": "slot0-logical0", - "o-ran-hardware:o-ran-name": "slot0-logical0-bbu", - "serial-num": "AYR3GA2", - "parent-rel-pos": 0 - }, - { - "name": "slot2", - "state": { - "oper-state": "enabled", - "admin-state": "unlocked" - }, - "model-name": "385A-SFP-2P-40-FHL-JC3", - "alias": "slot2", - "class": "iana-hardware:module", - "contains-child": [ - "slot2-temperature", - "slot2-logical0", - "slot2-logical1", - "slot2-logical2" - ], - "parent": "chassis", - "firmware-rev": "12.00.42-S (0F7F1001)", - "serial-num": "7220718", - "parent-rel-pos": 9, - "software-rev": "0" - }, - { - "name": "chassis-fan0-speed", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan0-speed", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 4100, - "value-type": "rpm", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "chassis-fan0", - "parent-rel-pos": 0 - }, - { - "name": "slot0", - "state": { - "oper-state": "enabled", - "admin-state": "unlocked" - }, - "model-name": "385A-SFP-2P-40-FHL-JC3", - "alias": "slot0", - "class": "iana-hardware:module", - "contains-child": [ - "slot0-logical0", - "slot0-logical2", - "slot0-temperature", - "slot0-logical1" - ], - "parent": "chassis", - "firmware-rev": "12.00.42-S (0F7F1001)", - "serial-num": "7220530", - "parent-rel-pos": 7, - "software-rev": "0" - }, - { - "name": "slot0-temperature", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "slot0-temperature", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 51, - "value-type": "celsius", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "slot0", - "parent-rel-pos": 0 - }, - { - "name": "cpu", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "cpu", - "class": "iana-hardware:cpu", - "contains-child": [ - "cpu-temperature" - ], - "parent": "chassis", - "parent-rel-pos": 6 - }, - { - "name": "slot0-logical0-rrh-temperature", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "Slot0-A-rrh-temperature", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 35, - "value-type": "celsius", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "slot0-logical0-rrh", - "parent-rel-pos": 0 - }, - { - "name": "chassis-fan3-speed", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan3-speed", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 1000, - "value-type": "rpm", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "chassis-fan3", - "parent-rel-pos": 0 - }, - { - "name": "chassis-fan2-speed", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "chassis-fan2-speed", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 4100, - "value-type": "rpm", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "chassis-fan2", - "parent-rel-pos": 0 - }, - { - "name": "slot2-temperature", - "state": { - "oper-state": "enabled", - "admin-state": "locked" - }, - "alias": "slot2-temperature", - "sensor-data": { - "value-timestamp": "2021-02-18T12:11:03.5Z", - "value": 49, - "value-type": "celsius", - "oper-status": "ok" - }, - "class": "iana-hardware:sensor", - "parent": "slot2", - "parent-rel-pos": 0 - } - ] - } -}
\ No newline at end of file diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/resources/simplelogger.properties b/sdnr/wt/devicemanager-oran/provider/src/test/resources/simplelogger.properties deleted file mode 100644 index 9af26dc96..000000000 --- a/sdnr/wt/devicemanager-oran/provider/src/test/resources/simplelogger.properties +++ /dev/null @@ -1,61 +0,0 @@ -# -# ============LICENSE_START======================================================= -# ONAP : ccsdk features -# ================================================================================ -# Copyright (C) 2020 AT&T 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======================================================= -# -# - -# SLF4J's SimpleLogger configuration file -# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. - -# Default logging detail level for all instances of SimpleLogger. -# Must be one of ("trace", "debug", "info", "warn", or "error"). -# If not specified, defaults to "info". -org.slf4j.simpleLogger.defaultLogLevel=info - -# Logging detail level for a SimpleLogger instance named "xxx.yyy.zzz". -# Must be one of ("trace", "debug", "info", "warn", or "error"). -# If not specified, the default logging detail level is used. -# org.slf4j.simpleLogger.log.xxx.yyy=debug -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager=info -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.test=debug -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.database=debug -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice=info -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources=info -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container=info - -# Set to true if you want the current date and time to be included in output messages. -# Default is false, and will output the number of milliseconds elapsed since startup. -#org.slf4j.simpleLogger.showDateTime=false - -# The date and time format to be used in the output messages. -# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. -# If the format is not specified or is invalid, the default format is used. -# The default format is yyyy-MM-dd HH:mm:ss:SSS Z. -#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z - -# Set to true if you want to output the current thread name. -# Defaults to true. -#org.slf4j.simpleLogger.showThreadName=true - -# Set to true if you want the Logger instance name to be included in output messages. -# Defaults to true. -#org.slf4j.simpleLogger.showLogName=true - -# Set to true if you want the last component of the name to be included in output messages. -# Defaults to false. -#org.slf4j.simpleLogger.showShortLogName=false |