aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java9
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js7
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js3
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js4
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js737
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java24
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java215
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java24
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java25
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java5
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json1
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json1
15 files changed, 623 insertions, 449 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index 96e777a13..c73a01877 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -92,7 +92,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
if (serviceModelId == null) {
return asyncInstantiationBL.getAllServicesInfo();
} else {
- return asyncInstantiationRepository.listServicesByServiceModelId(serviceModelId);
+ return asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(serviceModelId);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
index c26b88a5e..e26247281 100644
--- a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
@@ -90,9 +90,10 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:
" and created >= '" + filterDate + "' "
}
- private fun filterByServiceModelId(serviceModelUuid: UUID): String {
+ private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String {
return filterServicesByNotHiddenAndNotDeleted() +
- " and SERVICE_MODEL_ID = '$serviceModelUuid'"
+ " and SERVICE_MODEL_ID = '$serviceModelUuid'" +
+ " and ACTION = 'INSTANTIATE'"
}
private fun filterServicesByNotHiddenAndNotDeleted(): String {
@@ -154,6 +155,6 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:
return dataAccessService.getList(className, " WHERE $condition", orderBy, null) as List<T>
}
- fun listServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> =
- dataAccessService.getList(ServiceInfo::class.java, filterByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>;
+ fun listInstantiatedServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> =
+ dataAccessService.getList(ServiceInfo::class.java, filterInstantiatedServiceByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java
index 17ce1bcc3..4872ce2c8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiationTemplate.java
@@ -20,6 +20,8 @@
package org.onap.vid.model.serviceInstantiation;
+import static java.util.Collections.emptyMap;
+
import java.util.Map;
import java.util.Objects;
import org.onap.vid.model.aaiTree.ExistingElementsCounterMaps;
@@ -30,6 +32,7 @@ public class ServiceInstantiationTemplate extends ServiceInstantiation implement
private final Map<String, Long> existingNetworksCounterMap;
private final Map<String, Long> existingVnfGroupCounterMap;
private final Map<String, Long> existingVRFCounterMap;
+ private final Map<String, String> existingNames = emptyMap();
public ServiceInstantiationTemplate(
ServiceInstantiation baseService,
@@ -78,4 +81,7 @@ public class ServiceInstantiationTemplate extends ServiceInstantiation implement
return existingVRFCounterMap;
}
+ public Map<String, String> getExistingNames() {
+ return existingNames;
+ }
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
index ad5b39e28..89e25e662 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java
@@ -22,6 +22,7 @@ package org.onap.vid.model.serviceInstantiation;
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
@@ -39,8 +40,8 @@ import org.onap.vid.mso.model.ModelInfo;
@JsonInclude(NON_NULL)
public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest {
- @JsonInclude(NON_NULL) private final String volumeGroupInstanceName;
- @JsonInclude(NON_NULL) private Boolean usePreload;
+ @JsonInclude(NON_NULL) @JsonProperty("volumeGroupName") private final String volumeGroupInstanceName;
+ @JsonInclude(NON_NULL) @JsonProperty("sdncPreLoad") private Boolean usePreload;
private Map<String, String> supplementaryParams;
@JsonInclude(NON_NULL)
@@ -51,7 +52,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
@JsonProperty("instanceName") String instanceName,
- @JsonProperty("volumeGroupName") String volumeGroupInstanceName,
+ @JsonProperty("volumeGroupName") @JsonAlias("volumeGroupInstanceName") String volumeGroupInstanceName,
@JsonProperty("action") String action,
@JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
@JsonProperty("legacyRegion") String legacyRegion,
@@ -59,7 +60,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
@JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
@JsonProperty("supplementaryFileContent") Map<String, String> supplementaryParams,
@JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
- @JsonProperty("sdncPreLoad") Boolean usePreload,
+ @JsonProperty("sdncPreLoad") @JsonAlias("usePreload") Boolean usePreload,
@JsonProperty("instanceId") String instanceId,
@JsonProperty("trackById") String trackById,
@JsonProperty("isFailed") Boolean isFailed,
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
index 110f24ec6..2701e3e9e 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
@@ -539,6 +539,12 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
var serviceNetworkVlans = [];
var vnfNetworksAndVlans = [];
+ function fetchServiceIfMissing() {
+ if (_.isEmpty(DataService.getServiceIdList())) {
+ $scope.fetchServices();
+ }
+ }
+
$scope.getComponentList = function (event, request) {
$scope.isSpinnerVisible = true;
@@ -569,6 +575,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
})
.then(resolveModelDataIfMissing)
.then($scope.prepareScopeWithModel)
+ .then(fetchServiceIfMissing)
.then(function () {
return AaiService.getVlansByNetworksMapping($scope.globalCustomerId, $scope.serviceType, $scope.serviceInstanceId, $scope.service.model.service.uuid);
})
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js
index af3c2186a..03a299877 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.test.js
@@ -223,6 +223,7 @@ describe('aaiSubscriberController testing', () => {
includes(array, status){
return array.includes(status);
},
+ isEmpty(something) {return true;},
};
let mockedLog = {};
@@ -1502,4 +1503,4 @@ describe('aaiSubscriberController testing', () => {
});
-}); \ No newline at end of file
+});
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 d3075764e..cfab522c7 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
@@ -347,13 +347,9 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE
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) {
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js
index 95bdb3a14..56729f2d3 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js
@@ -1,411 +1,326 @@
-/*-
- * ============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 DataService = function($log, DataService) {
-
- var _this = this;
-
- return {
- getAvailableVolumeGroupList : function() {
- return _this.availableVolumeGroupList;
- },
- setAvailableVolumeGroupList : function(availableVolumeGroupList) {
- _this.availableVolumeGroupList = availableVolumeGroupList;
- },
- getCloudRegionTenantList : function() {
- return _this.cloudRegionTenantList;
- },
- setCloudRegionTenantList : function(cloudRegionTenantList) {
- _this.cloudRegionTenantList = cloudRegionTenantList;
- },
- getCloudOwnerAndLcpCloudRegionFromOptionId : function (cloudRegionOptionId) {
- var cloudRegionTenantList = this.getCloudRegionTenantList();
- var cloudRegionTenant = _.find(cloudRegionTenantList, {"cloudRegionOptionId": cloudRegionOptionId});
- return {
- cloudOwner: cloudRegionTenant.cloudOwner,
- cloudRegionId: cloudRegionTenant.cloudRegionId
- };
- },
- getGlobalCustomerId : function() {
- return _this.globalCustomerId;
- },
- setGlobalCustomerId : function(globalCustomerId) {
- _this.globalCustomerId = globalCustomerId;
- },
- getCustomizationUuid : function() {
- return _this.customizationUUID;
- },
- setCustomizationUuid : function(customizationUUID) {
- _this.customizationUUID = customizationUUID;
- },
- getResCustomizationUuid : function() {
- return _this.rescustomizationUUID;
- },
- setResCustomizationUuid : function(rescustomizationUUID) {
- _this.rescustomizationUUID = rescustomizationUUID;
- },
- getInventoryItem : function() {
- return _this.inventoryItem;
- },
- setInventoryItem : function(inventoryItem) {
- _this.inventoryItem = inventoryItem;
- },
- getModelId : function() {
- return _this.modelId;
- },
- setModelId : function(modelId) {
- _this.modelId = modelId;
- },
- getModelInstanceName : function() {
- return _this.modelInstanceName;
- },
- setModelInstanceName : function(modelInstanceName) {
- _this.modelInstanceName = modelInstanceName;
- },
- getModelInfo : function(componentId) {
- return _this.modelInfo[componentId];
- },
- setModelInfo : function(componentId, modelInfo) {
- if (_this.modelInfo === undefined) {
- _this.modelInfo = new Object;
- }
- _this.modelInfo[componentId] = modelInfo;
- },
- getNetworkInstanceId : function() {
- return _this.networkInstanceId;
- },
- setNetworkInstanceId : function(networkInstanceId) {
- _this.networkInstanceId = networkInstanceId;
- },
- getServiceIdList : function() {
- return _this.serviceIdList;
- },
- setServiceIdList : function(serviceIdList) {
- _this.serviceIdList = serviceIdList;
- },
- setAicZones : function(aicZones) {
- _this.aicZones = aicZones;
- },
- getAicZones : function(){
- return _this.aicZones;
- },
- setAicZoneForPNF: function(aicZone) {
- _this.aicZone = aicZone;
- },
- getAicZoneForPNF : function(){
- return _this.aicZone;
- },
- getServiceInstanceId : function() {
- return _this.serviceInstanceId;
- },
- setServiceInstanceId : function(serviceInstanceId) {
- _this.serviceInstanceId = serviceInstanceId;
- },
- getServiceInstanceName : function() {
- return _this.serviceInstanceName;
- },
- setServiceInstanceName : function(serviceInstanceName) {
- _this.serviceInstanceName = serviceInstanceName;
- },
- getServiceName : function() {
- return _this.serviceName;
- },
- setServiceName : function(serviceName) {
- _this.serviceName = serviceName;
- },
- getServiceType : function() {
- return _this.serviceType;
- },
- setServiceType : function(serviceType) {
- _this.serviceType = serviceType;
- },
- getServiceUuid : function() {
- return _this.serviceUuid;
- },
- setServiceUuid : function(serviceUuid) {
- _this.serviceUuid = serviceUuid;
- },
- getServiceTypeName : function() {
- return _this.serviceTypeName;
- },
- setServiceTypeName : function(serviceTypeName) {
- _this.serviceTypeName = serviceTypeName;
- },
- getCreateSubscriberName : function() {
- return _this.createSubscriberName;
- },
- setCreateSubscriberName : function(createSubscriberName) {
- _this.createSubscriberName = createSubscriberName;
- },
- getSdncPreload : function() {
- return _this.sdncPreload;
- },
- setSdncPreload : function(sdncPreload) {
- _this.sdncPreload = sdncPreload;
- },
- getUploadSupplementoryDataFile : function() {
- return _this.uploadSupplementoryDataFile;
- },
- setUploadSupplementoryDataFile : function(uploadSupplementoryDataFile) {
- _this.uploadSupplementoryDataFile = uploadSupplementoryDataFile;
- },
- getSupplementoryDataFile : function() {
- return _this.supplementoryDataFile;
- },
- setSupplementoryDataFile : function(supplementoryDataFile) {
- _this.supplementoryDataFile = supplementoryDataFile;
- },
- getSubscriberId : function() {
- return _this.subscriberId;
- },
- setSubscriberId : function(subscriberId) {
- _this.subscriberId = subscriberId;
- },
- getLoggedInUserId : function() {
- return _this.loggedInUserId;
- },
- setLoggedInUserId : function(loggedInUserId) {
- _this.loggedInUserId = loggedInUserId;
- },
- getSubscriberName : function() {
- return _this.subscriberName;
- },
- setSubscriberName : function(subscriberName) {
- _this.subscriberName = subscriberName;
- },
- getSubscribers : function() {
- return _this.subscribers;
- },
- setSubscribers : function(subscribers) {
- _this.subscribers = subscribers;
- },
- getSubscriptionServiceTypeList : function() {
- return _this.subscriptionServiceTypeList;
- },
- setSubscriptionServiceTypeList : function(subscriptionServiceTypeList) {
- _this.subscriptionServiceTypeList = subscriptionServiceTypeList;
- },
- getUserParams : function() {
- return _this.userParams;
- },
- setUserParams : function(userParams) {
- _this.userParams = userParams;
- },
- getUserServiceInstanceName : function() {
- return _this.userServiceInstanceName;
- },
- setUserServiceInstanceName : function(userServiceInstanceName) {
- _this.userServiceInstanceName = userServiceInstanceName;
- },
- getVfModuleInstanceId : function() {
- return _this.vfModuleInstanceId;
- },
- setVfModuleInstanceId : function(vfModuleInstanceId) {
- _this.vfModuleInstanceId = vfModuleInstanceId;
- },
- getVnfInstanceId : function() {
- return _this.vnfInstanceId;
- },
- setVnfInstanceId : function(vnfInstanceId) {
- _this.vnfInstanceId = vnfInstanceId;
- },
- getVfModuleInstanceName : function() {
- return _this.vfModuleInstanceName;
- },
- setVfModuleInstanceName : function(vfModuleInstanceName) {
- _this.vfModuleInstanceName = vfModuleInstanceName;
- },
- getVolumeGroupInstanceId : function() {
- return _this.volumeGroupInstanceId;
- },
- setVolumeGroupInstanceId : function(volumeGroupInstanceId) {
- _this.volumeGroupInstanceId = volumeGroupInstanceId;
- },
- getLcpRegion : function() {
- return _this.lcpRegion;
- },
- setLcpRegion : function(lcpRegion) {
- _this.lcpRegion = lcpRegion;
- },
- getTenant : function() {
- return _this.tenant;
- },
- setTenant : function(tenant) {
- _this.tenant = tenant;
- },
- getTreeHandle : function() {
- return _this.treeHandle;
- },
- setTreeHandle : function(treeHandle) {
- _this.treeHandle = treeHandle;
- },
- setServiceInstanceToCustomer : function(serviceInstanceToCustomer) {
- _this.serviceInstanceToCustomer = [];
- _this.serviceInstanceToCustomer = serviceInstanceToCustomer;
- },
- getServiceInstanceToCustomer : function() {
- return _this.serviceInstanceToCustomer;
- },
- getMsoRequestParametersTestApi: function(){
- return sessionStorage.getItem("msoRequestParametersTestApiValue");
- },
- setALaCarte : function(aval) {
- _this.aLaCarte = aval;
- },
- getALaCarte : function() {
- // if not set return true
- if (_this.aLaCarte === undefined) {
- return true;
- }
- return _this.aLaCarte;
- },
- setShouldIncludeInAsyncInstantiationFlow: function (val) {
- _this.shouldIncludeInAsyncInstantiationFlow = val;
- },
- getShouldIncludeInAsyncInstantiationFlow: function(){
- if (_this.shouldIncludeInAsyncInstantiationFlow === undefined) {
- return false;
- }
- return _this.shouldIncludeInAsyncInstantiationFlow;
- },
- setMacro : function(aval) {
- _this.macro = aval;
- },
- getMacro : function() {
- if (_this.macro === undefined) {
- return false;
- }
- return _this.macro;
- },
- getResources : function() {
- return _this.resources;
- },
- setResources : function(r) {
- _this.resources = r;
- },
- getSystemPropProvStatus : function() {
- return _this.syspropProvStatusList;
- },
- setSystemPropProvStatus : function(r) {
- _this.syspropProvStatusList = r;
- },
- getUpdatedVNFProvStatus : function() {
- return _this.updatedvnfProvStatus;
- },
- setUpdatedVNFProvStatus : function(r) {
- _this.updatedvnfProvStatus = r;
- },
- setArbitraryParameters : function (pList) {
- _this.arbitraryParameters = pList;
- },
- getArbitraryParameters : function () {
- return _this.arbitraryParameters;
- },
- setE2EService:function(b){
- _this.e2eService=b;
- },
- getE2EService:function(){
- return _this.e2eService;
- },
- setHideServiceFields:function(b){
- _this.hideServiceFields=b;
- },
- getHideServiceFields:function(){
- return _this.hideServiceFields;
- },
- getServiceProxies:function(){
- return _this.serviceProxies;
- },
- setServiceProxies:function(serviceProxies){
- _this.serviceProxies = serviceProxies;
- },
- getSourceServiceProxies:function(){
- return _this.sourceServiceProxies;
- },
- setSourceServiceProxies:function(sourceServiceProxies){
- _this.sourceServiceProxies = sourceServiceProxies;
- },
- getCollectorServiceProxies:function(){
- return _this.collectorServiceProxies;
- },
- setCollectorServiceProxies:function(collectorServiceProxies){
- _this.collectorServiceProxies = collectorServiceProxies;
- },
- getConfigurationByPolicy:function() {
- return _this.configurationByPolicy;
- },
- setConfigurationByPolicy:function (configurationByPolicy) {
- _this.configurationByPolicy = configurationByPolicy;
- },
- getSuppressRollback:function(){
- return _this.suppressRollback;
- },
- setSuppressRollback:function(suppressRollback){
- _this.suppressRollback = suppressRollback;
- },
- getPortMirroningConfigFields:function(){
- return _this.portMirroningConfigFields;
- },
- setPortMirroningConfigFields:function(portMirroningConfigFields){
- _this.portMirroningConfigFields = portMirroningConfigFields;
- },
- getConfigurationInstanceId : function() {
- return _this.configurationInstanceId;
- },
- setConfigurationInstanceId : function(configurationInstanceId) {
- _this.configurationInstanceId = configurationInstanceId;
- },
- getConfigurationStatus: function () {
- return _this.configurationStatus;
- },
- setConfigurationStatus: function (configurationStatus) {
- _this.configurationStatus = configurationStatus;
- },
- getPortStatus: function () {
- return _this.portStatus;
- },
- setPortStatus: function (portStatus) {
- _this.portStatus = portStatus;
- },
- getPortId: function () {
- return _this.portId;
- },
- setPortId: function (portId) {
- _this.portId = portId;
- },
- getPnf: function () {
- return _this.pnf;
- },
- setPnf: function (pnf) {
- _this.pnf = pnf;
- },
- getOwningEntityProperties: function () {
- return _this.owningEntityProperties;
- },
- setOwningEntityProperties: function (properties) {
- _this.owningEntityProperties = properties;
- }
-
- };
-};
-
-appDS2.factory("DataService", [ "$log", DataService ]);
+/*-
+ * ============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 DataService = function($log, DataService) {
+
+ var _this = this;
+
+ return {
+ getAvailableVolumeGroupList : function() {
+ return _this.availableVolumeGroupList;
+ },
+ setAvailableVolumeGroupList : function(availableVolumeGroupList) {
+ _this.availableVolumeGroupList = availableVolumeGroupList;
+ },
+ getCloudRegionTenantList : function() {
+ return _this.cloudRegionTenantList;
+ },
+ setCloudRegionTenantList : function(cloudRegionTenantList) {
+ _this.cloudRegionTenantList = cloudRegionTenantList;
+ },
+ getCloudOwnerAndLcpCloudRegionFromOptionId : function (cloudRegionOptionId) {
+ var cloudRegionTenantList = this.getCloudRegionTenantList();
+ var cloudRegionTenant = _.find(cloudRegionTenantList, {"cloudRegionOptionId": cloudRegionOptionId});
+ return {
+ cloudOwner: cloudRegionTenant.cloudOwner,
+ cloudRegionId: cloudRegionTenant.cloudRegionId
+ };
+ },
+ getGlobalCustomerId : function() {
+ return _this.globalCustomerId;
+ },
+ setGlobalCustomerId : function(globalCustomerId) {
+ _this.globalCustomerId = globalCustomerId;
+ },
+ getCustomizationUuid : function() {
+ return _this.customizationUUID;
+ },
+ setCustomizationUuid : function(customizationUUID) {
+ _this.customizationUUID = customizationUUID;
+ },
+ getResCustomizationUuid : function() {
+ return _this.rescustomizationUUID;
+ },
+ setResCustomizationUuid : function(rescustomizationUUID) {
+ _this.rescustomizationUUID = rescustomizationUUID;
+ },
+ getInventoryItem : function() {
+ return _this.inventoryItem;
+ },
+ setInventoryItem : function(inventoryItem) {
+ _this.inventoryItem = inventoryItem;
+ },
+ getModelId : function() {
+ return _this.modelId;
+ },
+ setModelId : function(modelId) {
+ _this.modelId = modelId;
+ },
+ setModelInstanceName : function(modelInstanceName) {
+ _this.modelInstanceName = modelInstanceName;
+ },
+ getModelInfo : function(componentId) {
+ return _this.modelInfo[componentId];
+ },
+ setModelInfo : function(componentId, modelInfo) {
+ if (_this.modelInfo === undefined) {
+ _this.modelInfo = new Object;
+ }
+ _this.modelInfo[componentId] = modelInfo;
+ },
+ getNetworkInstanceId : function() {
+ return _this.networkInstanceId;
+ },
+ setNetworkInstanceId : function(networkInstanceId) {
+ _this.networkInstanceId = networkInstanceId;
+ },
+ getServiceIdList : function() {
+ return _this.serviceIdList;
+ },
+ setServiceIdList : function(serviceIdList) {
+ _this.serviceIdList = serviceIdList;
+ },
+ setAicZones : function(aicZones) {
+ _this.aicZones = aicZones;
+ },
+ getAicZones : function(){
+ return _this.aicZones;
+ },
+ getAicZoneForPNF : function(){
+ return _this.aicZone;
+ },
+ getServiceInstanceId : function() {
+ return _this.serviceInstanceId;
+ },
+ setServiceInstanceId : function(serviceInstanceId) {
+ _this.serviceInstanceId = serviceInstanceId;
+ },
+ getServiceInstanceName : function() {
+ return _this.serviceInstanceName;
+ },
+ setServiceInstanceName : function(serviceInstanceName) {
+ _this.serviceInstanceName = serviceInstanceName;
+ },
+ getServiceName : function() {
+ return _this.serviceName;
+ },
+ setServiceName : function(serviceName) {
+ _this.serviceName = serviceName;
+ },
+ getServiceType : function() {
+ return _this.serviceType;
+ },
+ setServiceType : function(serviceType) {
+ _this.serviceType = serviceType;
+ },
+ getServiceUuid : function() {
+ return _this.serviceUuid;
+ },
+ setServiceUuid : function(serviceUuid) {
+ _this.serviceUuid = serviceUuid;
+ },
+ getLoggedInUserId : function() {
+ return _this.loggedInUserId;
+ },
+ setLoggedInUserId : function(loggedInUserId) {
+ _this.loggedInUserId = loggedInUserId;
+ },
+ getSubscriberName : function() {
+ return _this.subscriberName;
+ },
+ setSubscriberName : function(subscriberName) {
+ _this.subscriberName = subscriberName;
+ },
+ getSubscribers : function() {
+ return _this.subscribers;
+ },
+ setSubscribers : function(subscribers) {
+ _this.subscribers = subscribers;
+ },
+ getSubscriptionServiceTypeList : function() {
+ return _this.subscriptionServiceTypeList;
+ },
+ setSubscriptionServiceTypeList : function(subscriptionServiceTypeList) {
+ _this.subscriptionServiceTypeList = subscriptionServiceTypeList;
+ },
+ setUserServiceInstanceName : function(userServiceInstanceName) {
+ _this.userServiceInstanceName = userServiceInstanceName;
+ },
+ getVfModuleInstanceId : function() {
+ return _this.vfModuleInstanceId;
+ },
+ setVfModuleInstanceId : function(vfModuleInstanceId) {
+ _this.vfModuleInstanceId = vfModuleInstanceId;
+ },
+ getVnfInstanceId : function() {
+ return _this.vnfInstanceId;
+ },
+ setVnfInstanceId : function(vnfInstanceId) {
+ _this.vnfInstanceId = vnfInstanceId;
+ },
+ getVfModuleInstanceName : function() {
+ return _this.vfModuleInstanceName;
+ },
+ setVfModuleInstanceName : function(vfModuleInstanceName) {
+ _this.vfModuleInstanceName = vfModuleInstanceName;
+ },
+ getVolumeGroupInstanceId : function() {
+ return _this.volumeGroupInstanceId;
+ },
+ setVolumeGroupInstanceId : function(volumeGroupInstanceId) {
+ _this.volumeGroupInstanceId = volumeGroupInstanceId;
+ },
+ getLcpRegion : function() {
+ return _this.lcpRegion;
+ },
+ setLcpRegion : function(lcpRegion) {
+ _this.lcpRegion = lcpRegion;
+ },
+ getTenant : function() {
+ return _this.tenant;
+ },
+ setTenant : function(tenant) {
+ _this.tenant = tenant;
+ },
+ setServiceInstanceToCustomer : function(serviceInstanceToCustomer) {
+ _this.serviceInstanceToCustomer = [];
+ _this.serviceInstanceToCustomer = serviceInstanceToCustomer;
+ },
+ getMsoRequestParametersTestApi: function(){
+ return sessionStorage.getItem("msoRequestParametersTestApiValue");
+ },
+ setALaCarte : function(aval) {
+ _this.aLaCarte = aval;
+ },
+ getALaCarte : function() {
+ // if not set return true
+ if (_this.aLaCarte === undefined) {
+ return true;
+ }
+ return _this.aLaCarte;
+ },
+ setShouldIncludeInAsyncInstantiationFlow: function (val) {
+ _this.shouldIncludeInAsyncInstantiationFlow = val;
+ },
+ getShouldIncludeInAsyncInstantiationFlow: function(){
+ if (_this.shouldIncludeInAsyncInstantiationFlow === undefined) {
+ return false;
+ }
+ return _this.shouldIncludeInAsyncInstantiationFlow;
+ },
+ setMacro : function(aval) {
+ _this.macro = aval;
+ },
+ getMacro : function() {
+ if (_this.macro === undefined) {
+ return false;
+ }
+ return _this.macro;
+ },
+ getResources : function() {
+ return _this.resources;
+ },
+ setResources : function(r) {
+ _this.resources = r;
+ },
+ getSystemPropProvStatus : function() {
+ return _this.syspropProvStatusList;
+ },
+ setSystemPropProvStatus : function(r) {
+ _this.syspropProvStatusList = r;
+ },
+ getUpdatedVNFProvStatus : function() {
+ return _this.updatedvnfProvStatus;
+ },
+ setUpdatedVNFProvStatus : function(r) {
+ _this.updatedvnfProvStatus = r;
+ },
+ setArbitraryParameters : function (pList) {
+ _this.arbitraryParameters = pList;
+ },
+ getArbitraryParameters : function () {
+ return _this.arbitraryParameters;
+ },
+ setE2EService:function(b){
+ _this.e2eService=b;
+ },
+ getE2EService:function(){
+ return _this.e2eService;
+ },
+ setHideServiceFields:function(b){
+ _this.hideServiceFields=b;
+ },
+ getHideServiceFields:function(){
+ return _this.hideServiceFields;
+ },
+ getServiceProxies:function(){
+ return _this.serviceProxies;
+ },
+ setServiceProxies:function(serviceProxies){
+ _this.serviceProxies = serviceProxies;
+ },
+ getSourceServiceProxies:function(){
+ return _this.sourceServiceProxies;
+ },
+ setSourceServiceProxies:function(sourceServiceProxies){
+ _this.sourceServiceProxies = sourceServiceProxies;
+ },
+ getCollectorServiceProxies:function(){
+ return _this.collectorServiceProxies;
+ },
+ setCollectorServiceProxies:function(collectorServiceProxies){
+ _this.collectorServiceProxies = collectorServiceProxies;
+ },
+ getConfigurationByPolicy:function() {
+ return _this.configurationByPolicy;
+ },
+ setConfigurationByPolicy:function (configurationByPolicy) {
+ _this.configurationByPolicy = configurationByPolicy;
+ },
+ getPortMirroningConfigFields:function(){
+ return _this.portMirroningConfigFields;
+ },
+ setPortMirroningConfigFields:function(portMirroningConfigFields){
+ _this.portMirroningConfigFields = portMirroningConfigFields;
+ },
+ getConfigurationInstanceId : function() {
+ return _this.configurationInstanceId;
+ },
+ setConfigurationInstanceId : function(configurationInstanceId) {
+ _this.configurationInstanceId = configurationInstanceId;
+ },
+ getPnf: function () {
+ return _this.pnf;
+ },
+ setPnf: function (pnf) {
+ _this.pnf = pnf;
+ },
+ getOwningEntityProperties: function () {
+ return _this.owningEntityProperties;
+ },
+ setOwningEntityProperties: function (properties) {
+ _this.owningEntityProperties = properties;
+ }
+ };
+};
+
+appDS2.factory("DataService", [ "$log", DataService ]);
diff --git a/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
index 012c37f4d..27be3fb50 100644
--- a/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
@@ -45,6 +45,7 @@ import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
import org.onap.vid.job.Job;
import org.onap.vid.model.ResourceInfo;
import org.onap.vid.model.ServiceInfo;
+import org.onap.vid.model.ServiceInfo.ServiceAction;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.RequestStatus;
@@ -73,14 +74,16 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest
LocalDateTime NOW = LocalDateTime.now();
- addNewServiceInfo(UUID.randomUUID(), "abc", "1", NOW.minusYears(1L), NOW, COMPLETED, false, false,
- MODEL_UUID);
- addNewServiceInfo(UUID.randomUUID(), "abc", "2", NOW, NOW, COMPLETED, false, false,
- MODEL_UUID_2);
- addNewServiceInfo(UUID.randomUUID(), "abc", "3", NOW, NOW, COMPLETED, false, false,
- MODEL_UUID);
- addNewServiceInfo(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false,
- MODEL_UUID);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "0", NOW.minusYears(1L), NOW, COMPLETED, false, false,
+ MODEL_UUID, ServiceAction.RESUME);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "1", NOW.minusYears(1L), NOW, COMPLETED, false, false,
+ MODEL_UUID, ServiceAction.INSTANTIATE);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "2", NOW, NOW, COMPLETED, false, false,
+ MODEL_UUID_2, ServiceAction.INSTANTIATE);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "3", NOW, NOW, COMPLETED, false, false,
+ MODEL_UUID, ServiceAction.INSTANTIATE);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false,
+ MODEL_UUID, ServiceAction.INSTANTIATE);
}
@DataProvider
@@ -93,14 +96,15 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest
@Test(dataProvider = "listServicesByServiceModelIdDataProvider")
public void testListServicesByServiceModelId(String desc, String modelUUID, String... expectedResult) {
- List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listServicesByServiceModelId(UUID.fromString(modelUUID));
+ List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.
+ listInstantiatedServicesByServiceModelId(UUID.fromString(modelUUID));
assertThat(desc, serviceInfoListResult.stream().map(ServiceInfo::getServiceInstanceName).collect(toList()),
contains(expectedResult));
}
@Test
public void whenFilterServiceByNotExistUUID_emptyListIsReturned() {
- List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listServicesByServiceModelId(UUID.randomUUID());
+ List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(UUID.randomUUID());
assertThat(serviceInfoListResult, is(empty()));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java
new file mode 100644
index 000000000..b5d281622
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java
@@ -0,0 +1,215 @@
+/*-
+ * ============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.model.serviceInstantiation;
+
+import static java.util.Collections.emptyMap;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonNodeAbsent;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
+import static org.hamcrest.CoreMatchers.either;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.Matchers.samePropertyValuesAs;
+import static org.onap.vid.model.Action.Create;
+import static org.onap.vid.testUtils.TestUtils.setStringsInStringProperties;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.onap.vid.model.VidNotions;
+import org.onap.vid.model.VidNotions.InstantiationType;
+import org.onap.vid.model.VidNotions.InstantiationUI;
+import org.onap.vid.model.VidNotions.ModelCategory;
+import org.onap.vid.mso.model.ModelInfo;
+import org.testng.annotations.Test;
+
+public class InstantiationModelSerializationTest {
+
+ final ImmutableList<Map<String, String>> instanceParams =
+ ImmutableList.of(
+ ImmutableMap.of("one", "1"),
+ ImmutableMap.of("two", "2")
+ );
+
+ @Test
+ public void serializeAndDeserializeServiceInstantiation() throws Exception {
+
+ ServiceInstantiation serviceInstantiation = new ServiceInstantiation(
+ newModelInfo(),
+ "owningEntityId",
+ "owningEntityName",
+ "projectName",
+ "globalSubscriberId",
+ "subscriberName",
+ "productFamilyId",
+ "instanceName",
+ "subscriptionServiceType",
+ "lcpCloudRegionId",
+ "legacyRegion",
+ "tenantId",
+ "tenantName",
+ "aicZoneId",
+ "aicZoneName",
+ emptyMap(),
+ emptyMap(),
+ emptyMap(),
+ emptyMap(),
+ instanceParams,
+ true,
+ 1,
+ true,
+ true,
+ "testApi",
+ "instanceId",
+ "Delete",
+ "trackById",
+ true,
+ "statusMessage",
+ new VidNotions(InstantiationUI.ANY_ALACARTE_WHICH_NOT_EXCLUDED,
+ ModelCategory.INFRASTRUCTURE_VPN,
+ InstantiationUI.INFRASTRUCTURE_VPN,
+ InstantiationType.Macro)
+ );
+
+ verifySerializationAndDeserialization(serviceInstantiation);
+ }
+
+ @Test
+ public void serializeAndDeserializeVnf() throws Exception {
+
+ Vnf vnf = new Vnf(
+ newModelInfo(), "productFamilyId",
+ "instanceName",
+ "Upgrade",
+ "platformName",
+ "lcpCloudRegionId",
+ "legacyRegion",
+ "tenantId",
+ instanceParams,
+ "lineOfBusinessName",
+ true,
+ "instanceId",
+ emptyMap(),
+ "trackById",
+ true,
+ "statusMessage",
+ 5);
+
+ verifySerializationAndDeserialization(vnf);
+ }
+
+ @Test
+ public void serializeAndDeserializeVfModule() throws Exception {
+
+ ImmutableMap<String, String> supplementaryParams = ImmutableMap.of(
+ "uno", "1",
+ "dos", "2",
+ "tres", "3"
+ );
+
+ VfModule vfModule = new VfModule(
+ newModelInfo(),
+ "instanceName",
+ "volumeGroupInstanceName",
+ "Delete",
+ "lcpCloudRegionId",
+ "legacyRegion",
+ "tenantId",
+ instanceParams,
+ supplementaryParams,
+ true,
+ true,
+ "instanceId",
+ "trackById",
+ true,
+ "statusMessage",
+ true,
+ true,
+ 1);
+
+ verifySerializationAndDeserialization(vfModule);
+ }
+
+ @Test
+ public void VfModule_sdncPreLoad_shouldBeSerializedWithCorrectName() {
+
+ final boolean USE_PRELOAD = true;
+
+ VfModule vfModule = new VfModule(newModelInfo(), null, null, null,
+ null, null, null, null, null, false,
+ /* HERE ====> */ USE_PRELOAD,
+ null, null, null, null, null, null, null);
+
+ assertThat(vfModule, jsonPartEquals("sdncPreLoad", USE_PRELOAD));
+ assertThat(vfModule, jsonNodeAbsent("usePreload"));
+ }
+
+ @Test
+ public void VfModule_volumeGroupName_shouldBeSerializedWithCorrectName() {
+
+ final String VOLUME_GROUP_INSTANCE_NAME = "my volume group name";
+
+ VfModule vfModule = new VfModule(newModelInfo(), null,
+ /* HERE ====> */ VOLUME_GROUP_INSTANCE_NAME,
+ null, null, null, null, null, null,
+ false, null, null, null, null, null,
+ null, null, null);
+
+ assertThat(vfModule, jsonPartEquals("volumeGroupName", VOLUME_GROUP_INSTANCE_NAME));
+ assertThat(vfModule, jsonNodeAbsent("volumeGroupInstanceName"));
+ }
+
+ private ModelInfo newModelInfo() {
+ ModelInfo modelInfo = new ModelInfo();
+ setStringsInStringProperties(modelInfo);
+ return modelInfo;
+ }
+
+ private void verifySerializationAndDeserialization(Object object) throws Exception {
+
+ assertThatAllValuesAreNotDefaultValues(object);
+
+ String valueAsString = JACKSON_OBJECT_MAPPER.writeValueAsString(object);
+ Object objectReconstructed = JACKSON_OBJECT_MAPPER.readValue(valueAsString, object.getClass());
+
+ // verify that all fields' values were reconstructed
+ assertThat(objectReconstructed, samePropertyValuesAs(object));
+ }
+
+ private void assertThatAllValuesAreNotDefaultValues(Object object)
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+ assertThat("setup is expected to have no field with a default Java value",
+ PropertyUtils.describe(object).entrySet(),
+ not(hasItem(hasProperty("value",
+ either(nullValue())
+ .or(equalTo(0))
+ .or(equalTo(""))
+ .or(equalTo(false))
+ .or(equalTo(Create))))));
+ }
+
+}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index d41ce87bf..7c0abbe6e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -23,7 +23,6 @@ package org.onap.vid.services;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -49,6 +48,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
import org.hibernate.SessionFactory;
+import org.jetbrains.annotations.NotNull;
import org.onap.portalsdk.core.domain.FusionObject;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.vid.aai.AaiClientInterface;
@@ -56,6 +56,7 @@ import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.model.Action;
import org.onap.vid.model.ServiceInfo;
+import org.onap.vid.model.ServiceInfo.ServiceAction;
import org.onap.vid.model.VidNotions;
import org.onap.vid.model.serviceInstantiation.InstanceGroup;
import org.onap.vid.model.serviceInstantiation.Network;
@@ -67,7 +68,6 @@ import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.RequestStatus;
import org.onap.vid.properties.Features;
-import org.onap.vid.services.AsyncInstantiationBusinessLogicTest.ServiceInfoComparator;
import org.onap.vid.utils.DaoUtils;
import org.onap.vid.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -149,9 +149,19 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
});
}
+
protected void addNewServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate,
LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled,
String modelUUID) {
+ ServiceInfo serviceInfo = createServiceInfo(uuid, userId, serviceName, createDate, statusModifiedDate, status,
+ isHidden, retryEnabled, modelUUID);
+ dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
+ setCreateDateToServiceInfo(uuid, createDate);
+ serviceCount++;
+ }
+ @NotNull
+ private ServiceInfo createServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate,
+ LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled, String modelUUID) {
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setJobId(uuid);
serviceInfo.setUserId(userId);
@@ -164,10 +174,18 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
serviceInfo.setRetryEnabled(retryEnabled);
serviceInfo.setServiceModelId(modelUUID);
serviceInfo.setHidden(isHidden);
+ return serviceInfo;
+ }
+
+ protected void addNewServiceInfoWithAction(UUID uuid, String userId, String serviceName, LocalDateTime createDate,
+ LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled,
+ String modelUUID, ServiceAction action) {
+ ServiceInfo serviceInfo = createServiceInfo(uuid, userId, serviceName, createDate, statusModifiedDate, status,
+ isHidden, retryEnabled, modelUUID);
+ serviceInfo.setAction(action);
dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
setCreateDateToServiceInfo(uuid, createDate);
serviceCount++;
-
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
index cb59129c3..efd9e2b27 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
@@ -22,6 +22,7 @@ package org.onap.vid.services;
import static com.google.common.collect.Maps.newHashMap;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonNodeAbsent;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -47,7 +48,9 @@ import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.inject.Inject;
+import net.javacrumbs.jsonunit.ConfigurableJsonMatcher;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.BooleanUtils;
import org.hibernate.SessionFactory;
import org.mockito.Mock;
import org.mockito.Mockito;
@@ -611,19 +614,23 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
assertThat(result, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
}
- @Test(dataProvider = "trueAndFalse", dataProviderClass = TestUtils.class)
- public void generateReplaceVfModuleRequest_whenRetainAssignmentsProvidedFromFrontend_retainAssignmentsToMsoIsTheSame(boolean retainAssignments) {
-
+ @Test(dataProvider = "trueAndFalseAndNull", dataProviderClass = TestUtils.class)
+ public void generateReplaceVfModuleRequest_whenRetainAssignmentsProvidedFromFrontend_retainAssignmentsToMsoIsTheSame(Boolean retainAssignments) {
assertThat(generatedVfModuleReplaceRequest(retainAssignments, null, null),
- jsonPartEquals("requestDetails.requestParameters.retainAssignments", retainAssignments));
+ jsonPartEqualsOrUndefined(
+ "requestDetails.requestParameters.retainAssignments", retainAssignments));
}
- @Test
- public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsTrue_rebuildVolumeGroupIsFalse() {
- boolean retainVolumeGroups = true;
-
+ @Test(dataProvider = "trueAndFalseAndNull", dataProviderClass = TestUtils.class)
+ public void generateReplaceVfModuleRequest_whenRetainVolumeGroupIsGiven_rebuildVolumeGroupIsNegated(Boolean retainVolumeGroups) {
assertThat(generatedVfModuleReplaceRequest(null, retainVolumeGroups, null),
- jsonPartEquals("requestDetails.requestParameters.rebuildVolumeGroups", false));
+ jsonPartEqualsOrUndefined("requestDetails.requestParameters.rebuildVolumeGroups", BooleanUtils.negate(retainVolumeGroups)));
+ }
+
+ private <T> ConfigurableJsonMatcher<T> jsonPartEqualsOrUndefined(String path, Boolean expected) {
+ return (expected != null)
+ ? jsonPartEquals(path, expected)
+ : jsonNodeAbsent(path);
}
@Test
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 857221a2a..862b8db8f 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
@@ -389,4 +389,9 @@ public class TestUtils {
return new Object[][]{{true}, {false}};
}
+ @DataProvider
+ public static Object[][] trueAndFalseAndNull() {
+ return new Boolean[][]{{Boolean.TRUE}, {Boolean.FALSE}, {null}};
+ }
+
}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json
index 748b5f267..d215a4331 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json
@@ -34,7 +34,6 @@
"b0732bed-3ddf-43cc-b193-7f18db84e476": {
"action": "None_Upgrade",
"retainAssignments" : false,
- "retainVolumeGroups" : false,
"sdncPreLoad" : true,
"instanceName": "PST-VfMod-Replace-5-Vfmod",
"instanceId": "b0732bed-3ddf-43cc-b193-7f18db84e476",
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json
index 45b89f730..91f80e9f1 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json
@@ -34,7 +34,6 @@
],
"requestParameters": {
"retainAssignments": false,
- "rebuildVolumeGroups":true,
"usePreload" : true,
"userParams": [],
"testApi": "VNF_API"