aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-05 12:16:19 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-05 14:11:14 +0000
commit5b51c60562b6a42500d502bb13d3ebbc17920b0a (patch)
tree9b6a6c4f691df4d99349f350a64b05e9c5982b56 /appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java
parentd535447594e5812ed7e038f944741b0b38fe73b6 (diff)
Test coverage in netconf-oldconnector
Increased coverage from 0% to 92% for package Issue-ID: APPC-1388 Change-Id: I9f332f799f67937a40c09bdf724701ef80bbad89 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java')
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java12
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java55
2 files changed, 40 insertions, 27 deletions
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
index ce29451d1..70a202865 100644
--- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -119,11 +121,11 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService {
@Override
public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) {
- String queryString = "INSERT INTO "+ Constants.DEVICE_INTERFACE_LOG_TABLE_NAME+"("+
- Constants.SERVICE_INSTANCE_ID_FIELD_NAME+","+
- Constants.REQUEST_ID_FIELD_NAME+","+
- Constants.CREATION_DATE_FIELD_NAME+","+
- Constants.LOG_FIELD_NAME+") ";
+ String queryString = "INSERT INTO " + Constants.DEVICE_INTERFACE_LOG_TABLE_NAME + "(" +
+ Constants.SERVICE_INSTANCE_ID_FIELD_NAME + "," +
+ Constants.REQUEST_ID_FIELD_NAME + "," +
+ Constants.CREATION_DATE_FIELD_NAME + "," +
+ Constants.LOG_FIELD_NAME + ") ";
queryString += "values(?,?,?,?)";
ArrayList<String> argList = new ArrayList<>();
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
index 4e9ef913b..beb14e359 100644
--- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,59 +53,66 @@ public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRe
@Override
public void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException {
- logger.info("Configuring device "+deviceMountPointName+" with configuration "+configuration);
+ logger.info("Configuring device " + deviceMountPointName + " with configuration " + configuration);
- int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/json");
+ int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,
+ getModuleConfigurePath(deviceMountPointName, moduleName, nodeName), configuration, "application/json");
if (httpCode != HttpStatus.SC_OK) {
logger.error("Configuration request failed. throwing Exception !");
- throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ throw new APPCException("Error configuring node :" + nodeName + ", of Module :" + moduleName +
+ ", in device :" + deviceMountPointName);
}
}
@Override
public void connect(String deviceMountPointName, String payload) throws APPCException{
- logger.info("Connecting device "+deviceMountPointName);
+ logger.info("Connecting device " + deviceMountPointName);
- int httpCode = httpClient.postMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getConnectPath(),payload,"application/json");
+ int httpCode = httpClient.postMethod(Constants.PROTOCOL, Constants.CONTROLLER_IP, Constants.CONTROLLER_PORT,
+ getConnectPath(), payload, "application/json");
if(httpCode != HttpStatus.SC_NO_CONTENT){
- logger.error("Connect request failed with code "+httpCode+". throwing Exception !");
+ logger.error("Connect request failed with code " + httpCode + ". throwing Exception !");
throw new APPCException("Error connecting device :" + deviceMountPointName);
}
}
@Override
public boolean checkConnection(String deviceMountPointName) throws APPCException {
- logger.info("Checking device "+deviceMountPointName+" connectivity");
+ logger.info("Checking device " + deviceMountPointName + " connectivity");
- String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getCheckConnectivityPath(deviceMountPointName),"application/json");
+ String result = httpClient.getMethod(Constants.PROTOCOL, Constants.CONTROLLER_IP,
+ Constants.CONTROLLER_PORT, getCheckConnectivityPath(deviceMountPointName), "application/json");
return result != null;
}
@Override
public void disconnect(String deviceMountPointName) throws APPCException {
- logger.info("Disconnecting "+deviceMountPointName);
+ logger.info("Disconnecting " + deviceMountPointName);
- int httpCode = httpClient.deleteMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getDisconnectPath(deviceMountPointName),"application/json");
+ int httpCode = httpClient.deleteMethod(Constants.PROTOCOL, Constants.CONTROLLER_IP, Constants.CONTROLLER_PORT,
+ getDisconnectPath(deviceMountPointName), "application/json");
if(httpCode != HttpStatus.SC_OK){
- logger.error("Disconnection of device "+deviceMountPointName+" failed!");
- throw new APPCException("Disconnection of device "+deviceMountPointName+" failed!");
+ logger.error("Disconnection of device " + deviceMountPointName + " failed!");
+ throw new APPCException("Disconnection of device " + deviceMountPointName + " failed!");
}
}
@Override
public String getConfiguration(String deviceMountPointName, String moduleName, String nodeName) throws APPCException{
- logger.info("Getting configuration of device "+deviceMountPointName);
+ logger.info("Getting configuration of device " + deviceMountPointName);
- String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),"application/json");
+ String result = httpClient.getMethod(Constants.PROTOCOL, Constants.CONTROLLER_IP, Constants.CONTROLLER_PORT,
+ getModuleConfigurePath(deviceMountPointName, moduleName, nodeName), "application/json");
if (result == null) {
logger.error("Configuration request failed. throwing Exception !");
- throw new APPCException("Error getting configuration of node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ throw new APPCException("Error getting configuration of node :" + nodeName + ", of Module :" + moduleName +
+ ", in device :" + deviceMountPointName);
}
return result;
@@ -117,7 +126,7 @@ public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRe
throw new APPCException("Invalid connection details - null value");
}
this.connectionDetails = connectionDetails;
- this.connect(connectionDetails.getHost(),getPayload());
+ this.connect(connectionDetails.getHost(), getPayload());
}
@Override
@@ -133,7 +142,7 @@ public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRe
}
Properties props = connectionDetails.getAdditionalProperties();
- if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){
+ if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")) {
throw new APPCException("Invalid properties!");
}
@@ -141,11 +150,13 @@ public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRe
String nodeName = props.getProperty("node.name");
String deviceMountPointName = connectionDetails.getHost();
- int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/xml");
+ int httpCode = httpClient.putMethod(Constants.PROTOCOL, Constants.CONTROLLER_IP, Constants.CONTROLLER_PORT,
+ getModuleConfigurePath(deviceMountPointName, moduleName, nodeName), configuration, "application/xml");
if (httpCode != HttpStatus.SC_OK) {
logger.error("Configuration request failed. throwing Exception !");
- throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ throw new APPCException("Error configuring node :" + nodeName + ", of Module :" + moduleName +
+ ", in device :" + deviceMountPointName);
}
}
@@ -156,11 +167,12 @@ public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRe
}
Properties props = connectionDetails.getAdditionalProperties();
- if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){
+ if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")) {
throw new APPCException("Invalid properties!");
}
- return this.getConfiguration(connectionDetails.getHost(),props.getProperty("module.name"),props.getProperty("node.name"));
+ return this.getConfiguration(connectionDetails.getHost(), props.getProperty("module.name"),
+ props.getProperty("node.name"));
}
@Override
@@ -174,7 +186,6 @@ public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRe
//private methods
private String getModuleConfigurePath(String deviceMountPointName, String moduleName, String nodeName){
-
String deviceSpecificPath = deviceMountPointName + "/yang-ext:mount/" + moduleName + ":" + nodeName;
return Constants.CONFIGURE_PATH + deviceSpecificPath;