aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/.gitignore6
-rwxr-xr-xvid-app-common/pom.xml20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java18
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java139
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt43
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/Features.java1
-rw-r--r--vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties1
-rw-r--r--vid-app-common/src/main/webapp/WEB-INF/conf/features.properties5
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js3
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js126
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js24
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js81
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js4
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html2
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js1562
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js3
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js2598
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java1
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java216
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java15
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java97
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java36
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java84
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java35
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java31
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java421
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/InstanceIdsTest.java84
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java71
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java787
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java79
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java113
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java211
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsWrapperTest.java42
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java99
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestStatusTest.java84
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java124
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestWrapperTest.java32
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/ResponseTest.java48
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/SubscriberInfoTest.java81
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskListTest.java28
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java279
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java34
46 files changed, 4469 insertions, 3352 deletions
diff --git a/vid-app-common/.gitignore b/vid-app-common/.gitignore
index 675c1faed..ce72daaf2 100644
--- a/vid-app-common/.gitignore
+++ b/vid-app-common/.gitignore
@@ -5,4 +5,8 @@ debug-logs/
target/
.idea/
.classpath
-.project \ No newline at end of file
+.project
+
+# gulp/jest files #
+node_modules/
+coverage/
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index 6b73d79ca..38b06f1f8 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -14,6 +14,13 @@
<name>VID Common</name>
<description>VID Common code for opensource version</description>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>1.2.3</version>
+ <relativePath/>
+ </parent>
+
<properties>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -21,7 +28,7 @@
<epsdk.version>2.4.0</epsdk.version>
<springframework.version>4.2.9.RELEASE</springframework.version>
<hibernate.version>4.3.11.Final</hibernate.version>
- <jackson.version>2.9.7</jackson.version>
+ <jackson.version>2.9.8</jackson.version>
<jersey.version>2.27</jersey.version>
<surefire.version>2.22.1</surefire.version>
<sonar.coverage.exclusions>**/webapp/**/*,**/*.js</sonar.coverage.exclusions>
@@ -448,7 +455,6 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
@@ -458,7 +464,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
- <version>4.3.6</version>
+ <version>4.5.7</version>
</dependency>
<dependency>
<groupId>com.xebialabs.restito</groupId>
@@ -522,13 +528,7 @@
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
</dependency>
<dependency>
@@ -682,7 +682,6 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- <version>1.9.3</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
@@ -799,7 +798,6 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>23.0</version>
</dependency>
</dependencies>
</project>
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
index 563e798df..a472268a3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -23,6 +23,7 @@ package org.onap.vid.controller;
import io.joshworks.restclient.http.mapper.ObjectMapper;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.factories.MsoRequestFactory;
import org.onap.vid.mso.MsoBusinessLogic;
@@ -47,10 +48,10 @@ public class MsoConfig {
}
@Bean
- public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper){
+ public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient){
// Satisfy both interfaces -- MsoInterface and RestMsoImplementation
return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty(
- MsoProperties.MSO_SERVER_URL));
+ MsoProperties.MSO_SERVER_URL),httpsAuthClient);
}
@Bean
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
index ff12bb8bc..e14ac0e11 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
@@ -51,7 +51,7 @@ import static org.onap.vid.utils.Logging.*;
/**
* Created by pickjonathan on 26/06/2017.
*/
-public abstract class RestMsoImplementation implements RestInterface {
+public class RestMsoImplementation implements RestInterface {
/**
* The logger.
@@ -62,7 +62,7 @@ public abstract class RestMsoImplementation implements RestInterface {
/** The client. */
private Client client = null;
- @Autowired
+
protected HttpsAuthClient httpsAuthClient;
private static final String START_LOG = " start";
@@ -79,6 +79,11 @@ public abstract class RestMsoImplementation implements RestInterface {
* Instantiates a new mso rest interface.
*/
+ @Autowired
+ protected RestMsoImplementation(HttpsAuthClient httpsAuthClient){
+ this.httpsAuthClient=httpsAuthClient;
+ }
+
@SuppressWarnings("Duplicates")
protected MultivaluedHashMap<String, Object> initMsoClient()
{
@@ -139,7 +144,7 @@ public abstract class RestMsoImplementation implements RestInterface {
MultivaluedHashMap<String, Object> commonHeaders = initMsoClient();
Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url);
- final Response cres = client.target(url)
+ final Response cres = client.target(url)
.request()
.accept(APPLICATION_JSON)
.headers(commonHeaders)
@@ -219,7 +224,8 @@ public abstract class RestMsoImplementation implements RestInterface {
.accept(APPLICATION_JSON)
.headers(commonHeaders)
//.entity(r)
- .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke();
+ .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON))
+ .invoke();
Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres);
int status = cres.getStatus();
restObject.setStatusCode (status);
@@ -245,6 +251,7 @@ public abstract class RestMsoImplementation implements RestInterface {
catch ( Exception e ) {
logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG
+ e.getMessage());
+ throw e;
}
}
@@ -252,7 +259,6 @@ public abstract class RestMsoImplementation implements RestInterface {
{
logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString());
throw e;
-
}
}
@@ -349,7 +355,6 @@ public abstract class RestMsoImplementation implements RestInterface {
restObject.setStatusCode (status);
return restObject;
-
}
@Override
@@ -383,6 +388,7 @@ public abstract class RestMsoImplementation implements RestInterface {
catch ( Exception e ) {
logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG
+ e.getMessage());
+ throw e;
}
int status = cres.getStatus();
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index 76e61b35f..8dac0ce1b 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -22,25 +22,31 @@ package org.onap.vid.mso.rest;
import com.google.common.collect.ImmutableMap;
import io.joshworks.restclient.http.HttpResponse;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
import org.apache.commons.codec.binary.Base64;
import org.eclipse.jetty.util.security.Password;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.changeManagement.MsoRequestDetails;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.model.RequestReferencesContainer;
-import org.onap.vid.mso.*;
+import org.onap.vid.mso.MsoInterface;
+import org.onap.vid.mso.MsoProperties;
+import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.mso.MsoResponseWrapperInterface;
+import org.onap.vid.mso.MsoUtil;
+import org.onap.vid.mso.RestMsoImplementation;
+import org.onap.vid.mso.RestObject;
import org.onap.vid.utils.Logging;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Created by pickjonathan on 21/06/2017.
@@ -61,7 +67,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
*/
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class);
- public MsoRestClientNew(SyncRestClient client, String baseUrl) {
+ public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient) {
+ super(authClient);
this.client = client;
this.baseUrl = baseUrl;
this.commonHeaders = initCommonHeaders();
@@ -218,13 +225,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
return MsoUtil.wrapResponse(response);
}
- public MsoResponseWrapper getManualTasks(String endpoint) {
- String path = baseUrl + endpoint;
-
- HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
- return MsoUtil.wrapResponse(response);
- }
-
+ @Override
public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) {
String methodName = "getManualTasksByRequestId";
logger.debug(methodName + START);
@@ -232,9 +233,10 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
try {
String path = baseUrl + endpoint;
- MsoResponseWrapper w =getManualTasks(path);
- logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse());
+ HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
+ MsoResponseWrapper w = MsoUtil.wrapResponse(response);
+ logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse());
return w;
} catch (Exception e) {
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java
deleted file mode 100644
index 23a5119e9..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 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.onap.vid.mso.rest;
-
-import java.util.List;
-
-public class Task {
-
- private String taskId;
- private String type;
- private String nfRole;
- private String subscriptionServiceType;
- private String originalRequestId;
- private String originalRequestorId;
- private String errorSource;
- private String errorCode;
- private String errorMessage;
- private String buildingBlockName;
- private String buildingBlockStep;
- private List<String> validResponses;
-
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getNfRole() {
- return nfRole;
- }
-
- public void setNfRole(String nfRole) {
- this.nfRole = nfRole;
- }
-
- public String getSubscriptionServiceType() {
- return subscriptionServiceType;
- }
-
- public void setSubscriptionServiceType(String subscriptionServiceType) {
- this.subscriptionServiceType = subscriptionServiceType;
- }
-
- public String getOriginalRequestId() {
- return originalRequestId;
- }
-
- public void setOriginalRequestId(String originalRequestId) {
- this.originalRequestId = originalRequestId;
- }
-
- public String getOriginalRequestorId() {
- return originalRequestorId;
- }
-
- public void setOriginalRequestorId(String originalRequestorId) {
- this.originalRequestorId = originalRequestorId;
- }
-
- public String getErrorSource() {
- return errorSource;
- }
-
- public void setErrorSource(String errorSource) {
- this.errorSource = errorSource;
- }
-
- public String getErrorCode() {
- return errorCode;
- }
-
- public void setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public String getBuildingBlockName() {
- return buildingBlockName;
- }
-
- public void setBuildingBlockName(String buildingBlockName) {
- this.buildingBlockName = buildingBlockName;
- }
-
- public String getBuildingBlockStep() {
- return buildingBlockStep;
- }
-
- public void setBuildingBlockStep(String buildingBlockStep) {
- this.buildingBlockStep = buildingBlockStep;
- }
-
- public List<String> getValidResponses() {
- return validResponses;
- }
-
- public void setValidResponses(List<String> validResponses) {
- this.validResponses = validResponses;
- }
-
-
-
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt
new file mode 100644
index 000000000..311b0fbbe
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.onap.vid.mso.rest
+
+data class Task(
+ var taskId: String?,
+ var type: String?,
+ var nfRole: String?,
+ var subscriptionServiceType: String?,
+ var originalRequestId: String?,
+ var originalRequestorId: String?,
+ var errorSource: String?,
+ var errorCode: String?,
+ var errorMessage: String?,
+ var buildingBlockName: String?,
+ var buildingBlockStep: String?,
+ var validResponses: List<String>?
+) {
+ // i.e. "default constructor", no params
+ constructor() : this(
+ null, null, null, null,
+ null, null, null, null,
+ null, null, null, null
+ )
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
index dfe3185b2..1c68e8292 100644
--- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
@@ -62,6 +62,7 @@ public enum Features implements Feature {
FLAG_1902_NEW_VIEW_EDIT,
FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER,
FLAG_1902_VNF_GROUPING,
+ FLAG_HANDLE_SO_WORKFLOWS
;
public boolean isActive() {
diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties
index d82b043c5..8ba148465 100644
--- a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties
+++ b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties
@@ -8,6 +8,7 @@ FLAG_COLLECTION_RESOURCE_SUPPORT = true
FLAG_NETWORK_TO_ASYNC_INSTANTIATION = false
FLAG_SERVICE_MODEL_CACHE = true
FLAG_SHOW_ASSIGNMENTS = true
+FLAG_HANDLE_SO_WORKFLOWS = true
FLAG_SHOW_VERIFY_SERVICE = true
FLAG_DUPLICATE_VNF = true
diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties
index 36f607f62..4cf42f235 100644
--- a/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties
+++ b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties
@@ -20,11 +20,12 @@ FLAG_SHOW_ASSIGNMENTS = true
FLAG_SHOW_VERIFY_SERVICE = false
FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS = true
FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS = true
-FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST=true
-FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY=true
+FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST = true
+FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY = true
FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE = true
FLAG_1810_AAI_LOCAL_CACHE = true
FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER = false
+FLAG_HANDLE_SO_WORKFLOWS = false
# Modern UI (Drawing-Board; View/Edit)
# - - - - - - - - - - - - - - - - - -
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
index dbf6588ce..fc3d8f792 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
@@ -257,7 +257,8 @@ appDS2
FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS: "FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS",
FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST: "FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST",
FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY: "FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY",
- FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE: "FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE"
+ FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE: "FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE",
+ FLAG_HANDLE_SO_WORKFLOWS: "FLAG_HANDLE_SO_WORKFLOWS"
}
};
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js
new file mode 100644
index 000000000..f5821f7de
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 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=========================================================
+ */
+
+require('./change-management-manual-tasks.controller');
+const jestMock = require('jest-mock');
+
+describe('changeManagementManualTasksController testing', () => {
+ let $controller;
+ let $uibModalInstance = jestMock.fn();
+ let $MsoService = jestMock.fn();
+ let $log = jestMock.fn();
+
+ beforeEach(
+ angular.mock.module('app')
+ );
+
+ beforeEach(inject(function (_$controller_) {
+ $MsoService.getManualTasks = jestMock.fn().mockResolvedValue(
+ {data: [manualTaskResponse]});
+ $log.error = jestMock.fn();
+
+ $controller = _$controller_('changeManagementManualTasksController', {
+ "MsoService": $MsoService,
+ "$uibModalInstance": $uibModalInstance,
+ "$log": $log,
+ "jobInfo": {
+ requestState: job.requestStatus.requestState,
+ details: job.requestStatus.statusMessage,
+ job: job,
+ },
+ "COMPONENT": {
+ MANUAL_TASKS: ["manualTaskName1", "manualTaskName2"]
+ },
+ });
+ }));
+
+ const job = {
+ "requestId": "db775fac-d9b5-480e-8b3e-4f0d0ae67890",
+ "requestScope": "vnf",
+ "requestStatus": {
+ "percentProgress": 100.0,
+ "requestState": "FAILED",
+ "statusMessage": "Error validating request. No valid catalog entry is specified",
+ "finishTime": "Thu, 05 Oct 2017 18:58:29 GMT"
+ },
+ "requestType": "replaceInstance",
+ "startTime": "Thu, 05 Oct 2017 18:58:29 GMT",
+ "instanceReferences": {
+ "serviceInstanceId": "cc8fa0a9-7576-4c39-af31-7ad61d057ac9",
+ "vnfInstanceId": "bec0c3d3-09ae-4eb1-b694-057987a10982",
+ "requestorId": "pa2396"
+ }
+ };
+
+ const manualTaskResponse = {
+ "taskId": "db775fac-d9b5-480e-8b3e-4f0d0ae67890",
+ "validResponses": ["rollback", "abort", "skip", "resume", "retry"]
+ };
+
+ test('should populate vm.manualTasks (while init)', () => {
+ expect($controller.manualTasks).toEqual(
+ manualTaskResponse.validResponses);
+ });
+
+ test('should populate vm.MANUAL_TASKS from COMPONENT (while init)', () => {
+ expect($controller.MANUAL_TASKS).toEqual(
+ ["manualTaskName1", "manualTaskName2"]);
+ });
+
+ test('should populate vm.task (while init)', () => {
+ expect($controller.task).toEqual(manualTaskResponse);
+ });
+
+ test('should find manual task using isTaskAvailable', () => {
+ expect($controller.isTaskAvailable('abort')).toBeTruthy();
+ expect($controller.isTaskAvailable('resume')).toBeTruthy();
+
+ expect($controller.isTaskAvailable('foo')).toBeFalsy();
+ expect($controller.isTaskAvailable(undefined)).toBeFalsy();
+ });
+
+ test('should call MsoService upon completeTask', () => {
+ $MsoService.completeTask = jestMock.fn().mockResolvedValue({data: {}});
+
+ $controller.completeTask("taskName");
+ expect($MsoService.completeTask).toBeCalledWith(
+ manualTaskResponse.taskId, "taskName");
+ });
+
+ test('should close modal upon completeTask', done => {
+ $MsoService.completeTask = jestMock.fn().mockResolvedValue({data: {}});
+ $uibModalInstance.close = jestMock.fn(() => {
+ done();
+ });
+
+ $controller.completeTask("taskName");
+ });
+
+ test('should close modal upon failed completeTask', done => {
+ $MsoService.completeTask = jestMock.fn().mockRejectedValue();
+ $uibModalInstance.close = jestMock.fn(() => {
+ done();
+ });
+
+ $controller.completeTask("taskName");
+ });
+
+});
+
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index 8a7d59a62..88caef29e 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -634,16 +634,20 @@
};
vm.loadWorkFlows = function () {
- // Should be corrected when VID-397 will be closed. At the moment there is a need
- // to merge local and remote workflows not to broke current functionality.
- return vm.loadLocalWorkFlows()
- .then(vm.loadLocalWorkFlowsParameters)
- .then(vm.loadRemoteWorkFlows)
- .then(function () {
- vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name));
- }).then(function () {
- vm.loadRemoteWorkFlowsParameters();
- });
+ if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_HANDLE_SO_WORKFLOWS)) {
+ return vm.loadRemoteWorkFlows()
+ .then(function () {
+ vm.workflows = vm.remoteWorkflows.map(item => item.name);
+ }).then(function () {
+ vm.loadRemoteWorkFlowsParameters();
+ });
+ }else{
+ return vm.loadLocalWorkFlows()
+ .then(vm.loadLocalWorkFlowsParameters)
+ .then(function () {
+ vm.workflows = vm.localWorkflows;
+ })
+ }
};
vm.loadLocalWorkFlows = function () {
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
index 5f3669152..9810c0013 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
@@ -25,6 +25,8 @@ describe('Testing workFlows from SO', () => {
let $notNeeded;
let $controller;
let $changeManagementService;
+ let $featureFlags;
+
beforeEach(
angular.mock.module('app')
);
@@ -38,6 +40,10 @@ describe('Testing workFlows from SO', () => {
// mock q
$q = jestMock.fn();
$defer = jestMock.fn();
+ $flags = jestMock.fn();
+ $flags.FEATURE_FLAGS = {FLAG_HANDLE_SO_WORKFLOWS: ''};
+ $featureFlags = jestMock.fn();
+ $featureFlags.isOn = jestMock.fn(() => true);
$q.defer = jestMock.fn(() => $defer);
$defer.promise = Promise.resolve({});
// mock AaiService
@@ -53,10 +59,10 @@ describe('Testing workFlows from SO', () => {
Upload: $notNeeded,
$log: $notNeeded,
_: $notNeeded,
- COMPONENT: $notNeeded,
+ COMPONENT: $flags,
VIDCONFIGURATION: $notNeeded,
DataService: $notNeeded,
- featureFlags: $notNeeded,
+ featureFlags: $featureFlags,
$scope: $notNeeded,
});
}));
@@ -77,10 +83,23 @@ describe('Testing workFlows from SO', () => {
);
});
- test('Verify load workflows will call load from SO and join workflow lists', () => {
+ test('Verify load workflows wont load parameters from local service', () => {
// given
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
- let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
+ "parameterDefinitions": [
+ {
+ "id": 1,
+ "name": "Configuration Parameters",
+ "required": true,
+ "type": "STRING",
+ "pattern": ".*",
+ "msgOnPatternError": null,
+ "msgOnContentError": null,
+ "acceptableFileType": null
+ }
+ ],
+ }});
let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]});
let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}});
@@ -91,7 +110,6 @@ describe('Testing workFlows from SO', () => {
$changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
return $controller.loadWorkFlows().then(() => {
- expect($controller.workflows).toContain('workflow 0');
expect($controller.workflows).toContain('workflow 1');
expect($controller.workflows).toContain('workflow 2');
});
@@ -122,8 +140,33 @@ describe('Testing workFlows from SO', () => {
});
});
+ test('Verify load workflows wont load workflows parameters from SO if feature flag is disabled', () => {
+ // given
+ $featureFlags.isOn = jestMock.fn(() => false);
+ let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}});
+ let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]});
+ let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [
+ {"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"},
+ {"id": 2, "name": "parameter 2", "required": true, "type": "STRING", "pattern": ".*"},
+ {"id": 3, "name": "parameter 3", "required": false, "type": "STRING", "pattern": "[0-9]*"}]}});
+
+ $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
+ $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
+ $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
+ $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
+ // when
+ return $controller.loadWorkFlows()
+ .then(() => {
+ expect($controller.workflows).toEqual(["workflow 0"]);
+ expect($controller.remoteWorkflowsParameters).toEqual(undefined);
+ });
+ });
+
test('Verify load workflows will call load workflows parameters from local service', () => {
// given
+ $featureFlags.isOn = jestMock.fn(() => false);
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
"parameterDefinitions": [
@@ -139,14 +182,10 @@ describe('Testing workFlows from SO', () => {
}
],
}});
- let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]});
- let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}});
$controller.changeManagement.vnfNames = [{name: 'test1'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
- $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
- $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
let result = new Map();
@@ -172,23 +211,22 @@ describe('Testing workFlows from SO', () => {
});
});
- test('Verify broken SO workflows wont change content of local workflows', () => {
+ test('Verify broken SO workflows will return empty list of workflows', () => {
// given
- let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
let getSOWorkflowsPromiseStub = Promise.reject(new Error("Broken SO workflows service."));
- $controller.changeManagement.vnfNames = "any";
- $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $controller.changeManagement.vnfNames = [{name:"any"}];
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
// when
$controller.loadWorkFlows()
.then(() => {
- expect($controller.workflows).toEqual(['workflow 0']);
+ expect($controller.workflows).toEqual([]);
});
});
test('Verify get internal workflow parameters should return an empty list if not such workflow exist', () => {
// given
+ $featureFlags.isOn = jestMock.fn(() => false);
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
"parameterDefinitions": [
@@ -204,14 +242,10 @@ describe('Testing workFlows from SO', () => {
}
],
}});
- let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]});
- let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}});
$controller.changeManagement.vnfNames = [{name: 'test1'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
- $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
- $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
return $controller.loadWorkFlows()
.then(() => {
@@ -222,6 +256,7 @@ describe('Testing workFlows from SO', () => {
test('Verify get internal workflow parameters should return an empty list if not such type exist', () => {
// given
+ $featureFlags.isOn = jestMock.fn(() => false);
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
"parameterDefinitions": [
@@ -237,14 +272,10 @@ describe('Testing workFlows from SO', () => {
}
],
}});
- let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]});
- let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}});
$controller.changeManagement.vnfNames = [{name: 'test1'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
- $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
- $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
return $controller.loadWorkFlows()
.then(() => {
@@ -255,6 +286,7 @@ describe('Testing workFlows from SO', () => {
test('Verify get internal workflow parameters should return a list if such workflow and type exist', () => {
// given
+ $featureFlags.isOn = jestMock.fn(() => false);
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
"parameterDefinitions": [
@@ -270,14 +302,9 @@ describe('Testing workFlows from SO', () => {
}
],
}});
- let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]});
- let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}});
-
$controller.changeManagement.vnfNames = [{name: 'test1'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
- $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
- $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
let result = [{
"acceptableFileType": null,
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js
index 819be9374..956ae1db5 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js
@@ -127,6 +127,10 @@ var vfModuleActionModalController = function(COMPONENT, $scope, $uibModal, Creat
$uibModalInstance.close({requestParams : requestParams, msoType: COMPONENT.MSO_DEACTIVATE_AND_CLOUD_DELETE});
};
+ $scope.removeVendorFromCloudOwner = function(cloudOwner) {
+ return AaiService.removeVendorFromCloudOwner(cloudOwner)
+ };
+
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html
index 620754307..eb67e6ed9 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html
@@ -64,7 +64,7 @@
<option ng-repeat="option in lcpRegionList" value="{{option.cloudRegionId}}"
data-ng-if="option.isPermitted && isFeatureFlagCloudOwner">
- {{option.cloudRegionId}} ({{option.cloudOwner.trim().toUpperCase().replace("ATT-", "")}})
+ {{option.cloudRegionId}} ({{removeVendorFromCloudOwner(option.cloudOwner).toUpperCase()}})
</option>
</select>
</div>
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
index bd8bd9baa..030faf524 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
@@ -1,778 +1,784 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 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=========================================================
- */
-
-"use strict";
-
-var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD, $q, featureFlags) {
-
- function getServiceInstance(serviceInstanceIdentifier, findBy) {
- serviceInstanceIdentifier.trim();
-
- return $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + serviceInstanceIdentifier + "/" + findBy + "?r=" + Math.random(), {}, {
- timeout: PropertyService.getServerResponseTimeoutMsec()
- });
- }
-
- function getPnfByName(pnfName) {
- var deferred = $q.defer();
- var url = COMPONENT.AAI_GET_PNF_BY_NAME+ encodeURIComponent(pnfName) ;
- var config = { timeout: PropertyService.getServerResponseTimeoutMsec() };
-
- $http.get(url, config)
- .success(function (response) {
- deferred.resolve({data: response});
- })
- .error(function(data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
- }
- function getGlobalCustomerIdFromServiceInstanceResponse(response) {
- var globalCustomerId = "";
- if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) {
- var customerIndex = 5;
- var customerIdIndex = 6;
- var itemIndex = 0;
-
- var item = response.data[FIELD.ID.RESULT_DATA][itemIndex];
- var url = item[FIELD.ID.RESOURCE_LINK];
- var urlParts = url.split("/");
- if (urlParts[customerIndex] === FIELD.ID.CUSTOMER) {
- globalCustomerId = urlParts[customerIdIndex];
- }
- }
- return globalCustomerId;
- }
-
- function searchServiceInstances(query) {
- return $http.get( COMPONENT.SEARCH_SERVICE_INSTANCES + query, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function (response) {
- var displayData = response.data[FIELD.ID.SERVICE_INSTANCES];
- if (!displayData || !displayData.length) {
- displayData = [{
- globalCustomerId : null,
- subscriberName : null,
- serviceType : FIELD.PROMPT.NO_SERVICE_SUB,
- serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE
- }];
- }
- return {displayData: displayData};
- });
- };
-
- function getJoinedQueryString(queries) {
- return queries.filter(function (val) {return val;}).join("&");
- }
-
- return {
- getSubscriberName : function(globalCustomerId,
- successCallbackFunction) {
- $log
- .debug("AaiService:getSubscriberName: globalCustomerId: "
- + globalCustomerId);
- $http.get(
- COMPONENT.AAI_SUB_DETAILS_PATH
- + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- var result = {};
- if (response.data) {
- result.subscriberName = response.data[FIELD.ID.SUBNAME];
- result.serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS];
- }
- successCallbackFunction(result);
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
-
- runNamedQuery : function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
-
- var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- return $http.get(url, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- successCallback(response);
- } else {
- errorCallback(response);
- }
- }, function(response) {
- errorCallback(response);
- });
- },
-
-
- getVNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
-
- var url = COMPONENT.AAI_GET_VNF_INFO +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- $http.get(url, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- successCallback(response);
- } else {
- errorCallback(response);
- }
- }, function(response) {
- errorCallback(response);
- });
- },
-
- getPNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
-
- var url = COMPONENT.AAI_GET_PNF_INSTANCE +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- $http.get(url, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- successCallback(response);
- } else {
- errorCallback(response);
- }
- }, function(response) {
- errorCallback(response);
- });
- },
-
- getCRInformationByInstanceId : function (serviceInstanceId) {
-
- var deferred = $q.defer();
-
- var url = COMPONENT.AAI_GET_CR_INSTANCE +
- COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
- $http.get(url, {}, {
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data != null) {
- deferred.resolve(response);
- } else {
- deferred.resolve(response);
- }
- }, function(response) {
- deferred.resolve(response);
- });
- return deferred.promise;
- },
-
- searchServiceInstances: searchServiceInstances,
-
- getModelVersionId: function (subscriberId, instanceId) {
- var globalCustomerIdQuery = COMPONENT.SELECTED_SUBSCRIBER_SUB_PATH + subscriberId;
- var serviceInstanceQuery = COMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH + instanceId;
-
- var query = "?" + getJoinedQueryString([globalCustomerIdQuery, serviceInstanceQuery]);
-
- var deferred = $q.defer();
-
- searchServiceInstances(query).then(function (response) {
- var displayData = response.displayData;
- if (displayData[0] && displayData[0].aaiModelVersionId) {
- deferred.resolve(displayData[0].aaiModelVersionId);
- } else {
- deferred.reject(FIELD.ERROR.MODEL_VERSION_ID_MISSING);
- }
- }).catch(function (err) {
- deferred.reject(err);
- });
-
- return deferred.promise;
- },
-
- getSubDetails : function(selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) {
- var subscriber;
- var displayData;
- $http.get( COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- displayData = [];
- subscriber = response.data;
- var subscriberName = subscriber[FIELD.ID.SUBNAME];
- if (subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {
- angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {
- var serviceInstanceId = [];
- var serviceType = "";
- if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {
- serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];
- } else {
- serviceType = FIELD.PROMPT.NO_SERVICE_SUB;
- }
- if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {
- angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {
- // put them together, i guess
- var inst = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID],
- "aaiModelInvariantId": instValue[FIELD.ID.MODEL_INVAR_ID],
- "aaiModelVersionId": instValue[FIELD.ID.MODEL_VERSION_ID],
- "serviceInstanceName": instValue[FIELD.ID.SERVICE_INSTANCE_NAME]
- };
- if (selectedServiceInstance != null) {
- if ((instValue[FIELD.ID.SERVICE_INSTANCE_ID] == selectedServiceInstance ) || (instValue[FIELD.ID.SERVICE_INSTANCE_NAME] == selectedServiceInstance)) {
- serviceInstanceId.push(inst);
- }
- } else {
- serviceInstanceId.push(inst);
- }
- });
- } else {
- serviceInstanceId = [ FIELD.PROMPT.NO_SERVICE_INSTANCE ];
- }
- angular.forEach(serviceInstanceId, function(subVal, subKey) {
- displayData.push({
- globalCustomerId : selectedSubscriber,
- subscriberName : subscriberName,
- serviceType : serviceType,
- serviceInstanceId : subVal.serviceInstanceId,
- aaiModelInvariantId : subVal.aaiModelInvariantId,
- aaiModelVersionId
- : subVal.aaiModelVersionId,
- serviceInstanceName : subVal.serviceInstanceName,
- isPermitted: serviceSubscription[FIELD.ID.IS_PERMITTED]
- });
- });
- });
- } else {
- displayData.push({
- globalCustomerId : selectedSubscriber,
- subscriberName : subscriberName,
- serviceType : FIELD.PROMPT.NO_SERVICE_SUB,
- serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE
- });
- }
- successCallback(displayData, subscriberName);
- }, function(response) {
- errorCallback(response);});
- },
-
- getSubList : function(successCallback, errorCallback ) {
-
- $http.get( FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- var customerList = [];
- if (response.data.customer != null) {
- angular.forEach(response.data.customer, function(subVal, subKey) {
- var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME],
- "isPermitted": subVal[FIELD.ID.IS_PERMITTED], };
- customerList.push(cust);
- });
- successCallback(customerList);
- } else {
- errorCallback(response);
- }
- },function(response) {
- errorCallback(response);
- });
- },
-
- getServiceInstance : getServiceInstance,
- getPnfByName : getPnfByName,
-
- getGlobalCustomerIdByInstanceIdentifier : function(serviceInstanceIdentifier, findBy) {
- serviceInstanceIdentifier.trim();
-
- return getServiceInstance(serviceInstanceIdentifier, findBy)
- .then(function (response) {
- return getGlobalCustomerIdFromServiceInstanceResponse(response);
- });
- },
-
- getMultipleValueParamQueryString: function(values, paramSubPath) {
- if (values.length) {
- return paramSubPath + values.filter(function (val) {return val;}).join("&" + paramSubPath);
- }
- },
-
- getJoinedQueryString: getJoinedQueryString,
-
- getServices2 : function(successCallback, errorCallback ) {
-
- $http.get( FIELD.ID.AAI_GET_SERVICES, {}, {
-
-
- timeout : PropertyService.getServerResponseTimeoutMsec()
- }).then(function(response) {
- var customerList = [];
- if (response.data != null) {
- var serviceIdList = [];
- angular.forEach(response.data, function(value, key) {
- angular.forEach(value, function(subVal, key) {
- var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] ,
- "isPermitted" : subVal[FIELD.ID.IS_PERMITTED]
-
- };serviceIdList.push(newVal);
- });
- });
- successCallback(serviceIdList);
- } else {
- errorCallback(response);
- }
- },function(response) {
- errorCallback(response);
- });
- },
-
- getPortMirroringData: function (ids) {
- var defer = $q.defer();
-
- var url = COMPONENT.AAI_GET_PORT_MIRRORING_CONFIGS_DATA + '?configurationIds=' + ids.join(',');
- $http.get(url).then(function (res) {
- defer.resolve(res);
- }).catch(function (err) {
- $log.error(err);
- defer.resolve({});
- });
-
- return defer.promise;
-
- },
-
- getPortMirroringSourcePorts : function (ids) {
- var defer = $q.defer();
- var url = COMPONENT.AAI_GET_PORT_MIRRORING_SOURCE_PORTS +'?configurationIds=' + ids.join(',');
- $http.get(url).then(function(res){
- defer.resolve(res);
- }).catch(function(err) {
- $log.error(err);
- defer.resolve({});
- });
- return defer.promise;
- },
-
- getVlansByNetworksMapping : function (globalCustomerId, serviceType, serviceInstanceId, sdcModelUuid) {
- var defer = $q.defer();
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)) {
- var url = COMPONENT.AAI_GET_PROVIDER_NETWORKS_ASSOCIATIONS + '?'
- + 'globalCustomerId=' + globalCustomerId
- + '&serviceType=' + serviceType
- + '&serviceInstanceId=' + serviceInstanceId
- + '&sdcModelUuid=' + sdcModelUuid
- ;
-
- $http.get(url).then(function(res){
- defer.resolve(res.data);
- }).catch(function(err) {
- $log.error(err);
- defer.resolve({});
- });
-
- } else {
- defer.resolve({});
- }
- return defer.promise;
- },
-
- getSubscriptionServiceTypeList : function(globalCustomerId,
- successCallbackFunction) {
- $log
- .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: "
- + globalCustomerId);
- if ( UtilityService.hasContents(globalCustomerId) ) {
- $http.get(
- COMPONENT.AAI_SUB_DETAILS_PATH
- + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data && response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]) {
- var serviceTypes = [];
- var serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION];
-
- for (var i = 0; i < serviceSubscriptions.length; i++) {
- serviceTypes.push({
- "name":serviceSubscriptions[i][FIELD.ID.SERVICETYPE],
- "isPermitted": serviceSubscriptions[i][FIELD.ID.IS_PERMITTED],
- "id": i
- });}
- successCallbackFunction(serviceTypes);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- }
- },
- getLcpCloudRegionTenantList : function(globalCustomerId, serviceType,
- successCallbackFunction) {
- $log
- .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: "
- + globalCustomerId);
- var url = COMPONENT.AAI_GET_TENANTS
- + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- var lcpCloudRegionTenants = [];
- var aaiLcpCloudRegionTenants = response.data;
-
- for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) {
- lcpCloudRegionTenants.push({
- "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID],
- "cloudOwner": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_OWNER],
- "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME],
- "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID],
- "isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED]});
- }
-
- successCallbackFunction(lcpCloudRegionTenants);
- }).catch(function(error) {
- (UtilityService.runHttpErrorHandler(error.data, error.status));
- })
- },
- getSubscribers : function(successCallbackFunction) {
- $log
- .debug("AaiService:getSubscribers");
- var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response.data.customer);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
- getProvOptionsFromSystemProp : function(successCallbackFunction) {
- $log
- .debug("AaiService:getProvOptionsFromSystemProp");
- var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH;
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
- getLoggedInUserID : function(successCallbackFunction, catchCallbackFunction) {
- $log
- .debug("AaiService:getLoggedInUserID");
- var url = COMPONENT.GET_USER_ID;
-
- $http.get(url,
- {
- transformResponse: [function (data) {
- return data;
- }],
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"] (function(response, status) {
- if (catchCallbackFunction) {
- catchCallbackFunction();
- }
- UtilityService.runHttpErrorHandler(response, status);
- })
- },
- getServices : function(successCallbackFunction) {
- $log
- .debug("AaiService:getServices");
- var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout: PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function (response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
-
- getAicZones: function (successCallbackFunction) {
- $log
- .debug("getAicZones:getAicZones");
- var url = COMPONENT.AAI_GET_AIC_ZONES +COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);},
- getAicZoneForPNF: function (globalCustomerId,serviceType,serviceInstanceId,successCallbackFunction) {
- $log
- .debug("getAicZones:getAicZones");
- var url = COMPONENT.AAI_GET_AIC_ZONE_FOR_PNF
- .replace('@serviceInstanceId', serviceInstanceId)
- .replace('@globalCustomerId', globalCustomerId)
- .replace('@serviceType', serviceType);
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- successCallbackFunction(response.data);
- })["catch"]
- (UtilityService.runHttpErrorHandler);},
-
- getServiceModels : function(globalCustomerId,serviceType,successCallbackFunction) {
- $log
- .debug("AaiService:getServices");
- var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH+globalCustomerId+ COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
- getServiceModelsByServiceType : function(namedQueryId,globalCustomerId,serviceType,successCallbackFunction) {
- $log
- .debug("AaiService:getServiceModelsByServiceType");
- var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE+COMPONENT.FORWARD_SLASH+namedQueryId+COMPONENT.FORWARD_SLASH+globalCustomerId+COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random();
-
- $http.get(url,
- {
- timeout : PropertyService
- .getServerResponseTimeoutMsec()
- }).then(function(response) {
- if (response.data) {
- successCallbackFunction(response);
- } else {
- successCallbackFunction([]);
- }
- })["catch"]
- (UtilityService.runHttpErrorHandler);
- },
-
- getVnfsByCustomerIdAndServiceType: function(globalSubscriberId, serviceType){
- var deferred = $q.defer();
-
- if (UtilityService.hasContents(globalSubscriberId) &&
- UtilityService.hasContents(serviceType) ) {
-
- $http.get(COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + globalSubscriberId + COMPONENT.FORWARD_SLASH
- + serviceType )
- .success(function (response) {
- if(response) {
- deferred.resolve({data: response});
- } else {
- deferred.resolve({data: []});
- }
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
- }
-
- return deferred.promise;
- },
-
- getVnfVersionsByInvariantId: function(modelInvariantId){
- var deferred = $q.defer();
-
- if (UtilityService.hasContents(modelInvariantId)) {
- var body = {"versions": modelInvariantId};
- $http.post(( COMPONENT.AAI_GET_VERSION_BY_INVARIANT_ID),body)
-
- .success(function (response) {
- if(response) {
- deferred.resolve({data: response});
- } else {
- deferred.resolve({data: []});
- }
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
- }
-
- return deferred.promise;
- },
-
-
-
- getSubscriberServiceTypes: function(subscriberUuid) {
- var deferred = $q.defer();
- $log.debug("AaiService:getSubscriberServiceTypes: subscriberUuid: " + subscriberUuid);
-
- if (UtilityService.hasContents(subscriberUuid)) {
- $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + subscriberUuid + COMPONENT.ASSIGN + Math.random())
- .success(function (response) {
- if(response && [FIELD.ID.SERVICE_SUBSCRIPTIONS]) {
- deferred.resolve({data: response[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]});
- } else {
- deferred.resolve({data: []});
- }
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
- }
-
- return deferred.promise;
- },
- getVnfInstancesList: function(globalSubscriberId, serviceType, modelVersionId ,modelInvariantId, cloudRegionId) {
- var deferred = $q.defer();
- $http.get([COMPONENT.AAI_GET_VNF_INSTANCES_LIST,
- globalSubscriberId,
- serviceType,
- modelVersionId,
- modelInvariantId,
- cloudRegionId]
- .join(COMPONENT.FORWARD_SLASH))
- .success(function (response) {
- deferred.resolve(response);
- }).error(function (data, status) {
- deferred.reject({message: data, status: status});
- });
- return deferred.promise;
- },
- getPnfInstancesList: function (globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegionId, equipVendor, equipModel) {
- var deferred = $q.defer();
- $http.get([COMPONENT.AAI_GET_PNF_INSTANCES_LIST,
- globalCustomerId, serviceType,
- modelVersionId, modelInvariantId,
- cloudRegionId,
- equipVendor, equipModel
- ].join(COMPONENT.FORWARD_SLASH))
- .success(function (response) {
- deferred.resolve(response);
- }).error(function (data, status) {
- deferred.reject({message: data, status: status});
- });
- return deferred.promise;
- },
- getByUri: function(uri) {
- var deferred = $q.defer();
-
- $http.get(COMPONENT.AAI_GET_BY_URI + uri)
- .success(function (response) {
- deferred.resolve({data: []});
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
- },
- getConfiguration: function(configurationId) {
- var deferred = $q.defer();
-
- $http.get(COMPONENT.AAI_GET_CONFIGURATION + configurationId)
- .success(function (response) {
- deferred.resolve({data: []});
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
- },
-
- getInstanceGroupsByVNFInstanceId: function (vnf_instance_id, successCallback, errorCallback) {
- var url = COMPONENT.AAI_GET_INSTANCE_GROUPS_BY_VNF_INSTANCE_ID_PATH + "/" + vnf_instance_id;
-
- $http.get(url, {}, {
- timeout: PropertyService.getServerResponseTimeoutMsec()
- }).then(function (response) {
- successCallback(response);
- }, function (response) {
- errorCallback(response);
- });
- },
-
- postPOMBAverificationRequest: function (url, data, config) {
- $http.post(url, data, config)
- .success(function (data, status, headers, config) {
- //If at some point in the future the result should be handled - this should be the entry point.
- log.debug("POMBA was called successfully with data: " + data);
- })
- .error(function (data, status, header, config) {
- log.debug("Error: " +
- "Data: " + data +
- "status: " + status +
- "headers: " + header +
- "config: " + config);
- });
- },
-
- getHomingData: function(vnfInstanceId, vfModuleId) {
- var url = COMPONENT.AAI_GET_HOMING_DATA.replace('@vnfInstanceId', vnfInstanceId)
- .replace('@vfModuleId', vfModuleId);
-
- var deferred = $q.defer();
-
- $http.get(url)
- .success(function (response) {
- deferred.resolve({data: response});
- }).error(function (data, status, headers, config) {
- deferred.reject({message: data, status: status});
- });
-
- return deferred.promise;
-
- }
- };
-};
-
-appDS2.factory("AaiService", ["$http", "$log", "PropertyService",
- "UtilityService", "COMPONENT", "FIELD", "$q", "featureFlags", AaiService]);
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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=========================================================
+ */
+
+"use strict";
+
+var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONENT, FIELD, $q, featureFlags) {
+
+ function getServiceInstance(serviceInstanceIdentifier, findBy) {
+ serviceInstanceIdentifier.trim();
+
+ return $http.get(COMPONENT.AAI_GET_SERVICE_INSTANCE_PATH + serviceInstanceIdentifier + "/" + findBy + "?r=" + Math.random(), {}, {
+ timeout: PropertyService.getServerResponseTimeoutMsec()
+ });
+ }
+
+ function getPnfByName(pnfName) {
+ var deferred = $q.defer();
+ var url = COMPONENT.AAI_GET_PNF_BY_NAME+ encodeURIComponent(pnfName) ;
+ var config = { timeout: PropertyService.getServerResponseTimeoutMsec() };
+
+ $http.get(url, config)
+ .success(function (response) {
+ deferred.resolve({data: response});
+ })
+ .error(function(data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+
+ return deferred.promise;
+ }
+ function getGlobalCustomerIdFromServiceInstanceResponse(response) {
+ var globalCustomerId = "";
+ if (angular.isArray(response.data[FIELD.ID.RESULT_DATA])) {
+ var customerIndex = 5;
+ var customerIdIndex = 6;
+ var itemIndex = 0;
+
+ var item = response.data[FIELD.ID.RESULT_DATA][itemIndex];
+ var url = item[FIELD.ID.RESOURCE_LINK];
+ var urlParts = url.split("/");
+ if (urlParts[customerIndex] === FIELD.ID.CUSTOMER) {
+ globalCustomerId = urlParts[customerIdIndex];
+ }
+ }
+ return globalCustomerId;
+ }
+
+ function searchServiceInstances(query) {
+ return $http.get( COMPONENT.SEARCH_SERVICE_INSTANCES + query, {}, {
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function (response) {
+ var displayData = response.data[FIELD.ID.SERVICE_INSTANCES];
+ if (!displayData || !displayData.length) {
+ displayData = [{
+ globalCustomerId : null,
+ subscriberName : null,
+ serviceType : FIELD.PROMPT.NO_SERVICE_SUB,
+ serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE
+ }];
+ }
+ return {displayData: displayData};
+ });
+ };
+
+ function getJoinedQueryString(queries) {
+ return queries.filter(function (val) {return val;}).join("&");
+ }
+
+ return {
+ getSubscriberName : function(globalCustomerId,
+ successCallbackFunction) {
+ $log
+ .debug("AaiService:getSubscriberName: globalCustomerId: "
+ + globalCustomerId);
+ $http.get(
+ COMPONENT.AAI_SUB_DETAILS_PATH
+ + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ var result = {};
+ if (response.data) {
+ result.subscriberName = response.data[FIELD.ID.SUBNAME];
+ result.serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS];
+ }
+ successCallbackFunction(result);
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+
+ runNamedQuery : function (namedQueryId, globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
+
+ var url = COMPONENT.AAI_SUB_VIEWEDIT_PATH +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(namedQueryId) +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
+ return $http.get(url, {}, {
+
+
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data != null) {
+ successCallback(response);
+ } else {
+ errorCallback(response);
+ }
+ }, function(response) {
+ errorCallback(response);
+ });
+ },
+
+
+ getVNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
+
+ var url = COMPONENT.AAI_GET_VNF_INFO +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
+ $http.get(url, {}, {
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data != null) {
+ successCallback(response);
+ } else {
+ errorCallback(response);
+ }
+ }, function(response) {
+ errorCallback(response);
+ });
+ },
+
+ getPNFInformationByServiceTypeAndId : function (globalCustomerId, serviceType, serviceInstanceId, successCallback, errorCallback) {
+
+ var url = COMPONENT.AAI_GET_PNF_INSTANCE +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(globalCustomerId) +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceType) +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
+ $http.get(url, {}, {
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data != null) {
+ successCallback(response);
+ } else {
+ errorCallback(response);
+ }
+ }, function(response) {
+ errorCallback(response);
+ });
+ },
+
+ getCRInformationByInstanceId : function (serviceInstanceId) {
+
+ var deferred = $q.defer();
+
+ var url = COMPONENT.AAI_GET_CR_INSTANCE +
+ COMPONENT.FORWARD_SLASH + encodeURIComponent(serviceInstanceId);
+ $http.get(url, {}, {
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data != null) {
+ deferred.resolve(response);
+ } else {
+ deferred.resolve(response);
+ }
+ }, function(response) {
+ deferred.resolve(response);
+ });
+ return deferred.promise;
+ },
+
+ searchServiceInstances: searchServiceInstances,
+
+ getModelVersionId: function (subscriberId, instanceId) {
+ var globalCustomerIdQuery = COMPONENT.SELECTED_SUBSCRIBER_SUB_PATH + subscriberId;
+ var serviceInstanceQuery = COMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH + instanceId;
+
+ var query = "?" + getJoinedQueryString([globalCustomerIdQuery, serviceInstanceQuery]);
+
+ var deferred = $q.defer();
+
+ searchServiceInstances(query).then(function (response) {
+ var displayData = response.displayData;
+ if (displayData[0] && displayData[0].aaiModelVersionId) {
+ deferred.resolve(displayData[0].aaiModelVersionId);
+ } else {
+ deferred.reject(FIELD.ERROR.MODEL_VERSION_ID_MISSING);
+ }
+ }).catch(function (err) {
+ deferred.reject(err);
+ });
+
+ return deferred.promise;
+ },
+
+ getSubDetails : function(selectedSubscriber, selectedServiceInstance, successCallback, errorCallback) {
+ var subscriber;
+ var displayData;
+ $http.get( COMPONENT.AAI_SUB_DETAILS_PATH + selectedSubscriber, {}, {
+
+
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ displayData = [];
+ subscriber = response.data;
+ var subscriberName = subscriber[FIELD.ID.SUBNAME];
+ if (subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {
+ angular.forEach(subscriber[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {
+ var serviceInstanceId = [];
+ var serviceType = "";
+ if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {
+ serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];
+ } else {
+ serviceType = FIELD.PROMPT.NO_SERVICE_SUB;
+ }
+ if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {
+ angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {
+ // put them together, i guess
+ var inst = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID],
+ "aaiModelInvariantId": instValue[FIELD.ID.MODEL_INVAR_ID],
+ "aaiModelVersionId": instValue[FIELD.ID.MODEL_VERSION_ID],
+ "serviceInstanceName": instValue[FIELD.ID.SERVICE_INSTANCE_NAME]
+ };
+ if (selectedServiceInstance != null) {
+ if ((instValue[FIELD.ID.SERVICE_INSTANCE_ID] == selectedServiceInstance ) || (instValue[FIELD.ID.SERVICE_INSTANCE_NAME] == selectedServiceInstance)) {
+ serviceInstanceId.push(inst);
+ }
+ } else {
+ serviceInstanceId.push(inst);
+ }
+ });
+ } else {
+ serviceInstanceId = [ FIELD.PROMPT.NO_SERVICE_INSTANCE ];
+ }
+ angular.forEach(serviceInstanceId, function(subVal, subKey) {
+ displayData.push({
+ globalCustomerId : selectedSubscriber,
+ subscriberName : subscriberName,
+ serviceType : serviceType,
+ serviceInstanceId : subVal.serviceInstanceId,
+ aaiModelInvariantId : subVal.aaiModelInvariantId,
+ aaiModelVersionId
+ : subVal.aaiModelVersionId,
+ serviceInstanceName : subVal.serviceInstanceName,
+ isPermitted: serviceSubscription[FIELD.ID.IS_PERMITTED]
+ });
+ });
+ });
+ } else {
+ displayData.push({
+ globalCustomerId : selectedSubscriber,
+ subscriberName : subscriberName,
+ serviceType : FIELD.PROMPT.NO_SERVICE_SUB,
+ serviceInstanceId : FIELD.PROMPT.NO_SERVICE_INSTANCE
+ });
+ }
+ successCallback(displayData, subscriberName);
+ }, function(response) {
+ errorCallback(response);});
+ },
+
+ getSubList : function(successCallback, errorCallback ) {
+
+ $http.get( FIELD.ID.AAI_GET_FULL_SUBSCRIBERS, {}, {
+
+
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ var customerList = [];
+ if (response.data.customer != null) {
+ angular.forEach(response.data.customer, function(subVal, subKey) {
+ var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME],
+ "isPermitted": subVal[FIELD.ID.IS_PERMITTED], };
+ customerList.push(cust);
+ });
+ successCallback(customerList);
+ } else {
+ errorCallback(response);
+ }
+ },function(response) {
+ errorCallback(response);
+ });
+ },
+
+ getServiceInstance : getServiceInstance,
+ getPnfByName : getPnfByName,
+
+ getGlobalCustomerIdByInstanceIdentifier : function(serviceInstanceIdentifier, findBy) {
+ serviceInstanceIdentifier.trim();
+
+ return getServiceInstance(serviceInstanceIdentifier, findBy)
+ .then(function (response) {
+ return getGlobalCustomerIdFromServiceInstanceResponse(response);
+ });
+ },
+
+ getMultipleValueParamQueryString: function(values, paramSubPath) {
+ if (values.length) {
+ return paramSubPath + values.filter(function (val) {return val;}).join("&" + paramSubPath);
+ }
+ },
+
+ getJoinedQueryString: getJoinedQueryString,
+
+ getServices2 : function(successCallback, errorCallback ) {
+
+ $http.get( FIELD.ID.AAI_GET_SERVICES, {}, {
+
+
+ timeout : PropertyService.getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ var customerList = [];
+ if (response.data != null) {
+ var serviceIdList = [];
+ angular.forEach(response.data, function(value, key) {
+ angular.forEach(value, function(subVal, key) {
+ var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] ,
+ "isPermitted" : subVal[FIELD.ID.IS_PERMITTED]
+
+ };serviceIdList.push(newVal);
+ });
+ });
+ successCallback(serviceIdList);
+ } else {
+ errorCallback(response);
+ }
+ },function(response) {
+ errorCallback(response);
+ });
+ },
+
+ getPortMirroringData: function (ids) {
+ var defer = $q.defer();
+
+ var url = COMPONENT.AAI_GET_PORT_MIRRORING_CONFIGS_DATA + '?configurationIds=' + ids.join(',');
+ $http.get(url).then(function (res) {
+ defer.resolve(res);
+ }).catch(function (err) {
+ $log.error(err);
+ defer.resolve({});
+ });
+
+ return defer.promise;
+
+ },
+
+ getPortMirroringSourcePorts : function (ids) {
+ var defer = $q.defer();
+ var url = COMPONENT.AAI_GET_PORT_MIRRORING_SOURCE_PORTS +'?configurationIds=' + ids.join(',');
+ $http.get(url).then(function(res){
+ defer.resolve(res);
+ }).catch(function(err) {
+ $log.error(err);
+ defer.resolve({});
+ });
+ return defer.promise;
+ },
+
+ getVlansByNetworksMapping : function (globalCustomerId, serviceType, serviceInstanceId, sdcModelUuid) {
+ var defer = $q.defer();
+ if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS)) {
+ var url = COMPONENT.AAI_GET_PROVIDER_NETWORKS_ASSOCIATIONS + '?'
+ + 'globalCustomerId=' + globalCustomerId
+ + '&serviceType=' + serviceType
+ + '&serviceInstanceId=' + serviceInstanceId
+ + '&sdcModelUuid=' + sdcModelUuid
+ ;
+
+ $http.get(url).then(function(res){
+ defer.resolve(res.data);
+ }).catch(function(err) {
+ $log.error(err);
+ defer.resolve({});
+ });
+
+ } else {
+ defer.resolve({});
+ }
+ return defer.promise;
+ },
+
+ getSubscriptionServiceTypeList : function(globalCustomerId,
+ successCallbackFunction) {
+ $log
+ .debug("AaiService:getSubscriptionServiceTypeList: globalCustomerId: "
+ + globalCustomerId);
+ if ( UtilityService.hasContents(globalCustomerId) ) {
+ $http.get(
+ COMPONENT.AAI_SUB_DETAILS_PATH
+ + globalCustomerId + COMPONENT.ASSIGN + Math.random(),
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data && response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS]) {
+ var serviceTypes = [];
+ var serviceSubscriptions = response.data[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION];
+
+ for (var i = 0; i < serviceSubscriptions.length; i++) {
+ serviceTypes.push({
+ "name":serviceSubscriptions[i][FIELD.ID.SERVICETYPE],
+ "isPermitted": serviceSubscriptions[i][FIELD.ID.IS_PERMITTED],
+ "id": i
+ });}
+ successCallbackFunction(serviceTypes);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ }
+ },
+ getLcpCloudRegionTenantList : function(globalCustomerId, serviceType,
+ successCallbackFunction) {
+ $log
+ .debug("AaiService:getLcpCloudRegionTenantList: globalCustomerId: "
+ + globalCustomerId);
+ var url = COMPONENT.AAI_GET_TENANTS
+ + globalCustomerId + COMPONENT.FORWARD_SLASH + serviceType + COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ var lcpCloudRegionTenants = [];
+ var aaiLcpCloudRegionTenants = response.data;
+
+ for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) {
+ lcpCloudRegionTenants.push({
+ "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID],
+ "cloudOwner": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_OWNER],
+ "tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME],
+ "tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID],
+ "isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED]});
+ }
+
+ successCallbackFunction(lcpCloudRegionTenants);
+ }).catch(function(error) {
+ (UtilityService.runHttpErrorHandler(error.data, error.status));
+ })
+ },
+ getSubscribers : function(successCallbackFunction) {
+ $log
+ .debug("AaiService:getSubscribers");
+ var url = FIELD.ID.AAI_GET_SUBSCRIBERS + COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response.data.customer);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+ getProvOptionsFromSystemProp : function(successCallbackFunction) {
+ $log
+ .debug("AaiService:getProvOptionsFromSystemProp");
+ var url = COMPONENT.GET_SYSTEM_PROP_VNF_PROV_STATUS_PATH;
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+ getLoggedInUserID : function(successCallbackFunction, catchCallbackFunction) {
+ $log
+ .debug("AaiService:getLoggedInUserID");
+ var url = COMPONENT.GET_USER_ID;
+
+ $http.get(url,
+ {
+ transformResponse: [function (data) {
+ return data;
+ }],
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"] (function(response, status) {
+ if (catchCallbackFunction) {
+ catchCallbackFunction();
+ }
+ UtilityService.runHttpErrorHandler(response, status);
+ })
+ },
+ getServices : function(successCallbackFunction) {
+ $log
+ .debug("AaiService:getServices");
+ var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout: PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function (response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+
+ getAicZones: function (successCallbackFunction) {
+ $log
+ .debug("getAicZones:getAicZones");
+ var url = COMPONENT.AAI_GET_AIC_ZONES +COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);},
+ getAicZoneForPNF: function (globalCustomerId,serviceType,serviceInstanceId,successCallbackFunction) {
+ $log
+ .debug("getAicZones:getAicZones");
+ var url = COMPONENT.AAI_GET_AIC_ZONE_FOR_PNF
+ .replace('@serviceInstanceId', serviceInstanceId)
+ .replace('@globalCustomerId', globalCustomerId)
+ .replace('@serviceType', serviceType);
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ successCallbackFunction(response.data);
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);},
+
+ getServiceModels : function(globalCustomerId,serviceType,successCallbackFunction) {
+ $log
+ .debug("AaiService:getServices");
+ var url = COMPONENT.AAI_GET_SERVICES + COMPONENT.FORWARD_SLASH+globalCustomerId+ COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+ getServiceModelsByServiceType : function(namedQueryId,globalCustomerId,serviceType,successCallbackFunction) {
+ $log
+ .debug("AaiService:getServiceModelsByServiceType");
+ var url = COMPONENT.AAI_GET_SERVICES_BY_TYPE+COMPONENT.FORWARD_SLASH+namedQueryId+COMPONENT.FORWARD_SLASH+globalCustomerId+COMPONENT.FORWARD_SLASH +serviceType+COMPONENT.ASSIGN + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+ if (response.data) {
+ successCallbackFunction(response);
+ } else {
+ successCallbackFunction([]);
+ }
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+ },
+
+ getVnfsByCustomerIdAndServiceType: function(globalSubscriberId, serviceType){
+ var deferred = $q.defer();
+
+ if (UtilityService.hasContents(globalSubscriberId) &&
+ UtilityService.hasContents(serviceType) ) {
+
+ $http.get(COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + globalSubscriberId + COMPONENT.FORWARD_SLASH
+ + serviceType )
+ .success(function (response) {
+ if(response) {
+ deferred.resolve({data: response});
+ } else {
+ deferred.resolve({data: []});
+ }
+ }).error(function (data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+ }
+
+ return deferred.promise;
+ },
+
+ getVnfVersionsByInvariantId: function(modelInvariantId){
+ var deferred = $q.defer();
+
+ if (UtilityService.hasContents(modelInvariantId)) {
+ var body = {"versions": modelInvariantId};
+ $http.post(( COMPONENT.AAI_GET_VERSION_BY_INVARIANT_ID),body)
+
+ .success(function (response) {
+ if(response) {
+ deferred.resolve({data: response});
+ } else {
+ deferred.resolve({data: []});
+ }
+ }).error(function (data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+ }
+
+ return deferred.promise;
+ },
+
+
+
+ getSubscriberServiceTypes: function(subscriberUuid) {
+ var deferred = $q.defer();
+ $log.debug("AaiService:getSubscriberServiceTypes: subscriberUuid: " + subscriberUuid);
+
+ if (UtilityService.hasContents(subscriberUuid)) {
+ $http.get(COMPONENT.AAI_SUB_DETAILS_PATH + subscriberUuid + COMPONENT.ASSIGN + Math.random())
+ .success(function (response) {
+ if(response && [FIELD.ID.SERVICE_SUBSCRIPTIONS]) {
+ deferred.resolve({data: response[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION]});
+ } else {
+ deferred.resolve({data: []});
+ }
+ }).error(function (data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+ }
+
+ return deferred.promise;
+ },
+ getVnfInstancesList: function(globalSubscriberId, serviceType, modelVersionId ,modelInvariantId, cloudRegionId) {
+ var deferred = $q.defer();
+ $http.get([COMPONENT.AAI_GET_VNF_INSTANCES_LIST,
+ globalSubscriberId,
+ serviceType,
+ modelVersionId,
+ modelInvariantId,
+ cloudRegionId]
+ .join(COMPONENT.FORWARD_SLASH))
+ .success(function (response) {
+ deferred.resolve(response);
+ }).error(function (data, status) {
+ deferred.reject({message: data, status: status});
+ });
+ return deferred.promise;
+ },
+ getPnfInstancesList: function (globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegionId, equipVendor, equipModel) {
+ var deferred = $q.defer();
+ $http.get([COMPONENT.AAI_GET_PNF_INSTANCES_LIST,
+ globalCustomerId, serviceType,
+ modelVersionId, modelInvariantId,
+ cloudRegionId,
+ equipVendor, equipModel
+ ].join(COMPONENT.FORWARD_SLASH))
+ .success(function (response) {
+ deferred.resolve(response);
+ }).error(function (data, status) {
+ deferred.reject({message: data, status: status});
+ });
+ return deferred.promise;
+ },
+ getByUri: function(uri) {
+ var deferred = $q.defer();
+
+ $http.get(COMPONENT.AAI_GET_BY_URI + uri)
+ .success(function (response) {
+ deferred.resolve({data: []});
+ }).error(function (data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+
+ return deferred.promise;
+ },
+ getConfiguration: function(configurationId) {
+ var deferred = $q.defer();
+
+ $http.get(COMPONENT.AAI_GET_CONFIGURATION + configurationId)
+ .success(function (response) {
+ deferred.resolve({data: []});
+ }).error(function (data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+
+ return deferred.promise;
+ },
+
+ getInstanceGroupsByVNFInstanceId: function (vnf_instance_id, successCallback, errorCallback) {
+ var url = COMPONENT.AAI_GET_INSTANCE_GROUPS_BY_VNF_INSTANCE_ID_PATH + "/" + vnf_instance_id;
+
+ $http.get(url, {}, {
+ timeout: PropertyService.getServerResponseTimeoutMsec()
+ }).then(function (response) {
+ successCallback(response);
+ }, function (response) {
+ errorCallback(response);
+ });
+ },
+
+ postPOMBAverificationRequest: function (url, data, config) {
+ $http.post(url, data, config)
+ .success(function (data, status, headers, config) {
+ //If at some point in the future the result should be handled - this should be the entry point.
+ log.debug("POMBA was called successfully with data: " + data);
+ })
+ .error(function (data, status, header, config) {
+ log.debug("Error: " +
+ "Data: " + data +
+ "status: " + status +
+ "headers: " + header +
+ "config: " + config);
+ });
+ },
+
+ getHomingData: function(vnfInstanceId, vfModuleId) {
+ var url = COMPONENT.AAI_GET_HOMING_DATA.replace('@vnfInstanceId', vnfInstanceId)
+ .replace('@vfModuleId', vfModuleId);
+
+ var deferred = $q.defer();
+
+ $http.get(url)
+ .success(function (response) {
+ deferred.resolve({data: response});
+ }).error(function (data, status, headers, config) {
+ deferred.reject({message: data, status: status});
+ });
+
+ return deferred.promise;
+
+ },
+
+ removeVendorFromCloudOwner: function(cloudOwner) {
+ // Handle the case where cloud owner is formatted
+ // like "{vendor}-{cloud-name}"
+ return cloudOwner.trim().replace(/^[^-]*-/, '');
+ }
+ };
+};
+
+appDS2.factory("AaiService", ["$http", "$log", "PropertyService",
+ "UtilityService", "COMPONENT", "FIELD", "$q", "featureFlags", AaiService]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
index 45aedd1a1..2a06e75b1 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
@@ -45,7 +45,8 @@
return $http.get(COMPONENT.GET_SO_WORKFLOWS, {params: {vnfName: vnfNames}})
.success(function (response) {
return {data: response};
- }).catch(function () {
+ }).catch(function (ex) {
+ console.error("Problem when getting workflows from SO API occurred.", ex.stack);
return {data: []};
});
};
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js
index 739a17912..d5fd32001 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js
@@ -1,1299 +1,1299 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 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=========================================================
- */
-
-"use strict";
-
-/*
- * "CreationService" isolates the "component-specific" logic required by the
- * "CreationDialog" controller.
- *
- * "Components" are defined as the 5 element types managed by the dialogs: A)
- * Service B) VNF C) VF Module D) Volume Group and E) Network.
- *
- */
-
-var CreationService = function($log, AaiService, AsdcService, DataService,VIDCONFIGURATION,
- ComponentService, COMPONENT, FIELD, PARAMETER, UtilityService, OwningEntityService,featureFlags) {
-
- var _this = this;
- var getAsyncOperationList = function() {
- if (DataService.getLoggedInUserId() == null) {
- getLoggedInUserID();
- } else {
- UtilityService.startNextAsyncOperation();
- }
- switch (_this.componentId) {
- case COMPONENT.SERVICE:
- return [ getSubscribers, getServices, getAicZones, getOwningEntityProperties ];
- case COMPONENT.NETWORK:
- return [ getLcpCloudRegionTenantList, getOwningEntityProperties ];
- case COMPONENT.VNF:
- return [ getLcpCloudRegionTenantList, getOwningEntityProperties ];
- case COMPONENT.VF_MODULE:
- return [ getLcpCloudRegionTenantList ];
- case COMPONENT.VOLUME_GROUP:
- return [ getLcpCloudRegionTenantList ];
- }
- };
-
- /*
- * "getSummaryList" and "getUserProvidedList" return parameters that should
- * be displayed in the summary and user provided sections, respectively. The
- * functions are expected to return lists that are in the format needed by
- * the parameter-block directive.
- */
-
- var getSummaryList = function() {
-
- /*
- * These placeholders should be removed and their usage in
- * "getSummaryList" should be replaced by appropriate code as the
- * requirements and interfaces firm up.
- */
-
- var PLACEHOLDER_RESOURCE_DESCRIPTION = "Resource Description (PLACEHOLDER)";
- var PLACEHOLDER_SERVICE_CATEGORY = "Service Category (PLACEHOLDER)";
- var PLACEHOLDER_VF_MODULE_DESCRIPTION = "VF Module Description (PLACEHOLDER)";
- var PLACEHOLDER_VF_MODULE_LABEL = "VF Module Label (PLACEHOLDER)";
- var PLACEHOLDER_VF_MODULE_TYPE = "VF Module Type (PLACEHOLDER)";
-
- _this.parameterList = new Array();
-
- /*
- * Common fields displayed at the top of all create instance screens.
- */
- if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]==null
- || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==undefined
- || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==''){
- addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
- }
-
- switch (_this.componentId) {
- case COMPONENT.SERVICE:
- if ( !DataService.getALaCarte() ) {
- // for macro instantiation need to add the resource names under the node template list
- // this field is called modelCustomizationName in the asdc client code
- var p;
- var rlist = DataService.getResources();
- var res;
- if ( rlist != null ) {
- for (var i = 0; i < rlist.length; i++) {
- res = rlist[i];
-
- p = FIELD.NAME.RESOURCE_NAME.concat(" " + (i+1));
- addToList(p, res.name );
- p = FIELD.NAME.RESOURCE_DESCRIPTION.concat(" " + (i+1));
- addToList(p, res.description );
- }
- }
- }
- if(DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=null && DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=''){
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getModelInfo(_this.componentId)["createSubscriberName"]);
- }
- if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=null && DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=''){
- addToList(FIELD.NAME.SERVICE_TYPE, DataService
- .getModelInfo(_this.componentId)["serviceTypeName"]);
- addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
- }
- addToList(FIELD.NAME.SERVICE_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.SERVICE_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.SERVICE_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.SERVICE_DESCRIPTION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.DESCRIPTION]);
- addToList(FIELD.NAME.SERVICE_CATEGORY, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CATEGORY]);
- if (DataService.getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE] != "null") {
- addToList(FIELD.NAME.SERVICE_TYPE, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE]);
- addToList(FIELD.NAME.SERVICE_ROLE, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_ROLE]);
- }
-
- break;
- case COMPONENT.VF_MODULE:
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getSubscriberName());
- addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
- .getServiceInstanceName());
- addToList(FIELD.NAME.MODEL_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
- addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.MODEL_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.MODEL_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
- break;
- case COMPONENT.VNF:
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getSubscriberName());
- addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
- .getServiceInstanceName());
- addToList(FIELD.NAME.MODEL_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
- addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.MODEL_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.MODEL_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_CUSTOMIZATION_NAME]);
- addToList(FIELD.NAME.MODEL_VNF_TYPE, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_TYPE]);
- addToList(FIELD.NAME.MODEL_VNF_ROLE, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_ROLE]);
- addToList(FIELD.NAME.MODEL_VNF_FUNCTION, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_FUNCTION]);
- addToList(FIELD.NAME.MODEL_VNF_CODE, DataService
- .getModelInfo(_this.componentId)[COMPONENT.VNF_CODE]);
- break;
- case COMPONENT.NETWORK:
- case COMPONENT.VOLUME_GROUP:
- addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
- .getSubscriberName());
- addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
- .getServiceInstanceName());
- addToList(FIELD.NAME.MODEL_NAME, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
- addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
- addToList(FIELD.NAME.MODEL_VERSION, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
- addToList(FIELD.NAME.MODEL_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
- addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
- .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
- break;
- }
-
- return _this.parameterList;
- };
-
- var getUserProvidedList = function() {
- var parameterList = [];
- var isUserProvidedNaming = false;
- if ( ((DataService.getModelInfo(_this.componentId).serviceEcompNaming != null)
- && (DataService.getModelInfo(_this.componentId).serviceEcompNaming === "false")) || DataService.getE2EService() ) {
- isUserProvidedNaming = true;
- }
-
- var isInTop = DataService.getHideServiceFields() || false;
- if (_this.componentId === COMPONENT.SERVICE) {
- if ( DataService.getALaCarte() ) {
- parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
- if(!isInTop){
- parameterList = parameterList.concat([ getSubscribersParameter(),
- FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
- }
- }
- else {
- // macro
-
- if(!isInTop){
- if (isUserProvidedNaming) {
- parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
-
- }
- parameterList = parameterList.concat([ getSubscribersParameter() ]);
- parameterList = parameterList.concat([ getServiceId(),
- FIELD.PARAMETER.SERVICE_TYPE,
- FIELD.PARAMETER.LCP_REGION,
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED
- ]);
- if(!DataService.getE2EService()) {
- parameterList = parameterList.concat([getAicZonesParameter()]);
- }
-
- }else{
- parameterList = parameterList.concat([ getServiceId(),
- FIELD.PARAMETER.LCP_REGION,
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED ]);
- }
- }
-
- if(!DataService.getE2EService()) {
- parameterList = parameterList.concat([getProjectParameter()]);
- parameterList = parameterList.concat([getOwningEntityParameter()]);
- }
-
- //if service model has a pnf, add a PNF ID parameter
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PNP_INSTANTIATION) && DataService.getPnf()) {
- parameterList = parameterList.concat([ FIELD.PARAMETER.PNF_ID ]);
- }
- }
- else {
- parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
- switch (_this.componentId) {
- case COMPONENT.NETWORK:
- case COMPONENT.VNF:
- parameterList = parameterList.concat([ getServiceId(),
- getLcpRegionParameter(), FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED ]);
- parameterList = parameterList.concat([ getLineOfBusinessParameter() ]);
- parameterList = parameterList.concat([ getPlatformParameter() ]);
-
- break;
- case COMPONENT.VF_MODULE:
- parameterList = parameterList.concat([
- getLcpRegionParameter(),
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED
- ]);
-
- var availableVolumeGroupList = DataService.getAvailableVolumeGroupList();
-
- if (availableVolumeGroupList && availableVolumeGroupList.length > 0) {
- var availableVolumeGroupNames = [FIELD.STATUS.NONE];
-
- for (var i = 0; i < availableVolumeGroupList.length; i++) {
- availableVolumeGroupNames.push(availableVolumeGroupList[i].instance.name);
- }
-
- parameterList.push(addOptionList(
- FIELD.PARAMETER.AVAILABLE_VOLUME_GROUP,
- availableVolumeGroupNames));
- }
- break;
- case COMPONENT.VOLUME_GROUP:
- parameterList = parameterList.concat([ getLcpRegionParameter(),
- FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
- FIELD.PARAMETER.TENANT_DISABLED ]);
- }
- }
- parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK);
- if(_this.componentId === COMPONENT.VF_MODULE ){
- parameterList.push({name: FIELD.NAME.SDN_C_PRELOAD,
- id: FIELD.ID.SDN_C_PRELOAD,
- type: "checkbox",
- isEnabled: true,
- isRequired: false,
- hideFieldAndLabel: true
- }
- );
- parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- type: "checkbox",
- isEnabled: true,
- isRequired: false,
- value:false
- }
- );
-
- parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.SUPPLEMENTORY_DATA_FILE,
- type: "file",
- isRequired: false,
- isVisiblity: false
- }
- );
- }
-
- if( VIDCONFIGURATION.UPLOAD_SUPPLEMENTARY_STATUS_CHECK_ENABLED && _this.componentId === COMPONENT.VOLUME_GROUP){
- parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE,
- type: "checkbox",
- isEnabled: true,
- isRequired: false
- }
- );
-
- parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE,
- id: FIELD.ID.SUPPLEMENTORY_DATA_FILE,
- type: "file",
- isRequired: false,
- isVisiblity: false
- }
- );
- }
-
- addArbitraryParameters(parameterList);
-
- return parameterList;
- };
-
- var addArbitraryParameters = function(parameterList) {
- if ( DataService.getModelInfo(_this.componentId).displayInputs != null ) {
- var inputs = DataService.getModelInfo(_this.componentId).displayInputs;
- for ( var key in inputs) {
- var parameter = {
- id : key,
- type : PARAMETER.STRING,
- name : ComponentService.getFieldDisplayName(key),
- value : inputs[key][PARAMETER.DEFAULT],
- isRequired : inputs[key][PARAMETER.REQUIRED],
- description : inputs[key][PARAMETER.DESCRIPTION]
- };
- if ( DataService.getALaCarte() ) {
- parameter.name = ComponentService.getFieldDisplayName(inputs[key][PARAMETER.DISPLAY_NAME]);
- }
- switch (inputs[key][PARAMETER.TYPE]) {
- case PARAMETER.INTEGER:
- parameter.type = PARAMETER.NUMBER;
- break;
- case PARAMETER.BOOLEAN:
- parameter.type = PARAMETER.BOOLEAN;
- break;
- case PARAMETER.RANGE:
- break;
- case PARAMETER.LIST:
- parameter.type = PARAMETER.LIST;
- break;
- case PARAMETER.MAP:
- parameter.type = PARAMETER.MAP;
- break;
- }
-
- if ( UtilityService.hasContents(inputs[key][PARAMETER.CONSTRAINTS])
- && ( inputs[key][PARAMETER.CONSTRAINTS].length > 0 ) ) {
- var constraintsArray = inputs[key][PARAMETER.CONSTRAINTS];
- //console.log ("Calling addConstraintParameters for input name=" + key);
- addConstraintParameters (parameterList, constraintsArray, key, inputs, parameter);
- }
- else {
-
- parameterList.push(parameter);
- }
- }
- DataService.setArbitraryParameters (parameterList);
- }
- };
-
- var addConstraintParameters = function(parameterList, constraintsArray, key, inputs, parameter) {
- // If there are constraints and the operator is "valid_values",
- // use a select parameter type.
- var i = constraintsArray.length;
- var parameterPushed = false;
- if ( i > 0 ) {
- while ( (i--) && (!parameterPushed) ) {
- var keys = Object.keys(constraintsArray[i]);
- //var keys_len = keys.length;
- for ( var operator in keys ) {
- //console.log ("keys[operator]=" + keys[operator]);
- switch (keys[operator]) {
- case PARAMETER.VALID_VALUES:
- var j = constraintsArray[i][PARAMETER.VALID_VALUES].length;
- if ( j > 0 ) {
- var oList = [];
- var option;
- while (j--) {
- option = {
- name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
- isDefault: false
- }
- if ( ( UtilityService.hasContents (inputs[key][PARAMETER.DEFAULT]) )
- && (inputs[key][PARAMETER.DEFAULT] === constraintsArray[i][PARAMETER.VALID_VALUES][j] ) ) {
- option = {
- name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
- isDefault: true
- }
- }
- oList.push(option);
- }
- parameter.type = PARAMETER.SELECT;
- parameter.optionList = oList;
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for valid values");
- }
- break;
-
- case PARAMETER.EQUAL:
- if ( constraintsArray[i][PARAMETER.EQUAL] != null ) {
- //override parameter type
- parameter.type = PARAMETER.STRING;
- parameter.isReadOnly = true;
- parameter.value = constraintsArray[i][PARAMETER.EQUAL];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for equal");
- }
- break;
-
- case PARAMETER.LENGTH:
- if ( constraintsArray[i][PARAMETER.LENGTH] != null ) {
- parameter.minLength = constraintsArray[i][PARAMETER.LENGTH];
- parameter.maxLength = constraintsArray[i][PARAMETER.LENGTH];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for length: ");
- //console.log (JSON.stringify (parameter, null, 4));
- }
- break;
- case PARAMETER.MAX_LENGTH:
- if ( constraintsArray[i][PARAMETER.MAX_LENGTH] != null ) {
- parameter.maxLength = constraintsArray[i][PARAMETER.MAX_LENGTH];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for max length: ");
- //console.log (JSON.stringify (parameter, null, 4));
- }
- break;
- case PARAMETER.MIN_LENGTH:
- if ( constraintsArray[i][PARAMETER.MIN_LENGTH] != null ) {
- parameter.minLength = constraintsArray[i][PARAMETER.MIN_LENGTH];
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for min length: ");
- //console.log (JSON.stringify (parameter, null, 4));
- }
- break;
- case PARAMETER.IN_RANGE:
- if ( constraintsArray[i][PARAMETER.IN_RANGE] != null ) {
- if (constraintsArray[i][PARAMETER.IN_RANGE].length > 1 ) {
- parameter.min = constraintsArray[i][PARAMETER.IN_RANGE][0];
- parameter.max = constraintsArray[i][PARAMETER.IN_RANGE][1];
- parameter.type = PARAMETER.NUMBER;
- parameter.value = inputs[key][PARAMETER.DEFAULT]
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for in_range");
- }
- }
- break;
- case PARAMETER.GREATER_THAN:
- if ( constraintsArray[i][PARAMETER.GREATER_THAN] != null ) {
- parameter.type = PARAMETER.NUMBER;
- parameter.min = constraintsArray[i][PARAMETER.GREATER_THAN];
- parameter.value = inputs[key][PARAMETER.DEFAULT]
- parameterList.push(parameter);
- parameterPushed = true;
- //console.log ("pushed param for greater_than");
-
- }
- break;
- }//switch
- }//for
-
- }//while
- }//if
- };
- var addToList = function(name, value) {
- _this.parameterList.push({
- name : name,
- value : value
- });
- };
- var setInventoryInfo = function(){
- var inventoryItem = DataService.getInventoryItem();
- var inventoryInfo = ComponentService.getInventoryInfo(
- _this.componentId, inventoryItem);
- }
-
- /*
- * The "*Mso*" functions return URL and request details that can be passed
- * to the MSO controller. The request details defines the info passed as
- * part of the POST body.
- */
-
- var getMsoUrl = function() {
- switch (_this.componentId) {
- case COMPONENT.NETWORK:
- return "mso_create_nw_instance/"
- + DataService.getServiceInstanceId();
- case COMPONENT.SERVICE:
- if(DataService.getE2EService() === true)
- return "mso_create_e2e_svc_instance";
- else
- return "mso_create_svc_instance";
- case COMPONENT.VNF:
- return "mso_create_vnf_instance/"
- + DataService.getServiceInstanceId();
- case COMPONENT.VF_MODULE:
- return "mso_create_vfmodule_instance/"
- + DataService.getServiceInstanceId() + "/vnfs/"
- + DataService.getVnfInstanceId();
- case COMPONENT.VOLUME_GROUP:
- return "mso_create_volumegroup_instance/"
- + DataService.getServiceInstanceId() + "/vnfs/"
- + DataService.getVnfInstanceId();
- }
- };
-
- var getMsoE2ERequest = function(parameterList) {
- var modelInfo = DataService.getModelInfo(_this.componentId);
-
- //region id
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- var cloudOwner = _.find(DataService.getCloudRegionTenantList(), function(region){
- return region.cloudRegionId === lcpRegion;
- }).cloudOwner;
-
- var params = [];
- var displayInputs = modelInfo.displayInputs;
- var groupBy = _.groupBy(displayInputs, "templateUUID");
-
- _.forEach(groupBy, function(nodeTemplateInputs, nodeTemplateUUID) {
- var reqParas = {};
- var vfLocations = [];
-
- nodeTemplateInputs.forEach(function(parameter){
- if(parameter.type === 'vf_location') {
- var loc = {
- vnfProfileId: parameter.displayName,
- locationConstraints : {
- vimId: cloudOwner + '_' + lcpRegion
- }
- };
- vfLocations.push(loc);
- } else if(parameter.type === 'sdn_controller') {
- if(parameter.value === undefined || parameter.value === null) {
- reqParas[parameter.name] = '';
- } else {
- reqParas[parameter.name] = parameter.value.value;
- }
- } else {
- var name;
- _.forEach(displayInputs, function(item, key){
- if(item === parameter) {
- name = key;
- }
- });
- var value = _.find(parameterList, function(item){
- return item.id === name;
- }).value;
- reqParas[parameter.displayName] = value;
- }
- });
-
- params.push({
- resourceName: nodeTemplateInputs[0].templateName,
- resourceInvariantUuid: nodeTemplateInputs[0].templateInvariantUUID,
- resourceUuid: nodeTemplateInputs[0].templateUUID,
- resourceCustomizationUuid: nodeTemplateInputs[0].templateCustomizationUUID,
- parameters: {
- locationConstraints: vfLocations,
- //TODO resources: [],
- requestInputs: reqParas
- }
- });
- });
-
- var requestBody = {
- service: {
- name: getValueFromList(FIELD.ID.INSTANCE_NAME, parameterList),
- description: modelInfo["description"],
- serviceInvariantUuid: modelInfo["modelInvariantId"],
- serviceUuid: modelInfo["modelNameVersionId"],
- globalSubscriberId: DataService.getGlobalCustomerId(),
- serviceType: getValueFromList(FIELD.ID.SERVICE_TYPE, parameterList) || modelInfo["serviceTypeName"],
- parameters: {
- locationConstraints: [],
- resources: params,
- requestInputs: {} //TODO
- }
- }
- };
-
- return requestBody;
- };
-
- var getMsoRequestDetails = function(parameterList) {
- console.log("getMsoRequestDetails invoked, parameterList="); console.log(JSON.stringify(parameterList,null,4));
- //console.log("getMsoRequestDetails invoked, DataService.getArbitraryParameters()=");
- //console.log(JSON.stringify(DataService.getArbitraryParameters(),null,4));
-
- //VoLTE logic goes here
- if(DataService.getE2EService() === true) {
- return getMsoE2ERequest(parameterList);
- }
-
- var modelInfo = DataService.getModelInfo(_this.componentId);
- var requestorloggedInId = DataService.getLoggedInUserId();
- var owningEntityId = getValueFromList(FIELD.ID.OWNING_ENTITY, parameterList);
- if (requestorloggedInId == null)
- requestorloggedInId = "";
- var isSupRollback = false;
- if (getValueFromList(FIELD.ID.SUPPRESS_ROLLBACK,parameterList) === "true") {
- isSupRollback = true;
- }
- var requestDetails = {
- requestInfo : {
- instanceName : getValueFromList(FIELD.ID.INSTANCE_NAME,
- parameterList) || DataService.getVfModuleInstanceName(),
- source : FIELD.ID.VID,
- suppressRollback : isSupRollback,
- requestorId: requestorloggedInId
- },
- modelInfo : {
- modelType : _this.componentId,
- modelInvariantId : modelInfo.modelInvariantId,
- modelVersionId : modelInfo.modelNameVersionId,
- modelName : modelInfo.modelName,
- modelVersion : modelInfo.modelVersion,
- modelCustomizationId: modelInfo.customizationUuid,
- modelCustomizationName : modelInfo.modelCustomizationName
- },
- requestParameters : {
- userParams : getArbitraryParameters(parameterList)
- }
- };
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) {
- if ((_this.componentId != COMPONENT.SERVICE) || ( DataService.getALaCarte() )) {
- requestDetails.requestParameters.testApi = DataService.getMsoRequestParametersTestApi();
- }
- }
- if ( (_this.componentId != COMPONENT.SERVICE) || ( !DataService.getALaCarte() ) ) {
- // include cloud region for everything but service create alacarte
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- requestDetails.cloudConfiguration = {
- lcpCloudRegionId : lcpRegion,
- tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
- };
- }
- switch (_this.componentId) {
-
- case COMPONENT.SERVICE:
- requestDetails.subscriberInfo = {
- globalSubscriberId : DataService.getGlobalCustomerId(),
- subscriberName : DataService.getSubscriberName()
- };
- var isInTop = DataService.getHideServiceFields() || false;
- if(isInTop){
- requestDetails.requestParameters.subscriptionServiceType = DataService.getModelInfo(_this.componentId)["serviceTypeName"];
- }else{
- requestDetails.requestParameters.subscriptionServiceType = getValueFromList(
- FIELD.ID.SERVICE_TYPE, parameterList);
- }
- requestDetails.requestParameters.aLaCarte = DataService.getALaCarte();
- if ( !DataService.getALaCarte() ) {
- requestDetails.requestInfo.productFamilyId = getValueFromList(
- FIELD.ID.PRODUCT_FAMILY, parameterList);
- }
- var svcModelInfo = {
- modelType : _this.componentId,
- modelInvariantId : modelInfo.modelInvariantId,
- modelVersionId : modelInfo.modelNameVersionId,
- modelName : modelInfo.modelName,
- modelVersion : modelInfo.modelVersion
- };
- requestDetails.modelInfo = svcModelInfo;
-
- var selectedProject = getValueFromList(FIELD.ID.PROJECT, parameterList);
-
- if (selectedProject) {
- requestDetails.project = {
- projectName: getValueFromList(FIELD.ID.PROJECT, parameterList)
- };
- }
-
- requestDetails.owningEntity = {
- owningEntityId: owningEntityId,
- owningEntityName: getOwningEntityNameById(owningEntityId)
- };
-
- break;
- case COMPONENT.VNF:
-
- requestDetails.requestInfo.productFamilyId = getValueFromList(
- FIELD.ID.PRODUCT_FAMILY, parameterList);
-
- var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList);
-
- if(lineOfBusiness) {
- var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", ");
-
- requestDetails.lineOfBusiness = {
- lineOfBusinessName: lineOfBusinessNamesString
- }
- }
-
- requestDetails.platform = {
- platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList)
- };
-
- break;
- case COMPONENT.NETWORK:
- requestDetails.requestInfo.productFamilyId = getValueFromList(
- FIELD.ID.PRODUCT_FAMILY, parameterList);
- var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList);
-
- if(lineOfBusiness) {
- var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", ");
-
- requestDetails.lineOfBusiness = {
- lineOfBusinessName: lineOfBusinessNamesString
- }
- }
-
- requestDetails.platform = {
- platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList)
- };
- break;
- case COMPONENT.VF_MODULE:
- requestDetails.requestParameters.usePreload = getValueFromList(
- FIELD.ID.SDN_C_PRELOAD, parameterList);
- if(_this.componentId == COMPONENT.VF_MODULE &&(requestDetails.requestParameters.usePreload== null || requestDetails.requestParameters.usePreload === '')){
- requestDetails.requestParameters.usePreload = false;
- }
- break;
- case COMPONENT.VOLUME_GROUP:
- break;
- }
-
- var relatedInstanceList = getRelatedInstanceList(parameterList);
-
- if (relatedInstanceList !== undefined) {
- requestDetails.relatedInstanceList = relatedInstanceList;
- }
-
- return requestDetails;
- };
-
- var getRelatedInstanceList = function(parameterList) {
- var relatedInstanceList = new Array();
- switch (_this.componentId) {
- case COMPONENT.SERVICE:
- return undefined;
- case COMPONENT.NETWORK:
- case COMPONENT.VNF:
- addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
- DataService.getServiceInstanceId());
- break;
- case COMPONENT.VF_MODULE:
- addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
- DataService.getServiceInstanceId());
- addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
- .getVnfInstanceId());
-
- var availableVolumeGroup = getValueFromList(
- FIELD.ID.AVAILABLE_VOLUME_GROUP, parameterList);
-
- if (UtilityService.hasContents(availableVolumeGroup) && availableVolumeGroup !== "None") {
- var availableVolumeGroups = DataService.getAvailableVolumeGroupList();
-
- for (var i = 0; i < availableVolumeGroups.length; i++) {
- if (availableVolumeGroups[i].instance.name == availableVolumeGroup) {
- DataService.setModelInfo(COMPONENT.VOLUME_GROUP, DataService.getModelInfo(COMPONENT.VF_MODULE));
- DataService.setVolumeGroupInstanceId(availableVolumeGroups[i].instance.object["volume-group-id"]);
- break;
- }
- }
-
- addRelatedInstance(relatedInstanceList, COMPONENT.VOLUME_GROUP,
- DataService.getVolumeGroupInstanceId());
- }
- break;
- case COMPONENT.VOLUME_GROUP:
- addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
- DataService.getServiceInstanceId());
- addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
- .getVnfInstanceId());
- break;
- }
-
- return relatedInstanceList;
- };
-
- var addRelatedInstance = function(relatedInstanceList, componentId,
- instanceId) {
- var modelInfo = DataService.getModelInfo(componentId);
- var relatedInstance;
- if (modelInfo !== undefined) {
- if (componentId === COMPONENT.SERVICE) {
- relatedInstance = {
- "instanceId" : instanceId,
- "modelInfo" : {
- "modelType" : componentId,
- "modelName" : modelInfo.modelName,
- "modelInvariantId" : modelInfo.modelInvariantId,
- "modelVersion" : modelInfo.modelVersion,
- "modelVersionId" : modelInfo.modelNameVersionId,
-
- }
- };
- }
- else {
- relatedInstance = {
- "instanceId" : instanceId,
- "modelInfo" : {
- "modelType" : componentId,
- "modelName" : modelInfo.modelName,
- "modelInvariantId" : modelInfo.modelInvariantId,
- "modelVersion" : modelInfo.modelVersion,
- "modelVersionId" : modelInfo.modelNameVersionId,
- "modelCustomizationId": modelInfo.customizationUuid,
- "modelCustomizationName": modelInfo.modelCustomizationName
- }
- }
- }
- relatedInstanceList.push({
- relatedInstance : relatedInstance
- });
- }
- };
-
- /*
- * var getArbitraryParameters = function(parameterList) { var
- * arbitraryParameters = new Object(); for (var i = 0; i <
- * parameterList.length; i++) { var parameter = parameterList[i]; switch
- * (parameter.id) { case FIELD.ID.INSTANCE_NAME: case
- * FIELD.ID.PRODUCT_FAMILY: case FIELD.ID.LCP_REGION: case
- * FIELD.ID.LCP_REGION_TEXT: case FIELD.ID.SERVICE_TYPE: case
- * FIELD.ID.TENANT: case FIELD.ID.SUPPRESS_ROLLBACK: break; default:
- * arbitraryParameters[parameter.id] = parameter.value; } } return
- * arbitraryParameters; }
- */
- var getArbitraryParameters = function(parameterList) {
- var arbitraryParameters = new Object();
- var arbitraryArray = new Array();
- for (var i = 0; i < parameterList.length; i++) {
- var parameter = parameterList[i];
- switch (parameter.id) {
- case FIELD.ID.AVAILABLE_VOLUME_GROUP:
- case FIELD.ID.INSTANCE_NAME:
- case FIELD.ID.PRODUCT_FAMILY:
- case FIELD.ID.LCP_REGION:
- case FIELD.ID.LCP_REGION_TEXT:
- case FIELD.ID.SERVICE_TYPE:
- case FIELD.ID.TENANT:
- case FIELD.ID.SUPPRESS_ROLLBACK:
- case FIELD.ID.SUBSCRIBER_NAME:
- case FIELD.ID.SDN_C_PRELOAD:
- case FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE:
- case FIELD.ID.OWNING_ENTITY:
- case FIELD.ID.PLATFORM:
- case FIELD.ID.LINE_OF_BUSINESS:
- case FIELD.ID.PROJECT:
- break;
- case FIELD.ID.SUPPLEMENTORY_DATA_FILE:
- arbitraryParameters = FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'];
- arbitraryArray=arbitraryParameters;
- FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value']=[];
- break;
-
- default:
- if (parameter.value != '') {
- arbitraryParameters = {
- name: parameter.id,
- value: parameter.value
- }
- arbitraryArray.push(arbitraryParameters);
- }
- }
- }
- return (arbitraryArray);
- }
-
- var getModel = function() {
- AsdcService.getModel(DataService.getModelId(), function(response) {
- DataService.setModelInfo(_this.componentId, {
- modelInvariantId : response.data.invariantUUID,
- modelNameVersionId : response.data.uuid,
- modelName : response.data.name,
- modelVersion : response.data.version,
- inputs : response.data.inputs
- });
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getSubscriptionServiceTypeList = function() {
- AaiService.getSubscriptionServiceTypeList(DataService
- .getGlobalCustomerId(), function(response) {
- DataService.setSubscriptionServiceTypeList(response);
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getLoggedInUserID = function() {
- AaiService.getLoggedInUserID(function(response) {
- DataService.setLoggedInUserId(response.data);
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getSubscribers = function() {
- AaiService.getSubscribers(function(response) {
- DataService.setSubscribers(response);
- UtilityService.startNextAsyncOperation();
- });
- };
- var getServices = function() {
- AaiService.getServices(function(response) {
- var serviceIdList = [];
- angular.forEach(response.data, function(value, key) {
- angular.forEach(value, function(subVal, key) {
- var newVal = {
- "id" : subVal[FIELD.ID.SERVICE_ID],
- "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION],
- "isPermitted" : subVal[FIELD.ID.IS_PERMITTED],
- };
- serviceIdList.push(newVal);
- DataService.setServiceIdList(serviceIdList);
- });
- });
-
- UtilityService.startNextAsyncOperation();
- });
- };
- var getAicZones = function() {
- AaiService.getAicZones(function(response) {
- var serviceIdList = [];
- angular.forEach(response.data, function(value, key) {
- angular.forEach(value, function(subVal, key) {
- var newVal = {
- "id" : subVal[FIELD.ID.ZONE_ID],
- "name" : subVal[FIELD.ID.ZONE_NAME],
- };
- serviceIdList.push(newVal);
- DataService.setAicZones(serviceIdList);
- });
- });
-
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var getOwningEntityProperties = function() {
- OwningEntityService.getOwningEntityProperties(function(owningEntityProperties) {
- DataService.setOwningEntityProperties(owningEntityProperties);
- UtilityService.startNextAsyncOperation();
- });
-
- };
-
- var getLcpCloudRegionTenantList = function() {
- AaiService.getLcpCloudRegionTenantList(DataService
- .getGlobalCustomerId(), DataService.getServiceType(), function(
- response) {
- DataService.setCloudRegionTenantList(response);
- UtilityService.startNextAsyncOperation();
- });
- };
-
- var internalGetParametersHandler = function() {
- if (angular.isFunction(_this.getParametersHandler)) {
- _this.getParametersHandler({
- summaryList : getSummaryList(),
- userProvidedList : getUserProvidedList()
- });
- }
- };
-
- var getSubscribersParameter = function() {
- var subscribers = DataService.getSubscribers();
- var parameter = FIELD.PARAMETER.SUBSCRIBER_NAME;
- if ( UtilityService.hasContents(subscribers)) {
- parameter.optionList = [];
-
- for (var i = 0; i < subscribers.length; i++) {
- parameter.optionList.push({
- id : subscribers[i][FIELD.ID.GLOBAL_CUSTOMER_ID],
- name : subscribers[i][FIELD.ID.SUBNAME],
- isPermitted : subscribers[i][FIELD.ID.IS_PERMITTED]
- })
- }
- }
- return parameter;
- };
-
- var getServiceId = function() {
- var serviceIdList = DataService.getServiceIdList();
- //var serviceTypeList = DataService.getSubscriptionServiceTypeList();
- var parameter = FIELD.PARAMETER.PRODUCT_FAMILY;
- parameter.optionList = new Array();
- if ( UtilityService.hasContents(serviceIdList) ) {
- // load them all
- for (var i = 0; i < serviceIdList.length; i++) {
- parameter.optionList.push({
- id : serviceIdList[i].id,
- name : serviceIdList[i].description,
- isPermitted : serviceIdList[i].isPermitted
- });
- }
- }
-
- return parameter;
- };
-
- var getAicZonesParameter = function() {
- var aicList = DataService.getAicZones();
- var parameter = FIELD.PARAMETER.AIC_ZONES;
- parameter.optionList = new Array();
- if ( UtilityService.hasContents(aicList) ) {
- // load them all
- for (var i = 0; i < aicList.length; i++) {
- parameter.optionList.push({
- id : aicList[i].id,
- name : aicList[i].name,
- isPermitted : true
-
- });
- }
- }
-
- return parameter;
- };
-
- var getProjectParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PROJECT);
- };
-
- var getOwningEntityParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.OWNING_ENTITY);
- };
-
- var getLineOfBusinessParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.LINE_OF_BUSINESS);
- };
-
- var getPlatformParameter = function() {
- return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PLATFORM);
- };
-
- var getOwningEntityNameById = function (id) {
- var properties = DataService.getOwningEntityProperties();
- var parameter = _.find(properties[FIELD.ID.OWNING_ENTITY], {"id": id});
- return parameter && parameter.name;
- };
-
- var getOwningEntityParameterWithOptions = function(parameter) {
- var properties = DataService.getOwningEntityProperties();
- if (properties && properties[parameter.id]) {
- parameter.optionList = _.map(properties[parameter.id], function(parameter) {
- return {
- "id" : parameter.id,
- "name" : parameter.name,
- "isPermitted": true
- };
- });
- }
-
- return parameter;
- };
-
- var getLcpRegionParameter = function() {
- var cloudRegionTenantList = DataService.getCloudRegionTenantList();
- console.log ( "cloudRegionTenantList=");
- console.log ( JSON.stringify (cloudRegionTenantList, null, 4 ));
-
- var parameter = FIELD.PARAMETER.LCP_REGION;
- if ( UtilityService.hasContents (cloudRegionTenantList) ) {
- parameter.optionList = new Array();
- for (var i = 0; i < cloudRegionTenantList.length; i++) {
- for (var j = 0; j < parameter.optionList.length; j++) {
- if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) {
- parameter.optionList[j].isPermitted =
- parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted;
- break;
- }
- }
- if (j < parameter.optionList.length) {
- continue;
- }
-
- var optionName = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) && cloudRegionTenantList[i].cloudOwner ?
- cloudRegionTenantList[i].cloudRegionId + " (" + cloudRegionTenantList[i].cloudOwner.trim().toLowerCase().replace(/^att-/, "").toUpperCase() + ")" :
- cloudRegionTenantList[i].cloudRegionId;
-
- parameter.optionList.push({
- id : cloudRegionTenantList[i].cloudRegionId,
- name: optionName,
- isPermitted : cloudRegionTenantList[i].isPermitted
- });
- }
- }
- return parameter;
- };
-
- var getTenantList = function(cloudRegionId) {
- var cloudRegionTenantList = DataService.getCloudRegionTenantList();
- var parameter = "";
- if ( UtilityService.hasContents (cloudRegionTenantList) ) {
- parameter = FIELD.PARAMETER.TENANT_ENABLED;
- parameter.optionList = new Array();
- for (var i = 0; i < cloudRegionTenantList.length; i++) {
- if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) {
- parameter.optionList.push({
- id : cloudRegionTenantList[i].tenantId,
- name : cloudRegionTenantList[i].tenantName,
- isPermitted : cloudRegionTenantList[i].isPermitted
-
- });
- }
- }
- }
- return parameter;
-
- };
-
- var addOptionList = function(parameter, optionSimpleArray) {
- var optionList = new Array();
- if (!angular.isArray(optionSimpleArray)) {
- return optionList;
- }
- for (var i = 0; i < optionSimpleArray.length; i++) {
- optionList.push({
- name : optionSimpleArray[i],
- isPermitted :true,
- });
- }
- parameter.optionList = optionList;
- return parameter;
- };
-
- var getValueFromList = function(id, parameterList) {
- for (var i = 0; i < parameterList.length; i++) {
- if (parameterList[i].id === id) {
- return parameterList[i].value;
- }
- }
- };
- var updateUserParameterList = function(updatedId, parameterListControl) {
- console.log ("updateUserParameterList() updatedId=" + updatedId);
- if (updatedId === FIELD.ID.PRODUCT_FAMILY && DataService.getHideServiceFields()) {
- var cloudRegionTenantList = new Array();
- AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) {
- DataService.setCloudRegionTenantList(cloudRegionTenantList);
- parameterListControl.updateList([ getLcpRegionParameter() ]);
- });
- }else if (updatedId === FIELD.ID.SDN_C_PRELOAD) {
- var list = parameterListControl.getList(updatedId);
- if($('input[parameter-id="'+updatedId+'"]').is(':checked')){
- FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED.value=true;
- parameterListControl
- .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED ]);
- }else{
- parameterListControl
- .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_UNCHECKED ]);
- }
- }else if (updatedId === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE) {
- if($('input[parameter-id="'+updatedId+'"]').is(':checked')){
- $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').show();
- FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=true;
- parameterListControl
- .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED ]);
- }else{
- $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').hide();
- FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=false;
- parameterListControl
- .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_UNCHECKED ]);
- }
- } else if (updatedId === FIELD.ID.SUPPLEMENTORY_DATA_FILE) {
- var filePath = $('input[parameter-id="'+updatedId+'"]').val();
- var arr =filePath.split('.');
- var fileExt = arr[arr.length-1];
- if(fileExt!='' && fileExt.toLowerCase()!='json'){
- $('input[parameter-id="'+updatedId+'"]').val('');
- alert("Invalid file format. Please select *.json format file.");
- return false;
- }
- } else if (updatedId === FIELD.ID.LCP_REGION) {
- var list = parameterListControl.getList(updatedId);
- if (list[0].selectedIndex >= 0) {
- parameterListControl
- .updateList([ getTenantList(list[0].value) ]);
- } else {
- parameterListControl
- .updateList([ FIELD.PARAMETER.TENANT_DISABLED ]);
- }
- if (list[0].value === FIELD.KEY.LCP_REGION_TEXT) {
- parameterListControl
- .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_VISIBLE ]);
- } else {
- parameterListControl
- .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN ]);
- }
- } else if (updatedId === FIELD.ID.SUBSCRIBER_NAME) {
- var list = parameterListControl.getList(updatedId);
- if (list[0].selectedIndex >= 0) {
- DataService.setGlobalCustomerId(list[0].value);
-
- AaiService.getSubscriptionServiceTypeList(DataService
- .getGlobalCustomerId(), function(response) {
- DataService.setSubscriptionServiceTypeList(response);
- var serviceTypeParameters = FIELD.PARAMETER.SERVICE_TYPE;
- serviceTypeParameters.optionList = [];
-
- for (var i = 0; i < response.length; i++) {
- serviceTypeParameters.optionList.push({
- "id" : response[i].name,
- "name" : response[i].name,
- "isPermitted" :response[i].isPermitted
-
- });
- }
- console.log ( "updateUserParameterList: service type parameters " );
- console.log ( JSON.stringify (serviceTypeParameters, null, 4));
- parameterListControl.updateList([ serviceTypeParameters ]);
- });
-
- }
- } else if ( updatedId === FIELD.ID.SERVICE_TYPE ) {
- var list = parameterListControl.getList(updatedId);
- if (list[0].selectedIndex >= 0) {
-
- DataService.setServiceType(list[0].value);
- var cloudRegionTenantList = new Array();
- AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) {
- DataService.setCloudRegionTenantList(cloudRegionTenantList);
- parameterListControl.updateList([ getLcpRegionParameter() ]);
- });
- } else {
- parameterListControl
- .updateList([ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
- }
- }
-
- };
-
- return {
- initializeComponent : function(componentId) {
- _this.componentId = ComponentService.initialize(componentId);
- },
- setHttpErrorHandler : function(httpErrorHandler) {
- _this.httpErrorHandler = httpErrorHandler;
- },
- getComponentDisplayName : ComponentService.getComponentDisplayName,
- getParameters : function(getParametersHandler) {
- _this.getParametersHandler = getParametersHandler;
- UtilityService.setHttpErrorHandler(_this.httpErrorHandler);
- UtilityService.startAsyncOperations(getAsyncOperationList(),
- internalGetParametersHandler);
- },
- updateUserParameterList : updateUserParameterList,
- getMsoRequestDetails : getMsoRequestDetails,
- getMsoUrl : getMsoUrl,
- setInventoryInfo: setInventoryInfo
- }
-}
-
-appDS2.factory("CreationService", [ "$log", "AaiService", "AsdcService",
- "DataService","VIDCONFIGURATION", "ComponentService", "COMPONENT", "FIELD", "PARAMETER",
- "UtilityService", "OwningEntityService","featureFlags", CreationService ]);
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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=========================================================
+ */
+
+"use strict";
+
+/*
+ * "CreationService" isolates the "component-specific" logic required by the
+ * "CreationDialog" controller.
+ *
+ * "Components" are defined as the 5 element types managed by the dialogs: A)
+ * Service B) VNF C) VF Module D) Volume Group and E) Network.
+ *
+ */
+
+var CreationService = function($log, AaiService, AsdcService, DataService,VIDCONFIGURATION,
+ ComponentService, COMPONENT, FIELD, PARAMETER, UtilityService, OwningEntityService,featureFlags) {
+
+ var _this = this;
+ var getAsyncOperationList = function() {
+ if (DataService.getLoggedInUserId() == null) {
+ getLoggedInUserID();
+ } else {
+ UtilityService.startNextAsyncOperation();
+ }
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ return [ getSubscribers, getServices, getAicZones, getOwningEntityProperties ];
+ case COMPONENT.NETWORK:
+ return [ getLcpCloudRegionTenantList, getOwningEntityProperties ];
+ case COMPONENT.VNF:
+ return [ getLcpCloudRegionTenantList, getOwningEntityProperties ];
+ case COMPONENT.VF_MODULE:
+ return [ getLcpCloudRegionTenantList ];
+ case COMPONENT.VOLUME_GROUP:
+ return [ getLcpCloudRegionTenantList ];
+ }
+ };
+
+ /*
+ * "getSummaryList" and "getUserProvidedList" return parameters that should
+ * be displayed in the summary and user provided sections, respectively. The
+ * functions are expected to return lists that are in the format needed by
+ * the parameter-block directive.
+ */
+
+ var getSummaryList = function() {
+
+ /*
+ * These placeholders should be removed and their usage in
+ * "getSummaryList" should be replaced by appropriate code as the
+ * requirements and interfaces firm up.
+ */
+
+ var PLACEHOLDER_RESOURCE_DESCRIPTION = "Resource Description (PLACEHOLDER)";
+ var PLACEHOLDER_SERVICE_CATEGORY = "Service Category (PLACEHOLDER)";
+ var PLACEHOLDER_VF_MODULE_DESCRIPTION = "VF Module Description (PLACEHOLDER)";
+ var PLACEHOLDER_VF_MODULE_LABEL = "VF Module Label (PLACEHOLDER)";
+ var PLACEHOLDER_VF_MODULE_TYPE = "VF Module Type (PLACEHOLDER)";
+
+ _this.parameterList = new Array();
+
+ /*
+ * Common fields displayed at the top of all create instance screens.
+ */
+ if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]==null
+ || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==undefined
+ || DataService.getModelInfo(_this.componentId)["serviceTypeName"]==''){
+ addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
+ }
+
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ if ( !DataService.getALaCarte() ) {
+ // for macro instantiation need to add the resource names under the node template list
+ // this field is called modelCustomizationName in the asdc client code
+ var p;
+ var rlist = DataService.getResources();
+ var res;
+ if ( rlist != null ) {
+ for (var i = 0; i < rlist.length; i++) {
+ res = rlist[i];
+
+ p = FIELD.NAME.RESOURCE_NAME.concat(" " + (i+1));
+ addToList(p, res.name );
+ p = FIELD.NAME.RESOURCE_DESCRIPTION.concat(" " + (i+1));
+ addToList(p, res.description );
+ }
+ }
+ }
+ if(DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=null && DataService.getModelInfo(_this.componentId)["createSubscriberName"]!=''){
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getModelInfo(_this.componentId)["createSubscriberName"]);
+ }
+ if(DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=null && DataService.getModelInfo(_this.componentId)["serviceTypeName"]!=''){
+ addToList(FIELD.NAME.SERVICE_TYPE, DataService
+ .getModelInfo(_this.componentId)["serviceTypeName"]);
+ addToList(FIELD.NAME.SERVICE_NAME, DataService.getServiceName());
+ }
+ addToList(FIELD.NAME.SERVICE_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.SERVICE_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.SERVICE_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.SERVICE_DESCRIPTION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.DESCRIPTION]);
+ addToList(FIELD.NAME.SERVICE_CATEGORY, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CATEGORY]);
+ if (DataService.getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE] != "null") {
+ addToList(FIELD.NAME.SERVICE_TYPE, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_TYPE]);
+ addToList(FIELD.NAME.SERVICE_ROLE, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.SERVICE_ROLE]);
+ }
+
+ break;
+ case COMPONENT.VF_MODULE:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
+ break;
+ case COMPONENT.VNF:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_CUSTOMIZATION_NAME]);
+ addToList(FIELD.NAME.MODEL_VNF_TYPE, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_TYPE]);
+ addToList(FIELD.NAME.MODEL_VNF_ROLE, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_ROLE]);
+ addToList(FIELD.NAME.MODEL_VNF_FUNCTION, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_FUNCTION]);
+ addToList(FIELD.NAME.MODEL_VNF_CODE, DataService
+ .getModelInfo(_this.componentId)[COMPONENT.VNF_CODE]);
+ break;
+ case COMPONENT.NETWORK:
+ case COMPONENT.VOLUME_GROUP:
+ addToList(FIELD.NAME.SUBSCRIBER_NAME, DataService
+ .getSubscriberName());
+ addToList(FIELD.NAME.SERVICE_INSTANCE_NAME, DataService
+ .getServiceInstanceName());
+ addToList(FIELD.NAME.MODEL_NAME, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME]);
+ addToList(FIELD.NAME.MODEL_INVARIANT_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_INVARIANT_ID]);
+ addToList(FIELD.NAME.MODEL_VERSION, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_VERSION]);
+ addToList(FIELD.NAME.MODEL_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.MODEL_NAME_VERSION_ID]);
+ addToList(FIELD.NAME.MODEL_CUSTOMIZATION_UUID, DataService
+ .getModelInfo(_this.componentId)[FIELD.ID.CUSTOMIZATION_UUID]);
+ break;
+ }
+
+ return _this.parameterList;
+ };
+
+ var getUserProvidedList = function() {
+ var parameterList = [];
+ var isUserProvidedNaming = false;
+ if ( ((DataService.getModelInfo(_this.componentId).serviceEcompNaming != null)
+ && (DataService.getModelInfo(_this.componentId).serviceEcompNaming === "false")) || DataService.getE2EService() ) {
+ isUserProvidedNaming = true;
+ }
+
+ var isInTop = DataService.getHideServiceFields() || false;
+ if (_this.componentId === COMPONENT.SERVICE) {
+ if ( DataService.getALaCarte() ) {
+ parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
+ if(!isInTop){
+ parameterList = parameterList.concat([ getSubscribersParameter(),
+ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
+ }
+ }
+ else {
+ // macro
+
+ if(!isInTop){
+ if (isUserProvidedNaming) {
+ parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
+
+ }
+ parameterList = parameterList.concat([ getSubscribersParameter() ]);
+ parameterList = parameterList.concat([ getServiceId(),
+ FIELD.PARAMETER.SERVICE_TYPE,
+ FIELD.PARAMETER.LCP_REGION,
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED
+ ]);
+ if(!DataService.getE2EService()) {
+ parameterList = parameterList.concat([getAicZonesParameter()]);
+ }
+
+ }else{
+ parameterList = parameterList.concat([ getServiceId(),
+ FIELD.PARAMETER.LCP_REGION,
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ }
+
+ if(!DataService.getE2EService()) {
+ parameterList = parameterList.concat([getProjectParameter()]);
+ parameterList = parameterList.concat([getOwningEntityParameter()]);
+ }
+
+ //if service model has a pnf, add a PNF ID parameter
+ if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_PNP_INSTANTIATION) && DataService.getPnf()) {
+ parameterList = parameterList.concat([ FIELD.PARAMETER.PNF_ID ]);
+ }
+ }
+ else {
+ parameterList = [ FIELD.PARAMETER.INSTANCE_NAME ];
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ case COMPONENT.VNF:
+ parameterList = parameterList.concat([ getServiceId(),
+ getLcpRegionParameter(), FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ parameterList = parameterList.concat([ getLineOfBusinessParameter() ]);
+ parameterList = parameterList.concat([ getPlatformParameter() ]);
+
+ break;
+ case COMPONENT.VF_MODULE:
+ parameterList = parameterList.concat([
+ getLcpRegionParameter(),
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED
+ ]);
+
+ var availableVolumeGroupList = DataService.getAvailableVolumeGroupList();
+
+ if (availableVolumeGroupList && availableVolumeGroupList.length > 0) {
+ var availableVolumeGroupNames = [FIELD.STATUS.NONE];
+
+ for (var i = 0; i < availableVolumeGroupList.length; i++) {
+ availableVolumeGroupNames.push(availableVolumeGroupList[i].instance.name);
+ }
+
+ parameterList.push(addOptionList(
+ FIELD.PARAMETER.AVAILABLE_VOLUME_GROUP,
+ availableVolumeGroupNames));
+ }
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ parameterList = parameterList.concat([ getLcpRegionParameter(),
+ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN,
+ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ }
+ parameterList.push(FIELD.PARAMETER.SUPPRESS_ROLLBACK);
+ if(_this.componentId === COMPONENT.VF_MODULE ){
+ parameterList.push({name: FIELD.NAME.SDN_C_PRELOAD,
+ id: FIELD.ID.SDN_C_PRELOAD,
+ type: "checkbox",
+ isEnabled: true,
+ isRequired: false,
+ hideFieldAndLabel: true
+ }
+ );
+ parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE,
+ id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE,
+ type: "checkbox",
+ isEnabled: true,
+ isRequired: false,
+ value:false
+ }
+ );
+
+ parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE,
+ id: FIELD.ID.SUPPLEMENTORY_DATA_FILE,
+ type: "file",
+ isRequired: false,
+ isVisiblity: false
+ }
+ );
+ }
+
+ if( VIDCONFIGURATION.UPLOAD_SUPPLEMENTARY_STATUS_CHECK_ENABLED && _this.componentId === COMPONENT.VOLUME_GROUP){
+ parameterList.push({name: FIELD.NAME.UPLOAD_SUPPLEMENTORY_DATA_FILE,
+ id: FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE,
+ type: "checkbox",
+ isEnabled: true,
+ isRequired: false
+ }
+ );
+
+ parameterList.push({name: FIELD.NAME.SUPPLEMENTORY_DATA_FILE,
+ id: FIELD.ID.SUPPLEMENTORY_DATA_FILE,
+ type: "file",
+ isRequired: false,
+ isVisiblity: false
+ }
+ );
+ }
+
+ addArbitraryParameters(parameterList);
+
+ return parameterList;
+ };
+
+ var addArbitraryParameters = function(parameterList) {
+ if ( DataService.getModelInfo(_this.componentId).displayInputs != null ) {
+ var inputs = DataService.getModelInfo(_this.componentId).displayInputs;
+ for ( var key in inputs) {
+ var parameter = {
+ id : key,
+ type : PARAMETER.STRING,
+ name : ComponentService.getFieldDisplayName(key),
+ value : inputs[key][PARAMETER.DEFAULT],
+ isRequired : inputs[key][PARAMETER.REQUIRED],
+ description : inputs[key][PARAMETER.DESCRIPTION]
+ };
+ if ( DataService.getALaCarte() ) {
+ parameter.name = ComponentService.getFieldDisplayName(inputs[key][PARAMETER.DISPLAY_NAME]);
+ }
+ switch (inputs[key][PARAMETER.TYPE]) {
+ case PARAMETER.INTEGER:
+ parameter.type = PARAMETER.NUMBER;
+ break;
+ case PARAMETER.BOOLEAN:
+ parameter.type = PARAMETER.BOOLEAN;
+ break;
+ case PARAMETER.RANGE:
+ break;
+ case PARAMETER.LIST:
+ parameter.type = PARAMETER.LIST;
+ break;
+ case PARAMETER.MAP:
+ parameter.type = PARAMETER.MAP;
+ break;
+ }
+
+ if ( UtilityService.hasContents(inputs[key][PARAMETER.CONSTRAINTS])
+ && ( inputs[key][PARAMETER.CONSTRAINTS].length > 0 ) ) {
+ var constraintsArray = inputs[key][PARAMETER.CONSTRAINTS];
+ //console.log ("Calling addConstraintParameters for input name=" + key);
+ addConstraintParameters (parameterList, constraintsArray, key, inputs, parameter);
+ }
+ else {
+
+ parameterList.push(parameter);
+ }
+ }
+ DataService.setArbitraryParameters (parameterList);
+ }
+ };
+
+ var addConstraintParameters = function(parameterList, constraintsArray, key, inputs, parameter) {
+ // If there are constraints and the operator is "valid_values",
+ // use a select parameter type.
+ var i = constraintsArray.length;
+ var parameterPushed = false;
+ if ( i > 0 ) {
+ while ( (i--) && (!parameterPushed) ) {
+ var keys = Object.keys(constraintsArray[i]);
+ //var keys_len = keys.length;
+ for ( var operator in keys ) {
+ //console.log ("keys[operator]=" + keys[operator]);
+ switch (keys[operator]) {
+ case PARAMETER.VALID_VALUES:
+ var j = constraintsArray[i][PARAMETER.VALID_VALUES].length;
+ if ( j > 0 ) {
+ var oList = [];
+ var option;
+ while (j--) {
+ option = {
+ name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
+ isDefault: false
+ }
+ if ( ( UtilityService.hasContents (inputs[key][PARAMETER.DEFAULT]) )
+ && (inputs[key][PARAMETER.DEFAULT] === constraintsArray[i][PARAMETER.VALID_VALUES][j] ) ) {
+ option = {
+ name: constraintsArray[i][PARAMETER.VALID_VALUES][j],
+ isDefault: true
+ }
+ }
+ oList.push(option);
+ }
+ parameter.type = PARAMETER.SELECT;
+ parameter.optionList = oList;
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for valid values");
+ }
+ break;
+
+ case PARAMETER.EQUAL:
+ if ( constraintsArray[i][PARAMETER.EQUAL] != null ) {
+ //override parameter type
+ parameter.type = PARAMETER.STRING;
+ parameter.isReadOnly = true;
+ parameter.value = constraintsArray[i][PARAMETER.EQUAL];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for equal");
+ }
+ break;
+
+ case PARAMETER.LENGTH:
+ if ( constraintsArray[i][PARAMETER.LENGTH] != null ) {
+ parameter.minLength = constraintsArray[i][PARAMETER.LENGTH];
+ parameter.maxLength = constraintsArray[i][PARAMETER.LENGTH];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for length: ");
+ //console.log (JSON.stringify (parameter, null, 4));
+ }
+ break;
+ case PARAMETER.MAX_LENGTH:
+ if ( constraintsArray[i][PARAMETER.MAX_LENGTH] != null ) {
+ parameter.maxLength = constraintsArray[i][PARAMETER.MAX_LENGTH];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for max length: ");
+ //console.log (JSON.stringify (parameter, null, 4));
+ }
+ break;
+ case PARAMETER.MIN_LENGTH:
+ if ( constraintsArray[i][PARAMETER.MIN_LENGTH] != null ) {
+ parameter.minLength = constraintsArray[i][PARAMETER.MIN_LENGTH];
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for min length: ");
+ //console.log (JSON.stringify (parameter, null, 4));
+ }
+ break;
+ case PARAMETER.IN_RANGE:
+ if ( constraintsArray[i][PARAMETER.IN_RANGE] != null ) {
+ if (constraintsArray[i][PARAMETER.IN_RANGE].length > 1 ) {
+ parameter.min = constraintsArray[i][PARAMETER.IN_RANGE][0];
+ parameter.max = constraintsArray[i][PARAMETER.IN_RANGE][1];
+ parameter.type = PARAMETER.NUMBER;
+ parameter.value = inputs[key][PARAMETER.DEFAULT]
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for in_range");
+ }
+ }
+ break;
+ case PARAMETER.GREATER_THAN:
+ if ( constraintsArray[i][PARAMETER.GREATER_THAN] != null ) {
+ parameter.type = PARAMETER.NUMBER;
+ parameter.min = constraintsArray[i][PARAMETER.GREATER_THAN];
+ parameter.value = inputs[key][PARAMETER.DEFAULT]
+ parameterList.push(parameter);
+ parameterPushed = true;
+ //console.log ("pushed param for greater_than");
+
+ }
+ break;
+ }//switch
+ }//for
+
+ }//while
+ }//if
+ };
+ var addToList = function(name, value) {
+ _this.parameterList.push({
+ name : name,
+ value : value
+ });
+ };
+ var setInventoryInfo = function(){
+ var inventoryItem = DataService.getInventoryItem();
+ var inventoryInfo = ComponentService.getInventoryInfo(
+ _this.componentId, inventoryItem);
+ }
+
+ /*
+ * The "*Mso*" functions return URL and request details that can be passed
+ * to the MSO controller. The request details defines the info passed as
+ * part of the POST body.
+ */
+
+ var getMsoUrl = function() {
+ switch (_this.componentId) {
+ case COMPONENT.NETWORK:
+ return "mso_create_nw_instance/"
+ + DataService.getServiceInstanceId();
+ case COMPONENT.SERVICE:
+ if(DataService.getE2EService() === true)
+ return "mso_create_e2e_svc_instance";
+ else
+ return "mso_create_svc_instance";
+ case COMPONENT.VNF:
+ return "mso_create_vnf_instance/"
+ + DataService.getServiceInstanceId();
+ case COMPONENT.VF_MODULE:
+ return "mso_create_vfmodule_instance/"
+ + DataService.getServiceInstanceId() + "/vnfs/"
+ + DataService.getVnfInstanceId();
+ case COMPONENT.VOLUME_GROUP:
+ return "mso_create_volumegroup_instance/"
+ + DataService.getServiceInstanceId() + "/vnfs/"
+ + DataService.getVnfInstanceId();
+ }
+ };
+
+ var getMsoE2ERequest = function(parameterList) {
+ var modelInfo = DataService.getModelInfo(_this.componentId);
+
+ //region id
+ var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+ if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ }
+ var cloudOwner = _.find(DataService.getCloudRegionTenantList(), function(region){
+ return region.cloudRegionId === lcpRegion;
+ }).cloudOwner;
+
+ var params = [];
+ var displayInputs = modelInfo.displayInputs;
+ var groupBy = _.groupBy(displayInputs, "templateUUID");
+
+ _.forEach(groupBy, function(nodeTemplateInputs, nodeTemplateUUID) {
+ var reqParas = {};
+ var vfLocations = [];
+
+ nodeTemplateInputs.forEach(function(parameter){
+ if(parameter.type === 'vf_location') {
+ var loc = {
+ vnfProfileId: parameter.displayName,
+ locationConstraints : {
+ vimId: cloudOwner + '_' + lcpRegion
+ }
+ };
+ vfLocations.push(loc);
+ } else if(parameter.type === 'sdn_controller') {
+ if(parameter.value === undefined || parameter.value === null) {
+ reqParas[parameter.name] = '';
+ } else {
+ reqParas[parameter.name] = parameter.value.value;
+ }
+ } else {
+ var name;
+ _.forEach(displayInputs, function(item, key){
+ if(item === parameter) {
+ name = key;
+ }
+ });
+ var value = _.find(parameterList, function(item){
+ return item.id === name;
+ }).value;
+ reqParas[parameter.displayName] = value;
+ }
+ });
+
+ params.push({
+ resourceName: nodeTemplateInputs[0].templateName,
+ resourceInvariantUuid: nodeTemplateInputs[0].templateInvariantUUID,
+ resourceUuid: nodeTemplateInputs[0].templateUUID,
+ resourceCustomizationUuid: nodeTemplateInputs[0].templateCustomizationUUID,
+ parameters: {
+ locationConstraints: vfLocations,
+ //TODO resources: [],
+ requestInputs: reqParas
+ }
+ });
+ });
+
+ var requestBody = {
+ service: {
+ name: getValueFromList(FIELD.ID.INSTANCE_NAME, parameterList),
+ description: modelInfo["description"],
+ serviceInvariantUuid: modelInfo["modelInvariantId"],
+ serviceUuid: modelInfo["modelNameVersionId"],
+ globalSubscriberId: DataService.getGlobalCustomerId(),
+ serviceType: getValueFromList(FIELD.ID.SERVICE_TYPE, parameterList) || modelInfo["serviceTypeName"],
+ parameters: {
+ locationConstraints: [],
+ resources: params,
+ requestInputs: {} //TODO
+ }
+ }
+ };
+
+ return requestBody;
+ };
+
+ var getMsoRequestDetails = function(parameterList) {
+ console.log("getMsoRequestDetails invoked, parameterList="); console.log(JSON.stringify(parameterList,null,4));
+ //console.log("getMsoRequestDetails invoked, DataService.getArbitraryParameters()=");
+ //console.log(JSON.stringify(DataService.getArbitraryParameters(),null,4));
+
+ //VoLTE logic goes here
+ if(DataService.getE2EService() === true) {
+ return getMsoE2ERequest(parameterList);
+ }
+
+ var modelInfo = DataService.getModelInfo(_this.componentId);
+ var requestorloggedInId = DataService.getLoggedInUserId();
+ var owningEntityId = getValueFromList(FIELD.ID.OWNING_ENTITY, parameterList);
+ if (requestorloggedInId == null)
+ requestorloggedInId = "";
+ var isSupRollback = false;
+ if (getValueFromList(FIELD.ID.SUPPRESS_ROLLBACK,parameterList) === "true") {
+ isSupRollback = true;
+ }
+ var requestDetails = {
+ requestInfo : {
+ instanceName : getValueFromList(FIELD.ID.INSTANCE_NAME,
+ parameterList) || DataService.getVfModuleInstanceName(),
+ source : FIELD.ID.VID,
+ suppressRollback : isSupRollback,
+ requestorId: requestorloggedInId
+ },
+ modelInfo : {
+ modelType : _this.componentId,
+ modelInvariantId : modelInfo.modelInvariantId,
+ modelVersionId : modelInfo.modelNameVersionId,
+ modelName : modelInfo.modelName,
+ modelVersion : modelInfo.modelVersion,
+ modelCustomizationId: modelInfo.customizationUuid,
+ modelCustomizationName : modelInfo.modelCustomizationName
+ },
+ requestParameters : {
+ userParams : getArbitraryParameters(parameterList)
+ }
+ };
+ if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) {
+ if ((_this.componentId != COMPONENT.SERVICE) || ( DataService.getALaCarte() )) {
+ requestDetails.requestParameters.testApi = DataService.getMsoRequestParametersTestApi();
+ }
+ }
+ if ( (_this.componentId != COMPONENT.SERVICE) || ( !DataService.getALaCarte() ) ) {
+ // include cloud region for everything but service create alacarte
+ var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+ if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ }
+ requestDetails.cloudConfiguration = {
+ lcpCloudRegionId : lcpRegion,
+ tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+ }
+ switch (_this.componentId) {
+
+ case COMPONENT.SERVICE:
+ requestDetails.subscriberInfo = {
+ globalSubscriberId : DataService.getGlobalCustomerId(),
+ subscriberName : DataService.getSubscriberName()
+ };
+ var isInTop = DataService.getHideServiceFields() || false;
+ if(isInTop){
+ requestDetails.requestParameters.subscriptionServiceType = DataService.getModelInfo(_this.componentId)["serviceTypeName"];
+ }else{
+ requestDetails.requestParameters.subscriptionServiceType = getValueFromList(
+ FIELD.ID.SERVICE_TYPE, parameterList);
+ }
+ requestDetails.requestParameters.aLaCarte = DataService.getALaCarte();
+ if ( !DataService.getALaCarte() ) {
+ requestDetails.requestInfo.productFamilyId = getValueFromList(
+ FIELD.ID.PRODUCT_FAMILY, parameterList);
+ }
+ var svcModelInfo = {
+ modelType : _this.componentId,
+ modelInvariantId : modelInfo.modelInvariantId,
+ modelVersionId : modelInfo.modelNameVersionId,
+ modelName : modelInfo.modelName,
+ modelVersion : modelInfo.modelVersion
+ };
+ requestDetails.modelInfo = svcModelInfo;
+
+ var selectedProject = getValueFromList(FIELD.ID.PROJECT, parameterList);
+
+ if (selectedProject) {
+ requestDetails.project = {
+ projectName: getValueFromList(FIELD.ID.PROJECT, parameterList)
+ };
+ }
+
+ requestDetails.owningEntity = {
+ owningEntityId: owningEntityId,
+ owningEntityName: getOwningEntityNameById(owningEntityId)
+ };
+
+ break;
+ case COMPONENT.VNF:
+
+ requestDetails.requestInfo.productFamilyId = getValueFromList(
+ FIELD.ID.PRODUCT_FAMILY, parameterList);
+
+ var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList);
+
+ if(lineOfBusiness) {
+ var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", ");
+
+ requestDetails.lineOfBusiness = {
+ lineOfBusinessName: lineOfBusinessNamesString
+ }
+ }
+
+ requestDetails.platform = {
+ platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList)
+ };
+
+ break;
+ case COMPONENT.NETWORK:
+ requestDetails.requestInfo.productFamilyId = getValueFromList(
+ FIELD.ID.PRODUCT_FAMILY, parameterList);
+ var lineOfBusiness = getValueFromList(FIELD.ID.LINE_OF_BUSINESS, parameterList);
+
+ if(lineOfBusiness) {
+ var lineOfBusinessNamesString = _.map(lineOfBusiness, "name").join(", ");
+
+ requestDetails.lineOfBusiness = {
+ lineOfBusinessName: lineOfBusinessNamesString
+ }
+ }
+
+ requestDetails.platform = {
+ platformName: getValueFromList(FIELD.ID.PLATFORM, parameterList)
+ };
+ break;
+ case COMPONENT.VF_MODULE:
+ requestDetails.requestParameters.usePreload = getValueFromList(
+ FIELD.ID.SDN_C_PRELOAD, parameterList);
+ if(_this.componentId == COMPONENT.VF_MODULE &&(requestDetails.requestParameters.usePreload== null || requestDetails.requestParameters.usePreload === '')){
+ requestDetails.requestParameters.usePreload = false;
+ }
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ break;
+ }
+
+ var relatedInstanceList = getRelatedInstanceList(parameterList);
+
+ if (relatedInstanceList !== undefined) {
+ requestDetails.relatedInstanceList = relatedInstanceList;
+ }
+
+ return requestDetails;
+ };
+
+ var getRelatedInstanceList = function(parameterList) {
+ var relatedInstanceList = new Array();
+ switch (_this.componentId) {
+ case COMPONENT.SERVICE:
+ return undefined;
+ case COMPONENT.NETWORK:
+ case COMPONENT.VNF:
+ addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
+ DataService.getServiceInstanceId());
+ break;
+ case COMPONENT.VF_MODULE:
+ addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
+ DataService.getServiceInstanceId());
+ addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
+ .getVnfInstanceId());
+
+ var availableVolumeGroup = getValueFromList(
+ FIELD.ID.AVAILABLE_VOLUME_GROUP, parameterList);
+
+ if (UtilityService.hasContents(availableVolumeGroup) && availableVolumeGroup !== "None") {
+ var availableVolumeGroups = DataService.getAvailableVolumeGroupList();
+
+ for (var i = 0; i < availableVolumeGroups.length; i++) {
+ if (availableVolumeGroups[i].instance.name == availableVolumeGroup) {
+ DataService.setModelInfo(COMPONENT.VOLUME_GROUP, DataService.getModelInfo(COMPONENT.VF_MODULE));
+ DataService.setVolumeGroupInstanceId(availableVolumeGroups[i].instance.object["volume-group-id"]);
+ break;
+ }
+ }
+
+ addRelatedInstance(relatedInstanceList, COMPONENT.VOLUME_GROUP,
+ DataService.getVolumeGroupInstanceId());
+ }
+ break;
+ case COMPONENT.VOLUME_GROUP:
+ addRelatedInstance(relatedInstanceList, COMPONENT.SERVICE,
+ DataService.getServiceInstanceId());
+ addRelatedInstance(relatedInstanceList, COMPONENT.VNF, DataService
+ .getVnfInstanceId());
+ break;
+ }
+
+ return relatedInstanceList;
+ };
+
+ var addRelatedInstance = function(relatedInstanceList, componentId,
+ instanceId) {
+ var modelInfo = DataService.getModelInfo(componentId);
+ var relatedInstance;
+ if (modelInfo !== undefined) {
+ if (componentId === COMPONENT.SERVICE) {
+ relatedInstance = {
+ "instanceId" : instanceId,
+ "modelInfo" : {
+ "modelType" : componentId,
+ "modelName" : modelInfo.modelName,
+ "modelInvariantId" : modelInfo.modelInvariantId,
+ "modelVersion" : modelInfo.modelVersion,
+ "modelVersionId" : modelInfo.modelNameVersionId,
+
+ }
+ };
+ }
+ else {
+ relatedInstance = {
+ "instanceId" : instanceId,
+ "modelInfo" : {
+ "modelType" : componentId,
+ "modelName" : modelInfo.modelName,
+ "modelInvariantId" : modelInfo.modelInvariantId,
+ "modelVersion" : modelInfo.modelVersion,
+ "modelVersionId" : modelInfo.modelNameVersionId,
+ "modelCustomizationId": modelInfo.customizationUuid,
+ "modelCustomizationName": modelInfo.modelCustomizationName
+ }
+ }
+ }
+ relatedInstanceList.push({
+ relatedInstance : relatedInstance
+ });
+ }
+ };
+
+ /*
+ * var getArbitraryParameters = function(parameterList) { var
+ * arbitraryParameters = new Object(); for (var i = 0; i <
+ * parameterList.length; i++) { var parameter = parameterList[i]; switch
+ * (parameter.id) { case FIELD.ID.INSTANCE_NAME: case
+ * FIELD.ID.PRODUCT_FAMILY: case FIELD.ID.LCP_REGION: case
+ * FIELD.ID.LCP_REGION_TEXT: case FIELD.ID.SERVICE_TYPE: case
+ * FIELD.ID.TENANT: case FIELD.ID.SUPPRESS_ROLLBACK: break; default:
+ * arbitraryParameters[parameter.id] = parameter.value; } } return
+ * arbitraryParameters; }
+ */
+ var getArbitraryParameters = function(parameterList) {
+ var arbitraryParameters = new Object();
+ var arbitraryArray = new Array();
+ for (var i = 0; i < parameterList.length; i++) {
+ var parameter = parameterList[i];
+ switch (parameter.id) {
+ case FIELD.ID.AVAILABLE_VOLUME_GROUP:
+ case FIELD.ID.INSTANCE_NAME:
+ case FIELD.ID.PRODUCT_FAMILY:
+ case FIELD.ID.LCP_REGION:
+ case FIELD.ID.LCP_REGION_TEXT:
+ case FIELD.ID.SERVICE_TYPE:
+ case FIELD.ID.TENANT:
+ case FIELD.ID.SUPPRESS_ROLLBACK:
+ case FIELD.ID.SUBSCRIBER_NAME:
+ case FIELD.ID.SDN_C_PRELOAD:
+ case FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE:
+ case FIELD.ID.OWNING_ENTITY:
+ case FIELD.ID.PLATFORM:
+ case FIELD.ID.LINE_OF_BUSINESS:
+ case FIELD.ID.PROJECT:
+ break;
+ case FIELD.ID.SUPPLEMENTORY_DATA_FILE:
+ arbitraryParameters = FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'];
+ arbitraryArray=arbitraryParameters;
+ FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value']=[];
+ break;
+
+ default:
+ if (parameter.value != '') {
+ arbitraryParameters = {
+ name: parameter.id,
+ value: parameter.value
+ }
+ arbitraryArray.push(arbitraryParameters);
+ }
+ }
+ }
+ return (arbitraryArray);
+ }
+
+ var getModel = function() {
+ AsdcService.getModel(DataService.getModelId(), function(response) {
+ DataService.setModelInfo(_this.componentId, {
+ modelInvariantId : response.data.invariantUUID,
+ modelNameVersionId : response.data.uuid,
+ modelName : response.data.name,
+ modelVersion : response.data.version,
+ inputs : response.data.inputs
+ });
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getSubscriptionServiceTypeList = function() {
+ AaiService.getSubscriptionServiceTypeList(DataService
+ .getGlobalCustomerId(), function(response) {
+ DataService.setSubscriptionServiceTypeList(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getLoggedInUserID = function() {
+ AaiService.getLoggedInUserID(function(response) {
+ DataService.setLoggedInUserId(response.data);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getSubscribers = function() {
+ AaiService.getSubscribers(function(response) {
+ DataService.setSubscribers(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+ var getServices = function() {
+ AaiService.getServices(function(response) {
+ var serviceIdList = [];
+ angular.forEach(response.data, function(value, key) {
+ angular.forEach(value, function(subVal, key) {
+ var newVal = {
+ "id" : subVal[FIELD.ID.SERVICE_ID],
+ "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION],
+ "isPermitted" : subVal[FIELD.ID.IS_PERMITTED],
+ };
+ serviceIdList.push(newVal);
+ DataService.setServiceIdList(serviceIdList);
+ });
+ });
+
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+ var getAicZones = function() {
+ AaiService.getAicZones(function(response) {
+ var serviceIdList = [];
+ angular.forEach(response.data, function(value, key) {
+ angular.forEach(value, function(subVal, key) {
+ var newVal = {
+ "id" : subVal[FIELD.ID.ZONE_ID],
+ "name" : subVal[FIELD.ID.ZONE_NAME],
+ };
+ serviceIdList.push(newVal);
+ DataService.setAicZones(serviceIdList);
+ });
+ });
+
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var getOwningEntityProperties = function() {
+ OwningEntityService.getOwningEntityProperties(function(owningEntityProperties) {
+ DataService.setOwningEntityProperties(owningEntityProperties);
+ UtilityService.startNextAsyncOperation();
+ });
+
+ };
+
+ var getLcpCloudRegionTenantList = function() {
+ AaiService.getLcpCloudRegionTenantList(DataService
+ .getGlobalCustomerId(), DataService.getServiceType(), function(
+ response) {
+ DataService.setCloudRegionTenantList(response);
+ UtilityService.startNextAsyncOperation();
+ });
+ };
+
+ var internalGetParametersHandler = function() {
+ if (angular.isFunction(_this.getParametersHandler)) {
+ _this.getParametersHandler({
+ summaryList : getSummaryList(),
+ userProvidedList : getUserProvidedList()
+ });
+ }
+ };
+
+ var getSubscribersParameter = function() {
+ var subscribers = DataService.getSubscribers();
+ var parameter = FIELD.PARAMETER.SUBSCRIBER_NAME;
+ if ( UtilityService.hasContents(subscribers)) {
+ parameter.optionList = [];
+
+ for (var i = 0; i < subscribers.length; i++) {
+ parameter.optionList.push({
+ id : subscribers[i][FIELD.ID.GLOBAL_CUSTOMER_ID],
+ name : subscribers[i][FIELD.ID.SUBNAME],
+ isPermitted : subscribers[i][FIELD.ID.IS_PERMITTED]
+ })
+ }
+ }
+ return parameter;
+ };
+
+ var getServiceId = function() {
+ var serviceIdList = DataService.getServiceIdList();
+ //var serviceTypeList = DataService.getSubscriptionServiceTypeList();
+ var parameter = FIELD.PARAMETER.PRODUCT_FAMILY;
+ parameter.optionList = new Array();
+ if ( UtilityService.hasContents(serviceIdList) ) {
+ // load them all
+ for (var i = 0; i < serviceIdList.length; i++) {
+ parameter.optionList.push({
+ id : serviceIdList[i].id,
+ name : serviceIdList[i].description,
+ isPermitted : serviceIdList[i].isPermitted
+ });
+ }
+ }
+
+ return parameter;
+ };
+
+ var getAicZonesParameter = function() {
+ var aicList = DataService.getAicZones();
+ var parameter = FIELD.PARAMETER.AIC_ZONES;
+ parameter.optionList = new Array();
+ if ( UtilityService.hasContents(aicList) ) {
+ // load them all
+ for (var i = 0; i < aicList.length; i++) {
+ parameter.optionList.push({
+ id : aicList[i].id,
+ name : aicList[i].name,
+ isPermitted : true
+
+ });
+ }
+ }
+
+ return parameter;
+ };
+
+ var getProjectParameter = function() {
+ return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PROJECT);
+ };
+
+ var getOwningEntityParameter = function() {
+ return getOwningEntityParameterWithOptions(FIELD.PARAMETER.OWNING_ENTITY);
+ };
+
+ var getLineOfBusinessParameter = function() {
+ return getOwningEntityParameterWithOptions(FIELD.PARAMETER.LINE_OF_BUSINESS);
+ };
+
+ var getPlatformParameter = function() {
+ return getOwningEntityParameterWithOptions(FIELD.PARAMETER.PLATFORM);
+ };
+
+ var getOwningEntityNameById = function (id) {
+ var properties = DataService.getOwningEntityProperties();
+ var parameter = _.find(properties[FIELD.ID.OWNING_ENTITY], {"id": id});
+ return parameter && parameter.name;
+ };
+
+ var getOwningEntityParameterWithOptions = function(parameter) {
+ var properties = DataService.getOwningEntityProperties();
+ if (properties && properties[parameter.id]) {
+ parameter.optionList = _.map(properties[parameter.id], function(parameter) {
+ return {
+ "id" : parameter.id,
+ "name" : parameter.name,
+ "isPermitted": true
+ };
+ });
+ }
+
+ return parameter;
+ };
+
+ var getLcpRegionParameter = function() {
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ console.log ( "cloudRegionTenantList=");
+ console.log ( JSON.stringify (cloudRegionTenantList, null, 4 ));
+
+ var parameter = FIELD.PARAMETER.LCP_REGION;
+ if ( UtilityService.hasContents (cloudRegionTenantList) ) {
+ parameter.optionList = new Array();
+ for (var i = 0; i < cloudRegionTenantList.length; i++) {
+ for (var j = 0; j < parameter.optionList.length; j++) {
+ if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) {
+ parameter.optionList[j].isPermitted =
+ parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted;
+ break;
+ }
+ }
+ if (j < parameter.optionList.length) {
+ continue;
+ }
+
+ var optionName = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) && cloudRegionTenantList[i].cloudOwner ?
+ cloudRegionTenantList[i].cloudRegionId + " (" + AaiService.removeVendorFromCloudOwner(cloudRegionTenantList[i].cloudOwner).toUpperCase() + ")" :
+ cloudRegionTenantList[i].cloudRegionId;
+
+ parameter.optionList.push({
+ id : cloudRegionTenantList[i].cloudRegionId,
+ name: optionName,
+ isPermitted : cloudRegionTenantList[i].isPermitted
+ });
+ }
+ }
+ return parameter;
+ };
+
+ var getTenantList = function(cloudRegionId) {
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ var parameter = "";
+ if ( UtilityService.hasContents (cloudRegionTenantList) ) {
+ parameter = FIELD.PARAMETER.TENANT_ENABLED;
+ parameter.optionList = new Array();
+ for (var i = 0; i < cloudRegionTenantList.length; i++) {
+ if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) {
+ parameter.optionList.push({
+ id : cloudRegionTenantList[i].tenantId,
+ name : cloudRegionTenantList[i].tenantName,
+ isPermitted : cloudRegionTenantList[i].isPermitted
+
+ });
+ }
+ }
+ }
+ return parameter;
+
+ };
+
+ var addOptionList = function(parameter, optionSimpleArray) {
+ var optionList = new Array();
+ if (!angular.isArray(optionSimpleArray)) {
+ return optionList;
+ }
+ for (var i = 0; i < optionSimpleArray.length; i++) {
+ optionList.push({
+ name : optionSimpleArray[i],
+ isPermitted :true,
+ });
+ }
+ parameter.optionList = optionList;
+ return parameter;
+ };
+
+ var getValueFromList = function(id, parameterList) {
+ for (var i = 0; i < parameterList.length; i++) {
+ if (parameterList[i].id === id) {
+ return parameterList[i].value;
+ }
+ }
+ };
+ var updateUserParameterList = function(updatedId, parameterListControl) {
+ console.log ("updateUserParameterList() updatedId=" + updatedId);
+ if (updatedId === FIELD.ID.PRODUCT_FAMILY && DataService.getHideServiceFields()) {
+ var cloudRegionTenantList = new Array();
+ AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) {
+ DataService.setCloudRegionTenantList(cloudRegionTenantList);
+ parameterListControl.updateList([ getLcpRegionParameter() ]);
+ });
+ }else if (updatedId === FIELD.ID.SDN_C_PRELOAD) {
+ var list = parameterListControl.getList(updatedId);
+ if($('input[parameter-id="'+updatedId+'"]').is(':checked')){
+ FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED.value=true;
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_CHECKED ]);
+ }else{
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.SDN_C_PRELOAD_UNCHECKED ]);
+ }
+ }else if (updatedId === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE) {
+ if($('input[parameter-id="'+updatedId+'"]').is(':checked')){
+ $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').show();
+ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=true;
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED ]);
+ }else{
+ $('input[parameter-id="'+FIELD.ID.SUPPLEMENTORY_DATA_FILE+'"]').closest('tr').hide();
+ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_CHECKED.value=false;
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.UPLOAD_SUPPLEMENTORY_DATA_FILE_UNCHECKED ]);
+ }
+ } else if (updatedId === FIELD.ID.SUPPLEMENTORY_DATA_FILE) {
+ var filePath = $('input[parameter-id="'+updatedId+'"]').val();
+ var arr =filePath.split('.');
+ var fileExt = arr[arr.length-1];
+ if(fileExt!='' && fileExt.toLowerCase()!='json'){
+ $('input[parameter-id="'+updatedId+'"]').val('');
+ alert("Invalid file format. Please select *.json format file.");
+ return false;
+ }
+ } else if (updatedId === FIELD.ID.LCP_REGION) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+ parameterListControl
+ .updateList([ getTenantList(list[0].value) ]);
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.TENANT_DISABLED ]);
+ }
+ if (list[0].value === FIELD.KEY.LCP_REGION_TEXT) {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_VISIBLE ]);
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.LCP_REGION_TEXT_HIDDEN ]);
+ }
+ } else if (updatedId === FIELD.ID.SUBSCRIBER_NAME) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+ DataService.setGlobalCustomerId(list[0].value);
+
+ AaiService.getSubscriptionServiceTypeList(DataService
+ .getGlobalCustomerId(), function(response) {
+ DataService.setSubscriptionServiceTypeList(response);
+ var serviceTypeParameters = FIELD.PARAMETER.SERVICE_TYPE;
+ serviceTypeParameters.optionList = [];
+
+ for (var i = 0; i < response.length; i++) {
+ serviceTypeParameters.optionList.push({
+ "id" : response[i].name,
+ "name" : response[i].name,
+ "isPermitted" :response[i].isPermitted
+
+ });
+ }
+ console.log ( "updateUserParameterList: service type parameters " );
+ console.log ( JSON.stringify (serviceTypeParameters, null, 4));
+ parameterListControl.updateList([ serviceTypeParameters ]);
+ });
+
+ }
+ } else if ( updatedId === FIELD.ID.SERVICE_TYPE ) {
+ var list = parameterListControl.getList(updatedId);
+ if (list[0].selectedIndex >= 0) {
+
+ DataService.setServiceType(list[0].value);
+ var cloudRegionTenantList = new Array();
+ AaiService.getLcpCloudRegionTenantList(DataService.getGlobalCustomerId(), DataService.getServiceType(), function(cloudRegionTenantList) {
+ DataService.setCloudRegionTenantList(cloudRegionTenantList);
+ parameterListControl.updateList([ getLcpRegionParameter() ]);
+ });
+ } else {
+ parameterListControl
+ .updateList([ FIELD.PARAMETER.SERVICE_TYPE_DISABLED ]);
+ }
+ }
+
+ };
+
+ return {
+ initializeComponent : function(componentId) {
+ _this.componentId = ComponentService.initialize(componentId);
+ },
+ setHttpErrorHandler : function(httpErrorHandler) {
+ _this.httpErrorHandler = httpErrorHandler;
+ },
+ getComponentDisplayName : ComponentService.getComponentDisplayName,
+ getParameters : function(getParametersHandler) {
+ _this.getParametersHandler = getParametersHandler;
+ UtilityService.setHttpErrorHandler(_this.httpErrorHandler);
+ UtilityService.startAsyncOperations(getAsyncOperationList(),
+ internalGetParametersHandler);
+ },
+ updateUserParameterList : updateUserParameterList,
+ getMsoRequestDetails : getMsoRequestDetails,
+ getMsoUrl : getMsoUrl,
+ setInventoryInfo: setInventoryInfo
+ }
+}
+
+appDS2.factory("CreationService", [ "$log", "AaiService", "AsdcService",
+ "DataService","VIDCONFIGURATION", "ComponentService", "COMPONENT", "FIELD", "PARAMETER",
+ "UtilityService", "OwningEntityService","featureFlags", CreationService ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js
index efb9ebefd..6163184c2 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js
@@ -424,7 +424,7 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService,
}
var optionName = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) && cloudRegionTenantList[i].cloudOwner ?
- cloudRegionTenantList[i].cloudRegionId + " (" + cloudRegionTenantList[i].cloudOwner.trim().toLowerCase().replace(/^att-/, "").toUpperCase() + ")" :
+ cloudRegionTenantList[i].cloudRegionId + " (" + AaiService.removeVendorFromCloudOwner(cloudRegionTenantList[i].cloudOwner).toUpperCase() + ")" :
cloudRegionTenantList[i].cloudRegionId;
parameter.optionList.push({
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
index 8bcadd139..5bdfd1207 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AAITreeConverterTest.java
@@ -18,7 +18,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.onap.vid.aai;
import com.google.common.collect.ImmutableList;
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
index 76cd21391..7f5e362ba 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/OperationalEnvironmentTest.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -20,190 +21,43 @@
package org.onap.vid.aai;
-import org.junit.Test;
-import org.onap.vid.aai.model.RelationshipList;
-public class OperationalEnvironmentTest {
-
- private OperationalEnvironment createTestSubject() {
- return new OperationalEnvironment();
- }
-
- @Test
- public void testGetOperationalEnvironmentId() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentId();
- }
-
- @Test
- public void testSetOperationalEnvironmentId() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentId(operationalEnvironmentId);
- }
-
- @Test
- public void testGetOperationalEnvironmentName() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentName();
- }
-
- @Test
- public void testSetOperationalEnvironmentName() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentName(operationalEnvironmentName);
- }
-
- @Test
- public void testGetOperationalEnvironmentType() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentType();
- }
-
- @Test
- public void testSetOperationalEnvironmentType() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentType(operationalEnvironmentType);
- }
-
- @Test
- public void testGetOperationalEnvironmentStatus() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentStatus();
- }
-
- @Test
- public void testSetOperationalEnvironmentStatus() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentStatus = "";
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.testng.annotations.Test;
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonOperationalEnvironmentStatus(operationalEnvironmentStatus);
- }
+import java.io.IOException;
- @Test
- public void testGetTenantContext() throws Exception {
- OperationalEnvironment testSubject;
- String result;
+import static org.assertj.core.api.Assertions.assertThat;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTenantContext();
- }
-
- @Test
- public void testSetTenantContext() throws Exception {
- OperationalEnvironment testSubject;
- String tenantContext = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonTenantContext(tenantContext);
- }
-
- @Test
- public void testGetWorkloadContext() throws Exception {
- OperationalEnvironment testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getWorkloadContext();
- }
-
- @Test
- public void testSetWorkloadContext() throws Exception {
- OperationalEnvironment testSubject;
- String workloadContext = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonWorkloadContext(workloadContext);
- }
-
- @Test
- public void testGetResourceVersion() throws Exception {
- OperationalEnvironment testSubject;
- String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getResourceVersion();
- }
-
- @Test
- public void testSetResourceVersion() throws Exception {
- OperationalEnvironment testSubject;
- String resourceVersion = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonResourceVersion(resourceVersion);
- }
-
- @Test
- public void testGetRelationshipList() throws Exception {
- OperationalEnvironment testSubject;
- RelationshipList result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRelationshipList();
- }
-
- @Test
- public void testSetRelationshipList() throws Exception {
- OperationalEnvironment testSubject;
- RelationshipList relationshipList = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setJsonRelationshipList(relationshipList);
- }
-
- @Test
- public void testOperationalEnvironment() throws Exception {
- OperationalEnvironment testSubject;
- String operationalEnvironmentId = "";
- String operationalEnvironmentName = "";
- String operationalEnvironmentType = "";
- String operationalEnvironmentStatus = "";
- String tenantContext = "";
- String workloadContext = "";
- String resourceVersion = "";
- RelationshipList relationshipList = null;
+public class OperationalEnvironmentTest {
- // default test
- testSubject = new OperationalEnvironment(operationalEnvironmentId, operationalEnvironmentName,
- operationalEnvironmentType, operationalEnvironmentStatus, tenantContext, workloadContext,
- resourceVersion, relationshipList);
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private static final String OPERATIONAL_ENVIRONMENT_TEST = "{\n" +
+ "\"operational-environment-id\": \"environmentId\",\n" +
+ "\"operational-environment-name\": \"environmentName\",\n" +
+ "\"operational-environment-type\": \"environmentType\",\n" +
+ "\"operational-environment-status\": \"environmentStatus\",\n" +
+ "\"tenant-context\": \"tenantContext\",\n" +
+ "\"workload-context\": \"workloadContext\",\n" +
+ "\"resource-version\": \"resourceVersion\",\n" +
+ "\"relationship-list\": {\n" +
+ "\"relationship\": []\n" +
+ "}\n" +
+ "}";
+
+ @Test
+ public void shouldProperlyConvertJsonToOperationalEnvironment() throws IOException {
+ OperationalEnvironment operationalEnvironment = OBJECT_MAPPER.readValue(OPERATIONAL_ENVIRONMENT_TEST, OperationalEnvironment.class);
+
+ assertThat(operationalEnvironment.getOperationalEnvironmentId()).isEqualTo("environmentId");
+ assertThat(operationalEnvironment.getWorkloadContext()).isEqualTo("workloadContext");
+ assertThat(operationalEnvironment.getRelationshipList().getRelationship()).hasSize(0);
+ assertThat(operationalEnvironment.getResourceVersion()).isEqualTo("resourceVersion");
+ assertThat(operationalEnvironment.getTenantContext()).isEqualTo("tenantContext");
+ assertThat(operationalEnvironment.getOperationalEnvironmentType()).isEqualTo("environmentType");
+ assertThat(operationalEnvironment.getOperationalEnvironmentStatus()).isEqualTo("environmentStatus");
+ assertThat(operationalEnvironment.getOperationalEnvironmentName()).isEqualTo("environmentName");
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
index 222bf1e5b..c41a479d9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
@@ -19,6 +19,7 @@
*/
package org.onap.vid.aai;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
@@ -60,6 +61,20 @@ public class PombaClientImplTest {
then(pombaRestInterface).should().RestPost("VidAaiController", expectedUrl, expectedPayload);
}
+ @Test
+ public void should_handleException_withoutRethrowing() throws IOException {
+ //Given
+ String expectedUrl = "http://localhost/dummyUrl";
+ String expectedPayload = readExpectedPombaJsonRequest();
+ given(systemPropertiesWrapper.getProperty("pomba.server.url")).willReturn(expectedUrl);
+ given(pombaRestInterface.RestPost("VidAaiController", expectedUrl, expectedPayload))
+ .willThrow(new NullPointerException());
+ PombaRequest pombaRequest = createPombaRequest();
+
+ //When //Then
+ assertThatCode(() -> pombaClient.verify(pombaRequest)).doesNotThrowAnyException();
+ }
+
private String readExpectedPombaJsonRequest() throws IOException {
URL url = PombaClientImplTest.class.getClassLoader().getResource("pomba_request.json");
PombaRequest expectedPombaRequest = new ObjectMapper().readValue(url, PombaRequest.class);
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java
index 6ff766413..4c0875320 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/ServicePropertiesTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,35 +20,76 @@
package org.onap.vid.aai;
-import java.util.Map;
+import java.io.IOException;
-import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.vid.aai.model.ServiceProperties;
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
public class ServicePropertiesTest {
- private ServiceProperties createTestSubject() {
- return new ServiceProperties();
- }
-
- @Test
- public void testGetAdditionalProperties() throws Exception {
- ServiceProperties testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
- }
-
- @Test
- public void testSetAdditionalProperty() throws Exception {
- ServiceProperties testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAdditionalProperty(name, value);
- }
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ private static final String SERVICE_PROPERTIES_JSON = "{\n" +
+ "\"service-instance-id\": \"instanceId\",\n" +
+ "\"service-instance-name\": \"instanceName\",\n" +
+ "\"model-invariant-id\": \"invariantId\",\n" +
+ "\"model-version-id\": \"versionId\",\n" +
+ "\"resource-version\": \"version\",\n" +
+ "\"orchestration-status\": \"status\",\n" +
+ "\"global-customer-id\": \"customerId\",\n" +
+ "\"subscriber-name\": \"subscriberName\",\n" +
+ "\"subscriber-type\": \"subscriberType\",\n" +
+ "\"vnf-id\": \"vnfId\",\n" +
+ "\"vnf-name\": \"vnfName\",\n" +
+ "\"vnf-type\": \"vnfType\",\n" +
+ "\"service-id\": \"serviceId\",\n" +
+ "\"prov-status\": \"provStatus\",\n" +
+ "\"in-maint\": false,\n" +
+ "\"is-closed-loop-disabled\": false,\n" +
+ "\"model-customization-id\": \"customizationId\",\n" +
+ "\"nf-type\": \"nfType\",\n" +
+ "\"nf-function\": \"nfFunction\",\n" +
+ "\"nf-role\": \"nfRole\",\n" +
+ "\"nf-naming-code\": \"namingCode\",\n" +
+ "\"not-listed-property\":\"value\"}"+
+ "}";
+
+
+ @Test
+ public void shouldProperlyConvertJsonToServiceProperties() throws IOException {
+ ServiceProperties serviceProperties = OBJECT_MAPPER.readValue(SERVICE_PROPERTIES_JSON, ServiceProperties.class);
+
+
+ assertThat(serviceProperties.isClosedLoopDisabled).isFalse();
+ assertThat(serviceProperties.globalCustomerId).isEqualTo("customerId");
+ assertThat(serviceProperties.inMaint).isFalse();
+ assertThat(serviceProperties.modelCustomizationId).isEqualTo("customizationId");
+ assertThat(serviceProperties.modelInvariantId).isEqualTo("invariantId");
+ assertThat(serviceProperties.modelVersionId).isEqualTo("versionId");
+ assertThat(serviceProperties.nfRole).isEqualTo("nfRole");
+ assertThat(serviceProperties.nfFunction).isEqualTo("nfFunction");
+ assertThat(serviceProperties.nfType).isEqualTo("nfType");
+ assertThat(serviceProperties.nfNamingCode).isEqualTo("namingCode");
+ assertThat(serviceProperties.serviceId).isEqualTo("serviceId");
+ assertThat(serviceProperties.serviceInstanceName).isEqualTo("instanceName");
+ assertThat(serviceProperties.serviceInstanceId).isEqualTo("instanceId");
+ assertThat(serviceProperties.provStatus).isEqualTo("provStatus");
+ assertThat(serviceProperties.vnfId).isEqualTo("vnfId");
+ assertThat(serviceProperties.vnfName).isEqualTo("vnfName");
+ assertThat(serviceProperties.vnfType).isEqualTo("vnfType");
+ }
+
+ @Test
+ public void shouldProperlyAddAdditionalProperty() throws IOException {
+ ServiceProperties serviceProperties = OBJECT_MAPPER.readValue(SERVICE_PROPERTIES_JSON, ServiceProperties.class);
+
+
+ serviceProperties.setAdditionalProperty("additional", "property");
+
+ assertThat(serviceProperties.getAdditionalProperties())
+ .containsOnlyKeys("not-listed-property","additional")
+ .containsValues("value","property");
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java
index 2842b08dc..c690b5fa0 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/SubscriberWithFilterTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,31 +20,15 @@
package org.onap.vid.aai;
-import org.junit.Test;
-public class SubscriberWithFilterTest {
-
- private SubscriberWithFilter createTestSubject() {
- return new SubscriberWithFilter();
- }
-
- @Test
- public void testGetIsPermitted() throws Exception {
- SubscriberWithFilter testSubject;
- boolean result;
+import org.testng.annotations.Test;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getIsPermitted();
- }
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
- @Test
- public void testSetIsPermitted() throws Exception {
- SubscriberWithFilter testSubject;
- boolean isPermitted = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIsPermitted(isPermitted);
- }
+public class SubscriberWithFilterTest {
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(SubscriberWithFilter.class, hasValidGettersAndSetters());
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java
index 6f403d9da..7ee3b6152 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/VnfResultTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,34 +20,64 @@
package org.onap.vid.aai;
-import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.vid.aai.model.VnfResult;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+
+import static org.assertj.core.api.Assertions.assertThat;
-import java.util.Map;
public class VnfResultTest {
- private VnfResult createTestSubject() {
- return new VnfResult();
- }
-
- @Test
- public void testGetAdditionalProperties() throws Exception {
- VnfResult testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
- }
-
- @Test
- public void testSetAdditionalProperty() throws Exception {
- VnfResult testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- }
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private static final String VNF_RESULT_JSON = "{\n" +
+ "\"id\": \"sample\",\n" +
+ "\"node-type\": \"sampleNodeType\",\n" +
+ "\"url\": \"sample\",\n" +
+ "\"properties\": {\n" +
+ "\"service-instance-id\": \"sample\",\n" +
+ "\"service-instance-name\": \"sample\",\n" +
+ "\"model-invariant-id\": \"sample\",\n" +
+ "\"model-version-id\": \"sample\",\n" +
+ "\"resource-version\": \"sample\",\n" +
+ "\"orchestration-status\": \"sample\",\n" +
+ "\"global-customer-id\": \"sample\",\n" +
+ "\"subscriber-name\": \"sample\",\n" +
+ "\"subscriber-type\": \"sample\",\n" +
+ "\"vnf-id\": \"sample\",\n" +
+ "\"vnf-name\": \"sample\",\n" +
+ "\"vnf-type\": \"sample\",\n" +
+ "\"service-id\": \"sample\",\n" +
+ "\"prov-status\": \"sample\",\n" +
+ "\"in-maint\": false,\n" +
+ "\"is-closed-loop-disabled\": false,\n" +
+ "\"model-customization-id\": \"sample\",\n" +
+ "\"nf-type\": \"sample\",\n" +
+ "\"nf-function\": \"sample\",\n" +
+ "\"nf-role\": \"sample\",\n" +
+ "\"nf-naming-code\": \"sample\"\n" +
+ "},\n" +
+ "\"related-to\": [{\n" +
+ "\"id\": \"sample\",\n" +
+ "\"relationship-label\": \"sample\",\n" +
+ "\"node-type\": \"sample\",\n" +
+ "\"url\": \"sample\"\n" +
+ "\t}]\n" +
+ "}";
+
+
+ @Test
+ public void shouldProperlyConvertJsonToVnfResult() throws IOException {
+ VnfResult vnfResult = OBJECT_MAPPER.readValue(VNF_RESULT_JSON, VnfResult.class);
+
+ assertThat(vnfResult.nodeType).isEqualTo("sampleNodeType");
+ assertThat(vnfResult.id).isEqualTo("sample");
+ assertThat(vnfResult.url).isEqualTo("sample");
+ assertThat(vnfResult.relatedTo).hasSize(1);
+ assertThat(vnfResult.properties.globalCustomerId).isEqualTo("sample");
+ assertThat(vnfResult.getAdditionalProperties()).isEmpty();
+ }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java
new file mode 100644
index 000000000..cc57171b8
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipListTest.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.vid.aai.model;
+
+
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class RelationshipListTest {
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(RelationshipList.class, hasValidGettersAndSetters());
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java
index 47ec44ca7..b4a5c64f5 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/InstanceGroupCommandTest.java
@@ -20,8 +20,14 @@
package org.onap.vid.job.command;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.only;
+import static org.mockito.Mockito.same;
+import static org.mockito.Mockito.verify;
+
import com.google.common.collect.ImmutableMap;
-import org.apache.commons.beanutils.BeanUtils;
+import java.util.Optional;
import org.mockito.Answers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -32,19 +38,11 @@ import org.onap.vid.model.serviceInstantiation.InstanceGroup;
import org.onap.vid.mso.RestMsoImplementation;
import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
+import org.onap.vid.testUtils.TestUtils;
import org.springframework.http.HttpMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.Optional;
-import java.util.Set;
-
-import static java.util.function.Function.identity;
-import static java.util.stream.Collectors.toMap;
-import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
-
public class InstanceGroupCommandTest {
@Mock(answer = Answers.RETURNS_MOCKS)
@@ -73,7 +71,7 @@ public class InstanceGroupCommandTest {
@Test
public void createMyself_callsMso() {
- final ModelInfo serviceModelInfo = setRandomStrings(new ModelInfo());
+ final ModelInfo serviceModelInfo = setStrings(new ModelInfo());
final String serviceInstanceId = "service-instance-id";
final String userId = "ff3223";
@@ -92,14 +90,7 @@ public class InstanceGroupCommandTest {
}
- private ModelInfo setRandomStrings(ModelInfo object) {
- try {
- Set<String> fields = BeanUtils.describe(object).keySet();
- BeanUtils.populate(object,
- fields.stream().collect(toMap(identity(), s -> randomAlphanumeric(4))));
- return object;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ private ModelInfo setStrings(ModelInfo object) {
+ return TestUtils.setStringsInStringProperties(object);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
new file mode 100644
index 000000000..4cba53785
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
@@ -0,0 +1,421 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.vid.mso;
+
+import io.joshworks.restclient.request.HttpRequest;
+import org.glassfish.jersey.client.JerseyInvocation;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.util.HttpsAuthClient;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import java.util.Optional;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+public class RestMsoImplementationTest {
+
+ @Mock
+ private HttpRequest httpRequest;
+
+ @Mock
+ private Client mockClient;
+
+ @Mock
+ private HttpsAuthClient mockHttpsAuthClient;
+
+ @Mock
+ private WebTarget webTarget;
+
+ @Mock
+ private javax.ws.rs.client.Invocation.Builder builder;
+
+ @Mock
+ private Response response;
+
+ @Mock
+ private JerseyInvocation jerseyInvocation;
+
+ @InjectMocks
+ private RestMsoImplementation restMsoImplementation = new RestMsoImplementation(mockHttpsAuthClient);
+
+ String path = "/test_path/";
+ String rawData = "test-row-data";
+
+ @BeforeClass
+ public void setUp(){
+ initMocks(this);
+ }
+
+ @Test
+ public void shouldProperlyInitMsoClient() {
+ // when
+ MultivaluedHashMap<String, Object> result = restMsoImplementation.initMsoClient();
+
+ // then
+ assertThat(result).containsKeys("Authorization","X-ONAP-PartnerName");
+ assertThat(result).doesNotContainKey("notExistingKey");
+ }
+
+ @Test
+ public void shouldProperlyGetRestObjectWithRequestInfo() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+
+ prepareMocks(rawData, HttpStatus.ACCEPTED.value(),"");
+
+ // when
+ RestObjectWithRequestInfo<HttpRequest> response = restMsoImplementation.Get(httpRequest, path, restObject,false);
+
+ // then
+ assertThat(response.getRequestedUrl()).contains(path);
+ assertThat(response.getRawData()).isEqualTo(rawData);
+ assertThat(response.getHttpCode()).isEqualTo(HttpStatus.ACCEPTED.value());
+ assertThat(response.getHttpMethod()).isEqualTo(HttpMethod.GET);
+ }
+
+ @Test( expectedExceptions = GenericUncheckedException.class)
+ public void shouldThrowExceptionWhenGetRestObjectWithRequestInfoGetsWrongStatus() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+
+ prepareMocks("",HttpStatus.BAD_REQUEST.value(),"");
+
+ // when
+ restMsoImplementation.Get(httpRequest, "", restObject,false);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenGetRestObjectWithRequestInfoGetsWrongParameters() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+
+ prepareMocks("",HttpStatus.ACCEPTED.value(),"");
+ when(mockClient.target(SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL))).thenThrow(new MsoTestException("test-target-exception"));
+
+ // when
+ restMsoImplementation.Get(httpRequest, "", restObject,false);
+ }
+
+ @Test()
+ public void shouldProperlyGetRestObjectForObjectWithRequestInfoAndAcceptCode() {
+ // given
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"");
+
+ // when
+ RestObject response = restMsoImplementation.GetForObject(path, HttpRequest.class);
+
+ // then
+ assertThat(response.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED.value());
+ assertThat(response.getRaw()).isEqualTo(rawData);
+ }
+
+ @Test()
+ public void shouldProperlyGetRestObjectForObjectWithRequestInfoAndBadRequestCode() {
+ // given
+ prepareMocks(rawData,HttpStatus.BAD_REQUEST.value(),"");
+
+ // when
+ RestObject response = restMsoImplementation.GetForObject(path, HttpRequest.class);
+
+ // then
+ assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST.value());
+ assertThat(response.getRaw()).isEqualTo(rawData);
+ }
+
+ @Test()
+ public void shouldProperlyDeleteRestObjectWithStatusHttpAccepted() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE");
+
+ // when
+ restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
+
+ // then
+ assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED.value());
+ }
+
+ @Test()
+ public void shouldProperlyDeleteRestObjectWithStatusOK() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+
+ prepareMocks(rawData,HttpStatus.OK.value(),"DELETE");
+
+ // when
+ restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
+
+ // then
+ assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.OK.value());
+ }
+
+ @Test()
+ public void shouldProperlyReturnFromDeleteWithStatusBadRequest() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+
+ prepareMocks(rawData,HttpStatus.BAD_REQUEST.value(),"DELETE");
+
+ // when
+ restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
+
+ // then
+ assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST.value());
+ }
+
+ @Test()
+ public void shouldProperlyReturnFromDeleteWithStatusOtherThenAbove() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+ prepareMocks(rawData,HttpStatus.NOT_EXTENDED.value(),"DELETE");
+
+ // when
+ restMsoImplementation.Delete(httpRequest, "testObject", path, restObject);
+
+ // then
+ assertThat(restObject.getStatusCode()).isEqualTo(HttpStatus.NOT_EXTENDED.value());
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenCallsDeleteWithWrongParameters() {
+ // given
+ when(mockClient.target(any(String.class))).thenThrow(new MsoTestException("testDeleteException"));
+
+ // when
+ restMsoImplementation.Delete(httpRequest, "testObject", "", null);
+ }
+
+ @Test( expectedExceptions = NullPointerException.class)
+ public void shouldThrowExceptionWhenCallsDeleteWithWrongObjectType() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE");
+
+ // when
+ restMsoImplementation.Delete(null, "testObject", path, restObject);
+ }
+
+ @Test
+ public void shouldProperlyPostForObject() {
+ // given
+ RequestDetails requestDetails = new RequestDetails();
+
+ RestObject<HttpRequest> expectedResponse = new RestObject<>();
+ expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value());
+ expectedResponse.setRaw(rawData);
+
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"POST");
+
+ // when
+ RestObject<HttpRequest> response = restMsoImplementation.PostForObject(requestDetails, path, HttpRequest.class);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyDeleteForObject() {
+ // given
+ RequestDetails requestDetails = new RequestDetails();
+
+ RestObject<HttpRequest> expectedResponse = new RestObject<>();
+ expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value());
+ expectedResponse.setRaw(rawData);
+
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE");
+
+ // when
+ RestObject<HttpRequest> response = restMsoImplementation.DeleteForObject(requestDetails, path, HttpRequest.class);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyPost() {
+ // given
+ RequestDetails requestDetails = new RequestDetails();
+ RestObject<String> response = new RestObject<>();
+
+ RestObject<String> expectedResponse = new RestObject<>();
+ expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value());
+ expectedResponse.setRaw(rawData);
+
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"POST");
+
+ // when
+ restMsoImplementation.Post(rawData,requestDetails, path, response);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyPrepareClient() {
+ // given
+ String method = "POST";
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),method);
+
+ // when
+ javax.ws.rs.client.Invocation.Builder response = restMsoImplementation.prepareClient(path, method);
+
+ // then
+ assertThat(response).isEqualTo(builder);
+ }
+
+ @Test
+ public void shouldCreatRestObjectOnlyWithHttpMethod() {
+ // given
+ String method = "GET";
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),method);
+
+ RestObject<String> expectedResponse = new RestObject<>();
+ expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value());
+ expectedResponse.setRaw(rawData);
+
+ // when
+ RestObject<String> response = restMsoImplementation.restCall(HttpMethod.GET, String.class, null, path, Optional.empty());
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenCreateRestObjectIsCalledWithoutDefinedClient() {
+ // given
+ when(mockClient.target(any(String.class))).thenThrow(new MsoTestException("testNoClientException"));
+
+ // when
+ restMsoImplementation.restCall(HttpMethod.GET, String.class, null, "", Optional.empty());
+ }
+
+ @Test
+ public void shouldProperlyPutRestObjectWithProperParametersAndStatusAccepted() {
+ // given
+ String method = "PUT";
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),method);
+
+ org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ RestObject<String> response = new RestObject<>();
+
+ RestObject<String> expectedResponse = new RestObject<>();
+ expectedResponse.setStatusCode(HttpStatus.ACCEPTED.value());
+ expectedResponse.set(rawData);
+
+ // when
+ restMsoImplementation.Put("testPutBody", requestDetailsWrapper , path, response);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyPutRestObjectWithProperParametersAndStatusMultipleChoices() {
+ // given
+ String method = "PUT";
+ prepareMocks(rawData,HttpStatus.MULTIPLE_CHOICES.value(),method);
+
+ org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+ RestObject<String> response = new RestObject<>();
+
+ RestObject<String> expectedResponse = new RestObject<>();
+ expectedResponse.setStatusCode(HttpStatus.MULTIPLE_CHOICES.value());
+ expectedResponse.set(rawData);
+
+ // when
+ restMsoImplementation.Put("testPutBody", requestDetailsWrapper , path, response);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenCallsPutWithWrongParameters() {
+ // given
+ when(mockClient.target(any(String.class))).thenThrow(new MsoTestException("testDeleteException"));
+ org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+
+ // when
+ restMsoImplementation.Put(null, requestDetailsWrapper, "", null);
+ }
+
+ @Test( expectedExceptions = NullPointerException.class)
+ public void shouldThrowExceptionWhenCallsPutWithWrongObjectType() {
+ // given
+ RestObject<HttpRequest> restObject = new RestObject<>();
+ org.onap.vid.changeManagement.RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
+
+ prepareMocks(rawData,HttpStatus.ACCEPTED.value(),"DELETE");
+
+ // when
+ restMsoImplementation.Put(null, requestDetailsWrapper, path, restObject);
+ }
+
+
+
+ private void prepareMocks(String rawData,int status,String httpMethod) {
+
+ when(mockClient.target(any(String.class))).thenReturn(webTarget);
+ when(webTarget.request()).thenReturn(builder);
+
+
+ when(builder.accept(any(String.class))).thenReturn(builder);
+ when(builder.headers(any(MultivaluedMap.class))).thenReturn(builder);
+ when(builder.get()).thenReturn(response);
+
+ when(builder.build( eq(httpMethod), any(Entity.class))).thenReturn(jerseyInvocation);
+ when(builder.build( eq(httpMethod))).thenReturn(jerseyInvocation);
+
+ when(builder.put( any(Entity.class))).thenReturn(response);
+ when(jerseyInvocation.invoke()).thenReturn(response);
+
+
+ when(response.getStatus()).thenReturn(status);
+ when(response.readEntity(String.class)).thenReturn(rawData);
+ }
+
+ private class MsoTestException extends RuntimeException{
+ MsoTestException(String testException) {
+ super(testException);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/InstanceIdsTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/InstanceIdsTest.java
new file mode 100644
index 000000000..e40bab6c1
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/InstanceIdsTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.vid.mso.rest;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class InstanceIdsTest {
+
+ private InstanceIds instanceIds;
+
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
+ private String networkInstanceId = "testNetworkId";
+ private String serviceInstanceId = "testServiceId";
+
+ @BeforeMethod
+ public void setUp() {
+ instanceIds = new InstanceIds();
+ }
+
+ @Test
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(InstanceIds.class, hasValidGettersAndSettersExcluding("additionalProperties"));
+ }
+
+ @Test
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ instanceIds.setAdditionalProperty(propertyName,additionalProperty);
+
+ // then
+ assertThat( instanceIds.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
+ }
+
+ @Test
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ instanceIds.setNetworkInstanceId(networkInstanceId);
+ instanceIds.setServiceInstanceId(serviceInstanceId);
+ instanceIds.setAdditionalProperty(propertyName,additionalProperty);
+
+ // when
+ String response = instanceIds.toString();
+
+ // then
+ assertThat(response).contains(
+ "[networkInstanceId="+networkInstanceId +
+ ",serviceInstanceId="+serviceInstanceId +
+ ",vfModuleInstanceId=<null>," +
+ "vnfInstanceId=<null>" +
+ ",volumeGroupInstanceId=<null>" +
+ ",additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
+ }
+
+ @Test
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(InstanceIds.class, hasValidBeanEqualsExcluding("additionalProperties"));
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
index 6114552e6..12fd4a519 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
@@ -20,8 +20,18 @@
*/
package org.onap.vid.mso.rest;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.server.StubServer;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+import java.util.UUID;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -37,17 +47,6 @@ import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.RestObject;
import org.springframework.test.context.ContextConfiguration;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-import java.util.UUID;
-
-import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
-import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
-
@ContextConfiguration(classes = {SystemProperties.class})
public class MsoRestClientNewTest {
@@ -280,16 +279,39 @@ public class MsoRestClientNewTest {
}
@Test
- public void testGetManualTasks() {
+ public void testGetManualTasksByRequestId() {
String p = props.getProperty(MsoProperties.MSO_REST_API_GET_ORC_REQ);
String path = p + "/" + UUID.randomUUID();
+ String validResponse = ""
+ + "{ "
+ + " \"taskList\": [ "
+ + " { "
+ + " \"taskId\": \"daf4dd84-b77a-42da-a051-3239b7a9392c\", "
+ + " \"type\": \"fallout\", "
+ + " \"nfRole\": \"vEsmeralda\", "
+ + " \"subscriptionServiceType\": \"Emanuel\", "
+ + " \"originalRequestId\": \"d352c70d-5ef8-4977-9ea8-4c8cbe860422\", "
+ + " \"originalRequestorId\": \"ss835w\", "
+ + " \"errorSource\": \"A&AI\", "
+ + " \"errorCode\": \"404\", "
+ + " \"errorMessage\": \"Failed in A&AI 404\", "
+ + " \"validResponses\": [ "
+ + " \"rollback\", "
+ + " \"abort\", "
+ + " \"skip\", "
+ + " \"resume\", "
+ + " \"retry\" "
+ + " ] "
+ + " } "
+ + " ] "
+ + "}";
try(MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
server,
path,
HttpStatus.OK_200,
- CREATE_INSTANCE_RESPONSE_STR,CREATE_INSTANCE_RESPONSE_STR)) {
- closure.executeGet(msoRestClient()::getManualTasks);
+ validResponse,validResponse)) {
+ closure.executeGet(endpoint -> msoRestClient().getManualTasksByRequestId(null, null, endpoint, null));
}
}
@@ -311,23 +333,6 @@ public class MsoRestClientNewTest {
}
@Test
- public void testGetManualTasksByRequestId() throws Exception {
- MsoRestClientNew testSubject;
- String t = "";
- String sourceId = "";
- String endpoint = "";
- RestObject restObject = null;
- MsoResponseWrapper result;
-
- // default test
- try {
- testSubject = createTestSubject();
- result = testSubject.getManualTasksByRequestId(t, sourceId, endpoint, restObject);
- } catch (Exception e) {
- }
- }
-
- @Test
public void testCompleteManualTask() throws Exception {
MsoRestClientNew testSubject;
RequestDetails requestDetails = null;
@@ -468,10 +473,10 @@ public class MsoRestClientNewTest {
private MsoRestClientNew msoRestClient() {
final WebConfig webConfig = new WebConfig();
- return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper())), baseUrl());
+ return new MsoRestClientNew(new SyncRestClient(webConfig.unirestFasterxmlObjectMapper(new ObjectMapper())), baseUrl(),null);
}
private MsoRestClientNew createTestSubject() {
- return new MsoRestClientNew(null, "");
+ return new MsoRestClientNew(null, "",null);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
index 5a0f93b45..ff71d85fc 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
@@ -20,21 +20,33 @@
*/
package org.onap.vid.mso.rest;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.json.JSONObject;
-import org.junit.Assert;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import io.joshworks.restclient.http.HttpResponse;
+import io.joshworks.restclient.http.JsonMapper;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.StatusLine;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.message.BasicStatusLine;
+import org.mockito.Mock;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.changeManagement.RequestDetails;
+import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.controller.LocalWebConfig;
-import org.onap.vid.mso.MsoBusinessLogic;
-import org.onap.vid.mso.MsoBusinessLogicImpl;
-import org.onap.vid.mso.model.CloudConfiguration;
-import org.onap.vid.mso.model.ModelInfo;
-import org.onap.vid.mso.model.RequestInfo;
-import org.onap.vid.mso.model.RequestParameters;
+import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.mso.MsoResponseWrapperInterface;
+import org.onap.vid.mso.MsoUtil;
+import org.onap.vid.mso.RestObject;
+import org.onap.vid.mso.model.RequestReferences;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -43,51 +55,720 @@ import org.testng.annotations.Test;
public class MsoRestClientTest {
- private MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogicImpl(new MsoRestClientNew(new SyncRestClient(), ""), null);
- private ObjectMapper om = new ObjectMapper();
+ private final String baseUrl = "http://testURL/";
+
+ @Mock
+ private SyncRestClient client;
+
+ private MsoRestClientNew restClient;
+
+
+ @BeforeClass
+ private void setUp(){
+ initMocks(this);
+ restClient = new MsoRestClientNew(client,baseUrl,null);
+
+ }
@Test
- public void createInPlaceMsoRequest() {
- String result = null;
- try {
- RequestDetails requestDetails = generateMockMsoRequest();
- result = om.writeValueAsString(msoBusinessLogic.generateInPlaceMsoRequest(requestDetails));
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (result == null) {
- Assert.fail("Failed to create mso request");
+ public void shouldProperlyCreateServiceInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.createSvcInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenCreateSvcInstanceGetsWrongParameters() {
+ // given
+ String endpoint = "";
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(null),eq(String.class) ) ).
+ thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.createSvcInstance(null,endpoint);
+ }
+
+ @Test
+ public void shouldProperlyCreateE2eSvcInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.createE2eSvcInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyCreateVnf() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.createVnf(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyCreateNwInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.createNwInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyCreateVolumeGroupInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.createVolumeGroupInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyCreateVfModuleInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.createVfModuleInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyScaleOutVFModuleInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ RequestDetailsWrapper<RequestDetails> wrappedRequestDetails = new RequestDetailsWrapper<>(requestDetails);
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(wrappedRequestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.scaleOutVFModuleInstance(wrappedRequestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyCreateConfigurationInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ org.onap.vid.mso.rest.RequestDetailsWrapper wrappedRequestDetails = new org.onap.vid.mso.rest.RequestDetailsWrapper(requestDetails);
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(wrappedRequestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.createConfigurationInstance(wrappedRequestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyDeleteE2eSvcInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ org.onap.vid.mso.rest.RequestDetailsWrapper wrappedRequestDetails = new org.onap.vid.mso.rest.RequestDetailsWrapper(requestDetails);
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.delete( eq(baseUrl+endpoint),anyMap(),eq(wrappedRequestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.deleteE2eSvcInstance(wrappedRequestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyDeleteSvcInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.delete( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.deleteSvcInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyUnassignSvcInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.unassignSvcInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyDeleteVnf() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.delete( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.deleteVnf(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyDeleteVfModule() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.delete( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.deleteVfModule(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyDeleteVolumeGroupInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.delete( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.deleteVolumeGroupInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyDeleteNwInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.delete( eq(baseUrl+endpoint),anyMap(),eq(requestDetails),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.deleteNwInstance(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyGetOrchestrationRequest() {
+ // given
+ RestObject restObject = generateMockMsoRestObject();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.get( eq(baseUrl+endpoint),anyMap(),anyMap(),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.getOrchestrationRequest(null,null,endpoint,restObject,true);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyGetOrchestrationRequestWithOnlyEndpoint() {
+ // given
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.get( eq(baseUrl+endpoint),anyMap(),anyMap(),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.getOrchestrationRequest(endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyGetManualTasksByRequestId() {
+ // given
+ RestObject restObject = generateMockMsoRestObject();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.get( eq(baseUrl+endpoint),anyMap(),anyMap(),eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.getManualTasksByRequestId(null,null,endpoint,restObject);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test(expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenGetManualTasksByRequestIdGetsWrongParameter() {
+ // given
+ when( client.get( eq(baseUrl),anyMap(),anyMap(),eq(String.class) ) ).thenThrow(new MsoTestException("testsException"));
+
+ // when
+ restClient.getManualTasksByRequestId(null,null,"",null);
+ }
+
+ @Test
+ public void shouldProperlyCompleteManualTask() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+ RestObject restObject = generateMockMsoRestObject();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint), anyMap(), eq(requestDetails), eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.completeManualTask(requestDetails,null,null,endpoint,restObject);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test(expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenCompleteManualTaskWrongParameter() {
+ // given
+ when( client.post( eq(baseUrl),anyMap(),eq(null), eq(String.class) ) ).thenThrow(new MsoTestException("testsException"));
+
+ // when
+ restClient.completeManualTask(null, null,null,"",null);
+ }
+
+ @Test
+ public void shouldProperlyReplaceVnf() {
+ // given
+ org.onap.vid.changeManagement.RequestDetails requestDetails = MsoRestClientTestUtil.generateChangeManagementMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint), anyMap(), any(RequestDetailsWrapper.class), eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.replaceVnf(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldProperlyReplaceVnfWithStatus202() {
+ // given
+ org.onap.vid.changeManagement.RequestDetails requestDetails = MsoRestClientTestUtil.generateChangeManagementMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = createOkResponse();
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.post( eq(baseUrl+endpoint), anyMap(), any(RequestDetailsWrapper.class), eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.replaceVnf(requestDetails,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenReplaceVnfGetsWrongParameters() {
+ // given
+ org.onap.vid.changeManagement.RequestDetails requestDetails = MsoRestClientTestUtil.generateChangeManagementMockMsoRequest();
+
+ when( client.post( eq(baseUrl), anyMap(), any(RequestDetailsWrapper.class), eq(String.class) ) ).thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.replaceVnf(requestDetails, "");
+ }
+
+ @Test
+ public void shouldProperlyDeleteConfiguration() {
+ // given
+ org.onap.vid.changeManagement.RequestDetails requestDetails = MsoRestClientTestUtil.generateChangeManagementMockMsoRequest();
+ org.onap.vid.mso.rest.RequestDetailsWrapper requestDetailsWrapper = new org.onap.vid.mso.rest.RequestDetailsWrapper(requestDetails);
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when( client.delete( eq(baseUrl+endpoint), anyMap(), eq(requestDetailsWrapper), eq(String.class) ) ).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.deleteConfiguration(requestDetailsWrapper,endpoint);
+
+ // then
+ assertThat(response).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class )
+ public void shouldThrowExceptionWhenProperlyDeleteConfigurationGetsWrongParameters() {
+ // given
+ when( client.delete( eq(baseUrl), anyMap(), eq(null), eq(String.class) ) ).thenThrow(new MsoTestException("test-delete-exception"));
+
+ // when
+ restClient.deleteConfiguration(null,"");
+ }
+
+ @Test
+ public void shouldProperlySetConfigurationActiveStatus() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetails), eq(String.class))).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.setConfigurationActiveStatus(requestDetails, endpoint);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ @Test(expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenSetConfigurationActiveStatusGetsWrongParameters() {
+ // given
+
+ when(client.post(eq(baseUrl), anyMap(), eq(null), eq(String.class))).thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.setConfigurationActiveStatus(null, "");
+ }
+
+ @Test
+ public void shouldProperlySetPortOnConfigurationStatus() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetails), eq(String.class))).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.setPortOnConfigurationStatus(requestDetails, endpoint);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ @Test(expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenSetPortOnConfigurationStatusGetsWrongParameters() {
+ // given
+ String endpoint = "";
+
+ when(client.post(eq(baseUrl), anyMap(), eq(null), eq(String.class))).thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.setPortOnConfigurationStatus(null, endpoint);
+ }
+
+ @Test
+ public void shouldProperlyChangeManagementUpdate() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(requestDetails);
+
+ String endpoint = "testEndpoint";
+ HttpResponse<RequestReferencesContainer> httpResponse = HttpResponse.fallback(
+ new RequestReferencesContainer(
+ new RequestReferences()));
+
+ MsoResponseWrapperInterface expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetailsWrapper), eq(RequestReferencesContainer.class))).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapperInterface response = restClient.changeManagementUpdate(requestDetailsWrapper, endpoint);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ @Test
+ public void shouldProperlyUpdateVnfAndUpdateInstance() {
+ // given
+ org.onap.vid.changeManagement.RequestDetails requestDetails = MsoRestClientTestUtil.generateChangeManagementMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapperInterface expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+
+ when(client.put(eq(baseUrl + endpoint), anyMap(), any(RequestDetailsWrapper.class), eq(String.class))).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapperInterface response = restClient.updateVnf(requestDetails, endpoint);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class )
+ public void shouldThrowExceptionWhenUpdateVnfAndUpdateInstanceGetsWrongParameter() {
+ // given
+ org.onap.vid.changeManagement.RequestDetails requestDetails = MsoRestClientTestUtil.generateChangeManagementMockMsoRequest();
+ String endpoint = "";
+
+ when(client.put(eq(baseUrl), anyMap(), any(RequestDetailsWrapper.class), eq(String.class))).thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.updateVnf(requestDetails, endpoint);
+
+ // then
+ }
+
+ @Test
+ public void shouldProperlySetServiceInstanceStatus() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+ RestObject<String> restObject = generateMockMsoRestObject();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+
+ when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetails), eq(String.class))).thenReturn(httpResponse);
+
+ // when
+ restClient.setServiceInstanceStatus(requestDetails,"", "", endpoint, restObject);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenSetServiceInstanceStatusGetsWrongParameter() {
+ // given
+ String endpoint = "";
+
+ when(client.post(eq(baseUrl), anyMap(), eq(null), eq(String.class))).thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.setServiceInstanceStatus(null,"", "", endpoint, null);
+ }
+
+ @Test
+ public void shouldProperlyRemoveRelationshipFromServiceInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetails), eq(String.class))).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.removeRelationshipFromServiceInstance(requestDetails, endpoint);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenRemoveRelationshipFromServiceInstanceGetsWrongParameter() {
+ // given
+ String endpoint = "";
+
+ when(client.post(eq(baseUrl), anyMap(), eq(null), eq(String.class))).thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.removeRelationshipFromServiceInstance(null,endpoint);
+ }
+
+ @Test
+ public void shouldProperlyAddRelationshipToServiceInstance() {
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(httpResponse);
+
+ when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetails), eq(String.class))).thenReturn(httpResponse);
+
+ // when
+ MsoResponseWrapper response = restClient.addRelationshipToServiceInstance(requestDetails, endpoint);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ @Test( expectedExceptions = MsoTestException.class)
+ public void shouldThrowExceptionWhenAddRelationshipToServiceInstanceGetsWrongParameter() {
+ // given
+ String endpoint = "";
+
+ when(client.post(eq(baseUrl), anyMap(), eq(null), eq(String.class))).thenThrow(new MsoTestException("test-post-exception"));
+
+ // when
+ restClient.addRelationshipToServiceInstance(null,endpoint);
+ }
+
+ @Test
+ public void shouldProperlyPerformGetRequest() {
+ // given
+ String endpoint = "testEndpoint";
+ HttpResponse<String> expectedResponse = HttpResponse.fallback("testOkResponse");
+
+ when(client.get(eq(baseUrl + endpoint), anyMap(), anyMap(), eq(String.class))).thenReturn(expectedResponse);
+
+ // when
+ HttpResponse<String> response = restClient.get(endpoint, String.class);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ @Test
+ public void shouldProperlyPerformPostRequest() {
+ // given
+
+ RequestDetailsWrapper<RequestDetails> requestDetailsWrapper = new RequestDetailsWrapper<>(MsoRestClientTestUtil.generateMockMsoRequest());
+
+ String endpoint = "testEndpoint";
+ HttpResponse<String> expectedResponse = HttpResponse.fallback("testOkResponse");
+
+ when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetailsWrapper), eq(String.class))).thenReturn(expectedResponse);
+
+ // when
+ HttpResponse<String> response = restClient.post(endpoint,requestDetailsWrapper, String.class);
+
+ // then
+ assertThat(expectedResponse).isEqualToComparingFieldByField(response);
+ }
+
+ private class MsoTestException extends RuntimeException{
+ MsoTestException(String testException) {
+ super(testException);
}
- JSONObject jsonObj = new JSONObject(result);
- Assert.assertNotNull(jsonObj.getJSONObject("requestDetails"));
- }
-
- private RequestDetails generateMockMsoRequest() {
- RequestDetails requestDetails = new RequestDetails();
- requestDetails.setVnfInstanceId("vnf-instance-id");
- requestDetails.setVnfName("vnf-name");
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
- cloudConfiguration.setTenantId("tenant-id");
- cloudConfiguration.setLcpCloudRegionId("lcp-region");
- requestDetails.setCloudConfiguration(cloudConfiguration);
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelInvariantId("model-invarient-id");
- modelInfo.setModelCustomizationName("modelCustomizationName");
- requestDetails.setModelInfo(modelInfo);
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setRequestorId("ok883e");
- requestInfo.setSource("VID");
- requestDetails.setRequestInfo(requestInfo);
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setSubscriptionServiceType("subscriber-service-type");
- requestParameters.setAdditionalProperty("a", 1);
- requestParameters.setAdditionalProperty("b", 2);
- requestParameters.setAdditionalProperty("c", 3);
- requestParameters.setAdditionalProperty("d", 4);
- String payload = "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}";
- requestParameters.setAdditionalProperty("payload", payload);
-
- requestDetails.setRequestParameters(requestParameters);
- return requestDetails;
+ }
+
+ private HttpResponse<String> createOkResponse() {
+ StatusLine statusline = new BasicStatusLine(
+ new ProtocolVersion("http",1,1), 202, "acceptResponse");
+
+ org.apache.http.HttpResponse responseBase = new BasicHttpResponse(statusline);
+
+ return new HttpResponse<>(responseBase ,String.class, new JsonMapper());
+ }
+
+ private RestObject<String> generateMockMsoRestObject() {
+ RestObject<String> restObject = new RestObject<>();
+
+ restObject.set("test-rest-object-body");
+ restObject.setRaw("test-rest-object-raw-string");
+ restObject.setStatusCode(202);
+ return restObject;
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
index 2a607b511..f10a7f14f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
@@ -31,23 +31,30 @@ import static com.xebialabs.restito.semantics.Condition.method;
import static com.xebialabs.restito.semantics.Condition.post;
import static com.xebialabs.restito.semantics.Condition.uri;
import static com.xebialabs.restito.semantics.Condition.withHeader;
+import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.semantics.Action;
import com.xebialabs.restito.server.StubServer;
import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
-
import org.glassfish.grizzly.http.Method;
import org.glassfish.grizzly.http.util.HttpStatus;
import org.json.JSONObject;
import org.junit.Assert;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.changeManagement.RelatedInstanceList;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.mso.MsoResponseWrapper;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.RequestInfo;
+import org.onap.vid.mso.model.RequestParameters;
class MsoRestClientTestUtil implements AutoCloseable {
private final StubServer server;
@@ -109,6 +116,7 @@ class MsoRestClientTestUtil implements AutoCloseable {
MsoResponseWrapper response = func.apply(sampleRequestDetails, endpoint);
Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ assertJsonEquals(expectedResponseStr, response.getEntity());
verifyServer(server, endpoint, Method.DELETE);
}
@@ -120,9 +128,78 @@ class MsoRestClientTestUtil implements AutoCloseable {
MsoResponseWrapper response = func.apply(endpoint);
Assert.assertEquals(expectedStatus.getStatusCode(), response.getStatus());
+ assertJsonEquals(expectedResponseStr, response.getEntity());
verifyServer(server, endpoint, Method.GET);
}
+ static org.onap.vid.changeManagement.RequestDetails generateMockMsoRequest() {
+ org.onap.vid.changeManagement.RequestDetails requestDetails = new org.onap.vid.changeManagement.RequestDetails();
+ requestDetails.setVnfInstanceId("vnf-instance-id");
+ requestDetails.setVnfName("vnf-name");
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setTenantId("tenant-id");
+ cloudConfiguration.setLcpCloudRegionId("lcp-region");
+ requestDetails.setCloudConfiguration(cloudConfiguration);
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId("model-invarient-id");
+ modelInfo.setModelCustomizationName("modelCustomizationName");
+ requestDetails.setModelInfo(modelInfo);
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setRequestorId("ok883e");
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setSubscriptionServiceType("subscriber-service-type");
+ requestParameters.setAdditionalProperty("a", 1);
+ requestParameters.setAdditionalProperty("b", 2);
+ requestParameters.setAdditionalProperty("c", 3);
+ requestParameters.setAdditionalProperty("d", 4);
+ String payload = "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}";
+ requestParameters.setAdditionalProperty("payload", payload);
+
+ requestDetails.setRequestParameters(requestParameters);
+ return requestDetails;
+ }
+
+ static org.onap.vid.changeManagement.RequestDetails generateChangeManagementMockMsoRequest() {
+ List<RelatedInstanceList> relatedInstances = new LinkedList<>();
+ relatedInstances.add(new RelatedInstanceList());
+
+ org.onap.vid.changeManagement.RequestDetails requestDetails = new org.onap.vid.changeManagement.RequestDetails();
+
+ requestDetails.setVnfName("test-vnf-name");
+ requestDetails.setVnfInstanceId("test-vnf-instance_id");
+ requestDetails.setRelatedInstList(relatedInstances);
+
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setTenantId("tenant-id");
+ cloudConfiguration.setLcpCloudRegionId("lcp-region");
+ requestDetails.setCloudConfiguration(cloudConfiguration);
+
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelInvariantId("model-invarient-id");
+ modelInfo.setModelCustomizationName("modelCustomizationName");
+ modelInfo.setModelType("test-model-type");
+ requestDetails.setModelInfo(modelInfo);
+
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setRequestorId("ok883e");
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setSubscriptionServiceType("subscriber-service-type");
+ requestParameters.setAdditionalProperty("a", 1);
+ requestParameters.setAdditionalProperty("b", 2);
+ requestParameters.setAdditionalProperty("c", 3);
+ requestParameters.setAdditionalProperty("d", 4);
+ String payload = "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}";
+ requestParameters.setAdditionalProperty("payload", payload);
+
+ requestDetails.setRequestParameters(requestParameters);
+ return requestDetails;
+ }
+
private void verifyServer(StubServer server, String endpoint, Method httpMethod) {
verifyHttp(server).once(
method(httpMethod),
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
index 1a8aa3b48..c76298442 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -20,94 +21,66 @@
package org.onap.vid.mso.rest;
-import org.junit.Test;
-import org.onap.vid.mso.model.ModelInfo;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-import java.util.Map;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class RelatedInstanceTest {
- private RelatedInstance createTestSubject() {
- return new RelatedInstance();
- }
+ private RelatedInstance relatedInstance = new RelatedInstance();
-
- @Test
- public void testGetModelInfo() throws Exception {
- RelatedInstance testSubject;
- ModelInfo result;
+ private String instanceId = "testInstanceId";
+ private String InstanceName = "testInstance";
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModelInfo();
+ @BeforeMethod
+ public void setUp() {
+ relatedInstance = new RelatedInstance();
}
-
@Test
- public void testSetModelInfo() throws Exception {
- RelatedInstance testSubject;
- ModelInfo modelInfo = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setModelInfo(modelInfo);
+ public void shouldHaveProperGettersAndSetters() {
+ assertThat(RelatedInstance.class, hasValidGettersAndSettersExcluding("additionalProperties"));
}
-
@Test
- public void testToString() throws Exception {
- RelatedInstance testSubject;
- String result;
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ relatedInstance.setAdditionalProperty(propertyName,additionalProperty);
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ // then
+ assertThat( relatedInstance.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
}
-
@Test
- public void testGetAdditionalProperties() throws Exception {
- RelatedInstance testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ relatedInstance.setInstanceId(instanceId);
+ relatedInstance.setInstanceName(InstanceName);
+ relatedInstance.setAdditionalProperty(propertyName,additionalProperty);
+
+ // when
+ String response = relatedInstance.toString();
+
+ // then
+ assertThat(response).contains(
+ "instanceName="+InstanceName+"," +
+ "instanceId="+instanceId+"," +
+ "modelInfo=<null>," +
+ "additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
}
-
@Test
- public void testSetAdditionalProperty() throws Exception {
- RelatedInstance testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAdditionalProperty(name, value);
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(RelatedInstance.class, hasValidBeanEqualsExcluding("additionalProperties"));
}
-
- @Test
- public void testHashCode() throws Exception {
- RelatedInstance testSubject;
- int result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
- }
-
-
- @Test
- public void testEquals() throws Exception {
- RelatedInstance testSubject;
- Object other = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.equals(other);
- }
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
index 2ae7535dc..575ceab7c 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsTest.java
@@ -20,185 +20,114 @@
package org.onap.vid.mso.rest;
-import org.junit.Test;
-import org.onap.vid.mso.model.CloudConfiguration;
-import org.onap.vid.mso.model.ModelInfo;
-import org.onap.vid.mso.model.RequestInfo;
-
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.assertj.core.api.AssertionsForClassTypes;
+import org.onap.vid.exceptions.NotFoundException;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
import java.util.List;
import java.util.Map;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.testng.AssertJUnit.assertEquals;
+
public class RequestDetailsTest {
- private RequestDetails createTestSubject() {
- return new RequestDetails();
- }
+ private RequestDetails requestDetails;
-
- @Test
- public void testGetCloudConfiguration() throws Exception {
- RequestDetails testSubject;
- CloudConfiguration result;
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCloudConfiguration();
- }
+ private static final ImmutableList<String> LCP_CLOUD_REGION_ID_PATH =
+ ImmutableList.of("requestDetails", "cloudConfiguration", "lcpCloudRegionId");
-
- @Test
- public void testSetCloudConfiguration() throws Exception {
- RequestDetails testSubject;
- CloudConfiguration cloudConfiguration = null;
- // default test
- testSubject = createTestSubject();
- testSubject.setCloudConfiguration(cloudConfiguration);
+ @BeforeMethod
+ public void setUp() {
+ requestDetails = new RequestDetails();
}
-
@Test
- public void testGetModelInfo() throws Exception {
- RequestDetails testSubject;
- ModelInfo result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModelInfo();
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(RequestDetails.class, hasValidGettersAndSettersExcluding("additionalProperties"));
}
-
@Test
- public void testSetModelInfo() throws Exception {
- RequestDetails testSubject;
- ModelInfo modelInfo = null;
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ requestDetails.setAdditionalProperty(propertyName,additionalProperty);
- // default test
- testSubject = createTestSubject();
- testSubject.setModelInfo(modelInfo);
+ // then
+ AssertionsForClassTypes.assertThat( requestDetails.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
}
-
@Test
- public void testGetRelatedInstanceList() throws Exception {
- RequestDetails testSubject;
- List<RelatedInstanceWrapper> result;
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ requestDetails.setAdditionalProperty(propertyName,additionalProperty);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRelatedInstanceList();
- }
-
-
- @Test
- public void testSetRelatedInstanceList() throws Exception {
- RequestDetails testSubject;
- List<RelatedInstanceWrapper> relatedInstanceList = null;
+ // when
+ String response = requestDetails.toString();
- // default test
- testSubject = createTestSubject();
- testSubject.setRelatedInstanceList(relatedInstanceList);
+ // then
+ AssertionsForClassTypes.assertThat(response).contains(
+ "additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
}
-
@Test
- public void testGetRequestInfo() throws Exception {
- RequestDetails testSubject;
- RequestInfo result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRequestInfo();
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(RequestDetails.class, hasValidBeanEqualsExcluding("additionalProperties"));
}
-
- @Test
- public void testSetRequestInfo() throws Exception {
- RequestDetails testSubject;
- RequestInfo requestInfo = null;
+ @DataProvider
+ public static Object[][] extractValueByPathDataProvider() {
- // default test
- testSubject = createTestSubject();
- testSubject.setRequestInfo(requestInfo);
- }
+ RequestDetails requestDetails1 = new RequestDetails();
+ Map cloudConfiguration = ImmutableMap.of("lcpCloudRegionId", "lcp1");
+ requestDetails1.setAdditionalProperty("requestDetails",
+ ImmutableMap.of("cloudConfiguration", cloudConfiguration));
-
- @Test
- public void testGetSubscriberInfo() throws Exception {
- RequestDetails testSubject;
- SubscriberInfo result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getSubscriberInfo();
- }
-
-
- @Test
- public void testSetSubscriberInfo() throws Exception {
- RequestDetails testSubject;
- SubscriberInfo subscriberInfo = null;
+ return new Object[][] {
+ { requestDetails1, LCP_CLOUD_REGION_ID_PATH, String.class, "lcp1" },
+ { requestDetails1, ImmutableList.of("requestDetails", "cloudConfiguration"), Map.class, cloudConfiguration },
- // default test
- testSubject = createTestSubject();
- testSubject.setSubscriberInfo(subscriberInfo);
+ };
}
-
- @Test
- public void testToString() throws Exception {
- RequestDetails testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ @Test(dataProvider = "extractValueByPathDataProvider")
+ public void testExtractValueByPath(RequestDetails requestDetails, List<String> keys, Class clz, Object expectedValue) {
+ assertEquals(expectedValue, requestDetails.extractValueByPathUsingAdditionalProperties(keys, clz));
}
-
- @Test
- public void testGetAdditionalProperties() throws Exception {
- RequestDetails testSubject;
- Map<String, Object> result;
+ @DataProvider
+ public static Object[][] extractValueByPathDataProviderThrowException() {
+ RequestDetails requestDetails1 = new RequestDetails();
+ requestDetails1.setAdditionalProperty("requestDetails",
+ ImmutableMap.of("cloudConfiguration", "notMap"));
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
- }
+ RequestDetails requestDetails2 = new RequestDetails();
+ requestDetails2.setAdditionalProperty("requestDetails",
+ ImmutableMap.of("cloudConfiguration", Collections.EMPTY_MAP));
-
- @Test
- public void testSetAdditionalProperty() throws Exception {
- RequestDetails testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAdditionalProperty(name, value);
- }
-
-
- @Test
- public void testHashCode() throws Exception {
- RequestDetails testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
+ return new Object[][] {
+ { new RequestDetails(), LCP_CLOUD_REGION_ID_PATH, String.class},
+ { requestDetails1, LCP_CLOUD_REGION_ID_PATH, String.class},
+ { requestDetails1, ImmutableList.of("requestDetails", "abc"), String.class},
+ { requestDetails2, LCP_CLOUD_REGION_ID_PATH, String.class},
+ };
}
-
- @Test
- public void testEquals() throws Exception {
- RequestDetails testSubject;
- Object other = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.equals(other);
+ @Test(dataProvider = "extractValueByPathDataProviderThrowException", expectedExceptions = NotFoundException.class)
+ public void testExtractValueByPathThrowException(RequestDetails requestDetails, List<String> keys, Class clz) {
+ requestDetails.extractValueByPathUsingAdditionalProperties(keys, clz);
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsWrapperTest.java
new file mode 100644
index 000000000..d30f0b671
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestDetailsWrapperTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.vid.mso.rest;
+
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class RequestDetailsWrapperTest {
+
+ private RequestDetailsWrapper requestDetailsWrapper;
+
+ @Test
+ public void shouldHaveProperConstructorAndGet(){
+ // given
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+
+ // when
+ requestDetailsWrapper = new RequestDetailsWrapper(requestDetails);
+
+ // then
+ assertThat(requestDetailsWrapper.getRequestDetails()).isEqualToComparingFieldByField(requestDetails);
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java
index 12c11e091..f7e6deea8 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,86 +20,57 @@
package org.onap.vid.mso.rest;
-import java.util.List;
-import java.util.Map;
+import org.assertj.core.api.AssertionsForClassTypes;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
public class RequestListTest {
- private RequestList createTestSubject() {
- return new RequestList();
- }
+ private RequestList requestList;
- @Test
- public void testGetRequestList() throws Exception {
- RequestList testSubject;
- List<RequestWrapper> result;
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRequestList();
+ @BeforeMethod
+ public void setUp() {
+ requestList = new RequestList();
}
@Test
- public void testSetRequestList() throws Exception {
- RequestList testSubject;
- List<RequestWrapper> l = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setRequestList(l);
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(RequestList.class, hasValidGettersAndSettersExcluding("additionalProperties"));
}
@Test
- public void testToString() throws Exception {
- RequestList testSubject;
- String result;
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ requestList.setAdditionalProperty(propertyName,additionalProperty);
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ // then
+ AssertionsForClassTypes.assertThat( requestList.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
}
@Test
- public void testGetAdditionalProperties() throws Exception {
- RequestList testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(RequestList.class, hasValidBeanEqualsExcluding("additionalProperties"));
}
@Test
- public void testSetAdditionalProperty() throws Exception {
- RequestList testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAdditionalProperty(name, value);
- }
-
- @Test
- public void testHashCode() throws Exception {
- RequestList testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
- }
-
- @Test
- public void testEquals() throws Exception {
- RequestList testSubject;
- Object other = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.equals(other);
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ requestList.setAdditionalProperty(propertyName,additionalProperty);
+
+ // when
+ String response = requestList.toString();
+
+ // then
+ System.out.println(response);
+ AssertionsForClassTypes.assertThat(response).contains(
+ "additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestStatusTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestStatusTest.java
new file mode 100644
index 000000000..ab1f4340d
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestStatusTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.vid.mso.rest;
+
+import org.assertj.core.api.AssertionsForClassTypes;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class RequestStatusTest {
+
+ private RequestStatus RequestStatus;
+
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
+
+ @BeforeMethod
+ public void setUp() {
+ RequestStatus = new RequestStatus();
+ }
+
+ @Test
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(RequestStatus.class, hasValidGettersAndSettersExcluding("additionalProperties"));
+ }
+
+ @Test
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ RequestStatus.setAdditionalProperty(propertyName,additionalProperty);
+
+ // then
+ AssertionsForClassTypes.assertThat( RequestStatus.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
+ }
+
+ @Test
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(RequestStatus.class, hasValidBeanEqualsExcluding("additionalProperties"));
+ }
+
+ @Test
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ RequestStatus.setAdditionalProperty(propertyName,additionalProperty);
+ RequestStatus.setRequestState("testState");
+ RequestStatus.setTimestamp("100");
+
+ // when
+ String response = RequestStatus.toString();
+
+ // then
+ System.out.println(response);
+ AssertionsForClassTypes.assertThat(response).contains(
+ "percentProgress=<null>," +
+ "requestState=testState," +
+ "statusMessage=<null>," +
+ "timestamp=100," +
+ "wasRolledBack=<null>," +
+ "additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
+ }
+
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java
index 1f8898e2a..0b5e288d7 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,102 +20,68 @@
package org.onap.vid.mso.rest;
-import org.junit.Test;
-public class RequestTest {
-
- private Request createTestSubject() {
- return new Request();
- }
-
- @Test
- public void testGetInstanceIds() throws Exception {
- Request testSubject;
- InstanceIds result;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInstanceIds();
- }
-
- @Test
- public void testSetInstanceIds() throws Exception {
- Request testSubject;
- InstanceIds instanceIds = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInstanceIds(instanceIds);
- }
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
- @Test
- public void testGetRequestDetails() throws Exception {
- Request testSubject;
- RequestDetails result;
+public class RequestTest {
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRequestDetails();
- }
- @Test
- public void testSetRequestDetails() throws Exception {
- Request testSubject;
- RequestDetails requestDetails = null;
+ private Request request;
- // default test
- testSubject = createTestSubject();
- testSubject.setRequestDetails(requestDetails);
- }
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
- @Test
- public void testGetRequestStatus() throws Exception {
- Request testSubject;
- RequestStatus result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRequestStatus();
+ @BeforeMethod
+ public void setUp() {
+ request = new Request();
}
@Test
- public void testSetRequestStatus() throws Exception {
- Request testSubject;
- RequestStatus requestStatus = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setRequestStatus(requestStatus);
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(Request.class, hasValidGettersAndSettersExcluding("additionalProperties"));
}
@Test
- public void testToString() throws Exception {
- Request testSubject;
- String result;
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ request.setAdditionalProperty(propertyName,additionalProperty);
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ // then
+ assertThat( request.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
}
@Test
- public void testEquals() throws Exception {
- Request testSubject;
- Object other = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.equals(other);
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ request.setFinishTime("100");
+ request.setRequestId("testRequest");
+ request.setAdditionalProperty(propertyName,additionalProperty);
+
+ // when
+ String response = request.toString();
+
+ // then
+ assertThat(response).contains(
+ "[instanceIds=<null>," +
+ "requestDetails=<null>," +
+ "requestStatus=<null>," +
+ "finishTime="+100+"," +
+ "requestId=testRequest," +
+ "requestScope=<null>," +
+ "requestType=<null>," +
+ "startTime=<null>," +
+ "additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
}
@Test
- public void testHashCode() throws Exception {
- Request testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(Request.class, hasValidBeanEqualsExcluding("additionalProperties"));
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestWrapperTest.java
index 2a8e6d9b1..3e9b710c9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestWrapperTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestWrapperTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,31 +20,15 @@
package org.onap.vid.mso.rest;
-import org.junit.Test;
+import org.testng.annotations.Test;
-public class RequestWrapperTest {
-
- private RequestWrapper createTestSubject() {
- return new RequestWrapper();
- }
-
- @Test
- public void testGetRequest() throws Exception {
- RequestWrapper testSubject;
- Request result;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRequest();
- }
+public class RequestWrapperTest {
@Test
- public void testSetRequest() throws Exception {
- RequestWrapper testSubject;
- Request request = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setRequest(request);
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(RequestWrapper.class, hasValidGettersAndSetters());
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/ResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/ResponseTest.java
index 0a25e6d6a..a29e2a589 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/ResponseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/ResponseTest.java
@@ -20,51 +20,15 @@
package org.onap.vid.mso.rest;
-import org.junit.Test;
+import org.testng.annotations.Test;
-public class ResponseTest {
-
- private Response createTestSubject() {
- return new Response();
- }
-
- @Test
- public void testGetStatus() throws Exception {
- Response testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getStatus();
- }
-
- @Test
- public void testSetStatus() throws Exception {
- Response testSubject;
- int status = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setStatus(status);
- }
-
- @Test
- public void testGetEntity() throws Exception {
- Response testSubject;
- RequestList result;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getEntity();
- }
+public class ResponseTest {
@Test
- public void testSetEntity() throws Exception {
- Response testSubject;
- RequestList entity = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setEntity(entity);
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(Response.class, hasValidGettersAndSetters());
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/SubscriberInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/SubscriberInfoTest.java
new file mode 100644
index 000000000..5a7cd3b51
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/SubscriberInfoTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia 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.vid.mso.rest;
+
+import org.assertj.core.api.AssertionsForClassTypes;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class SubscriberInfoTest {
+
+ private SubscriberInfo SubscriberInfo;
+
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
+
+ @BeforeMethod
+ public void setUp() {
+ SubscriberInfo = new SubscriberInfo();
+ }
+
+ @Test
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(SubscriberInfo.class, hasValidGettersAndSettersExcluding("additionalProperties"));
+ }
+
+ @Test
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ SubscriberInfo.setAdditionalProperty(propertyName,additionalProperty);
+
+ // then
+ AssertionsForClassTypes.assertThat( SubscriberInfo.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
+ }
+
+ @Test
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(SubscriberInfo.class, hasValidBeanEqualsExcluding("additionalProperties"));
+ }
+
+ @Test
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ SubscriberInfo.setAdditionalProperty(propertyName,additionalProperty);
+ SubscriberInfo.setGlobalSubscriberId("testSubscriberId");
+ SubscriberInfo.setSubscriberName("testSubscriberName");
+
+ // when
+ String response = SubscriberInfo.toString();
+
+ // then
+ System.out.println(response);
+ AssertionsForClassTypes.assertThat(response).contains(
+ "globalSubscriberId=testSubscriberId," +
+ "subscriberCommonSiteId=<null>," +
+ "subscriberName=testSubscriberName," +
+ "additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
+ }
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskListTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskListTest.java
index 41ed6b9ca..4a8d40cbd 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskListTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskListTest.java
@@ -20,33 +20,15 @@
package org.onap.vid.mso.rest;
-import java.util.List;
+import org.testng.annotations.Test;
-import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
public class TaskListTest {
- private TaskList createTestSubject() {
- return new TaskList();
- }
-
@Test
- public void testGetTaskList() throws Exception {
- TaskList testSubject;
- List<Task> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTaskList();
- }
-
- @Test
- public void testSetTaskList() throws Exception {
- TaskList testSubject;
- List<Task> taskList = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTaskList(taskList);
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(TaskList.class, hasValidGettersAndSetters());
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java
index 81ae19d81..f6d0c763f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java
@@ -20,253 +20,64 @@
package org.onap.vid.mso.rest;
-import java.util.List;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
-import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import java.io.IOException;
+import org.onap.vid.testUtils.TestUtils;
+import org.testng.annotations.Test;
public class TaskTest {
- private Task createTestSubject() {
- return new Task();
- }
-
- @Test
- public void testGetTaskId() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTaskId();
- }
-
- @Test
- public void testSetTaskId() throws Exception {
- Task testSubject;
- String taskId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTaskId(taskId);
- }
-
- @Test
- public void testGetType() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getType();
- }
-
- @Test
- public void testSetType() throws Exception {
- Task testSubject;
- String type = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setType(type);
- }
-
- @Test
- public void testGetNfRole() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNfRole();
- }
-
- @Test
- public void testSetNfRole() throws Exception {
- Task testSubject;
- String nfRole = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNfRole(nfRole);
- }
-
- @Test
- public void testGetSubscriptionServiceType() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getSubscriptionServiceType();
- }
-
- @Test
- public void testSetSubscriptionServiceType() throws Exception {
- Task testSubject;
- String subscriptionServiceType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setSubscriptionServiceType(subscriptionServiceType);
- }
-
- @Test
- public void testGetOriginalRequestId() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOriginalRequestId();
- }
-
- @Test
- public void testSetOriginalRequestId() throws Exception {
- Task testSubject;
- String originalRequestId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setOriginalRequestId(originalRequestId);
- }
-
- @Test
- public void testGetOriginalRequestorId() throws Exception {
- Task testSubject;
- String result;
+ private final ObjectMapper mapper = new ObjectMapper();
+ private final String TASK_JSON = ""
+ + "{ "
+ + " \"taskId\": \"taskId\", "
+ + " \"type\": \"type\", "
+ + " \"nfRole\": \"nfRole\", "
+ + " \"subscriptionServiceType\": \"subscriptionServiceType\", "
+ + " \"originalRequestId\": \"originalRequestId\", "
+ + " \"originalRequestorId\": \"originalRequestorId\", "
+ + " \"buildingBlockName\": \"buildingBlockName\", "
+ + " \"buildingBlockStep\": \"buildingBlockStep\", "
+ + " \"errorSource\": \"errorSource\", "
+ + " \"errorCode\": \"errorCode\", "
+ + " \"errorMessage\": \"errorMessage\", "
+ + " \"validResponses\": [ "
+ + " \"a\", "
+ + " \"b\", "
+ + " \"c\" "
+ + " ] "
+ + "} ";
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOriginalRequestorId();
+ private Task newTaskWithPopulatedFields() {
+ Task task = TestUtils.setStringsInStringProperties(new Task());
+ task.setValidResponses(ImmutableList.of("a", "b", "c"));
+ return task;
}
@Test
- public void testSetOriginalRequestorId() throws Exception {
- Task testSubject;
- String originalRequestorId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setOriginalRequestorId(originalRequestorId);
- }
-
- @Test
- public void testGetErrorSource() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getErrorSource();
- }
-
- @Test
- public void testSetErrorSource() throws Exception {
- Task testSubject;
- String errorSource = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setErrorSource(errorSource);
- }
-
- @Test
- public void testGetErrorCode() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getErrorCode();
- }
-
- @Test
- public void testSetErrorCode() throws Exception {
- Task testSubject;
- String errorCode = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setErrorCode(errorCode);
+ public void shouldHaveProperSettersAndGetters() {
+ assertThat(Task.class, hasValidGettersAndSetters());
}
@Test
- public void testGetErrorMessage() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getErrorMessage();
- }
-
- @Test
- public void testSetErrorMessage() throws Exception {
- Task testSubject;
- String errorMessage = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setErrorMessage(errorMessage);
+ public void serializeTask() throws IOException {
+ assertThat(
+ mapper.writeValueAsString(newTaskWithPopulatedFields()),
+ jsonEquals(TASK_JSON)
+ );
}
@Test
- public void testGetBuildingBlockName() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getBuildingBlockName();
- }
-
- @Test
- public void testSetBuildingBlockName() throws Exception {
- Task testSubject;
- String buildingBlockName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setBuildingBlockName(buildingBlockName);
- }
-
- @Test
- public void testGetBuildingBlockStep() throws Exception {
- Task testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getBuildingBlockStep();
- }
-
- @Test
- public void testSetBuildingBlockStep() throws Exception {
- Task testSubject;
- String buildingBlockStep = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setBuildingBlockStep(buildingBlockStep);
- }
-
- @Test
- public void testGetValidResponses() throws Exception {
- Task testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getValidResponses();
- }
-
- @Test
- public void testSetValidResponses() throws Exception {
- Task testSubject;
- List<String> validResponses = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setValidResponses(validResponses);
+ public void deserializeTask() throws IOException {
+ assertThat(
+ mapper.readValue(TASK_JSON, Task.class),
+ is(newTaskWithPopulatedFields())
+ );
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
index b66899c31..e638605c1 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
@@ -26,6 +26,7 @@ import org.apache.commons.io.IOUtils;
import org.mockito.ArgumentCaptor;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.aai.util.HttpsAuthClient;
import org.onap.vid.changeManagement.ChangeManagementRequest;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.client.SyncRestClient;
@@ -116,11 +117,6 @@ public class ChangeManagementServiceUnitTest extends AbstractTestNGSpringContext
@Configuration
public static class TestMsoConfig extends MsoConfig {
- public MsoRestClientNew getMsoClient() {
- MsoRestClientNew spyClient = spy(new MsoRestClientNew(new SyncRestClient(), ""));
- return spyClient;
- }
-
@Bean
public ChangeManagementService getChangeManagementService(DataAccessService dataAccessService, MsoBusinessLogic msoInterface, SchedulerRestInterfaceIfc schedulerRestInterface, CloudOwnerService cloudOwnerService) {
return new ChangeManagementServiceImpl(dataAccessService, msoInterface, schedulerRestInterface, cloudOwnerService);
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
index 3a7d4690d..3d919d72d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
@@ -20,6 +20,9 @@
package org.onap.vid.testUtils;
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
import static org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.RETURNS_DEFAULTS;
@@ -46,6 +49,7 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.json.JSONArray;
@@ -55,7 +59,6 @@ import org.mockito.MockSettings;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.onap.portalsdk.core.domain.support.DomainVo;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.beans.Service;
import org.springframework.mock.env.MockEnvironment;
@@ -131,12 +134,39 @@ public class TestUtils {
valueType);
}
- public static String[] allPropertiesOf(Class<DomainVo> aClass) {
+ public static String[] allPropertiesOf(Class<?> aClass) {
return Arrays.stream(getPropertyDescriptors(aClass))
.map(PropertyDescriptor::getDisplayName)
.toArray(String[]::new);
}
+ private static <T> List<String> allStringPropertiesOf(T object) {
+ return Arrays.stream(getPropertyDescriptors(object.getClass()))
+ .filter(descriptor -> descriptor.getPropertyType().isAssignableFrom(String.class))
+ .map(PropertyDescriptor::getDisplayName)
+ .collect(toList());
+ }
+
+ /**
+ * Sets each String property with a value equal to the name of
+ * the property; e.g.: { name: "name", city: "city" }
+ * @param object
+ * @param <T>
+ * @return The modified object
+ */
+ public static <T> T setStringsInStringProperties(T object) {
+ try {
+ final List<String> stringFields = allStringPropertiesOf(object);
+
+ BeanUtils.populate(object, stringFields.stream()
+ .collect(toMap(identity(), identity())));
+
+ return object;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
public static class JavaxRsClientMocks {
private final javax.ws.rs.client.Client fakeClient;