summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider/src/test
diff options
context:
space:
mode:
authorMichael DÜrre <michael.duerre@highstreet-technologies.com>2022-03-10 10:39:16 +0100
committerDan Timoney <dtimoney@att.com>2022-03-23 15:08:48 -0400
commiteb2a7c97c0007b013bd1784ac17d57be02b63d03 (patch)
treeb0861438532727219216cfd426e21ae053abb31a /sdnr/wt/data-provider/provider/src/test
parent3c74361514bb920ed441d105f66ca978bd074ced (diff)
migrate sdnr features to phosphorus
fix mapper and switch to dom api Updated to use phosphorus version of parent poms Issue-ID: CCSDK-3566 Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com> Change-Id: I98c5bef9286622e0d66b53db687557d798cd53f5 Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/provider/src/test')
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java8
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java93
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java6
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java15
4 files changed, 107 insertions, 15 deletions
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
index d59a0784f..00e8075f9 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
@@ -379,7 +379,7 @@ public class TestCRUDforDatabase {
// ==PARTIAL UPDATE============================
System.out.println("Try partial update...");
- assertEquals(false, data.get(0).isIsRequired());
+ assertEquals(false, data.get(0).requireIsRequired());
updateInput = new UpdateNetworkElementConnectionInputBuilder().setId(dbId).setIsRequired(true).build();
try {
updateOutput = dbProvider.updateNetworkElementConnection(updateInput);
@@ -392,7 +392,7 @@ public class TestCRUDforDatabase {
readOperation = dbProvider.readNetworkElementConnectionList(readInput);
data = readOperation.getData();
- assertEquals(true, data.get(0).isIsRequired());
+ assertEquals(true, data.get(0).requireIsRequired());
assertEquals(url2, data.get(0).getHost());
assertEquals(port2, data.get(0).getPort().longValue());
@@ -463,7 +463,7 @@ public class TestCRUDforDatabase {
assertNotEquals(0, data.size());
assertNotNull(data);
assertEquals(nodeId, data.get(0).getNodeId());
- assertEquals(isActive, data.get(0).isActive());
+ assertEquals(isActive, data.get(0).requireActive());
// ==UPDATE============================
@@ -489,7 +489,7 @@ public class TestCRUDforDatabase {
assertNotNull(data);
assertEquals(nodeId2, data.get(0).getNodeId());
- assertEquals(isActive2, data.get(0).isActive());
+ assertEquals(isActive2, data.get(0).getActive());
// ==DELETE================================
System.out.println("Trying to delete...");
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java
new file mode 100644
index 000000000..50c231015
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java
@@ -0,0 +1,93 @@
+/*
+ * ============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.dataprovider.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
+
+public class TestMapper {
+
+ private static final YangToolsMapper MAPPER = new YangToolsMapper();
+
+ @Test
+ public void testYangGenEnumMapperDeser() {
+ NetworkElementConnection con = null;
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"O-RAN\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.ORAN, con.getDeviceType());
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"ORAN\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.ORAN, con.getDeviceType());
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"O-ROADM\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.OROADM, con.getDeviceType());
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"O-ROADM\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.OROADM, con.getDeviceType());
+ }
+
+ @Test
+ public void testYangGenEnumMapperSer() {
+ NetworkElementConnection con =
+ new NetworkElementConnectionBuilder().setDeviceType(NetworkElementDeviceType.ORAN).build();
+ String str = null;
+ try {
+ str = MAPPER.writeValueAsString(con);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals("O-RAN", new JSONObject(str).getString("device-type"));
+ con = new NetworkElementConnectionBuilder().setDeviceType(NetworkElementDeviceType.OROADM).build();
+ str = null;
+ try {
+ str = MAPPER.writeValueAsString(con);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals("O-ROADM", new JSONObject(str).getString("device-type"));
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java
index 1345d4edf..35ddaf2f3 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java
@@ -35,6 +35,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.DataProviderYangToolsMapper;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper2;
import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataTypeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.BIPErrorCounter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.OpticalPowerInputOSCMin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType;
@@ -78,7 +79,7 @@ public class TestYangGenSalMappingOpenRoadm extends Mockito {
String jsonString = mapper2.writeValueAsString(pmDataType);
out("Result json after mapping: " + jsonString);
- PmdataEntity generatepmdNode = mapper2.readValue(jsonString.getBytes(), PmdataEntity.class);
+ PmdataEntity generatepmdNode = mapper2.readValue(jsonString, PmdataEntity.class);
out("Original: " + pmDataType.toString());
out("Mapped : " + generatepmdNode.toString());
assertTrue("Can mapping not working", generatepmdNode.equals(pmDataType));
@@ -104,9 +105,10 @@ public class TestYangGenSalMappingOpenRoadm extends Mockito {
@Test
public void testOpenroadmPMString2() throws IOException, ClassNotFoundException {
out("Test: " + method());
+ PmDataTypeBuilder.getDefaultInstance("11298624220985537708");
String jsonString2 = getFileContent("pmdata2.json");
DataProviderYangToolsMapper mapper2 = new DataProviderYangToolsMapper();
- PmdataEntity generatepmdNode = mapper2.readValue(jsonString2.getBytes(), PmdataEntity.class);
+ PmdataEntity generatepmdNode = mapper2.readValue(jsonString2, PmdataEntity.class);
out(generatepmdNode.toString()); // Print it with specified indentation
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
index 18efde235..7d71571d4 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
@@ -154,20 +154,17 @@ public class MariaDBTestBase {
}
public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex) {
+ return createTable(dbService, cls, entity, autoIndex, true);
+ }
+ public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex,
+ boolean withControllerId) {
String createStatement = null;
try {
- createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex);
+ createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex,withControllerId);
} catch (UnableToMapClassException e) {
fail(e.getMessage());
}
System.out.println(createStatement);
- try {
- return dbService.write(createStatement);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
-
- }
- return false;
+ return dbService.createTable(createStatement);
}
}