aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-common/pom.xml8
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java27
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java21
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java3
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java3
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java8
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java7
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java7
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java11
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java12
-rw-r--r--mso-api-handlers/mso-requests-db/pom.xml16
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java283
-rw-r--r--mso-api-handlers/pom.xml4
17 files changed, 359 insertions, 85 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml
index eaab61c756..8eab5d6a47 100644
--- a/mso-api-handlers/mso-api-handler-common/pom.xml
+++ b/mso-api-handlers/mso-api-handler-common/pom.xml
@@ -3,13 +3,13 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-api-handler-common</artifactId>
<name>ECOMP MSO API Handler common</name>
@@ -73,13 +73,13 @@
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-catalog-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-requests-db</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java
index c8889beb33..b9c0725766 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java
@@ -36,6 +36,7 @@ import java.io.IOException;
public class CamundaClient extends RequestClient{
private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
+ private static final String CAMUNDA_URL_MESAGE = "Camunda url is: ";
public CamundaClient() {
super(CommonConstants.CAMUNDA);
@@ -47,13 +48,13 @@ public class CamundaClient extends RequestClient{
String requestTimeout, String schemaVersion, String serviceInstanceId, String action)
throws ClientProtocolException, IOException{
HttpPost post = new HttpPost(url);
- msoLogger.debug("Camunda url is: "+ url);
+ msoLogger.debug(CAMUNDA_URL_MESAGE + url);
String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion);
StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
- String encryptedCredentials = null;
+ String encryptedCredentials;
if(props!=null){
encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null);
if(encryptedCredentials != null){
@@ -65,22 +66,18 @@ public class CamundaClient extends RequestClient{
}
post.setEntity(input);
- HttpResponse response = client.execute(post);
-
- return response;
+ return client.execute(post);
}
@Override
- public HttpResponse post(String jsonReq)
- throws ClientProtocolException, IOException{
+ public HttpResponse post(String jsonReq) throws ClientProtocolException, IOException{
HttpPost post = new HttpPost(url);
- msoLogger.debug("Camunda url is: "+ url);
- //String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion);
+ msoLogger.debug(CAMUNDA_URL_MESAGE + url);
StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
- String encryptedCredentials = null;
+ String encryptedCredentials;
if(props!=null){
encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null);
if(encryptedCredentials != null){
@@ -92,9 +89,8 @@ public class CamundaClient extends RequestClient{
}
post.setEntity(input);
- HttpResponse response = client.execute(post);
- return response;
+ return client.execute(post);
}
@Override
@@ -105,7 +101,7 @@ public class CamundaClient extends RequestClient{
String requestDetails)
throws ClientProtocolException, IOException{
HttpPost post = new HttpPost(url);
- msoLogger.debug("Camunda url is: "+ url);
+ msoLogger.debug(CAMUNDA_URL_MESAGE + url);
String jsonReq = wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction,
serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId,
serviceType, vnfType, vfModuleType, networkType, requestDetails);
@@ -113,7 +109,7 @@ public class CamundaClient extends RequestClient{
StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
- String encryptedCredentials = null;
+ String encryptedCredentials;
if(props!=null){
encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null);
if(encryptedCredentials != null){
@@ -125,9 +121,8 @@ public class CamundaClient extends RequestClient{
}
post.setEntity(input);
- HttpResponse response = client.execute(post);
- return response;
+ return client.execute(post);
}
@Override
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java
index b4e7b7e068..64193cf6c4 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java
@@ -20,19 +20,14 @@
package org.openecomp.mso.apihandler.common;
-import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
import javax.xml.bind.DatatypeConverter;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
import java.io.IOException;
public class CamundaTaskClient extends RequestClient{
@@ -63,9 +58,7 @@ public class CamundaTaskClient extends RequestClient{
}
post.setEntity(input);
- HttpResponse response = client.execute(post);
-
- return response;
+ return client.execute(post);
}
@Override
@@ -88,8 +81,7 @@ public class CamundaTaskClient extends RequestClient{
}
@Override
- public HttpResponse get()
- throws ClientProtocolException, IOException{
+ public HttpResponse get() throws ClientProtocolException, IOException{
HttpGet get = new HttpGet(url);
msoLogger.debug("Camunda Task url is: "+ url);
String encryptedCredentials;
@@ -103,12 +95,7 @@ public class CamundaTaskClient extends RequestClient{
}
}
- HttpResponse getResponse = client.execute(get);
-
- return getResponse;
-}
-
-
-
+ return client.execute(get);
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java
index 72f72c2939..2cafef3253 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java
@@ -22,6 +22,9 @@ package org.openecomp.mso.apihandler.common;
public final class ErrorNumbers {
+ private ErrorNumbers() {
+ }
+
public static final String REQUEST_FAILED_SCHEMA_VALIDATION = "1000";
public static final String RECIPE_DOES_NOT_EXIST = "1010";
public static final String VFMODULE_TYPE_DOES_NOT_EXIST = "1011";
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java
index 42d77f5f00..b39b5347ee 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java
@@ -37,9 +37,6 @@ public class LSInputImpl implements LSInput {
protected String fEncoding;
protected boolean fCertifiedText;
- public LSInputImpl () {
- }
-
@Override
public InputStream getByteStream () {
return fByteStream;
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java
index 1324e12fbc..addf4e11a5 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java
@@ -22,7 +22,6 @@ package org.openecomp.mso.apihandler.common;
import java.io.IOException;
import java.security.GeneralSecurityException;
-import java.util.Properties;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
@@ -83,16 +82,11 @@ public abstract class RequestClient {
protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) {
try {
- String result = CryptoUtils.decrypt(prop, encryptionKey);
- return result;
+ return CryptoUtils.decrypt(prop, encryptionKey);
}
catch (GeneralSecurityException e) {
msoLogger.debug("Security exception", e);
}
return defaultValue;
}
-
-
-
-
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java
index 773c5b0a96..8f919861dc 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java
@@ -21,14 +21,15 @@
package org.openecomp.mso.apihandler.common;
-import java.util.Properties;
-
import org.apache.http.impl.client.DefaultHttpClient;
import org.openecomp.mso.properties.MsoJavaProperties;
public class RequestClientFactory {
-
+
+ private RequestClientFactory() {
+ }
+
//based on URI, returns BPEL, CamundaTask or Camunda client
public static RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
RequestClient retClient;
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java
index 6722a930ae..4e7cf4cddd 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java
@@ -41,6 +41,7 @@ public class ResponseHandler {
private HttpResponse httpResponse;
private int type;
private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
+ private static final String RESPONSE_BODY_MSG = "response body is: ";
public ResponseHandler(HttpResponse httpResponse, int type) {
this.httpResponse = httpResponse;
@@ -84,7 +85,7 @@ public class ResponseHandler {
if(response!=null){
responseBody = response.getResponse();
}
- msoLogger.debug("response body is: " + responseBody);
+ msoLogger.debug(RESPONSE_BODY_MSG + responseBody);
if(status!=HttpStatus.SC_ACCEPTED){
@@ -99,7 +100,7 @@ public class ResponseHandler {
try {
if (bpelEntity!=null) {
responseBody = EntityUtils.toString(bpelEntity);
- msoLogger.debug("response body is: " + responseBody);
+ msoLogger.debug(RESPONSE_BODY_MSG + responseBody);
}
if(status!=HttpStatus.SC_ACCEPTED){
@@ -118,7 +119,7 @@ public class ResponseHandler {
try {
if (camundataskEntity!=null) {
responseBody = EntityUtils.toString(camundataskEntity);
- msoLogger.debug("response body is: " + responseBody);
+ msoLogger.debug(RESPONSE_BODY_MSG + responseBody);
}
if(status!=HttpStatus.SC_NO_CONTENT && status != HttpStatus.SC_ACCEPTED){
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java
index bf2088ed45..73bf020c21 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java
@@ -31,17 +31,18 @@ public class ValidationException extends Exception {
**/
private static final long serialVersionUID = 1L;
- private static final String validationFailMessage = "No valid $ELEMENT is specified";
- private static final String invalidElementMessage = "$ELEMENT is not valid in the $VERSION version";
+ private static final String VALIDATION_FAIL_MESSAGE = "No valid $ELEMENT is specified";
+ private static final String INVALID_ELEMENT_MESSAGE = "$ELEMENT is not valid in the $VERSION version";
+ private static final String ELEMENT_MESSAGE = "\\$ELEMENT";
public ValidationException (String msg) {
- super (validationFailMessage.replaceAll ("\\$ELEMENT", msg));
+ super (VALIDATION_FAIL_MESSAGE.replaceAll (ELEMENT_MESSAGE, msg));
}
public ValidationException (String msg, Exception cause) {
- super (validationFailMessage.replaceAll ("\\$ELEMENT", msg), cause);
+ super (VALIDATION_FAIL_MESSAGE.replaceAll (ELEMENT_MESSAGE, msg), cause);
}
public ValidationException(String msg, String version) {
- super(invalidElementMessage.replaceAll("\\$ELEMENT", msg).replaceAll("\\$VERSION", version));
+ super(INVALID_ELEMENT_MESSAGE.replaceAll(ELEMENT_MESSAGE, msg).replaceAll("\\$VERSION", version));
}
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java
index b498259eed..ebb1dd28cf 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java
@@ -40,14 +40,14 @@ import org.openecomp.mso.logger.MsoLogger;
public class XMLValidator {
- private static String XSDS_PATH;
+ private static String xsdsPath;
static {
String prefixMsoPropertiesPath = System.getProperty ("mso.config.path");
if (prefixMsoPropertiesPath == null) {
prefixMsoPropertiesPath = "";
}
- XSDS_PATH = prefixMsoPropertiesPath + "xsds/";
+ xsdsPath = prefixMsoPropertiesPath + "xsds/";
}
private String stringXsd;
@@ -60,12 +60,12 @@ public class XMLValidator {
public XMLValidator (String xsdFile) {
- try (FileInputStream xsdStream = new FileInputStream (XSDS_PATH + xsdFile)) {
+ try (FileInputStream xsdStream = new FileInputStream (xsdsPath + xsdFile)) {
stringXsd = IOUtils.toString (xsdStream);
factory = SchemaFactory.newInstance (XMLConstants.W3C_XML_SCHEMA_NS_URI);
- factory.setResourceResolver (new PathResourceResolver (XSDS_PATH));
+ factory.setResourceResolver (new PathResourceResolver (xsdsPath));
factory.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true);
String quotedXsd = stringXsd.replaceAll ("&#34;", "\"");
@@ -73,7 +73,7 @@ public class XMLValidator {
schema = factory.newSchema (src);
} catch (IOException | SAXException e) {
- msoLogger.debug ("Cannot open file " + XSDS_PATH + xsdFile, e);
+ msoLogger.debug ("Cannot open file " + xsdsPath + xsdFile, e);
errorMsg = "ErrorDetails: xsd file " + xsdFile + "could not be opened - " + e.getMessage ();
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index f152116421..08ff9fedd0 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
@@ -220,22 +220,22 @@
<version>${spring-version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-catalog-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-requests-db</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-api-handler-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
index 2f32e80dc1..d60915bf43 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
@@ -160,7 +160,7 @@ public class OrchestrationRequests {
orchestrationList = new GetOrchestrationListResponse();
- List<RequestList> requestLists = new ArrayList<RequestList>();
+ List<RequestList> requestLists = new ArrayList<>();
for (InfraActiveRequests infraActive : activeRequests) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java
index a61ca5fb30..a55c13baed 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java
@@ -711,12 +711,12 @@ public class VnfRequestHandler {
requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props);
// Capture audit event
msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ());
- response = requestClient.post (msoRequest.getRequestXML (),
- requestId,
- Integer.toString (recipe.getRecipeTimeout ()).toString (),
- version,
- null,
- null);
+ response = requestClient.post(msoRequest.getRequestXML(),
+ requestId,
+ Integer.toString(recipe.getRecipeTimeout()),
+ version,
+ null,
+ null);
msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null);
} catch (Exception e) {
msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java
index 9a8bf35e5c..2c1f506943 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java
@@ -652,12 +652,12 @@ public class VolumeRequestHandler {
requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props);
// Capture audit event
msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ());
- response = requestClient.post (msoRequest.getRequestXML (),
- requestId,
- Integer.toString (recipe.getRecipeTimeout ()).toString (),
- version,
- null,
- null);
+ response = requestClient.post(msoRequest.getRequestXML(),
+ requestId,
+ Integer.toString(recipe.getRecipeTimeout()),
+ version,
+ null,
+ null);
msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null);
} catch (Exception e) {
msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null);
diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml
index 6a4941e53e..b14c87a0d4 100644
--- a/mso-api-handlers/mso-requests-db/pom.xml
+++ b/mso-api-handlers/mso-requests-db/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
@@ -55,6 +55,12 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.6.Final</version>
@@ -97,10 +103,16 @@
<version>1.0.0.Final</version>
</dependency>
<dependency>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.19</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<packaging>jar</packaging>
<build>
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java
new file mode 100644
index 0000000000..0bb126fa42
--- /dev/null
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseTest.java
@@ -0,0 +1,283 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 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=========================================================
+ */
+package org.openecomp.mso.requestsdb;
+
+
+import mockit.Expectations;
+import mockit.Mocked;
+import mockit.integration.junit4.JMockit;
+import org.hibernate.Criteria;
+import org.hibernate.Query;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(JMockit.class)
+public class RequestsDatabaseTest {
+
+ RequestsDatabase requestsDatabase = RequestsDatabase.getInstance();
+
+ @Test
+ public void getInstanceTest() throws Exception {
+ RequestsDatabase instance = RequestsDatabase.getInstance();
+ assertEquals(RequestsDatabase.class, instance.getClass());
+ }
+
+ @Test
+ public void healthCheckTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked SQLQuery query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createSQLQuery(" show tables "); result = query;
+ query.list(); result = Arrays.asList("table1", "table2");
+ }};
+
+ assertTrue(requestsDatabase.healthCheck());
+ }
+
+ @Test
+ public void updateInfraStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ query.executeUpdate(); result = 1;
+ }};
+ assertEquals(1, requestsDatabase.updateInfraStatus("123", "unknown", "unknown"));
+ }
+
+ @Test
+ public void updateInfraStatus1Test(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ query.executeUpdate(); result = 1;
+ }};
+ assertEquals(1, requestsDatabase.updateInfraStatus("123", "unknown", 0, "unknown"));
+ }
+
+ @Test
+ public void updateInfraFinalStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ query.executeUpdate(); result = 1;
+ }};
+ assertEquals(1, requestsDatabase.updateInfraFinalStatus("123",
+ "unknown",
+ "statusMessage",
+ 0,
+ "responsebody",
+ "lastmodifiedby"));
+ }
+
+ @Test
+ public void getRequestFromInfraActiveTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ query.uniqueResult(); result = new InfraActiveRequests("123", "action");
+ }};
+ assertEquals("123",
+ requestsDatabase.getRequestFromInfraActive("123").getRequestId());
+ }
+
+ @Test
+ public void getOrchestrationFiltersFromInfraActiveTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Criteria criteria) throws Exception {
+
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createCriteria(InfraActiveRequests.class); result = criteria;
+ criteria.list(); result = Arrays.asList(new InfraActiveRequests("123", "action"));
+ }};
+ assertEquals(1,
+ requestsDatabase.getRequestListFromInfraActive("queryattr",
+ "queryvalue",
+ "type").size());
+ }
+
+ @Test
+ public void getRequestListFromInfraActiveTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType"); result = query;
+ query.uniqueResult(); result = new InfraActiveRequests("123", "action");
+ }};
+ assertEquals("123",
+ requestsDatabase.getRequestFromInfraActive("123", "requestType").getRequestId());
+ }
+
+ @Test
+ public void getRequestFromInfraActive1Test(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Criteria criteria) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createCriteria(InfraActiveRequests.class); result = criteria;
+ criteria.list(); result = Arrays.asList(new InfraActiveRequests());
+ }};
+ assertEquals(1,
+ requestsDatabase.getRequestListFromInfraActive("queryAttr",
+ "queryvalue",
+ "type").size());
+ }
+
+ @Test
+ public void checkDuplicateByVnfNameTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); result = query;
+ query.list(); result = Arrays.asList(new InfraActiveRequests("123", "action"));
+ }};
+ assertEquals("123",
+ requestsDatabase.checkDuplicateByVnfName("vnfname",
+ "action",
+ "requesttype").getRequestId());
+ }
+
+ @Test
+ public void checkDuplicateByVnfIdTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); result = query;
+ query.list(); result = Arrays.asList(new InfraActiveRequests("123", "action"));
+ }};
+ assertEquals("123",
+ requestsDatabase.checkDuplicateByVnfId("vnfname",
+ "action",
+ "requesttype").getRequestId());
+ }
+
+ @Test
+ public void setMockDBTest() throws Exception {
+ requestsDatabase.setMockDB(null);
+ }
+
+ @Test
+ public void getSiteStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("FROM SiteStatus WHERE siteName = :site_name"); result = query;
+ query.uniqueResult(); result = new SiteStatus();
+ }};
+ assertEquals(SiteStatus.class,
+ requestsDatabase.getSiteStatus("site").getClass());
+ }
+
+ @Test
+ public void updateSiteStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("FROM SiteStatus WHERE siteName = :site_name"); result = query;
+ query.uniqueResult(); result = new SiteStatus();
+ }};
+ requestsDatabase.updateSiteStatus("site", true);
+ }
+
+ @Test
+ public void getOperationStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id"); result = query;
+ query.uniqueResult(); result = new OperationStatus();
+ }};
+ assertEquals(OperationStatus.class,
+ requestsDatabase.getOperationStatus("123",
+ "Unknown").getClass());
+ }
+
+ @Test
+ public void getOperationStatusByServiceIdTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id"); result = query;
+ query.uniqueResult(); result = new OperationStatus();
+ }};
+ assertEquals(OperationStatus.class,
+ requestsDatabase.getOperationStatusByServiceId("123").getClass());
+ }
+
+ @Test
+ public void getOperationStatusByServiceNameTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("FROM OperationStatus WHERE SERVICE_NAME = :service_name"); result = query;
+ query.uniqueResult(); result = new OperationStatus();
+ }};
+ assertEquals(OperationStatus.class,
+ requestsDatabase.getOperationStatusByServiceName("servicename").getClass());
+ }
+
+ @Test
+ public void updateOperationStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("FROM OperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id"); result = query;
+ query.uniqueResult(); result = new OperationStatus();
+ }};
+ requestsDatabase.updateOperationStatus(new OperationStatus());
+ }
+
+ @Test
+ public void getResourceOperationStatusTest(@Mocked AbstractSessionFactoryManager sessionFactoryManager,
+ @Mocked Session session,
+ @Mocked Query query) throws Exception {
+ new Expectations() {{
+ sessionFactoryManager.getSessionFactory().openSession(); result = session;
+ session.createQuery("FROM ResourceOperationStatus WHERE serviceId = :service_id and operationId = :operation_id and resourceTemplateUUID= :uuid"); result = query;
+ query.uniqueResult(); result = new ResourceOperationStatus();
+ }};
+ assertEquals(ResourceOperationStatus.class,
+ requestsDatabase.getResourceOperationStatus("serviceId",
+ "operationid",
+ "123-uuid").getClass());
+ }
+}
diff --git a/mso-api-handlers/pom.xml b/mso-api-handlers/pom.xml
index 4399c75155..06eedc5675 100644
--- a/mso-api-handlers/pom.xml
+++ b/mso-api-handlers/pom.xml
@@ -2,12 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>so</artifactId>
<version>1.2.0-SNAPSHOT</version>
</parent>
- <groupId>org.openecomp.so</groupId>
+ <groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
<name>API Handler</name>
<description>API Handler for MSO</description>