diff options
61 files changed, 1400 insertions, 744 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" diff --git a/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java index ab59f087d..828562041 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java @@ -22,7 +22,6 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; -import vid.automation.test.Constants; import vid.automation.test.Constants.Users; import vid.automation.test.model.User; import vid.automation.test.services.AsyncJobsService; @@ -77,18 +76,34 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase { @Test public void templateTopology_givenDeployFromCypressE2E_getTemplateTopologyDataIsEquivalent() throws IOException { - templateTopology_givenDeploy_templateTopologyIsEquivalent(objectMapper.readValue( - convertRequest(objectMapper, "asyncInstantiation/templates__instance_template.json"), - JsonNode.class)); + templateTopology_givenDeploy_templateTopologyIsEquivalentToBody( + fileAsJsonNode("asyncInstantiation/templates__instance_template.json")); } - public void templateTopology_givenDeploy_templateTopologyIsEquivalent(JsonNode body) { + @Test + public void templateTopology_givenDeployFromEditedTemplateCypressE2E_getTemplateTopologyDataIsEquivalentToOriginalTemplate() throws IOException { + templateTopology_givenDeploy_templateTopologyIsEquivalent( + fileAsJsonNode("asyncInstantiation/templates__instance_from_template__set_without_modify1.json"), + fileAsJsonNode("asyncInstantiation/templates__instance_template.json")); + } + + private JsonNode fileAsJsonNode(String fileName) throws IOException { + return objectMapper.readValue( + convertRequest(objectMapper, fileName), + JsonNode.class); + } + + public void templateTopology_givenDeploy_templateTopologyIsEquivalentToBody(JsonNode body) { + templateTopology_givenDeploy_templateTopologyIsEquivalent(body, body); + } + + public void templateTopology_givenDeploy_templateTopologyIsEquivalent(JsonNode body, JsonNode expectedTemplateTopology) { registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), RegistrationStrategy.CLEAR_THEN_SET); String uuid1 = postAsyncInstanceRequest(body); JsonNode templateTopology1 = restTemplate.getForObject(templateTopologyUri(uuid1), JsonNode.class); - assertThat(cleanupTemplate(templateTopology1), jsonEquals(cleanupTemplate(body))); + assertThat(cleanupTemplate(templateTopology1), jsonEquals(cleanupTemplate(expectedTemplateTopology))); } private JsonNode cleanupTemplate(JsonNode templateTopology) { diff --git a/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json b/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json index 013745c90..d602a15e3 100644 --- a/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json +++ b/vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json @@ -331,7 +331,7 @@ "baseModule": false }, "inputs": {}, - "volumeGroupAllowed": false + "volumeGroupAllowed": true }, "vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2": { "uuid": "41708296-e443-4c71-953f-d9a010f059e1", @@ -367,18 +367,18 @@ "baseModule": true }, "inputs": {}, - "volumeGroupAllowed": true + "volumeGroupAllowed": false } }, "volumeGroups": { - "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": { + "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-1": { "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87", "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d", "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861", "description": null, - "name": "VfVgeraldine..base_vflorence..module-0", + "name": "VfVgeraldine..base_vflorence..module-1", "version": "2", - "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0", + "modelCustomizationName": "VfVgeraldine..base_vflorence..module-1", "properties": { "minCountInstances": 1, "maxCountInstances": 1, diff --git a/vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json b/vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json new file mode 100644 index 000000000..7814b6554 --- /dev/null +++ b/vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json @@ -0,0 +1,161 @@ +{ + "action": "Create", + "aicZoneId": null, + "aicZoneName": null, + "bulkSize": 1, + "category": "Emanuel", + "description": "vProbe_NC_Service", + "existingNames": { + "hvf6arlba007": "", + "hvf6arlba007_lba_base_01": "", + "vprobe_nc_service_dg_new_si": "" + }, + "existingNetworksCounterMap": { + }, + "existingVNFCounterMap": { + "024a417d-ca46-40bf-95ce-809c6a269011": 1 + }, + "existingVnfGroupCounterMap": { + }, + "existingVRFCounterMap": { + }, + "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89", + "instanceId": null, + "instanceName": "vProbe_NC_Service_DG_new_SI", + "instanceParams": [ + { + } + ], + "invariantUuid": "90a32d31-8a01-4de2-a91f-7e2414d6f5aa", + "isALaCarte": true, + "isDirty": true, + "isEcompGeneratedNaming": false, + "isFailed": false, + "isMultiStepDesign": false, + "lcpCloudRegionId": null, + "modelInfo": { + "modelInvariantId": "90a32d31-8a01-4de2-a91f-7e2414d6f5aa", + "modelName": "vProbe_NC_Service", + "modelUniqueId": "6cfeeb18-c2b0-49df-987a-da47493c8e38", + "modelVersion": "1.0", + "modelVersionId": "6cfeeb18-c2b0-49df-987a-da47493c8e38", + "uuid": "6cfeeb18-c2b0-49df-987a-da47493c8e38" + }, + "name": "vProbe_NC_Service", + "networks": { + }, + "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", + "owningEntityName": "WayneHolland", + "pause": false, + "position": null, + "productFamilyId": null, + "projectName": "WATKINS", + "rollbackOnFailure": true, + "serviceRole": "VNF", + "serviceType": "INFRASTRUCTURE", + "statusMessage": null, + "subscriberName": "SILVIA ROBBINS", + "subscriptionServiceType": "TYLER SILVIA", + "tenantId": null, + "tenantName": null, + "testApi": "GR_API", + "trackById": "36601560-f8e3-4020-bdef-3e4709c51e84", + "uuid": "6cfeeb18-c2b0-49df-987a-da47493c8e38", + "version": "1.0", + "vidNotions": { + "instantiationType": "ALaCarte", + "instantiationUI": "anyAlacarteWhichNotExcluded", + "modelCategory": "5G Fabric Configuration", + "viewEditUI": "legacy" + }, + "vnfGroups": { + }, + "vnfs": { + "vProbe_NC_VNF 0": { + "action": "Create", + "instanceId": null, + "instanceName": "hvf6arlba007", + "instanceParams": [ + { + } + ], + "isFailed": false, + "isMissingData": false, + "lcpCloudRegionId": "hvf6", + "lineOfBusiness": "zzz1", + "modelInfo": { + "modelCustomizationId": "024a417d-ca46-40bf-95ce-809c6a269011", + "modelCustomizationName": "vProbe_NC_VNF 0", + "modelInvariantId": "a6a96924-b9c5-4c85-ae18-cbfca848095e", + "modelName": "vProbe_NC_VNF", + "modelUniqueId": "024a417d-ca46-40bf-95ce-809c6a269011", + "modelVersion": "1.0", + "modelVersionId": "21ae311e-432f-4c54-b855-446d0b8ded72", + "uuid": "21ae311e-432f-4c54-b855-446d0b8ded72" + }, + "platformName": "xxx1", + "position": null, + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "rollbackOnFailure": true, + "statusMessage": null, + "tenantId": "4914ab0ab3a743e58f0eefdacc1dde77", + "trackById": "1d2848a0-3573-4d29-b3dd-60bb263260ea", + "uuid": "21ae311e-432f-4c54-b855-446d0b8ded72", + "vfModules": { + "vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1": { + "vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1yprvi": { + "action": "Create", + "instanceName": "my_hvf6arlba007_lba_dj_01", + "instanceParams": [ + { + } + ], + "isFailed": false, + "lcpCloudRegionId": "hvf6", + "modelInfo": { + "modelCustomizationId": "9b99d340-a80b-45ef-9ff1-993fa3e4c001", + "modelCustomizationName": "VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1", + "modelInvariantId": "1bcc4824-6c1a-4b51-af7c-076b7fc14d05", + "modelName": "VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1", + "modelType": "vfModule", + "modelVersion": "1", + "modelVersionId": "c09e4530-8fd8-418f-9483-2f57ce927b05" + }, + "rollbackOnFailure": true, + "sdncPreLoad": true, + "tenantId": "4914ab0ab3a743e58f0eefdacc1dde77", + "trackById": "b134410e-3bc0-478e-883e-1b6bdf8a28df", + "volumeGroupName": "my_special_hvf6arlba007_lba_dj_01_vol" + } + }, + "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0": { + "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg": { + "instanceName": "hvf6arlba007_lba_Base_01", + "instanceParams": [ + { + } + ], + "isMissingData": false, + "lcpCloudRegionId": "hvf6", + "modelInfo": { + "modelCustomizationId": "4d0818cf-eaa9-4a3f-89c2-639953089e14", + "modelCustomizationName": "VprobeNcVnf..FE_base_module..module-0", + "modelInvariantId": "29b6fa3c-aeb3-4103-b3f7-6f98e097b005", + "modelName": "VprobeNcVnf..FE_base_module..module-0", + "modelUniqueId": "4d0818cf-eaa9-4a3f-89c2-639953089e14", + "modelVersion": "1", + "modelVersionId": "c5b26cc1-a66f-4b69-aa23-6abc7c647c88", + "uuid": "c5b26cc1-a66f-4b69-aa23-6abc7c647c88" + }, + "rollbackOnFailure": true, + "sdncPreLoad": null, + "tenantId": "4914ab0ab3a743e58f0eefdacc1dde77", + "uuid": "c5b26cc1-a66f-4b69-aa23-6abc7c647c88" + } + } + } + } + }, + "vrfs": { + } +} diff --git a/vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json b/vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json index a7b3a04c5..5a327fdd7 100644 --- a/vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json +++ b/vid-automation/src/test/resources/asyncInstantiation/templates__instance_template.json @@ -30,6 +30,8 @@ "existingVRFCounterMap": {}, "existingVnfGroupCounterMap": {}, "existingNetworksCounterMap": {}, + "existingNames": { + }, "vnfs": { "vProbe_NC_VNF 0": { "modelInfo": { @@ -87,7 +89,7 @@ "modelType": "vfModule", "modelVersion": "1" }, - "instanceName": "hvf6arlba007_lba_dj_01", + "instanceName": "my_hvf6arlba007_lba_dj_01", "action": "Create", "lcpCloudRegionId": "hvf6", "tenantId": "4914ab0ab3a743e58f0eefdacc1dde77", @@ -97,8 +99,8 @@ "rollbackOnFailure": true, "trackById": "b134410e-3bc0-478e-883e-1b6bdf8a28df", "isFailed": false, - "volumeGroupInstanceName": "hvf6arlba007_lba_dj_01_vol", - "usePreload": true + "volumeGroupName": "my_special_hvf6arlba007_lba_dj_01_vol", + "sdncPreLoad": true } } }, diff --git a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts index dbb9bca4d..0075dc240 100644 --- a/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts @@ -1,4 +1,5 @@ -import ObjectLike = Cypress.ObjectLike; +import * as _ from "lodash"; +import {PropertyPath} from "lodash"; describe('Drawing Board: Instantiation Templates', function () { @@ -6,7 +7,7 @@ describe('Drawing Board: Instantiation Templates', function () { beforeEach(() => { cy.clearSessionStorage(); - cy.setTestApiParamToVNF(); + cy.setTestApiParamToGR(); cy.initAAIMock(); cy.initGetAAISubDetails(); cy.initVidMock(); @@ -31,13 +32,12 @@ describe('Drawing Board: Instantiation Templates', function () { assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(); }); - it('View a template’s details as expected', ()=> { + it('Given a stored template - when "edit" vnf and vfmodules are opened - then template’s details are visible as expected and deploy without changes', () => { loadDrawingBoardWithRecreateMode(); // Then... - cy.drawingBoardTreeOpenContextMenuByElementDataTestId("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0") - .drawingBoardTreeClickOnContextMenuOptionByName('Edit') + editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0") .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007') .getElementByDataTestsId("productFamily").should('contain', 'Emanuel') .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') @@ -47,27 +47,26 @@ describe('Drawing Board: Instantiation Templates', function () { .checkPlatformValue('xxx1') .getElementByDataTestsId("cancelButton").click(); - cy.drawingBoardTreeOpenContextMenuByElementDataTestId("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0") - .drawingBoardTreeClickOnContextMenuOptionByName('Edit') + editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0") .getElementByDataTestsId("instanceName").should('have.value', 'hvf6arlba007_lba_Base_01') .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') .getElementByDataTestsId("rollback").should('contain', 'Rollback') .getElementByDataTestsId("cancelButton").click(); - cy.drawingBoardTreeOpenContextMenuByElementDataTestId("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1") - .drawingBoardTreeClickOnContextMenuOptionByName('Edit') + editNode("node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1") + .getElementByDataTestsId("instanceName").should('have.value', 'my_hvf6arlba007_lba_dj_01') + .getElementByDataTestsId("volumeGroupName").should('have.value', 'my_special_hvf6arlba007_lba_dj_01_vol') .getElementByDataTestsId("lcpRegion").should('contain', 'hvf6') .getElementByDataTestsId("tenant").should('contain', 'DN5242-Nov21-T1') .getElementByDataTestsId("rollback").should('contain', 'Rollback') + .getElementByDataTestsId("sdncPreLoad").should('have.value', 'on') .getElementByDataTestsId("cancelButton").click(); - - assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd(); }); - it(`Edit the service`, function () { + it(`Given a stored template - when "edit" service is opened - then template’s details are visible as expected`, function () { loadDrawingBoardWithRecreateMode(); @@ -80,13 +79,68 @@ describe('Drawing Board: Instantiation Templates', function () { .getElementByDataTestsId("project").should('contain', 'WATKINS') .getElementByDataTestsId("rollback").should('contain', 'Rollback'); + }); + [ + {desc: "with changes", modifySomeValues: true}, + {desc: "without changes", modifySomeValues: false}, + ].forEach((testCase) => { + + it(`Given a stored template - edit service vnf and vfmodule ${testCase.desc} - deploy request should be ${testCase.desc}`, function () { + + loadDrawingBoardWithRecreateMode(); + + //edit service + cy.openServiceContextMenu(); + cy.getElementByDataTestsId("context-menu-header-edit-item").click(); + if (testCase.modifySomeValues) { + cy.clearInput("instanceName"); + cy.typeToInput("instanceName", "different.instance.name"); + } + cy.getElementByDataTestsId('form-set').click(); + + // edit vnf + editNode("node-21ae311e-432f-4c54-b855-446d0b8ded72-vProbe_NC_VNF 0"); + if (testCase.modifySomeValues) { + cy.selectPlatformValue('platform'); + cy.selectDropdownOptionByText("tenant", "CESAR-100-D-spjg61909"); + } + cy.getElementByDataTestsId('form-set').click(); + + //edit vf module + editNode("node-c5b26cc1-a66f-4b69-aa23-6abc7c647c88-vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0"); + if (testCase.modifySomeValues) { + cy.getElementByDataTestsId('sdncPreLoad').click(); + } + cy.getElementByDataTestsId('form-set').click(); + + // Then... + let vnfPath = [ + "vnfs", "vProbe_NC_VNF 0" + ]; + let vfModule_0Path = [ + ...vnfPath, "vfModules", + "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0", + "vprobe_nc_vnf0..VprobeNcVnf..FE_base_module..module-0ahubg", + ]; + + assertThatBodyFromDeployRequestEqualsToFile(testCase.modifySomeValues ? [ + {path: ["instanceName"], value: "different.instance.name"}, + {path: ["existingNames", "vprobe_nc_service_dg_new_si"], value: undefined}, + {path: ["existingNames", "different.instance.name"], value: ""}, + + {path: [...vnfPath, "platformName"], value: "xxx1,platform"}, + {path: [...vnfPath, "tenantId"], value: "f2f3830e4c984d45bcd00e1a04158a79"}, + + {path: [...vfModule_0Path, "sdncPreLoad"], value: true}, + ] : []); + }) - - }); }); + }); }); +}); function loadDrawingBoardWithRecreateMode() { const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38'; @@ -112,6 +166,11 @@ function loadDrawingBoardWithRecreateMode() { cy.wait('@templateTopology'); } +function editNode(dataTestId: string) { + return cy.drawingBoardTreeOpenContextMenuByElementDataTestId(dataTestId) + .drawingBoardTreeClickOnContextMenuOptionByName('Edit') +} + function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() { cy.getDrawingBoardDeployBtn().click(); cy.wait('@expectedPostAsyncInstantiation').then(xhr => { @@ -124,6 +183,25 @@ function assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd() { }); } + +function assertThatBodyFromDeployRequestEqualsToFile(deviationFromExpected: { path: PropertyPath, value: any }[] = []) { + cy.getDrawingBoardDeployBtn().click(); + cy.wait('@expectedPostAsyncInstantiation').then(xhr => { + + cy.readFile('../vid-automation/src/test/resources/asyncInstantiation/templates__instance_from_template__set_without_modify1.json').then((expectedResult) => { + setDeviationInExpected(expectedResult, deviationFromExpected); + cy.deepCompare(xhr.request.body, expectedResult); + }); + + }); +} + +function setDeviationInExpected(expectedResult: any, deviation: { path: PropertyPath; value: any }[]) { + for (const caveat of deviation) { + _.set(expectedResult, caveat.path, caveat.value); + } +} + //We use this function because the deployService() on drawing-board-header.component class // changes rollbackOnFailure value from string type to boolean. function convertRollbackOnFailureValueFromStringToBoolean(expectedResult: any) { diff --git a/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts index 3caa4e81d..b2d3eb578 100644 --- a/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts @@ -39,6 +39,44 @@ describe('Template', () => { "serviceModelVersion": "1.0", "createdBulkDate": 1525075968000, "isRetryEnabled": true + }, + { + "id": 7, + "created": 1525075968000, + "modified": 1525075971000, + "action": "INSTANTIATE", + "createdId": null, + "modifiedId": null, + "rowNum": null, + "auditUserId": null, + "auditTrail": null, + "jobId": "13063a83-924e-4500-a3a1-e53d1b58450b", + "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e", + "userId": "17807000", + "aLaCarte": false, + "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9d", + "jobStatus": "IN_PROGRESS", + "statusModifiedDate": 1525075968000, + "hidden": false, + "pause": false, + "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", + "owningEntityName": "WayneHolland", + "project": "WATKINS", + "aicZoneId": "NFT1", + "aicZoneName": "NFTJSSSS-NFT1", + "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054", + "tenantName": "AIN Web Tool-15-D-testalexandria", + "regionId": "hvf6", + "regionName": null, + "serviceType": "TYLER SILVIA", + "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89", + "serviceInstanceId": null, + "serviceInstanceName": "nWUfl instance name_001", + "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "serviceModelName": "action-data", + "serviceModelVersion": "1.0", + "createdBulkDate": 1525075968000, + "isRetryEnabled": false } ]; @@ -65,6 +103,7 @@ describe('Template', () => { }); cy.route(Cypress.config('baseUrl') + "/asyncInstantiation**", asyncInstantiation); + cy.route(Cypress.config('baseUrl') + "/getuserID", '16807000'); cy.openIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true'); @@ -106,9 +145,14 @@ describe('Template', () => { //check load button is disabled - cy.getElementByDataTestsId('LoadTemplateButton').should('be.disabled') + cy.getElementByDataTestsId('LoadTemplateButton').should('be.disabled'); cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click(); - cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled') + cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled'); + + //filter by userId + cy.get('.member-table-row').should('have.length', 2); + cy.getElementByDataTestsId('filterByUserIdTestId').click(); + cy.get('.member-table-row').should('have.length', 1); }); diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts index 40ba258bd..8421cbd69 100644 --- a/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/viewEdit.e2e.ts @@ -143,6 +143,7 @@ describe('View Edit Page', function () { }); cy.initVidMock(); cy.mockLatestVersionForService(commonUuid, serviceInvariantId); + cy.initAAIServices(); cy.setReduxState(); cy.permissionVidMock(); cy.login(); @@ -166,6 +167,18 @@ describe('View Edit Page', function () { }); }); + it(`when using direct url should select elements in productFamily dropdown `, function () { + cy.visit('/serviceModels.htm#/instantiate?subscriberId=e433710f-9217-458d-a79d-1c7aff376d89&subscriberName=SILVIA%20ROBBINS&serviceType=TYLER%20SILVIA&serviceInstanceId=3f93c7cb-2fd0-4557-9514-e189b7b04f9d&aaiModelVersionId=6e59c5de-f052-46fa-aa7e-2fca9d674c44&isPermitted=true'); + cy.wait('@service-complexService'); + cy.wait('@aai_getPortMirroringConfigsDate - empty response'); + cy.wait('@initAAIServices'); + cy.getElementByDataTestsId('addNetworkButton').click(); + cy.getElementByDataTestsId('addNetworkOption-MULTI_PROVIDER_PORT_GROUP 0').click(); + cy.getElementByDataTestsId('productFamily').select('WILKINS'); + }); + + + it(`Check fabric configuration service with some configuration with diff orchStatus`, function () { cy.visit('/serviceModels.htm#/instantiate?subscriberId=e433710f-9217-458d-a79d-1c7aff376d89&subscriberName=SILVIA%20ROBBINS&serviceType=TYLER%20SILVIA&serviceInstanceId=c187e9fe-40c3-4862-b73e-84ff056205f61234&aaiModelVersionId=6e59c5de-f052-46fa-aa7e-2fca9d671234&isPermitted=true'); cy.wait('@service-FabricConfig'); diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts index 9f2499f3c..09734472c 100644 --- a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts @@ -100,20 +100,20 @@ describe('View Edit Page: Upgrade VFModule', function () { `servicePlanning/EDIT?serviceModelId=${serviceUuid}&subscriberId=${SUBSCRIBER_ID}&serviceType=${SERVICE_TYPE}&serviceInstanceId=${SERVICE_INSTANCE_ID}`); }); - it(`Upgrade a VFModule`, function () { + it(`Upgrade a VF Module`, function () { cy.initDrawingBoardUserPermission(); initServicePlanning("EDIT", '../vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json'); - upgradeTheVFM(); + upgradeTheVFM('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1', true); assertVfModuleActionInRedux("None_Upgrade"); undoUpgradeForVFM(); assertVfModuleActionInRedux("None"); - upgradeTheVFM(); + upgradeTheVFM('node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1',true); cy.getDrawingBoardDeployBtn().click(); cy.wait('@expectedPostAsyncInstantiation').then(xhr => { const requestBody = Object(xhr.request.body); const vfModuleRequest = requestBody.vnfs['VNF2_INSTANCE_ID'].vfModules['vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1']['2c1ca484-cbc2-408b-ab86-25a2c15ce280']; - expect(requestBody.action).to.equal("None_Upgrade"); + expect(requestBody.action).to.equal("None_Upgrade"); expect(requestBody.vnfs['VNF2_INSTANCE_ID'].action).to.equal("None_Upgrade"); expect(vfModuleRequest.action).to.equal("None_Upgrade"); }); @@ -129,7 +129,7 @@ describe('View Edit Page: Upgrade VFModule', function () { }); - describe('More UI tests', () => { + describe('More UI test', () => { beforeEach(() => { cy.clearSessionStorage(); @@ -174,7 +174,7 @@ describe('View Edit Page: Upgrade VFModule', function () { cy.openIframe(`app/ui/#/servicePlanning/EDIT?serviceModelId=${serviceModelId}&subscriberId=${subscriberId}&serviceType=${serviceType}&serviceInstanceId=${serviceInstanceId}`); - upgradeTheVFM('node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0'); + upgradeTheVFM('node-04b21d26-9780-4956-8329-b22b049329f4-xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0', false); mockAsyncBulkResponse(); cy.getDrawingBoardDeployBtn().click(); @@ -213,13 +213,18 @@ describe('View Edit Page: Upgrade VFModule', function () { }).as("expectLatestServiceModelUpgradeVersion"); } - function upgradeTheVFM(treeNodeId = 'node-522159d5-d6e0-4c2a-aa44-5a542a12a830-vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1') { + function upgradeTheVFM(treeNodeId: string, shouldVGCheckboxExist :boolean) { cy.getElementByDataTestsId(`${treeNodeId}-menu-btn`).click() .drawingBoardTreeClickOnContextMenuOptionByName("Upgrade"); // The following is needed when enabling FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS cy.getElementByDataTestsId('retainAssignments').click(); - cy.getElementByDataTestsId('retainVolumeGroups').click(); + if (shouldVGCheckboxExist) { + cy.getElementByDataTestsId('retainVolumeGroups').click(); + } + else { + cy.getElementByDataTestsId('retainVolumeGroups').should('not.exist'); + } cy.getElementByDataTestsId('sdncPreLoad').click(); cy.screenshot(); cy.getElementByDataTestsId('form-set').click(); diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/aai.mock.ts b/vid-webpack-master/cypress/support/jsonBuilders/mocks/aai.mock.ts index 3e6d5e33f..ae60361c2 100644 --- a/vid-webpack-master/cypress/support/jsonBuilders/mocks/aai.mock.ts +++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/aai.mock.ts @@ -8,6 +8,7 @@ declare namespace Cypress { initActiveNetworks : typeof initActiveNetworks; initActiveVPNs : typeof initActiveVPNs; initGetAAISubDetails : typeof initGetAAISubDetails; + initAAIServices: typeof initAAIServices; } } @@ -154,5 +155,7 @@ Cypress.Commands.add('initGetAAISubDetails', initGetAAISubDetails); Cypress.Commands.add('initSearchVNFMemebers', initSearchVNFMemebers); Cypress.Commands.add('initActiveNetworks', initActiveNetworks); Cypress.Commands.add('initActiveVPNs', initActiveVPNs); +Cypress.Commands.add('initAAIServices', initAAIServices); + diff --git a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json index 3e22bfea9..5ac833dca 100644 --- a/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json +++ b/vid-webpack-master/cypress/support/jsonBuilders/mocks/jsons/upgradeVfModule/upgrade_vfmodule_e2e__service_instance.json @@ -98,4 +98,4 @@ "existingNetworksCounterMap": {}, "existingVnfGroupCounterMap": {}, "existingVRFCounterMap": {} -}
\ No newline at end of file +} diff --git a/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts b/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts index 5444971b7..8d2bb8a24 100644 --- a/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts +++ b/vid-webpack-master/cypress/support/steps/drawingBoard/general.steps.ts @@ -26,8 +26,5 @@ function openServiceContextMenu() : Chainable<any> { return cy.getElementByDataTestsId('openMenuBtn').click({force: true}); } - - - Cypress.Commands.add('updateServiceShouldNotOverrideChild', updateServiceShouldNotOverrideChild); Cypress.Commands.add('openServiceContextMenu', openServiceContextMenu); diff --git a/vid-webpack-master/package.json b/vid-webpack-master/package.json index f2f913612..ee04de10d 100644 --- a/vid-webpack-master/package.json +++ b/vid-webpack-master/package.json @@ -8,6 +8,7 @@ "build": "ng build --no-progress --no-aot --output-hashing all", "build.prod": "ng build", "test": "jest", + "ci": "npm run test && npm run build", "test:jest": "jest", "test:jest:pipeline": "jest --silent --ci --reporters=default --reporters=jest-junit", "test:jest:watch": "jest --watch", @@ -92,7 +93,7 @@ "hammerjs": "2.0.8", "husky": "^1.3.1", "istanbul-reports": "2.1.1", - "jest": "24.1.0", + "jest": "24.9.0", "jest-each": "24.0.0", "jest-junit": "6.3.0", "jest-sonar-reporter": "2.0.0", diff --git a/vid-webpack-master/pom.xml b/vid-webpack-master/pom.xml index 2fe0a6eaf..f84a485eb 100644 --- a/vid-webpack-master/pom.xml +++ b/vid-webpack-master/pom.xml @@ -28,7 +28,7 @@ <stagingNexusPath>content/repositories/staging/</stagingNexusPath> <snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath> <releaseNexusPath>content/repositories/releases/</releaseNexusPath> - <NPM_CMD>build</NPM_CMD> + <NPM_CMD>ci</NPM_CMD> </properties> @@ -70,6 +70,7 @@ </distributionManagement> <profiles> + <profile> <id>if-not-webpack</id> <activation> @@ -107,6 +108,7 @@ </plugins> </build> </profile> + <profile> <id>webpack-npm</id> <activation> diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts index fb1172945..e277cb28c 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/available-models-tree/available-models-tree.component.ts @@ -10,7 +10,7 @@ import {AaiService} from '../../../shared/services/aaiService/aai.service'; import {ServiceNodeTypes} from '../../../shared/models/ServiceNodeTypes'; import {IframeService} from "../../../shared/utils/iframe.service"; import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataServiceGenerator/default.data.generator.service"; -import {VfModulePopuopService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service"; import {createVFModuleInstance} from "../../../shared/storeUtil/utils/vfModule/vfModule.actions"; import {VnfPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service"; @@ -56,7 +56,7 @@ export class AvailableModelsTreeComponent { private _drawingBoardTreeService: DrawingBoardTreeService, private _defaultDataGeneratorService: DefaultDataGeneratorService, private _vnfGroupControlGenerator: VnfGroupControlGenerator, - private _vfModulePopuopService: VfModulePopuopService, + private _vfModulePopuopService: VfModulePopupService, private _vnfGroupPopupService: VnfGroupPopupService, private _vnfPopupService: VnfPopupService, private _networkPopupService: NetworkPopupService, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts index f3542573d..4ad1b06cf 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts @@ -11,7 +11,7 @@ import {IframeService} from "../../../shared/utils/iframe.service"; import {DuplicateService} from '../duplicate/duplicate.service'; import {DrawingBoardTreeService, TreeNodeContextMenuModel} from "./drawing-board-tree.service"; import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service"; -import {VfModulePopuopService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VnfPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service"; import {SdcUiServices} from "onap-ui-angular"; import {HighlightPipe} from "../../../shared/pipes/highlight/highlight-filter.pipe"; @@ -63,7 +63,7 @@ export class DrawingBoardTreeComponent implements OnInit, AfterViewInit { private modalService: SdcUiServices.ModalService, private _drawingBoardTreeService: DrawingBoardTreeService, private _networkPopupService: NetworkPopupService, - private _vfModulePopuopService: VfModulePopuopService, + private _vfModulePopuopService: VfModulePopupService, private _vnfPopupService: VnfPopupService, private _vnfGroupPopupService: VnfGroupPopupService, private _errorMsgService: ErrorMsgService, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.spec.ts index a44c21bf0..59ef35abb 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.spec.ts @@ -8,7 +8,7 @@ import {NgRedux} from "@angular-redux/store"; import {AppState} from "../../../../../shared/store/reducers"; import {DefaultDataGeneratorService} from "../../../../../shared/services/defaultDataServiceGenerator/default.data.generator.service"; import {DialogService} from "ng2-bootstrap-modal"; -import {VfModulePopuopService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VnfPopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service"; import {DuplicateService} from "../../../duplicate/duplicate.service"; import {IframeService} from "../../../../../shared/utils/iframe.service"; @@ -38,7 +38,7 @@ describe('Related Vnf member Model Info', () => { MockNgRedux, DynamicInputsService, DialogService, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, VnfPopupService, DefaultDataGeneratorService, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts index 85e57613a..8bdab11e3 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts @@ -4,7 +4,7 @@ import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing"; import {VFModuleModelInfo} from "./vfModule.model.info"; import {DynamicInputsService} from "../../dynamicInputs.service"; import {SharedTreeService} from "../../shared.tree.service"; -import {VfModulePopuopService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {DialogService} from "ng2-bootstrap-modal"; import {NgRedux} from "@angular-redux/store"; import {AvailableNodeIcons} from "../../../available-models-tree/available-models-tree.service"; @@ -19,6 +19,7 @@ import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/fe import {VfModuleUpgradePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service"; import {instance, mock, when} from "ts-mockito"; import each from "jest-each"; +import {VfModule} from "../../../../../shared/models/vfModule"; class MockAppStore<T> { getState() { @@ -30,19 +31,13 @@ class MockAppStore<T> { } } -class MockFeatureFlagsService extends FeatureFlagsService{ - getAllFlags(): { [p: string]: boolean } { - return {}; - } -} - describe('VFModule Model Info', () => { let injector; let _dynamicInputsService : DynamicInputsService; let _sharedTreeService : SharedTreeService; let vfModuleModel: VFModuleModelInfo; let _dialogService : DialogService; - let _vfModulePopupService : VfModulePopuopService; + let _vfModulePopupService : VfModulePopupService; let _vfModuleUpgradePopupService : VfModuleUpgradePopupService; let _iframeService : IframeService; let _componentInfoService : ComponentInfoService; @@ -56,7 +51,7 @@ describe('VFModule Model Info', () => { providers: [ DynamicInputsService, DialogService, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, SharedTreeService, IframeService, @@ -133,8 +128,16 @@ describe('VFModule Model Info', () => { }); test('getModel should return Module model', () => { - let model = vfModuleModel.getModel('2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1',{}, getServiceHierarchy()); + let model = vfModuleModel.getModel('2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1',null, getServiceHierarchy()); expect(model.uuid).toEqual('25284168-24bb-4698-8cb4-3f509146eca5'); + expect(model.min).toBe(2); + expect(model.max).toBe(3); + expect(model.baseModule).toBeFalsy(); + expect(model.inputs).toEqual( + {"vnf_config_template_version": { + "type": "string" + }}); + expect(model.volumeGroupAllowed).toBeTruthy(); }); test('showNodeIcons should return false false if reachLimit of max', ()=>{ @@ -413,9 +416,35 @@ describe('VFModule Model Info', () => { 'modelInfo' : { modelVersionId : 'vfModuleId' } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } } } } + }, + 'vnfName_1' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } } } } @@ -438,6 +467,95 @@ describe('VFModule Model Info', () => { } }; let result = vfModuleModel.getNodeCount(<any>node , serviceId); + expect(result).toEqual(2); + }); + + + test('getNodeCount should return number of nodes : there is selectedVNF', ()=>{ + let serviceId : string = 'servicedId'; + jest.spyOn(MockNgRedux.getInstance(), 'getState').mockReturnValue({ + global : {}, + service : { + serviceHierarchy : { + 'servicedId' : { + 'vnfs' : { + 'vnfName' : { + 'properties' : { + 'max_instances' : 1 + } + } + }, + 'vfModules' : { + 'vfModuleName' : { + 'properties' : { + maxCountInstances : 2 + } + } + } + } + }, + serviceInstance : { + 'servicedId' : { + 'existingVNFCounterMap' : { + 'vnfId' : 1 + }, + 'vnfs' : { + 'vnfName' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } + }, + 'vnfName_1' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } + } + } + } + } + } + }); + jest.spyOn(_sharedTreeService, 'getSelectedVNF').mockReturnValue('vnfName_1'); + + let node = { + data : { + id : 'vfModuleId', + name : 'vfModuleName', + 'action': 'Create', + }, + parent : { + data : { + id : 'vnfId', + name : 'vnfName_1', + 'action': 'Create', + } + } + }; + let result = vfModuleModel.getNodeCount(<any>node , serviceId); expect(result).toEqual(1); }); @@ -510,7 +628,7 @@ describe('VFModule Model Info', () => { expect(vfModuleModel.isVFModuleReachedLimit(node, serviceHierarchy, 'servicedId', currentNodeCount)).toEqual(expected); }); - function getVFModule(){ + function getVFModule(): Partial<VfModule>{ return { "uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830", "invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b", @@ -519,13 +637,10 @@ describe('VFModule Model Info', () => { "name":"VfVgeraldine..vflorence_vlc..module-1", "version":"2", "modelCustomizationName":"VfVgeraldine..vflorence_vlc..module-1", - "properties":{ - "minCountInstances":0, - "maxCountInstances":null, - "initialCount":0, - "vfModuleLabel":"vflorence_vlc", - "baseModule":false - }, + "min":0, + "max":null, + "initial":0, + "baseModule":false, "inputs":{}, "volumeGroupAllowed":false }; @@ -1151,7 +1266,7 @@ describe('VFModule Model Info', () => { "type": "VF", "modelCustomizationName": "2017-488_PASQUALE-vPE 0", "vfModules": { - "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": { + "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1":{ "uuid": "25284168-24bb-4698-8cb4-3f509146eca5", "invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", "customizationUuid": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", @@ -1160,82 +1275,15 @@ describe('VFModule Model Info', () => { "version": "6", "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", "properties": { - "minCountInstances": 0, - "maxCountInstances": null, + "minCountInstances": 2, + "maxCountInstances": 3, "initialCount": 0, "vfModuleLabel": "PASQUALE_vRE_BV", "baseModule": false }, "inputs": { "vnf_config_template_version": { - "type": "string", - "description": "VPE Software Version", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_config_template_version" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version", - "constraints": null, - "required": true, - "default": "17.2" - }, - "bandwidth_units": { - "type": "string", - "description": "Units of bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth_units" - }, - "fromInputName": "pasqualevpe0_bandwidth_units", - "constraints": null, - "required": true, - "default": "Gbps" - }, - "bandwidth": { - "type": "string", - "description": "Requested VPE bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth" - }, - "fromInputName": "pasqualevpe0_bandwidth", - "constraints": null, - "required": true, - "default": "10" - }, - "AIC_CLLI": { - "type": "string", - "description": "AIC Site CLLI", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "AIC_CLLI" - }, - "fromInputName": "2017488_pasqualevpe0_AIC_CLLI", - "constraints": null, - "required": true, - "default": "ATLMY8GA" - }, - "vnf_instance_name": { - "type": "string", - "description": "The hostname assigned to the vpe.", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_instance_name" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_instance_name", - "constraints": null, - "required": true, - "default": "mtnj309me6" + "type": "string" } }, "volumeGroupAllowed": true @@ -1402,82 +1450,15 @@ describe('VFModule Model Info', () => { "version": "6", "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", "properties": { - "minCountInstances": 0, - "maxCountInstances": null, + "minCountInstances": 2, + "maxCountInstances": 3, "initialCount": 0, "vfModuleLabel": "PASQUALE_vRE_BV", "baseModule": false }, "inputs": { "vnf_config_template_version": { - "type": "string", - "description": "VPE Software Version", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_config_template_version" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version", - "constraints": null, - "required": true, - "default": "17.2" - }, - "bandwidth_units": { - "type": "string", - "description": "Units of bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth_units" - }, - "fromInputName": "pasqualevpe0_bandwidth_units", - "constraints": null, - "required": true, - "default": "Gbps" - }, - "bandwidth": { - "type": "string", - "description": "Requested VPE bandwidth", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "bandwidth" - }, - "fromInputName": "pasqualevpe0_bandwidth", - "constraints": null, - "required": true, - "default": "10" - }, - "AIC_CLLI": { - "type": "string", - "description": "AIC Site CLLI", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "AIC_CLLI" - }, - "fromInputName": "2017488_pasqualevpe0_AIC_CLLI", - "constraints": null, - "required": true, - "default": "ATLMY8GA" - }, - "vnf_instance_name": { - "type": "string", - "description": "The hostname assigned to the vpe.", - "entry_schema": null, - "inputProperties": { - "sourceType": "HEAT", - "vfModuleLabel": "PASQUALE_vRE_BV", - "paramName": "vnf_instance_name" - }, - "fromInputName": "2017488_pasqualevpe0_vnf_instance_name", - "constraints": null, - "required": true, - "default": "mtnj309me6" + "type": "string" } }, "volumeGroupAllowed": true diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts index 1e4a22c45..73f35279f 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts @@ -10,7 +10,7 @@ import {NgRedux} from "@angular-redux/store"; import {ITreeNode} from "angular-tree-component/dist/defs/api"; import {GenericFormPopupComponent, PopupType} from "../../../../../shared/components/genericFormPopup/generic-form-popup.component"; import {DialogService} from "ng2-bootstrap-modal"; -import {VfModulePopuopService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {AppState} from "../../../../../shared/store/reducers"; import {MessageBoxData} from "../../../../../shared/components/messageBox/messageBox.data"; import {MessageBoxService} from "../../../../../shared/components/messageBox/messageBox.service"; @@ -28,7 +28,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo { constructor(private _dynamicInputsService: DynamicInputsService, private _sharedTreeService: SharedTreeService, private _dialogService: DialogService, - private _vfModulePopupService: VfModulePopuopService, + private _vfModulePopupService: VfModulePopupService, private _vfModuleUpgradePopupService: VfModuleUpgradePopupService, private _iframeService: IframeService, private _featureFlagsService: FeatureFlagsService, @@ -67,10 +67,10 @@ export class VFModuleModelInfo implements ILevelNodeInfo { * @param instance * @param serviceHierarchy - serviceHierarchy ************************************************************/ - getModel = (vfModuleModelId: string, instance, serviceHierarchy): any => { + getModel = (vfModuleModelId: string, instance, serviceHierarchy): Partial<VfModule> => { if (!_.isNil(serviceHierarchy)) { if (!_.isNil(serviceHierarchy[this.name]) && !_.isNil(serviceHierarchy[this.name][vfModuleModelId])) { - return serviceHierarchy[this.name][vfModuleModelId]; + return new VfModule(serviceHierarchy[this.name][vfModuleModelId], this._featureFlagsService.getAllFlags()); } } return {}; @@ -177,12 +177,16 @@ export class VFModuleModelInfo implements ILevelNodeInfo { * @param serviceModelId - current service id ************************************************************/ getNodeCount(node: ITreeNode, serviceModelId: string): number { + const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; let count: number = 0; if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) { - const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; - - for (let vnfKey in vnfs) { - count += this.countNumberOfVFModule(vnfs[vnfKey], node); + const selectedVNF: string = this._sharedTreeService.getSelectedVNF(); + if (selectedVNF) { + count += this.countNumberOfVFModule(vnfs[selectedVNF], node); + }else { + for (let vnfKey in vnfs) { + count += this.countNumberOfVFModule(vnfs[vnfKey], node); + } } return count; } @@ -206,11 +210,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo { getCountVFModuleOfSelectedVNF(node: ITreeNode, vnfStoreKey: string, serviceModelId: string): number { let count: number = 0; if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) { - const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; - - for (let vnfKey in vnfs) { - count += this.countNumberOfVFModule(vnfs[vnfKey], node); - } + const vnf = this._store.getState().service.serviceInstance[serviceModelId].vnfs[vnfStoreKey]; + count += this.countNumberOfVFModule(vnf, node); return count; } return count; @@ -238,7 +239,6 @@ export class VFModuleModelInfo implements ILevelNodeInfo { showVFModuleOnSelectedVNF(node: ITreeNode, selectedVNF: string, serviceModelId: string): AvailableNodeIcons { - if (!_.isNil(this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF]) && node.parent.data.name === this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF].originalName) { const existingVFModules = this.getCountVFModuleOfSelectedVNF(node, selectedVNF, serviceModelId); const reachedLimit = this.isVFModuleReachedLimit(node, this._store.getState().service.serviceHierarchy, serviceModelId, existingVFModules); @@ -397,9 +397,9 @@ export class VFModuleModelInfo implements ILevelNodeInfo { vfModule : _.cloneDeep(node) }, node, - isUpdateMode: false + isUpdateMode: true }); - }else { + } else { this._sharedTreeService.upgradeBottomUp(node, serviceModelId); this._store.dispatch(upgradeVFModule(node.data.modelName, node.parent.data.vnfStoreKey, serviceModelId ,node.data.dynamicModelName)); } @@ -414,12 +414,12 @@ export class VFModuleModelInfo implements ILevelNodeInfo { return (!_.isNil(instance) && !_.isNil(instance[deepDynamicName])) ? instance[deepDynamicName].position : null; } - getInfo(model, instance): ModelInformationItem[] { - const modelInformation = !_.isEmpty(model) && !_.isEmpty(model.properties) ? [ - ModelInformationItem.createInstance("Base module", model.properties.baseModule), - ModelInformationItem.createInstance("Min instances", !_.isNull(model.properties.minCountInstances) ? String(model.properties.minCountInstances) : null), + getInfo(model:Partial<VfModule>, instance): ModelInformationItem[] { + const modelInformation = !_.isEmpty(model) ? [ + ModelInformationItem.createInstance("Base module", model.baseModule), + ModelInformationItem.createInstance("Min instances", !_.isNull(model.min) ? String(model.min) : null), this._sharedTreeService.createMaximumToInstantiateModelInformationItem(model), - ModelInformationItem.createInstance("Initial instances count", !_.isNull(model.properties.initialCount) ? String(model.properties.initialCount) : null) + ModelInformationItem.createInstance("Initial instances count", !_.isNull(model.initial) ? String(model.initial) : null) ] : []; const instanceInfo = []; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.spec.ts index 3ac6076dc..f700ed419 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.spec.ts @@ -10,7 +10,7 @@ import {NgRedux} from "@angular-redux/store"; import {AppState} from "../../../../../shared/store/reducers"; import {DefaultDataGeneratorService} from "../../../../../shared/services/defaultDataServiceGenerator/default.data.generator.service"; import {DialogService} from "ng2-bootstrap-modal"; -import {VfModulePopuopService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VnfPopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service"; import {AvailableNodeIcons} from "../../../available-models-tree/available-models-tree.service"; import {DuplicateService} from "../../../duplicate/duplicate.service"; @@ -38,7 +38,7 @@ describe('Vnf Model Info', () => { let _serviceInfoService: ServiceInfoService; let _defaultDataGeneratorService : DefaultDataGeneratorService; let _dialogService : DialogService; - let _vfModulePopupService : VfModulePopuopService; + let _vfModulePopupService : VfModulePopupService; let _vfModuleUpgradePopupService : VfModuleUpgradePopupService; let _vnfPopupService : VnfPopupService; let _duplicateService : DuplicateService; @@ -55,7 +55,7 @@ describe('Vnf Model Info', () => { MockNgRedux, DynamicInputsService, DialogService, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, VnfPopupService, DefaultDataGeneratorService, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts index a5a85c41a..355b5c597 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts @@ -12,7 +12,7 @@ import {DefaultDataGeneratorService} from "../../../../../shared/services/defaul import {GenericFormPopupComponent, PopupType} from "../../../../../shared/components/genericFormPopup/generic-form-popup.component"; import {DialogService} from 'ng2-bootstrap-modal'; import {VnfPopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service"; -import {VfModulePopuopService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {ITreeNode} from "angular-tree-component/dist/defs/api"; import {AvailableNodeIcons} from "../../../available-models-tree/available-models-tree.service"; import {DuplicateService} from "../../../duplicate/duplicate.service"; @@ -38,7 +38,7 @@ export class VnfModelInfo implements ILevelNodeInfo { private _defaultDataGeneratorService: DefaultDataGeneratorService, private _dialogService: DialogService, private _vnfPopupService: VnfPopupService, - private _vfModulePopupService: VfModulePopuopService, + private _vfModulePopupService: VfModulePopupService, private _vfModuleUpgradePopupService: VfModuleUpgradePopupService, private _duplicateService: DuplicateService, private modalService: SdcUiServices.ModalService, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts index 9add349db..c17d9c74c 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.spec.ts @@ -22,7 +22,7 @@ import {IframeService} from "../../../../shared/utils/iframe.service"; import {BasicPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/basic.popup.service"; import {NetworkPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service"; import {NetworkControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator"; -import {VfModulePopuopService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VfModuleControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; import {VnfGroupPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service"; import {VnfGroupControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator"; @@ -73,7 +73,7 @@ describe('Model Tree Generator service', () => { BasicPopupService, NetworkPopupService, NetworkControlGenerator, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, VfModuleControlGenerator, VnfGroupControlGenerator, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts index e5559ee15..8674a619e 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.spec.ts @@ -22,7 +22,7 @@ import {IframeService} from "../../../../shared/utils/iframe.service"; import {BasicPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/basic.popup.service"; import {NetworkPopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service"; import {NetworkControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator"; -import {VfModulePopuopService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VfModuleControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; import {FeatureFlagsService} from "../../../../shared/services/featureFlag/feature-flags.service"; import {VnfControlGenerator} from "../../../../shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator"; @@ -98,7 +98,7 @@ describe('Model Tree Generator service', () => { BasicPopupService, NetworkPopupService, NetworkControlGenerator, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, VfModuleControlGenerator, VnfGroupControlGenerator, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToTree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToTree.service.ts index 1e6825130..9b68627e2 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToTree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToTree.service.ts @@ -11,7 +11,7 @@ import {AppState} from "../../../shared/store/reducers"; import {DialogService} from "ng2-bootstrap-modal"; import {VnfPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service"; import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service"; -import {VfModulePopuopService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VnfGroupingModelInfo} from "./models/vnfGrouping/vnfGrouping.model.info"; import {VnfGroupPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service"; import {DuplicateService} from "../duplicate/duplicate.service"; @@ -35,7 +35,7 @@ export class ObjectToTreeService { private _dialogService : DialogService, private _vnfPopupService : VnfPopupService, private _networkPopupService : NetworkPopupService, - private _vfModulePopupService : VfModulePopuopService, + private _vfModulePopupService : VfModulePopupService, private _vfModuleUpgradePopupService : VfModuleUpgradePopupService, private _vnfGroupPopupService : VnfGroupPopupService, private _duplicateService : DuplicateService, diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts index 504dc86bd..277ea941e 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts @@ -12,7 +12,7 @@ import {BasicControlGenerator} from "../../../shared/components/genericForm/form import {AaiService} from "../../../shared/services/aaiService/aai.service"; import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service"; import {NetworkControlGenerator} from "../../../shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator"; -import {VfModulePopuopService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VfModuleControlGenerator} from "../../../shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; import {VnfGroupControlGenerator} from "../../../shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator"; import {FeatureFlagsService} from "../../../shared/services/featureFlag/feature-flags.service"; @@ -96,7 +96,7 @@ describe('Shared Tree Service', () => { DynamicInputsService, NetworkPopupService, NetworkControlGenerator, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, VfModuleControlGenerator, VnfGroupControlGenerator, diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss new file mode 100644 index 000000000..005e28cc6 --- /dev/null +++ b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.scss @@ -0,0 +1,41 @@ +.details-item input { + cursor: pointer; + opacity: 0; + position: absolute; + z-index: 100; + width: 24px; + height: 22px; + margin: 0; +} + +.details-item label { + position: relative; + cursor: pointer; +} + +.details-item label:before { + content:''; + -webkit-appearance: none; + background-color: transparent; + border: 2px solid #0079bf; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05); + padding: 10px; + display: inline-block; + position: relative; + vertical-align: middle; + cursor: pointer; + margin-right: 5px; +} + +.details-item input:checked + label:after { + content: ''; + display: block; + position: absolute; + top: 2px; + left: 9px; + width: 6px; + height: 14px; + border: solid #0079bf; + border-width: 0 2px 2px 0; + transform: rotate(45deg); +} diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts index f9ba48308..215b1fec1 100644 --- a/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts +++ b/vid-webpack-master/src/app/shared/components/formControls/component/checkbox/checkbox.formControl.component.ts @@ -4,7 +4,8 @@ import {FormGroup} from "@angular/forms"; @Component({ selector: 'checkbox-form-control', - templateUrl: './checkbox.formControl.component.html' + templateUrl: './checkbox.formControl.component.html', + styleUrls : ['./checkbox.formControl.component.scss'] }) export class CheckboxFormControlComponent{ @Input() data: FormControlModel; diff --git a/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts b/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts index 26a55e9d2..cf062f0e0 100644 --- a/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts +++ b/vid-webpack-master/src/app/shared/components/formControls/component/multiselect/multiselect.formControl.component.ts @@ -35,7 +35,7 @@ export class MultiselectFormControlComponent implements OnChanges{ this.options = options; this._multiselectFormControlService.convertSelectedItems(this.data).then((res)=> { this.selectedItems = res; - this.form.controls[this.data.controlName].setValue(this.selectedItems); + this.data.onChange(this.selectedItems ,this.form); }) }); } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts index 63c980cd5..514b9bfef 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts @@ -17,7 +17,7 @@ import {UUIDData} from "./generic-form-popup.component"; import {ITreeNode} from "angular-tree-component/dist/defs/api"; import {NetworkPopupService} from "./genericFormServices/network/network.popup.service"; import {NetworkControlGenerator} from "../genericForm/formControlsServices/networkGenerator/network.control.generator"; -import {VfModulePopuopService} from "./genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "./genericFormServices/vfModule/vfModule.popup.service"; import {VfModuleControlGenerator} from "../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service"; import {VfModuleUpgradePopupService} from "./genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service"; @@ -946,7 +946,7 @@ describe('Generic Form popup Service', () => { let form : FormGroup; let fb : FormBuilder; let netwokPopupService : NetworkPopupService; - let vfModulePopupService : VfModulePopuopService; + let vfModulePopupService : VfModulePopupService; let servicePopupService : ServicePopupService; let _aaiService : AaiService; let _activatedRoute : ActivatedRoute; @@ -967,7 +967,7 @@ describe('Generic Form popup Service', () => { AaiService, NetworkPopupService, NetworkControlGenerator, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, VfModuleControlGenerator, {provide:FeatureFlagsService, useClass: MockFeatureFlagsService}, @@ -981,7 +981,7 @@ describe('Generic Form popup Service', () => { httpMock = injector.get(HttpTestingController); fb = injector.get(FormBuilder); netwokPopupService = injector.get(NetworkPopupService); - vfModulePopupService = injector.get(VfModulePopuopService); + vfModulePopupService = injector.get(VfModulePopupService); servicePopupService = injector.get(ServicePopupService); _aaiService = injector.get(AaiService); _activatedRoute = injector.get(ActivatedRoute); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts index 6c487102f..935454752 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.spec.ts @@ -8,7 +8,7 @@ import {FormBuilder} from "@angular/forms"; import {IframeService} from "../../../../utils/iframe.service"; import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service"; import {BasicPopupService} from "../basic.popup.service"; -import {VfModulePopuopService} from "./vfModule.popuop.service"; +import {VfModulePopupService} from "./vfModule.popup.service"; import {VfModuleControlGenerator} from "../../../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; import {SdcUiServices} from "onap-ui-angular"; import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service"; @@ -1972,7 +1972,7 @@ class MockFeatureFlagsService {} describe('VFModule popup service', () => { let injector; - let service: VfModulePopuopService; + let service: VfModulePopupService; let genericFormService: GenericFormService let defaultDataGeneratorService: DefaultDataGeneratorService; let fb: FormBuilder; @@ -1981,7 +1981,7 @@ describe('VFModule popup service', () => { beforeAll(done => (async () => { TestBed.configureTestingModule({ providers : [ - VfModulePopuopService, + VfModulePopupService, BasicControlGenerator, VfModuleControlGenerator, DefaultDataGeneratorService, @@ -2000,7 +2000,7 @@ describe('VFModule popup service', () => { await TestBed.compileComponents(); injector = getTestBed(); - service = injector.get(VfModulePopuopService); + service = injector.get(VfModulePopupService); genericFormService = injector.get(GenericFormService); defaultDataGeneratorService = injector.get(DefaultDataGeneratorService); fb = injector.get(FormBuilder); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts index 3119cc8f8..6a31bb7ee 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service.ts @@ -34,7 +34,6 @@ export abstract class VfModulePopupServiceBase { formValues.modelInfo = new ModelInfo(that.model); formValues.uuid = formValues.modelInfo.uuid; formValues.isMissingData = false; - const vnf = that._store.getState().service.serviceInstance[that.uuidData.serviceId].vnfs[that.uuidData.vnfStoreKey]; if (!that.uuidData.vFModuleStoreKey) { this._store.dispatch(createVFModuleInstance(formValues, that.uuidData.modelName, that.uuidData.serviceId, 0, that.uuidData.vnfStoreKey)); @@ -154,7 +153,7 @@ export abstract class VfModulePopupServiceBase { } @Injectable() -export class VfModulePopuopService extends VfModulePopupServiceBase implements GenericPopupInterface { +export class VfModulePopupService extends VfModulePopupServiceBase implements GenericPopupInterface { constructor(_basicControlGenerator: BasicControlGenerator, diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts index bbfe8705e..667e79678 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts @@ -1,7 +1,7 @@ import {Injectable} from "@angular/core"; import {ITreeNode} from "angular-tree-component/dist/defs/api"; import {FormGroup} from "@angular/forms"; -import {VfModulePopupServiceBase} from "../vfModule/vfModule.popuop.service"; +import {VfModulePopupServiceBase} from "../vfModule/vfModule.popup.service"; import {upgradeVFModule} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; import {NgRedux} from "@angular-redux/store"; @@ -16,11 +16,12 @@ import {FormControlModel} from "../../../../models/formControlModels/formControl import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model"; import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum"; import {mergeObjectByPathAction} from "../../../../storeUtil/utils/general/general.actions"; +import * as _ from "lodash"; +import {VfModuleInstance} from "../../../../models/vfModuleInstance"; export enum UpgradeFormControlNames { RETAIN_VOLUME_GROUPS = 'retainVolumeGroups', RETAIN_ASSIGNMENTS = 'retainAssignments', - SDN_C_PRE_LOAD = 'sdncPreLoad', } @Injectable() @@ -43,11 +44,12 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean): FormControlModel[] { let result: FormControlModel[] =[ this.getRetainAssignmentsControl(), - this.getRetainVolumeGroupsControl(), this._basicControlGenerator.getSDNCControl(null) ]; - - const vfModuleInstance = this._vfModuleControlGenerator.getVfModuleInstance(serviceId, vnfStoreKey, this.uuidData, isUpdateMode); + const vfModuleInstance :VfModuleInstance = this._vfModuleControlGenerator.getVfModuleInstance(serviceId, vnfStoreKey, this.uuidData, isUpdateMode); + if(this._store.getState().service.serviceHierarchy[serviceId].vfModules[this.uuidData['modelName']].volumeGroupAllowed){ + result.push(this.getRetainVolumeGroupsControl()); + } result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance); return result; }; diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts index 7c1cc084a..4003b4dcc 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts @@ -1,6 +1,10 @@ import {LogService} from "../../../../utils/log/log.service"; import {NgRedux} from "@angular-redux/store"; -import {BasicControlGenerator, SDN_C_PRE_LOAD, SUPPLEMENTARY_FILE} from "../../../genericForm/formControlsServices/basic.control.generator"; +import { + BasicControlGenerator, + SDN_C_PRE_LOAD, + SUPPLEMENTARY_FILE +} from "../../../genericForm/formControlsServices/basic.control.generator"; import {AaiService} from "../../../../services/aaiService/aai.service"; import {HttpClient} from "@angular/common/http"; import {GenericFormService} from "../../../genericForm/generic-form.service"; @@ -20,6 +24,7 @@ import {GeneralActions} from "../../../../storeUtil/utils/general/general.action import {VfModuleActions} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; import {ServiceActions} from "../../../../storeUtil/utils/service/service.actions"; import {FormControlModel} from "../../../../models/formControlModels/formControl.model"; +import * as _ from "lodash"; class MockModalService<T> {} @@ -29,6 +34,15 @@ class MockReduxStore<T> { getState() { return { service: { + serviceHierarchy: { + serviceId: { + vfModules: { + vfModuleName: { + volumeGroupAllowed: true + } + } + } + }, serviceInstance : { serviceId : { vnfs : { @@ -40,7 +54,6 @@ class MockReduxStore<T> { }}}}}}}} }; } - dispatch() {} } @@ -101,19 +114,31 @@ describe('VFModule popup service', () => { }); } - function getControlByNameAndCheckValue(controlName: string, expectedValue: any) { + function getControlByNameAndCheckValue(controlName: string, expectedValue: any, shouldControllerExist: boolean) { const controls = service.getControls('serviceId', 'vnfStoreKey', 'vfModuleId', true); const control = findControlByName(controls, controlName); - expect(control).toBeDefined(); - expect(control.value).toEqual(expectedValue); + if(shouldControllerExist){ + expect(control).toBeDefined(); + expect(control.value).toEqual(expectedValue); + } + else{ + expect(control).toBeUndefined(); + } } test('get controls should return retainAssignments control with true value', ()=> { - getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_ASSIGNMENTS, true); + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_ASSIGNMENTS, true, true); }); test('get controls should return retainVolumeGroup control with true value', ()=> { - getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, true); + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, true, true); + }); + + test('get controls should NOT return retainVolumeGroup control with true value', ()=> { + let stateCopy =_.cloneDeep(store.getState()); + stateCopy.service.serviceHierarchy['serviceId'].vfModules['vfModuleName'].volumeGroupAllowed = false; + jest.spyOn(store, 'getState').mockReturnValue(stateCopy); + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, null, false); }); test('get controls should contain SUPPLEMENTARY_FILE controller', ()=> { @@ -196,6 +221,6 @@ describe('VFModule popup service', () => { test( 'get controls should return usePreload with false value', () => { - getControlByNameAndCheckValue(SDN_C_PRE_LOAD, false); + getControlByNameAndCheckValue(SDN_C_PRE_LOAD, false, true); }); }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts index 2f1904468..60f0f361e 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts @@ -1,7 +1,7 @@ import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service"; import {NgRedux} from "@angular-redux/store"; import {IframeService} from "../../../../utils/iframe.service"; -import {VfModulePopuopService} from "../vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../vfModule/vfModule.popup.service"; import {FormBuilder} from "@angular/forms"; import {GenericFormService} from "../../../genericForm/generic-form.service"; import {BasicPopupService} from "../basic.popup.service"; @@ -2258,7 +2258,7 @@ describe('vnf new popup service', () => { AaiService, LogService, BasicPopupService, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, BasicControlGenerator, VnfControlGenerator, diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts index 3a81e5b2b..8ee48e675 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts @@ -1,7 +1,7 @@ import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service"; import {NgRedux} from "@angular-redux/store"; import {IframeService} from "../../../../utils/iframe.service"; -import {VfModulePopuopService} from "../vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "../vfModule/vfModule.popup.service"; import {FormBuilder} from "@angular/forms"; import {GenericFormService} from "../../../genericForm/generic-form.service"; import {BasicPopupService} from "../basic.popup.service"; @@ -2255,7 +2255,7 @@ describe('vnf group new popup service', () => { AaiService, LogService, BasicPopupService, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, BasicControlGenerator, VnfGroupControlGenerator, diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html index fe08bf086..07fc7ab22 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html @@ -24,6 +24,17 @@ </div> <div class="col-md-6"> <div class="col-md-6"> + <div class="details-item" style="text-align: center;"> + <input type="checkbox" + #filterByUserIdCheckbox + id="filterByUserIdCheckbox" + [attr.data-tests-id]="'filterByUserIdTestId'" + [checked]="filterByUserId" + (change)="filterByUserIdChanged(filterByUserIdCheckbox.checked)" + data-toggle="toggle"> + <label class="checkbox-label" + for="'filterByUserIdTestId'">Show only mine</label> + </div> </div> <div class="col-md-6"> <input @@ -33,8 +44,8 @@ </div> </div> </div> - <div class="row" style="margin-left: 0;margin-right: 0;padding: 20px;"> - <table id="member-table" class="table table-bordered" style="table-layout: fixed"> + <div class="row table-container"> + <table id="member-table" class="table table-bordered table-responsive" style="table-layout: fixed"> <thead class="thead-dark"> <tr> <th class="header-title" id="header-userId">User ID</th> @@ -49,7 +60,7 @@ </thead> <tbody> <tr class="member-table-row" - *ngFor="let item of filterTableData | searchFilter: filterText ;" + *ngFor="let item of filterTableData | searchFilter: filterText;" (click)="selectedInstantiation = item" [ngClass]="{'selected' : selectedInstantiation && selectedInstantiation.jobId === item.jobId}" [attr.data-tests-id]="'row-' + item.jobId"> diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss index 267d2cee0..d62caf5de 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.scss @@ -6,6 +6,7 @@ $grid-border: 1px #d2d2d2 solid; thead { background: #F8F8F8; } + .left-panel { background: #f2f2f2; border-right: $grid-border; @@ -161,18 +162,28 @@ $grid-border: 1px #d2d2d2 solid; .description-section { padding: 20px; - font-size: 20px; + font-size: 13px; } .filter-input { float: right; - width: 50%; } .details-item { text-align: right; } + .table-container { + overflow: auto; + width: 97%; + margin: auto; + max-height: calc(100% - 122px); + } + + + table { + font-size: 12px; + } td.loadTemplateButton { text-align: center; @@ -193,4 +204,48 @@ $grid-border: 1px #d2d2d2 solid; .member-table-row.selected { background: #8080808f !important; } + + + .details-item input { + cursor: pointer; + opacity: 0; + position: absolute; + z-index: 100; + width: 24px; + height: 22px; + margin: 0; + } + + .details-item label { + position: relative; + cursor: pointer; + } + + .details-item label:before { + content:''; + -webkit-appearance: none; + background-color: transparent; + border: 2px solid #0079bf; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05); + padding: 10px; + display: inline-block; + position: relative; + vertical-align: middle; + cursor: pointer; + margin-right: 5px; + } + + .details-item input:checked + label:after { + content: ''; + display: block; + position: absolute; + top: 2px; + left: 9px; + width: 6px; + height: 14px; + border: solid #0079bf; + border-width: 0 2px 2px 0; + transform: rotate(45deg); + } + } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts index 7b16b6677..b37d7f9a2 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts @@ -7,7 +7,11 @@ import {InstantiationTemplatesModalService} from "./instantiation.templates.moda import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model"; import {DrawingBoardModes} from "../../../../drawingBoard/service-planning/drawing-board.modes"; import {InstantiationStatusComponentService} from "../../../../instantiationStatus/instantiationStatus.component.service"; - +import {AaiService} from "../../../services/aaiService/aai.service"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../../store/reducers"; +import * as _ from 'lodash'; +import {forkJoin} from "rxjs"; @Component({ selector: 'template-modal', templateUrl: 'instantiation.templates.modal.component.html', @@ -21,12 +25,15 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string originalTableData: InstantiationTemplatesRowModel[] = []; filterTableData : InstantiationTemplatesRowModel[] = []; filterText: string; + filterByUserId: boolean = false; constructor(dialogService: DialogService, private _iframeService: IframeService, private _serviceInfoService: ServiceInfoService, private _templateModalComponentService: InstantiationTemplatesModalService, private _instantiationStatusComponentService: InstantiationStatusComponentService, + private _aaiService: AaiService, + private _store : NgRedux<AppState>, private _route: ActivatedRoute) { super(dialogService); this.templateModalComponentService = _templateModalComponentService; @@ -37,7 +44,11 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string this._route .queryParams .subscribe(params => { - this._serviceInfoService.getServicesJobInfo(true, params['serviceModelId']).subscribe((jobs) => { + + const getServiceJobInfoRoute = this._serviceInfoService.getServicesJobInfo(true, params['serviceModelId']); + const getUserIdRoute = this._aaiService.getUserId(); + + forkJoin([getServiceJobInfoRoute, getUserIdRoute]).subscribe(([jobs]) => { this.originalTableData = this._templateModalComponentService.convertResponseToUI(jobs); this.filterTableData = this.originalTableData; }); @@ -46,16 +57,17 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string loadTemplate = () => { this._instantiationStatusComponentService.navigateToNewViewEdit(this.selectedInstantiation, DrawingBoardModes.RECREATE) - }; + filterByUserIdChanged = (value : boolean) : void => { + this.filterByUserId = value; + const userId: string = this._store.getState().service['userId']; + if(!_.isNil(userId)){ + this.filterTableData = this.filterByUserId ? this._templateModalComponentService.filterByUserId(userId, this.originalTableData) : this.originalTableData; + } + }; closeModal(): void { - this._iframeService.removeClassCloseModal('content'); this.dialogService.removeDialog(this); - setTimeout(() => { - window.parent.postMessage("closeIframe", "*"); - }, 15); - } } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts index 1ff0f61e2..2f044112b 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts @@ -130,4 +130,21 @@ describe('instantiation templates modal service', () => { expect(result.instanceName).toEqual('<Automatically generated>'); }); + test('filterByUserId should filter table data by userId: not empty list', () => { + const jobs : InstantiationTemplatesRowModel[] = [ + new InstantiationTemplatesRowModel({userId : 'userId_1'}), + new InstantiationTemplatesRowModel({userId : 'userId'}), + new InstantiationTemplatesRowModel({userId : 'userId'}), + new InstantiationTemplatesRowModel({userId : 'userId_1'}) + ]; + let result: InstantiationTemplatesRowModel[] = service.filterByUserId('userId', jobs); + expect(result).toHaveLength(2); + }); + + test('filterByUserId should filter table data by userId: empty list should return empty list', () => { + const jobs : InstantiationTemplatesRowModel[] = []; + let result: InstantiationTemplatesRowModel[] = service.filterByUserId('userId', jobs); + expect(result).toHaveLength(0); + }); + }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts index 8377ccf42..36691fda5 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts @@ -1,5 +1,6 @@ import {Injectable} from "@angular/core"; import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model"; +import * as _ from 'lodash'; @Injectable() export class InstantiationTemplatesModalService { @@ -14,4 +15,14 @@ export class InstantiationTemplatesModalService { return tableRows; }; + + filterByUserId = (userId: string, originalTableData: InstantiationTemplatesRowModel[]): InstantiationTemplatesRowModel[] => { + if (!_.isNil(originalTableData)) { + return originalTableData.filter((item: InstantiationTemplatesRowModel) => { + return item.userId === userId; + }); + } + return []; + }; + } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts index e68c34b85..673709462 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.row.model.ts @@ -14,7 +14,7 @@ export class InstantiationTemplatesRowModel extends InstantiationBase{ constructor(data) { super(data); - this.userId = !_.isNil(data.created) ? data.userId : null; + this.userId = !_.isNil(data.userId) ? data.userId : null; this.createDate = !_.isNil(data.created) ? moment(data.created).format("YYYY-MM-DD HH:mm:ss") : null; this.instanceName = this.getInstanceName(data.serviceInstanceName); this.instantiationStatus = !_.isNil(data.jobStatus) ? data.jobStatus : null; diff --git a/vid-webpack-master/src/app/shared/models/vfModule.ts b/vid-webpack-master/src/app/shared/models/vfModule.ts index 8f92ba428..a942a0d86 100644 --- a/vid-webpack-master/src/app/shared/models/vfModule.ts +++ b/vid-webpack-master/src/app/shared/models/vfModule.ts @@ -6,23 +6,26 @@ export interface Properties{ initialCount: number; maxCountInstances: number; minCountInstances: number; + baseModule: boolean; } export interface VFModuleResponseInterface extends NodeModelResponseInterface { customizationUuid: string; modelCustomizationName: string; volumeGroupAllowed : boolean; - properties: Properties + properties: Properties; + inputs: any; } export class VfModule extends NodeModel { - vgName:string; rollbackOnFailure:boolean; initial:number; customizationUuid: string; modelCustomizationName: string; volumeGroupAllowed : boolean; + baseModule : boolean; + inputs: any; constructor(vf?: VFModuleResponseInterface, flags?: { [key: string]: boolean }) { super(vf); @@ -30,12 +33,14 @@ export class VfModule extends NodeModel { this.customizationUuid = vf.customizationUuid; this.modelCustomizationName = vf.modelCustomizationName; this.volumeGroupAllowed = vf.volumeGroupAllowed || false; + this.inputs = vf.inputs; } if (vf && vf.properties) { this.min = vf.properties.minCountInstances; this.max = Utils.getMaxVfModule(vf.properties, flags); this.initial = vf.properties.initialCount; - this.rollbackOnFailure = true + this.rollbackOnFailure = true; + this.baseModule = vf.properties.baseModule; } } } diff --git a/vid-webpack-master/src/app/shared/shared.module.ts b/vid-webpack-master/src/app/shared/shared.module.ts index 273dff472..0f7c92060 100644 --- a/vid-webpack-master/src/app/shared/shared.module.ts +++ b/vid-webpack-master/src/app/shared/shared.module.ts @@ -41,7 +41,7 @@ import {VnfControlGenerator} from "./components/genericForm/formControlsServices import {NetworkPopupService} from "./components/genericFormPopup/genericFormServices/network/network.popup.service"; import {NetworkControlGenerator} from "./components/genericForm/formControlsServices/networkGenerator/network.control.generator"; import {BasicPopupService} from "./components/genericFormPopup/genericFormServices/basic.popup.service"; -import {VfModulePopuopService} from "./components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service"; +import {VfModulePopupService} from "./components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service"; import {VfModuleUpgradePopupService} from "./components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service"; import {VfModuleControlGenerator} from "./components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; import {OrderByPipe} from "./pipes/order/orderBy.pipe"; @@ -193,7 +193,7 @@ import {InstantiationTemplatesService} from "./services/templateService/instanti BasicControlGenerator, CustomValidators, NetworkPopupService, - VfModulePopuopService, + VfModulePopupService, VfModuleUpgradePopupService, NetworkControlGenerator, VnfGroupControlGenerator, diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts index 70c10c429..1b80452cb 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts @@ -10,7 +10,7 @@ export enum VfModuleActions { UPGRADE_VFMODULE = "UPGRADE_VFMODULE", UNDO_UPGRADE_VFMODULE_ACTION = "UNDO_UPGRADE_VFMODULE_ACTION", UPDATE_VFMODULE_FEILD = "UPDATE_VFMODULE_FEILD", - DELETE_VFMODULE_FEILD = "DELETE_VFMODULE_FEILD", + DELETE_VFMODULE_FIELD = "DELETE_VFMODULE_FEILD", } @@ -163,7 +163,7 @@ export const updateVFModuleField: ActionCreator<UpdateVFModuleField> = (modelNam }); export const deleteVFModuleField: ActionCreator<DeleteVFModuleField> = (modelName, vnfStoreKey, serviceId, dynamicModelName, deleteFieldName) => ({ - type: VfModuleActions.DELETE_VFMODULE_FEILD, + type: VfModuleActions.DELETE_VFMODULE_FIELD, dynamicModelName, modelName, vnfStoreKey, diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts index 7b890b715..9b3a287a6 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts @@ -172,7 +172,7 @@ describe('vfModuleReducer', () => { }; let newState = vfModuleReducer(<any>oldState, <DeleteVFModuleField>{ - type: VfModuleActions.DELETE_VFMODULE_FEILD, + type: VfModuleActions.DELETE_VFMODULE_FIELD, dynamicModelName: 'dynamicModelName1', vnfStoreKey: 'vnfStoreKey', serviceId: 'serviceModelId', diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts index 1bb2b15fd..2e91f8771 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts @@ -155,7 +155,7 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS return clonedState; } - case VfModuleActions.DELETE_VFMODULE_FEILD : { + case VfModuleActions.DELETE_VFMODULE_FIELD : { let clonedState = _.cloneDeep(state); let deleteAction = <DeleteVFModuleField> action; diff --git a/vid-webpack-master/src/app/shared/utils/constants.ts b/vid-webpack-master/src/app/shared/utils/constants.ts index f793e05db..6bf5ff1f4 100644 --- a/vid-webpack-master/src/app/shared/utils/constants.ts +++ b/vid-webpack-master/src/app/shared/utils/constants.ts @@ -39,6 +39,7 @@ export module Constants { public static AAI_GET_ACTIVE_NETWORKS_PATH = '../../aai_get_active_networks/'; public static AAI_GET_VPNS_PATH = '../../aai_get_vpn_list/'; public static AAI_GET_SERVICE_GROUP_MEMBERS_PATH = '../../aai_search_group_members/'; + public static AAI_GET_USER_ID_PATH = '../../getuserID'; public static AAI_GET_VERSION_BY_INVARIANT_ID = 'aai_get_version_by_invariant_id/'; public static SEARCH_SERVICE_INSTANCES = 'search_service_instances'; public static AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE = 'get_vnf_data_by_globalid_and_service_type/'; |