From 7e6d57e2c6dcf22567b7ef130d2a3c3a6866fe5f Mon Sep 17 00:00:00 2001 From: "lalena.aria" Date: Tue, 24 Jul 2018 09:28:47 -0400 Subject: Adding junits for refactored UEB Listener Changes made: Added null check in SdncBaseModel.java Cleaned up in SdncVFCModel.java Added tests in SdncARModelTest.java, SdncNodeModelTest and SdncVFCModelTest Added files SdncGroupModelTest, SdncServiceModelTest and SdncVFModelTest Change-Id: If0261c94d67a61b0b19db51cbbbff7ae32912d06 Issue-ID: CCSDK-360 Signed-off-by: lalena.aria --- .../sli/northbound/uebclient/SdncBaseModel.java | 28 ++++++++++++---------- .../sli/northbound/uebclient/SdncVFCModel.java | 14 ----------- 2 files changed, 16 insertions(+), 26 deletions(-) (limited to 'ueb-listener/src/main') diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java index fd5a29637..7f0e9398f 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java @@ -887,13 +887,15 @@ public class SdncBaseModel { try { int rowCount = 0; CachedRowSet data = jdbcDataSource.getData("SELECT * from " + tableName + " where " + keyName + " = " + keyValue + ";", null, ""); - while(data.next()) { + if (data != null) { + while(data.next()) { rowCount ++; - } - if (rowCount != 0) { - LOG.debug("cleanUpExistingToscaData from: " + tableName + " for " + keyValue); - jdbcDataSource.writeData("DELETE from " + tableName + " where " + keyName + " = " + keyValue + ";", null, null); - } + } + if (rowCount != 0) { + LOG.debug("cleanUpExistingToscaData from: " + tableName + " for " + keyValue); + jdbcDataSource.writeData("DELETE from " + tableName + " where " + keyName + " = " + keyValue + ";", null, null); + } + } } catch (SQLException e) { LOG.error("Could not clean up existing " + tableName + " for " + keyValue, e); @@ -907,13 +909,15 @@ public class SdncBaseModel { try { int rowCount = 0; CachedRowSet data = jdbcDataSource.getData("SELECT * from " + tableName + " where " + key1Name + " = " + key1Value + " AND " + key2Name + " = " + key2Value + ";", null, ""); - while(data.next()) { + if (data != null) { + while(data.next()) { rowCount ++; - } - if (rowCount != 0) { - LOG.debug("cleanUpExistingToscaData from : " + tableName + " for " + key1Value + " and " + key2Value); - jdbcDataSource.writeData("DELETE from " + tableName + " where " + key1Name + " = " + key1Value + " AND " + key2Name + " = " + key2Value + ";", null, null); - } + } + if (rowCount != 0) { + LOG.debug("cleanUpExistingToscaData from : " + tableName + " for " + key1Value + " and " + key2Value); + jdbcDataSource.writeData("DELETE from " + tableName + " where " + key1Name + " = " + key1Value + " AND " + key2Name + " = " + key2Value + ";", null, null); + } + } } catch (SQLException e) { LOG.error("Could not clean up existing " + tableName + " for " + key1Value + " and " + key2Value, e); diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java index 35639b366..5977e2888 100644 --- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java +++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java @@ -260,20 +260,6 @@ public class SdncVFCModel extends SdncBaseModel { return subnetRoleFound; } - private Map getIpPropMapWithMatchingSubnetRole (ArrayList> ipPropParamsList, String subnetRole) { - - Map ipPropMapMatch = new HashMap(); - - if (subnetRole != null) { - for (Map ipPropMap : ipPropParamsList) { - if (nullCheck(ipPropMap.get("subnet_role")) == subnetRole) { - return ipPropMap; - } - } - } - return ipPropMapMatch; - } - private void addRequiredParameters (Map mappingParams) { // Add parameters which can not be null if they have not already been added - network_role, ipv4_count, ipv6_count -- cgit 1.2.3-korg