aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-08-18 14:43:18 +0530
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-08-18 14:43:35 +0530
commita81a05e53871903d43aab71221b8ef2479dc3d58 (patch)
treed22f43b0bd8b1ad9ecaca126caa2c6b1f9c5f3b0 /sdnr/wt/data-provider/provider
parent1c4ad2b1a689d309d456a6ada894d1e8b1971b3c (diff)
Improve code-coverage for data-provider
Improve code-coverage for data-provider Issue-ID: CCSDK-3424 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: I5a50707c8fcec6c816fe645693b665d33743559c Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/provider')
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java9
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/TestTree/test3.json180
2 files changed, 186 insertions, 3 deletions
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
index 41e94e3f6..ea3296acb 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
@@ -80,6 +80,8 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
+ private static final int ROOT_TREE_LEVEL = 0;
+
private HtDatabaseClient client;
private EsDataObjectReaderWriter2<EventlogEntity> eventRWEventLogDevicemanager;
private EsDataObjectReaderWriter2<InventoryEntity> eventRWEquipment;
@@ -306,20 +308,21 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
.setTreeLevel(Uint32.valueOf(0));;
for (Inventory item : list) {
repairedItem = new InventoryBuilder(item);
- // check missing tree-level
+ // check for bad node-id
if (!nodeId.equals(item.getNodeId())) {
failures.add(String.format("missing node-id for equipment(uuid=%s)", item.getUuid()));
repairedItem.setNodeId(nodeId);
failCounter++;
}
+ // check missing tree-level
if (item.getTreeLevel() == null) {
failures.add(String.format("missing tree-level for equipment(uuid=%s)", item.getUuid()));
- repairedItem.setTreeLevel(Uint32.valueOf(1));
+ repairedItem.setTreeLevel(Uint32.valueOf(ROOT_TREE_LEVEL));
failCounter++;
} else {
treeLevel = item.getTreeLevel().longValue();
- if (treeLevel > 0) {
+ if (treeLevel > ROOT_TREE_LEVEL) {
// check non root elem and missing parent
if (item.getParentUuid() == null) {
failures.add(String.format("Non root level element (uuid=%s) has to have a parent element",
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/TestTree/test3.json b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/test3.json
new file mode 100644
index 000000000..833815cd7
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/TestTree/test3.json
@@ -0,0 +1,180 @@
+[
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/MOD-1-15",
+"_score": 3.465736,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "4ROADM-C96/0/OPM",
+"parent-uuid": "10.20.4.12/SHELF-1",
+"tree-level": 2,
+"uuid": "10.20.4.12/MOD-1-15",
+"description": "ProductCode: null Mode: NORMAL",
+"date": "N/A",
+"serial": "n/a",
+"type-name": "ROADM",
+"id": "10.20.4.12/MOD-1-15"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/SHELF-1",
+"_score": 2.358155,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "FSP 3000R7",
+"parent-uuid": "ADVA-ENC-SDN-40990-rdm",
+"tree-level": 2,
+"uuid": "10.20.4.12/SHELF-1",
+"description": "Position: null State: InService",
+"date": "N/A",
+"serial": "FA71171552617",
+"type-name": "FSP 3000R7",
+"id": "10.20.4.12/SHELF-1"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/MOD-1-7",
+"_score": 2.358155,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "4ROADM-C96/0/OPM",
+"parent-uuid": "10.20.4.12/SHELF-1",
+"tree-level": 2,
+"uuid": "10.20.4.12/MOD-1-7",
+"description": "ProductCode: null Mode: NORMAL",
+"date": "N/A",
+"serial": "n/a",
+"type-name": "ROADM",
+"id": "10.20.4.12/MOD-1-7"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/ADVA-ENC-SDN-40990-rdm",
+"_score": 2.358155,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "",
+"parent-uuid": "unbound",
+"part-type-id": "device",
+"tree-level": 1,
+"uuid": "ADVA-ENC-SDN-40990-rdm",
+"description": "org-openroadm-device",
+"date": "",
+"type-name": "rdm",
+"id": "ADVA-ENC-SDN-40990-rdm"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/MOD-1-14",
+"_score": 2.1238933,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "EDFA-C-D20-VLGC-DM",
+"parent-uuid": "10.20.4.12/SHELF-1",
+"tree-level": 2,
+"uuid": "10.20.4.12/MOD-1-14",
+"description": "ProductCode: null Mode: NORMAL",
+"date": "N/A",
+"serial": "n/a",
+"type-name": "AMPLIFIER",
+"id": "10.20.4.12/MOD-1-14"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/MOD-1-13",
+"_score": 2.1238933,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "EDFA-C-D20-VLGC-DM",
+"parent-uuid": "10.20.4.12/SHELF-1",
+"tree-level": 2,
+"uuid": "10.20.4.12/MOD-1-13",
+"description": "ProductCode: null Mode: NORMAL",
+"date": "N/A",
+"serial": "n/a",
+"type-name": "AMPLIFIER",
+"id": "10.20.4.12/MOD-1-13"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/MOD-1-17",
+"_score": 2.1238933,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "EDFA-C-S20-GCB-DM",
+"parent-uuid": "10.20.4.12/SHELF-1",
+"tree-level": 2,
+"uuid": "10.20.4.12/MOD-1-17",
+"description": "ProductCode: null Mode: NORMAL",
+"date": "N/A",
+"serial": "n/a",
+"type-name": "AMPLIFIER",
+"id": "10.20.4.12/MOD-1-17"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/MOD-1-6",
+"_score": 2.1238933,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "EDFA-C-S20-GCB-DM",
+"parent-uuid": "10.20.4.12/SHELF-1",
+"tree-level": 2,
+"uuid": "10.20.4.12/MOD-1-6",
+"description": "ProductCode: null Mode: NORMAL",
+"date": "N/A",
+"serial": "n/a",
+"type-name": "AMPLIFIER",
+"id": "10.20.4.12/MOD-1-6"
+}
+}
+,
+{
+"_index": "inventoryequipment-v6",
+"_type": "_doc",
+"_id": "FSP3000-ROADM-2/10.20.4.12/MOD-1-11",
+"_score": 2.1238933,
+"_source": {
+"node-id": "FSP3000-ROADM-2",
+"manufacturer-identifier": "ADVA",
+"model-identifier": "4ROADM-C96/0/OPM",
+"parent-uuid": "10.20.4.12/SHELF-1",
+"tree-level": 2,
+"uuid": "10.20.4.12/MOD-1-11",
+"description": "ProductCode: null Mode: NORMAL",
+"date": "N/A",
+"serial": "n/a",
+"type-name": "ROADM",
+"id": "10.20.4.12/MOD-1-11"
+}
+}
+] \ No newline at end of file