summaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rwxr-xr-xvid-app-common/pom.xml20
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java71
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java10
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java40
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt53
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/properties/Features.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java (renamed from vid-app-common/src/main/java/org/onap/vid/services/ExtWorkflowsService.java)2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java (renamed from vid-app-common/src/main/java/org/onap/vid/services/ExtWorkflowsServiceImpl.java)4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsService.java26
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsServiceImpl.java58
-rw-r--r--vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties1
-rw-r--r--vid-app-common/src/main/webapp/WEB-INF/conf/features.properties5
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js6
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js112
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js208
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html40
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js12
-rw-r--r--vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java55
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java15
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java186
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java186
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java6
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java83
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java27
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java20
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java67
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java44
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowServiceImplTest.java (renamed from vid-app-common/src/test/java/org/onap/vid/services/ExtWorkflowServiceImplTest.java)14
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java60
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java48
31 files changed, 864 insertions, 642 deletions
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index 6b73d79ca..38b06f1f8 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -14,6 +14,13 @@
<name>VID Common</name>
<description>VID Common code for opensource version</description>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>1.2.3</version>
+ <relativePath/>
+ </parent>
+
<properties>
<encoding>UTF-8</encoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -21,7 +28,7 @@
<epsdk.version>2.4.0</epsdk.version>
<springframework.version>4.2.9.RELEASE</springframework.version>
<hibernate.version>4.3.11.Final</hibernate.version>
- <jackson.version>2.9.7</jackson.version>
+ <jackson.version>2.9.8</jackson.version>
<jersey.version>2.27</jersey.version>
<surefire.version>2.22.1</surefire.version>
<sonar.coverage.exclusions>**/webapp/**/*,**/*.js</sonar.coverage.exclusions>
@@ -448,7 +455,6 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
@@ -458,7 +464,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
- <version>4.3.6</version>
+ <version>4.5.7</version>
</dependency>
<dependency>
<groupId>com.xebialabs.restito</groupId>
@@ -522,13 +528,7 @@
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
</dependency>
<dependency>
@@ -682,7 +682,6 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- <version>1.9.3</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
@@ -799,7 +798,6 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>23.0</version>
</dependency>
</dependencies>
</project>
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index 126fbe8d3..6a8439fee 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -20,8 +20,26 @@
package org.onap.vid.aai;
+import static java.util.Collections.emptyList;
+import static java.util.stream.Collectors.toMap;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
+import javax.inject.Inject;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
@@ -32,12 +50,28 @@ import org.json.simple.parser.JSONParser;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.exceptions.InvalidAAIResponseException;
import org.onap.vid.aai.model.AaiGetAicZone.AicZones;
-import org.onap.vid.aai.model.*;
-import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.*;
+import org.onap.vid.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetails;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetNetworkCollectionDetailsHelper;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetRelatedInstanceGroupsByVnfId;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.CloudRegion;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.InstanceGroup;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Network;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.AaiGetPnfResponse;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.aai.model.CustomQuerySimpleResult;
+import org.onap.vid.aai.model.GetServiceModelsByDistributionStatusResponse;
+import org.onap.vid.aai.model.LogicalLinkResponse;
+import org.onap.vid.aai.model.OwningEntityResponse;
+import org.onap.vid.aai.model.PortDetailsTranslator;
+import org.onap.vid.aai.model.ProjectResponse;
+import org.onap.vid.aai.model.Properties;
+import org.onap.vid.aai.model.ResourceType;
+import org.onap.vid.aai.model.ServiceRelationships;
+import org.onap.vid.aai.model.SimpleResult;
import org.onap.vid.aai.util.AAIRestInterface;
import org.onap.vid.aai.util.CacheProvider;
import org.onap.vid.aai.util.VidObjectMapperType;
@@ -51,23 +85,6 @@ import org.onap.vid.utils.Unchecked;
import org.springframework.http.HttpMethod;
import org.springframework.web.util.UriUtils;
-import javax.inject.Inject;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Function;
-
-import static java.util.Collections.emptyList;
-import static java.util.stream.Collectors.toMap;
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-
/**
* Created by Oren on 7/4/17.
@@ -233,7 +250,7 @@ public class AaiClient implements AaiClientInterface {
@Override
public boolean isNodeTypeExistsByName(String name, ResourceType type) {
- if (StringUtils.isEmpty(name)) {
+ if (isEmpty(name)) {
throw new GenericUncheckedException("Empty resource-name provided to searchNodeTypeByName; request is rejected as this will cause full resources listing");
}
@@ -697,7 +714,7 @@ public class AaiClient implements AaiClientInterface {
String propKey = checkForNull((String) innerObj.get("property-key"));
String propVal = checkForNull((String) innerObj.get("property-value"));
- if (propKey.equalsIgnoreCase("tenant.tenant-name")) {
+ if (equalsIgnoreCase(propKey, "tenant.tenant-name")) {
tenantNewObj.put("tenantName", propVal);
}
}
@@ -708,11 +725,11 @@ public class AaiClient implements AaiClientInterface {
String rShipKey = checkForNull((String) inner2Obj.get("relationship-key"));
String rShipVal = checkForNull((String) inner2Obj.get("relationship-value"));
- if (rShipKey.equalsIgnoreCase("cloud-region.cloud-owner")) {
+ if (equalsIgnoreCase(rShipKey, "cloud-region.cloud-owner")) {
tenantNewObj.put("cloudOwner", rShipVal);
- } else if (rShipKey.equalsIgnoreCase("cloud-region.cloud-region-id")) {
+ } else if (equalsIgnoreCase(rShipKey, "cloud-region.cloud-region-id")) {
tenantNewObj.put("cloudRegionID", rShipVal);
- } else if (rShipKey.equalsIgnoreCase("tenant.tenant-id")) {
+ } else if (equalsIgnoreCase(rShipKey, "tenant.tenant-id")) {
tenantNewObj.put("tenantID", rShipVal);
}
}
@@ -768,12 +785,12 @@ public class AaiClient implements AaiClientInterface {
@Override
public GetTenantsResponse getHomingDataByVfModule(String vnfInstanceId, String vfModuleId) {
- if (StringUtils.isEmpty(vnfInstanceId)||StringUtils.isEmpty(vfModuleId)){
+ if (isEmpty(vnfInstanceId)|| isEmpty(vfModuleId)){
throw new GenericUncheckedException("Failed to retrieve homing data associated to vfModule from A&AI, VNF InstanceId or VF Module Id is missing.");
}
Response resp = doAaiGet("network/generic-vnfs/generic-vnf/" + vnfInstanceId +"/vf-modules/vf-module/"+ vfModuleId, false);
String responseAsString = parseForTenantsByServiceSubscription("vserver",resp.readEntity(String.class));
- if (responseAsString.equals("")){
+ if (isEmpty(responseAsString)){
throw new GenericUncheckedException( String.format("A&AI has no homing data associated to vfModule '%s' of vnf '%s'", vfModuleId, vnfInstanceId));
}
else {
@@ -822,7 +839,7 @@ public class AaiClient implements AaiClientInterface {
Response resp = doAaiGet(url, false);
String responseAsString = parseForTenantsByServiceSubscription("tenant",resp.readEntity(String.class));
- if (StringUtils.isEmpty(responseAsString)){
+ if (isEmpty(responseAsString)){
throw new ParsingGetTenantsResponseFailure(String.format("A&AI has no LCP Region & Tenants associated to subscriber '%s' and service type '%s'", globalCustomerId, serviceType));
}
else {
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
index fdbe418ea..43be049a6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -21,21 +21,19 @@
package org.onap.vid.aai;
import com.fasterxml.jackson.databind.JsonNode;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.core.Response;
import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
-import org.onap.vid.aai.model.CustomQuerySimpleResult;
import org.onap.vid.aai.model.PortDetailsTranslator;
import org.onap.vid.aai.model.Properties;
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.model.SubscriberList;
import org.onap.vid.model.probes.ExternalComponentStatus;
-import javax.ws.rs.core.Response;
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
/**
* Created by Oren on 7/4/17.
*/
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
index b8f033c95..a94481b9e 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
@@ -21,10 +21,11 @@
package org.onap.vid.controller;
import java.util.List;
-import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.vid.model.LocalWorkflowParameterDefinitions;
import org.onap.vid.model.SOWorkflow;
import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.services.ExtWorkflowsService;
+import org.onap.vid.services.ExternalWorkflowsService;
+import org.onap.vid.services.LocalWorkflowsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,24 +35,31 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(WorkflowsController.WORKFLOWS_MANAGEMENT)
-public class WorkflowsController extends RestrictedBaseController {
+public class WorkflowsController extends VidRestrictedBaseController {
static final String WORKFLOWS_MANAGEMENT = "workflows-management";
- private ExtWorkflowsService extWorkflowsService;
+ private ExternalWorkflowsService externalWorkflowsService;
+ private LocalWorkflowsService localWorkflowsService;
@Autowired
- public WorkflowsController(ExtWorkflowsService extWorkflowsService) {
- this.extWorkflowsService = extWorkflowsService;
+ public WorkflowsController(ExternalWorkflowsService externalWorkflowsService, LocalWorkflowsService localWorkflowsService) {
+ this.externalWorkflowsService = externalWorkflowsService;
+ this.localWorkflowsService = localWorkflowsService;
}
@RequestMapping(value = "workflows", method = RequestMethod.GET)
public List<SOWorkflow> getWorkflows(@RequestParam(value = "vnfName") String vnfName){
- return extWorkflowsService.getWorkflows(vnfName);
+ return externalWorkflowsService.getWorkflows(vnfName);
}
- @RequestMapping(value = "workflow-parameters/{id}", method = RequestMethod.GET)
+ @RequestMapping(value = "remote-workflow-parameters/{id}", method = RequestMethod.GET)
SOWorkflowParameterDefinitions getParameters(@PathVariable Long id) {
- return extWorkflowsService.getWorkflowParameterDefinitions(id);
+ return externalWorkflowsService.getWorkflowParameterDefinitions(id);
+ }
+
+ @RequestMapping(value = "local-workflow-parameters/{name}", method = RequestMethod.GET)
+ LocalWorkflowParameterDefinitions getParameters(@PathVariable String name) {
+ return localWorkflowsService.getWorkflowParameterDefinitions(name);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
index 237747933..70f7b5aa2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
@@ -20,12 +20,19 @@
package org.onap.vid.model;
-import org.onap.portalsdk.core.domain.support.DomainVo;
-
-import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import org.onap.portalsdk.core.domain.support.DomainVo;
@Entity
@Table(name = "vid_category_parameter_option")
@@ -124,24 +131,39 @@ public class CategoryParameterOption extends DomainVo {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
CategoryParameterOption that = (CategoryParameterOption) o;
- if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) return false;
- if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
- return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter()) : that.getCategoryParameter() == null;
+ if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) {
+ return false;
+ }
+ if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) {
+ return false;
+ }
+ return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter())
+ : that.getCategoryParameter() == null;
}
@Override
public int hashCode() {
int result = getAppId() != null ? getAppId().hashCode() : 0;
result = 31 * result + (getName() != null ? getName().hashCode() : 0);
- result = 31 * result + (getCategoryParameter() != null ? getCategoryParameter().hashCode() : 0);
+ result = 31 * result + hashCodeOfParentCategoryParameter();
return result;
}
+ private int hashCodeOfParentCategoryParameter() {
+ // Don't use getCategoryParameter's hashCode, as it might loop back to self's hasCode
+ return (getCategoryParameter() == null || getCategoryParameter().getId() == null)
+ ? 0 : getCategoryParameter().getId().hashCode();
+ }
+
@Override
public String toString() {
return "CategoryParameterOption{" +
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
index 9fbae0612..b88c3f6f6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,27 +20,62 @@
package org.onap.vid.model
-data class SOWorkflow constructor(val id: Long, val name: String) {
+data class SOWorkflow constructor(
+ val id: Long,
+ val name: String) {
fun clone(): SOWorkflow {
return copy()
}
}
-data class SOWorkflows @JvmOverloads constructor(val workflows: List<SOWorkflow> = emptyList()) {
+data class SOWorkflows @JvmOverloads constructor(
+ val workflows: List<SOWorkflow> = emptyList()) {
fun clone(): SOWorkflows {
return copy(workflows.toMutableList())
}
}
-enum class SOWorkflowType(val type: String) {
+enum class SOWorkflowType(
+ val type: String) {
STRING("STRING")
}
-data class SOWorkflowParameterDefinition constructor(val id: Long, val name: String, val pattern: String,
- val type: SOWorkflowType, val required: Boolean)
+enum class LocalWorkflowType(
+ val type: String) {
+ STRING("STRING"),
+ FILE("FILE")
+}
+
+data class SOWorkflowParameterDefinition constructor(
+ val id: Long,
+ val name: String,
+ val pattern: String,
+ val type: SOWorkflowType,
+ val required: Boolean)
-data class SOWorkflowParameterDefinitions constructor(val parameterDefinitions: List<SOWorkflowParameterDefinition> = emptyList()) {
+data class SOWorkflowParameterDefinitions constructor(
+ val parameterDefinitions: List<SOWorkflowParameterDefinition> = emptyList()) {
fun clone(): SOWorkflowParameterDefinitions {
return copy(parameterDefinitions.toMutableList())
}
}
+
+data class LocalWorkflowParameterDefinition @JvmOverloads constructor(
+ val id: Long,
+ val name: String,
+ val required: Boolean,
+ val type: LocalWorkflowType,
+ val pattern: String? = null,
+ val msgOnPatternError: String? = null,
+ val msgOnContentError: String? = null,
+ val acceptableFileType: String? = null
+)
+
+data class LocalWorkflowParameterDefinitions constructor(
+ val parameterDefinitions: List<LocalWorkflowParameterDefinition> = emptyList()
+) {
+ fun clone(): LocalWorkflowParameterDefinitions {
+ return copy(parameterDefinitions.toMutableList())
+ }
+}
+
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
index dfe3185b2..1c68e8292 100644
--- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
+++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java
@@ -62,6 +62,7 @@ public enum Features implements Feature {
FLAG_1902_NEW_VIEW_EDIT,
FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER,
FLAG_1902_VNF_GROUPING,
+ FLAG_HANDLE_SO_WORKFLOWS
;
public boolean isActive() {
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExtWorkflowsService.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
index a4450ca01..da909a54d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExtWorkflowsService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
@@ -24,7 +24,7 @@ import java.util.List;
import org.onap.vid.model.SOWorkflow;
import org.onap.vid.model.SOWorkflowParameterDefinitions;
-public interface ExtWorkflowsService {
+public interface ExternalWorkflowsService {
List<SOWorkflow> getWorkflows(String vnfName);
SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExtWorkflowsServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
index 61ed2da67..1da03f0ac 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExtWorkflowsServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
@@ -30,12 +30,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
-public class ExtWorkflowsServiceImpl implements ExtWorkflowsService {
+public class ExternalWorkflowsServiceImpl implements ExternalWorkflowsService {
private MockedWorkflowsRestClient mockedWorkflowsRestClient;
@Autowired
- public ExtWorkflowsServiceImpl(MockedWorkflowsRestClient mockedWorkflowsRestClient) {
+ public ExternalWorkflowsServiceImpl(MockedWorkflowsRestClient mockedWorkflowsRestClient) {
this.mockedWorkflowsRestClient = mockedWorkflowsRestClient;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsService.java b/vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsService.java
new file mode 100644
index 000000000..b0674f0e3
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsService.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.services;
+
+import org.onap.vid.model.LocalWorkflowParameterDefinitions;
+
+public interface LocalWorkflowsService {
+ LocalWorkflowParameterDefinitions getWorkflowParameterDefinitions(String workflowName);
+}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsServiceImpl.java
new file mode 100644
index 000000000..733d275d8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/services/LocalWorkflowsServiceImpl.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.vid.services;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.onap.vid.model.LocalWorkflowParameterDefinition;
+import org.onap.vid.model.LocalWorkflowParameterDefinitions;
+import org.onap.vid.model.LocalWorkflowType;
+import org.springframework.stereotype.Service;
+
+@Service
+public class LocalWorkflowsServiceImpl implements LocalWorkflowsService {
+
+ Map<String, LocalWorkflowParameterDefinitions> WORKFLOWS_WITH_PARAMETERS = ImmutableMap.<String, LocalWorkflowParameterDefinitions>builder()
+ .put("VNF Scale Out", new LocalWorkflowParameterDefinitions(
+ ImmutableList.of(
+ new LocalWorkflowParameterDefinition(1, "Configuration Parameters", true, LocalWorkflowType.STRING,".*")
+ )
+ ))
+ .put("VNF In Place Software Update", new LocalWorkflowParameterDefinitions(
+ ImmutableList.of(
+ new LocalWorkflowParameterDefinition(2, "Operations timeout",true, LocalWorkflowType.STRING,"[0-9]+"),
+ new LocalWorkflowParameterDefinition(3, "Existing software version", true, LocalWorkflowType.STRING, "[-a-zA-Z0-9.]+"),
+ new LocalWorkflowParameterDefinition(4, "New software version", true, LocalWorkflowType.STRING, "[-a-zA-Z0-9.]+")
+ )
+ ))
+ .put("VNF Config Update", new LocalWorkflowParameterDefinitions(
+ ImmutableList.of(
+ new LocalWorkflowParameterDefinition(5, "Attach configuration file", true, LocalWorkflowType.FILE, ".*", "Invalid file type. Please select a file with a CSV extension.", "Invalid file structure.", ".csv")
+ )
+ ))
+ .build();
+
+ @Override
+ public LocalWorkflowParameterDefinitions getWorkflowParameterDefinitions(String workflowName) {
+ return WORKFLOWS_WITH_PARAMETERS.get(workflowName);
+ }
+
+}
diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties
index d82b043c5..8ba148465 100644
--- a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties
+++ b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties
@@ -8,6 +8,7 @@ FLAG_COLLECTION_RESOURCE_SUPPORT = true
FLAG_NETWORK_TO_ASYNC_INSTANTIATION = false
FLAG_SERVICE_MODEL_CACHE = true
FLAG_SHOW_ASSIGNMENTS = true
+FLAG_HANDLE_SO_WORKFLOWS = true
FLAG_SHOW_VERIFY_SERVICE = true
FLAG_DUPLICATE_VNF = true
diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties
index 36f607f62..4cf42f235 100644
--- a/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties
+++ b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties
@@ -20,11 +20,12 @@ FLAG_SHOW_ASSIGNMENTS = true
FLAG_SHOW_VERIFY_SERVICE = false
FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS = true
FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS = true
-FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST=true
-FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY=true
+FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST = true
+FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY = true
FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE = true
FLAG_1810_AAI_LOCAL_CACHE = true
FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER = false
+FLAG_HANDLE_SO_WORKFLOWS = false
# Modern UI (Drawing-Board; View/Edit)
# - - - - - - - - - - - - - - - - - -
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
index 4ac5f85ac..fc3d8f792 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
@@ -116,7 +116,8 @@ appDS2
CHANGE_MANAGEMENT_OPERATION_NO_SCHEDULER: "change-management/workflow/@vnfName",
GET_WORKFLOW: "change-management/get_vnf_workflow_relation",
GET_SO_WORKFLOWS: "workflows-management/workflows",
- GET_SO_WORKFLOW_PARAMETER: "workflows-management/workflow-parameters/@workflowID",
+ GET_SO_WORKFLOW_PARAMETER: "workflows-management/remote-workflow-parameters/@workflowID",
+ GET_LOCAL_WORKFLOW_PARAMETER: "workflows-management/local-workflow-parameters/@workflowName",
GET_MSO_WORKFLOWS: "change-management/mso",
GET_SCHEDULER_CHANGE_MANAGEMENTS: "change-management/scheduler",
CANCEL_SCHEDULE_REQUEST: "change-management/scheduler/schedules",
@@ -256,7 +257,8 @@ appDS2
FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS: "FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS",
FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST: "FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST",
FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY: "FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY",
- FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE: "FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE"
+ FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE: "FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE",
+ FLAG_HANDLE_SO_WORKFLOWS: "FLAG_HANDLE_SO_WORKFLOWS"
}
};
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index e525f0f5c..88caef29e 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -28,8 +28,6 @@
var vm = this;
vm.hasScheduler = !!VIDCONFIGURATION.SCHEDULER_PORTAL_URL;
- vm.configUpdatePatternError = "Invalid file type. Please select a file with a CSV extension.";
- vm.configUpdateContentError = "Invalid file structure.";
vm.wizardStep = 1;
vm.nextStep = function(){
@@ -202,7 +200,7 @@
}]
})
.then(function (configUpdateResponse) {
- vm.changeManagement.configUpdateFile = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload;
+ vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload;
defer.resolve(true);
})
.catch(function (error) {
@@ -218,7 +216,6 @@
var result = {};
result.requestType = changeManagement.workflow;
var workflowType = changeManagement.workflow;
- var configurationParameters = changeManagement.configurationParameters;
result.requestDetails = [];
_.forEach(changeManagement.vnfNames, function (vnf) {
@@ -246,51 +243,50 @@
}
}else if(workflowType=="VNF In Place Software Update"){
var payloadObj = {
- 'existing_software_version':changeManagement.existingSoftwareVersion,
- 'new_software_version':changeManagement.newSoftwareVersion,
- 'operations_timeout':changeManagement.operationTimeout
+ 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Existing software version').value,
+ 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'New software version').value,
+ 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Operations timeout').value
};
requestParametersData = {
payload: JSON.stringify(payloadObj)
}
}else if(workflowType=="VNF Config Update"){
requestParametersData = {
- payload: changeManagement.configUpdateFile
+ payload: vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value
}
- }else if(workflowType=="VNF Scale Out"){
- if(!moduleToScale) return null;
-
- if(moduleToScale.userParams) {
- requestParametersData = {
- userParams: moduleToScale.userParams
- //,usePreload: true
- }
- }else{
- requestParametersData = {
- userParams: []
- //,usePreload: false
- }
- }
- }
+ }else if(workflowType=="VNF Scale Out"){
+ if(!moduleToScale) return null;
+
+ if(moduleToScale.userParams) {
+ requestParametersData = {
+ userParams: moduleToScale.userParams
+ //,usePreload: true
+ }
+ }else{
+ requestParametersData = {
+ userParams: []
+ //,usePreload: false
+ }
+ }
+ }
$log.info('SchedulerWidgetCtrl:extractChangeManagementCallbackDataStr info:: workflowType '+ workflowType);
$log.info('SchedulerWidgetCtrl:extractChangeManagementCallbackDataStr info:: requestParametersData '+ requestParametersData);
}else if(workflowType=="VNF In Place Software Update"){
var payloadObj = {
- 'existing_software_version':changeManagement.existingSoftwareVersion,
- 'new_software_version':changeManagement.newSoftwareVersion,
- 'operations_timeout':changeManagement.operationTimeout
+ 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Existing software version').value,
+ 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'New software version').value,
+ 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Operations timeout').value
};
requestParametersData = {
payload: JSON.stringify(payloadObj)
}
}else if(workflowType=="VNF Config Update"){
requestParametersData = {
- payload: changeManagement.configUpdateFile
+ payload: vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value
}
}
-
var data;
if(workflowType=="VNF Scale Out") {
data = {
@@ -309,7 +305,7 @@
requestInfo: requestInfoData,
relatedInstanceList: [],
requestParameters:requestParametersData,
- configurationParameters: JSON.parse(configurationParameters)
+ configurationParameters: JSON.parse(vm.getInternalWorkFlowParameter("VNF Scale Out", "STRING", "Configuration Parameters").value)
};
requestInfoData.instanceName = vnf.name + "_" + (moduleToScale.currentCount + 1);
}else{
@@ -638,15 +634,20 @@
};
vm.loadWorkFlows = function () {
- // Should be corrected when VID-397 will be closed. At the moment there is a need
- // to merge local and remote workflows not to broke current functionality.
- return vm.loadLocalWorkFlows()
- .then(vm.loadRemoteWorkFlows)
- .then(function () {
- vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name));
- }).then(function () {
- vm.loadRemoteWorkFlowsParameters();
- });
+ if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_HANDLE_SO_WORKFLOWS)) {
+ return vm.loadRemoteWorkFlows()
+ .then(function () {
+ vm.workflows = vm.remoteWorkflows.map(item => item.name);
+ }).then(function () {
+ vm.loadRemoteWorkFlowsParameters();
+ });
+ }else{
+ return vm.loadLocalWorkFlows()
+ .then(vm.loadLocalWorkFlowsParameters)
+ .then(function () {
+ vm.workflows = vm.localWorkflows;
+ })
+ }
};
vm.loadLocalWorkFlows = function () {
@@ -668,6 +669,28 @@
});
};
+ vm.loadLocalWorkFlowsParameters = function () {
+ vm.localWorkflowsParameters = new Map();
+ vm.localWorkflows.forEach(function(workflow) {
+ vm.loadLocalWorkFlowParameters(workflow);
+ });
+ };
+
+ vm.loadLocalWorkFlowParameters = function (workflow) {
+ changeManagementService.getLocalWorkflowParameter(workflow)
+ .then(function (response) {
+ let fileParameters = response.data.parameterDefinitions.filter(item => item.type === 'FILE');
+ let textParameters = response.data.parameterDefinitions.filter(item => item.type === 'STRING');
+ let parameters = new Map();
+ parameters.set('FILE', fileParameters);
+ parameters.set('STRING', textParameters);
+ vm.localWorkflowsParameters.set(workflow, parameters);
+ })
+ .catch(function (error) {
+ $log.error(error);
+ });
+ };
+
vm.loadRemoteWorkFlowsParameters = function () {
vm.remoteWorkflowsParameters = new Map();
vm.remoteWorkflows.forEach(function(workflow) {
@@ -692,6 +715,19 @@
return [];
};
+ vm.getInternalWorkFlowParameters = function (workflow, type) {
+ if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).has(type)) {
+ return vm.localWorkflowsParameters.get(workflow).get(type)
+ }
+ return [];
+ };
+
+ vm.getInternalWorkFlowParameter = function (workflow, type, parameterName) {
+ if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).has(type)) {
+ return vm.localWorkflowsParameters.get(workflow).get(type).filter(parameter => parameter.name === parameterName)[0]
+ }
+ };
+
//Must be $scope because we bind to the onchange of the html (cannot attached to vm variable).
$scope.selectFileForVNFName = function (fileInput) {
if (fileInput && fileInput.id) {
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
index c271b7505..9810c0013 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
@@ -25,6 +25,8 @@ describe('Testing workFlows from SO', () => {
let $notNeeded;
let $controller;
let $changeManagementService;
+ let $featureFlags;
+
beforeEach(
angular.mock.module('app')
);
@@ -38,6 +40,10 @@ describe('Testing workFlows from SO', () => {
// mock q
$q = jestMock.fn();
$defer = jestMock.fn();
+ $flags = jestMock.fn();
+ $flags.FEATURE_FLAGS = {FLAG_HANDLE_SO_WORKFLOWS: ''};
+ $featureFlags = jestMock.fn();
+ $featureFlags.isOn = jestMock.fn(() => true);
$q.defer = jestMock.fn(() => $defer);
$defer.promise = Promise.resolve({});
// mock AaiService
@@ -53,10 +59,10 @@ describe('Testing workFlows from SO', () => {
Upload: $notNeeded,
$log: $notNeeded,
_: $notNeeded,
- COMPONENT: $notNeeded,
+ COMPONENT: $flags,
VIDCONFIGURATION: $notNeeded,
DataService: $notNeeded,
- featureFlags: $notNeeded,
+ featureFlags: $featureFlags,
$scope: $notNeeded,
});
}));
@@ -77,19 +83,33 @@ describe('Testing workFlows from SO', () => {
);
});
- test('Verify load workflows will call load from SO and join workflow lists', () => {
+ test('Verify load workflows wont load parameters from local service', () => {
// given
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
+ "parameterDefinitions": [
+ {
+ "id": 1,
+ "name": "Configuration Parameters",
+ "required": true,
+ "type": "STRING",
+ "pattern": ".*",
+ "msgOnPatternError": null,
+ "msgOnContentError": null,
+ "acceptableFileType": null
+ }
+ ],
+ }});
let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]});
let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}});
$controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
$changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
return $controller.loadWorkFlows().then(() => {
- expect($controller.workflows).toContain('workflow 0');
expect($controller.workflows).toContain('workflow 1');
expect($controller.workflows).toContain('workflow 2');
});
@@ -98,6 +118,7 @@ describe('Testing workFlows from SO', () => {
test('Verify load workflows will call load workflows parameters from SO', () => {
// given
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}});
let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]});
let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [
{"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"},
@@ -106,6 +127,7 @@ describe('Testing workFlows from SO', () => {
$controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
$changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
@@ -118,19 +140,187 @@ describe('Testing workFlows from SO', () => {
});
});
- test('Verify broken SO workflows wont change content of local workflows', () => {
+ test('Verify load workflows wont load workflows parameters from SO if feature flag is disabled', () => {
// given
+ $featureFlags.isOn = jestMock.fn(() => false);
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
- let getSOWorkflowsPromiseStub = Promise.reject(new Error("Broken SO workflows service."));
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}});
+ let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]});
+ let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [
+ {"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"},
+ {"id": 2, "name": "parameter 2", "required": true, "type": "STRING", "pattern": ".*"},
+ {"id": 3, "name": "parameter 3", "required": false, "type": "STRING", "pattern": "[0-9]*"}]}});
- $controller.changeManagement.vnfNames = "any";
+ $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
+ $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
+ $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
+ // when
+ return $controller.loadWorkFlows()
+ .then(() => {
+ expect($controller.workflows).toEqual(["workflow 0"]);
+ expect($controller.remoteWorkflowsParameters).toEqual(undefined);
+ });
+ });
+
+ test('Verify load workflows will call load workflows parameters from local service', () => {
+ // given
+ $featureFlags.isOn = jestMock.fn(() => false);
+ let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
+ "parameterDefinitions": [
+ {
+ "id": 1,
+ "name": "Configuration Parameters",
+ "required": true,
+ "type": "STRING",
+ "pattern": ".*",
+ "msgOnPatternError": null,
+ "msgOnContentError": null,
+ "acceptableFileType": null
+ }
+ ],
+ }});
+
+ $controller.changeManagement.vnfNames = [{name: 'test1'}];
+ $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
+ // when
+
+ let result = new Map();
+ const scaleOutResult = new Map();
+ scaleOutResult.set("FILE", []);
+ scaleOutResult.set("STRING", [
+ {
+ "acceptableFileType": null,
+ "id": 1,
+ "msgOnContentError": null,
+ "msgOnPatternError": null,
+ "name": "Configuration Parameters",
+ "pattern": ".*",
+ "required": true,
+ "type": "STRING",
+ }
+ ]);
+ result.set("VNF Scale Out", scaleOutResult);
+
+ return $controller.loadWorkFlows()
+ .then(() => {
+ expect($controller.localWorkflowsParameters).toEqual(result);
+ });
+ });
+
+ test('Verify broken SO workflows will return empty list of workflows', () => {
+ // given
+ let getSOWorkflowsPromiseStub = Promise.reject(new Error("Broken SO workflows service."));
+
+ $controller.changeManagement.vnfNames = [{name:"any"}];
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
// when
$controller.loadWorkFlows()
.then(() => {
- expect($controller.workflows).toEqual(['workflow 0']);
+ expect($controller.workflows).toEqual([]);
});
});
-});
+ test('Verify get internal workflow parameters should return an empty list if not such workflow exist', () => {
+ // given
+ $featureFlags.isOn = jestMock.fn(() => false);
+ let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
+ "parameterDefinitions": [
+ {
+ "id": 1,
+ "name": "Configuration Parameters",
+ "required": true,
+ "type": "STRING",
+ "pattern": ".*",
+ "msgOnPatternError": null,
+ "msgOnContentError": null,
+ "acceptableFileType": null
+ }
+ ],
+ }});
+
+ $controller.changeManagement.vnfNames = [{name: 'test1'}];
+ $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
+ // when
+ return $controller.loadWorkFlows()
+ .then(() => {
+ let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("NON-EXISTENT WF", "STRING");
+ expect(internalWorkFlowParameters).toEqual([]);
+ });
+ });
+
+ test('Verify get internal workflow parameters should return an empty list if not such type exist', () => {
+ // given
+ $featureFlags.isOn = jestMock.fn(() => false);
+ let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
+ "parameterDefinitions": [
+ {
+ "id": 1,
+ "name": "Configuration Parameters",
+ "required": true,
+ "type": "STRING",
+ "pattern": ".*",
+ "msgOnPatternError": null,
+ "msgOnContentError": null,
+ "acceptableFileType": null
+ }
+ ],
+ }});
+
+ $controller.changeManagement.vnfNames = [{name: 'test1'}];
+ $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
+ // when
+ return $controller.loadWorkFlows()
+ .then(() => {
+ let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("VNF Scale Out", "FILE");
+ expect(internalWorkFlowParameters).toEqual([]);
+ });
+ });
+
+ test('Verify get internal workflow parameters should return a list if such workflow and type exist', () => {
+ // given
+ $featureFlags.isOn = jestMock.fn(() => false);
+ let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data":{
+ "parameterDefinitions": [
+ {
+ "id": 1,
+ "name": "Configuration Parameters",
+ "required": true,
+ "type": "STRING",
+ "pattern": ".*",
+ "msgOnPatternError": null,
+ "msgOnContentError": null,
+ "acceptableFileType": null
+ }
+ ],
+ }});
+ $controller.changeManagement.vnfNames = [{name: 'test1'}];
+ $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
+
+ let result = [{
+ "acceptableFileType": null,
+ "id": 1,
+ "msgOnContentError": null,
+ "msgOnPatternError": null,
+ "name": "Configuration Parameters",
+ "pattern": ".*",
+ "required": true,
+ "type": "STRING",
+ }];
+ // when
+ return $controller.loadWorkFlows()
+ .then(() => {
+ let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("VNF Scale Out", "STRING");
+ expect(internalWorkFlowParameters).toEqual(result);
+ });
+ });
+});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
index 2cf879001..9fb978c42 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
@@ -78,38 +78,26 @@
<option value="" disabled>Select workflow</option>
</select>
</div>
- <div class="form-group" ng-if="vm.isScaleOut()">
- <label class="control-label">Configuration Parameters</label>
- <input type="text" name="configurationParameters" ng-model="vm.changeManagement.configurationParameters" id="configuration-parameters" required>
- </div>
- <div class="form-group" ng-if="vm.isConfigUpdate()">
- <label class="control-label">Attach configuration file</label>
+
+ <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'FILE')">
+ <label class="control-label">{{item.name}}</label>
<div class="file-wrapper">
- <input id="config-update-input" class="file-input" type="file" ngf-select ng-model="vm.configUpdateFile" ngf-validate-async-fn="vm.uploadConfigFile($file)" name="configUpdateFile"
- accept=".csv" ngf-pattern=".csv" required> </input>
- <label id="config-update-label" class="file-input-label">{{vm.configUpdateFile&&vm.configUpdateFile.name||"Select File"}} </label>
- <label for="config-update-input"><span class="icon-browse"></span></label>
+ <input id="internal-workflow-parameter-file-{{item.id}}" class="file-input" type="file" ngf-select ng-model="item.value" ngf-validate-async-fn="vm.uploadConfigFile($file)" name="configUpdateFile" accept="{{item.acceptableFileType}}" ngf-pattern="{{item.acceptableFileType}}" ng-required="{{item.required}}"/>
+ <label id="internal-workflow-parameter-file-{{item.id}}-label" class="file-input-label">{{item.value&&item.value.name||"Select File"}} </label>
+ <label for="internal-workflow-parameter-file-{{item.id}}"><span class="icon-browse"></span></label>
</div>
- <label id="errorLabel" class="icon-alert error" ng-if="newChangeManagement.configUpdateFile.$error.pattern">{{vm.configUpdatePatternError}}</label>
- <label id="errorContentLabel" class="icon-alert error" ng-if="newChangeManagement.configUpdateFile.$error.validateAsyncFn">{{vm.configUpdateContentError}}</label>
+ <label id="errorLabel" class="icon-alert error" ng-if="item.value.$error.pattern">{{item.msgOnPatternError}}</label>
+ <label id="errorContentLabel" class="icon-alert error" ng-if="item.value.$error.validateAsyncFn">{{item.msgOnContentError}}</label>
</div>
- <div ng-if="vm.shouldShowVnfInPlaceFields()">
- <div class="form-group">
- <label class="control-label">Operations timeout</label>
- <input class="form-control" ng-model="vm.changeManagement.operationTimeout" name="operationTimeout" type="text" id="operations-timeout" pattern="[0-9]+" required>
- </div>
- <div class="form-group">
- <label class="control-label">Existing software version</label>
- <input class="form-control" ng-model="vm.changeManagement.existingSoftwareVersion" name="existingSoftwareVersion" type="text" id="existing-software-version" pattern="{{vm.softwareVersionRegex}}" required>
- </div>
- <div class="form-group">
- <label class="control-label">New software version</label>
- <input class="form-control" ng-model="vm.changeManagement.newSoftwareVersion" name="newSoftwareVersion" type="text" id="new-software-version" pattern="{{vm.softwareVersionRegex}}" required>
- </div>
+
+ <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'STRING')">
+ <label for="internal-workflow-parameter-text-{{item.id}}" class="control-label">{{item.name}}</label>
+ <input ng-model="item.value" type="text" id="internal-workflow-parameter-text-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}">
</div>
+
<div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getRemoteWorkFlowParameters(vm.changeManagement.workflow)">
<label for="so-workflow-parameter-{{item.id}}" class="control-label">{{item.name}}</label>
- <input class="form-control" ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}">
+ <input ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}">
</div>
</div>
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
index 5820ae212..2a06e75b1 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
@@ -36,7 +36,7 @@
.success(function (response) {
return {data: response};
})
- .catch(function (err) {
+ .catch(function () {
return {data: []};
});
};
@@ -45,7 +45,8 @@
return $http.get(COMPONENT.GET_SO_WORKFLOWS, {params: {vnfName: vnfNames}})
.success(function (response) {
return {data: response};
- }).catch(function () {
+ }).catch(function (ex) {
+ console.error("Problem when getting workflows from SO API occurred.", ex.stack);
return {data: []};
});
};
@@ -57,6 +58,13 @@
});
};
+ this.getLocalWorkflowParameter = function (workflowName){
+ return $http.get(COMPONENT.GET_LOCAL_WORKFLOW_PARAMETER.replace('@workflowName', encodeURIComponent(workflowName)))
+ .success(function (response) {
+ return {data: response.parameterDefinitions}
+ });
+ };
+
this.getMSOChangeManagements = function() {
var deferred = $q.defer();
diff --git a/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java b/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
index 98be994fa..e06805cc1 100644
--- a/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
+++ b/vid-app-common/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,23 +20,52 @@
package org.onap.aai.util;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.io.PrintStream;
+import java.util.Arrays;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import org.onap.vid.aai.util.JettyObfuscationConversionCommandLineUtil;
+@RunWith(Parameterized.class)
public class JettyObfuscationConversionCommandLineUtilTest {
- private JettyObfuscationConversionCommandLineUtil createTestSubject() {
- return new JettyObfuscationConversionCommandLineUtil();
- }
+ final String[] args;
+ final String expected;
+
+ public JettyObfuscationConversionCommandLineUtilTest(String description, String[] args, String expected) {
+ this.args = args;
+ this.expected = expected;
+ }
-
- @Test
- public void testMain() throws Exception {
- String[] args = new String[] { "" };
+ @Parameters(name = "{0}")
+ public static Iterable<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {"print usage on missing params", new String[]{}, "usage:"},
+ {"obfuscate", new String[]{"-e", "foobar"}, "OBF:1vub1ua51uh81ugi1u9d1vuz"},
+ {"deobfuscate", new String[]{"-d", "OBF:1vub1ua51uh81ugi1u9d1vuz"}, "foobar"},
+ {"input parse exception", new String[]{"mm", "-mm", "-mm"}, "failed to parse input"},
+ {"deobfuscate exception", new String[]{"-d", "problematic string"},
+ "exception:java.lang.NumberFormatException"},
+ });
+ }
- // default test
- JettyObfuscationConversionCommandLineUtil.main(args);
- }
+ @Test
+ public void testMain() {
+ final PrintStream originalOut = System.out;
+ try {
+ PrintStream mockedOut = mock(PrintStream.class);
+ System.setOut(mockedOut);
+ JettyObfuscationConversionCommandLineUtil.main(args);
+ verify(mockedOut).println(contains(expected));
+ } finally {
+ System.setOut(originalOut);
+ }
+ }
-
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
index 222bf1e5b..c41a479d9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java
@@ -19,6 +19,7 @@
*/
package org.onap.vid.aai;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
@@ -60,6 +61,20 @@ public class PombaClientImplTest {
then(pombaRestInterface).should().RestPost("VidAaiController", expectedUrl, expectedPayload);
}
+ @Test
+ public void should_handleException_withoutRethrowing() throws IOException {
+ //Given
+ String expectedUrl = "http://localhost/dummyUrl";
+ String expectedPayload = readExpectedPombaJsonRequest();
+ given(systemPropertiesWrapper.getProperty("pomba.server.url")).willReturn(expectedUrl);
+ given(pombaRestInterface.RestPost("VidAaiController", expectedUrl, expectedPayload))
+ .willThrow(new NullPointerException());
+ PombaRequest pombaRequest = createPombaRequest();
+
+ //When //Then
+ assertThatCode(() -> pombaClient.verify(pombaRequest)).doesNotThrowAnyException();
+ }
+
private String readExpectedPombaJsonRequest() throws IOException {
URL url = PombaClientImplTest.class.getClassLoader().getResource("pomba_request.json");
PombaRequest expectedPombaRequest = new ObjectMapper().readValue(url, PombaRequest.class);
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java
index 5fe392751..a3a14a2dd 100644
--- a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterOptionTest.java
@@ -20,190 +20,34 @@
package org.onap.vid.model;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Set;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
-import org.junit.Assert;
+import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+import org.onap.vid.testUtils.TestUtils;
public class CategoryParameterOptionTest {
- private CategoryParameterOption createTestSubject() {
- return new CategoryParameterOption();
- }
-
- @Test
- public void testGetId() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
- @Test
- public void testSetId() throws Exception {
- CategoryParameterOption testSubject;
- Long id = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setId(id);
- }
-
- @Test
- public void testGetAppId() throws Exception {
- CategoryParameterOption testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAppId();
- }
-
- @Test
- public void testSetAppId() throws Exception {
- CategoryParameterOption testSubject;
- String appId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAppId(appId);
- }
-
- @Test
- public void testGetName() throws Exception {
- CategoryParameterOption testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test
- public void testSetName() throws Exception {
- CategoryParameterOption testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
-
- @Test
- public void testGetCategoryParameter() throws Exception {
- CategoryParameterOption testSubject;
- CategoryParameter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCategoryParameter();
- }
-
- @Test
- public void testSetCategoryParameter() throws Exception {
- CategoryParameterOption testSubject;
- CategoryParameter categoryParameter = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCategoryParameter(categoryParameter);
- }
-
- @Test
- public void testGetCreated() throws Exception {
- CategoryParameterOption testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreated();
- }
-
- @Test
- public void testGetModified() throws Exception {
- CategoryParameterOption testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModified();
- }
-
- @Test
- public void testGetCreatedId() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreatedId();
- }
+ final private String[] excludedProperties = TestUtils.allPropertiesOf(DomainVo.class);
@Test
- public void testGetModifiedId() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModifiedId();
- }
-
- @Test
- public void testGetAuditUserId() throws Exception {
- CategoryParameterOption testSubject;
- Serializable result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditUserId();
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(CategoryParameterOption.class, hasValidGettersAndSetters());
}
@Test
- public void testGetRowNum() throws Exception {
- CategoryParameterOption testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRowNum();
+ public void shouldHaveValidBeanHashCode() {
+ assertThat(CategoryParameterOption.class,
+ hasValidBeanHashCodeExcluding(ArrayUtils.addAll(new String[]{"categoryParameter"}, excludedProperties)));
}
@Test
- public void testGetAuditTrail() throws Exception {
- CategoryParameterOption testSubject;
- Set result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditTrail();
- }
-
- @Test
- public void testEquals() throws Exception {
- CategoryParameterOption testSubject;
- Object o = null;
- boolean result;
-
- // test 1
- testSubject = createTestSubject();
- o = null;
- result = testSubject.equals(o);
- Assert.assertEquals(false, result);
- }
-
- @Test
- public void testHashCode() throws Exception {
- CategoryParameterOption testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
+ public void shouldHaveValidBeanEquals() {
+ assertThat(CategoryParameterOption.class, hasValidBeanEqualsExcluding(excludedProperties));
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
index dc18c3065..c515a34d4 100644
--- a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
@@ -20,186 +20,64 @@
package org.onap.vid.model;
-import java.io.Serializable;
-import java.util.Date;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.onap.vid.testUtils.TestUtils.allPropertiesOf;
+
+import com.google.common.collect.ImmutableSet;
import java.util.Set;
-
+import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
+import org.onap.portalsdk.core.domain.support.DomainVo;
public class CategoryParameterTest {
- private CategoryParameter createTestSubject() {
- return new CategoryParameter();
- }
-
- @Test
- public void testGetFamily() throws Exception {
- CategoryParameter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getFamily();
- }
-
- @Test
- public void testSetFamily() throws Exception {
- CategoryParameter testSubject;
- String family = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setFamily(family);
- }
-
- @Test
- public void testGetId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
- @Test
- public void testGetCreated() throws Exception {
- CategoryParameter testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreated();
- }
-
- @Test
- public void testGetModified() throws Exception {
- CategoryParameter testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModified();
- }
-
- @Test
- public void testGetCreatedId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreatedId();
- }
-
- @Test
- public void testGetModifiedId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModifiedId();
- }
-
- @Test
- public void testGetName() throws Exception {
- CategoryParameter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
- @Test
- public void testSetName() throws Exception {
- CategoryParameter testSubject;
- String name = "";
+ final private String[] excludedProperties = allPropertiesOf(DomainVo.class);
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
+ private ImmutableSet<CategoryParameterOption> optionsWithRefTo(CategoryParameter categoryParameter) {
+ return ImmutableSet.of(
+ new CategoryParameterOption("appId1", "name1", categoryParameter),
+ new CategoryParameterOption("appId2", "name2", categoryParameter)
+ );
}
@Test
- public void testGetAuditUserId() throws Exception {
- CategoryParameter testSubject;
- Serializable result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditUserId();
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(CategoryParameter.class, hasValidGettersAndSettersExcluding("options"));
}
@Test
- public void testGetRowNum() throws Exception {
- CategoryParameter testSubject;
- Long result;
+ public void testSetAndGetOptions() {
+ CategoryParameter testSubject = new CategoryParameter();
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRowNum();
- }
-
- @Test
- public void testGetAuditTrail() throws Exception {
- CategoryParameter testSubject;
- Set result;
+ Set<CategoryParameterOption> options = optionsWithRefTo(testSubject);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditTrail();
+ testSubject.setOptions(options);
+ assertThat(testSubject.getOptions(), containsInAnyOrder(optionsWithRefTo(testSubject).toArray()));
}
@Test
- public void testGetOptions() throws Exception {
- CategoryParameter testSubject;
- Set<CategoryParameterOption> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOptions();
+ public void shouldHaveValidBeanHashCodeWithCycleReference() {
+ assertThat(CategoryParameter.class,
+ hasValidBeanHashCodeExcluding(ArrayUtils.addAll(new String[]{"options"}, excludedProperties)));
}
@Test
- public void testSetOptions() throws Exception {
- CategoryParameter testSubject;
- Set<CategoryParameterOption> options = null;
-
- // default test
- testSubject = createTestSubject();
+ public void hashCodeShouldNotExplodeWhenCycleReference() {
+ CategoryParameter testSubject = new CategoryParameter();
+ Set<CategoryParameterOption> options = optionsWithRefTo(testSubject);
testSubject.setOptions(options);
- }
- @Test
- public void testAddOption() throws Exception {
- CategoryParameter testSubject;
- CategoryParameterOption option = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addOption(option);
+ testSubject.hashCode(); // don't stackOverflow
}
@Test
- public void testIsIdSupported() throws Exception {
- CategoryParameter testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isIdSupported();
+ public void shouldHaveValidBeanEquals() {
+ assertThat(CategoryParameter.class, hasValidBeanEqualsExcluding(excludedProperties));
}
- @Test
- public void testSetIdSupported() throws Exception {
- CategoryParameter testSubject;
- boolean idSupported = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIdSupported(idSupported);
- }
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index a5fb1a5f0..39d777be9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -3,14 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2018 - 2019 Nokia. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java
index 5ec645a90..dd959a8aa 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapper2Test.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,41 +21,75 @@
package org.onap.vid.mso;
-import org.junit.Test;
+import static org.mockito.Mockito.when;
+
+import io.joshworks.restclient.http.HttpResponse;
+import org.mockito.Mock;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.MockitoAnnotations.initMocks;
public class MsoResponseWrapper2Test {
- private MsoResponseWrapper2 createTestSubject() {
- return new MsoResponseWrapper2(new RestObject());
+ @Mock
+ private RestObject<String> msoResponse;
+
+ @Mock
+ private HttpResponse<String> httpResponse;
+
+ private MsoResponseWrapper2<String> responseWrapper;
+
+ private int status = 202;
+ private String entity = "testEntity";
+ private String rawString = "testRawString";
+
+ @BeforeClass
+ public void setUp() {
+ initMocks(this);
}
@Test
- public void testGetStatus() throws Exception {
- MsoResponseWrapper2 testSubject;
- int result;
+ public void shouldProperlyCreateInstanceFromRestObject() {
+ // given
+ when(msoResponse.getStatusCode()).thenReturn(status);
+ when(msoResponse.get()).thenReturn(entity);
+ when(msoResponse.getRaw()).thenReturn(rawString);
+
+ // when
+ responseWrapper = new MsoResponseWrapper2<>(msoResponse);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getStatus();
+ // then
+ assertThat(responseWrapper.getStatus()).isEqualTo(status);
+ assertThat(responseWrapper.getEntity()).isEqualTo(entity);
+ assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
}
@Test
- public void testGetResponse() throws Exception {
- MsoResponseWrapper2 testSubject;
- String result;
+ public void shouldProperlyCreateInstanceFromHttpResponse() {
+ // given
+ when(httpResponse.getStatus()).thenReturn(status);
+ when(httpResponse.getBody()).thenReturn(entity);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getResponse();
+ // when
+ responseWrapper = new MsoResponseWrapper2<>(httpResponse);
+
+ // then
+ assertThat(responseWrapper.getStatus()).isEqualTo(status);
+ assertThat(responseWrapper.getEntity()).isEqualTo(entity);
+ assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
}
@Test
- public void testGetEntity() throws Exception {
- MsoResponseWrapper2 testSubject;
- Object result;
+ public void shouldProperlyCreateInstanceFromStatusAndEntity() {
+ // when
+ responseWrapper = new MsoResponseWrapper2<>(status,entity);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getEntity();
+ // then
+ assertThat(responseWrapper.getStatus()).isEqualTo(status);
+ assertThat(responseWrapper.getEntity()).isEqualTo(entity);
+ assertThat(responseWrapper.getResponse()).isEqualTo("{\"status\":"+status+",\"entity\":\""+entity+"\"}");
}
-}
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java
index 6cba339d1..191b91ba2 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoResponseWrapperTest.java
@@ -25,12 +25,12 @@ import org.mockito.Mock;
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
import javax.ws.rs.core.Response;
@@ -46,7 +46,7 @@ public class MsoResponseWrapperTest {
private MsoResponseWrapper responseWrapper;
- @BeforeSuite
+ @BeforeClass
public void setUp() {
initMocks(this);
}
@@ -57,45 +57,58 @@ public class MsoResponseWrapperTest {
}
@Test
- public void shouldProperlyConstructResponseWrapperWithParameters(){
+ public void shouldProperlyConstructMsoResponseWrapperWithParameters(){
+ // when
responseWrapper = new MsoResponseWrapper(1,"testEntity");
+ // then
assertThat(responseWrapper.getStatus()).isEqualTo(1);
assertThat(responseWrapper.getEntity()).isEqualTo("testEntity");
}
@Test
- public void shouldProperlyConstructResponseWrapperFromResponse(){
+ public void shouldProperlyConstructMsoResponseWrapperFromResponse(){
+ // given
when(response.getStatus()).thenReturn(1);
when(response.readEntity(String.class)).thenReturn("testEntity");
+ // when
responseWrapper = new MsoResponseWrapper(response);
+ // then
assertThat(responseWrapper.getStatus()).isEqualTo(1);
assertThat(responseWrapper.getEntity()).isEqualTo("testEntity");
}
@Test
public void shouldProperlyGetResponseWithEmptyEntity(){
+ // given
responseWrapper = new MsoResponseWrapper();
+
+ // when
responseWrapper.setStatus(1);
+ // then
assertThat(responseWrapper.getResponse()).isEqualToIgnoringWhitespace(PROPER_RESPONSE_WITH_NO_ENTITY);
}
@Test
public void shouldProperlyGetResponse(){
+ // when
responseWrapper = new MsoResponseWrapper(1,"testEntity");
+ // then
assertThat(responseWrapper.getResponse()).isEqualToIgnoringWhitespace(PROPER_RESPONSE);
}
@Test
public void shouldProperlyConvertToString(){
+ // when
responseWrapper = new MsoResponseWrapper(1,"testEntity");
+ // then
assertThat(responseWrapper.toString()).endsWith(PROPER_TO_STRING);
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java
index 803083321..9f8614b92 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestObjectTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,7 @@
package org.onap.vid.mso;
import org.hamcrest.MatcherAssert;
-import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
@@ -29,11 +29,11 @@ import static org.assertj.core.api.Assertions.assertThat;
public class RestObjectTest {
- private RestObject restObject;
+ private RestObject<Object> restObject;
- @BeforeSuite
+ @BeforeClass
private void setUp() {
- restObject = new RestObject();
+ restObject = new RestObject<>();
}
@Test
@@ -42,7 +42,7 @@ public class RestObjectTest {
}
@Test
- public void shouldHaveValidGetterAndSetterForBody() {
+ public void shouldHaveValidGetterAndSetterForTObject() {
// given
String testString = "set/get_testString";
@@ -54,13 +54,13 @@ public class RestObjectTest {
}
@Test
- public void shouldProperlyCopyRestObject() {
+ public void shouldProperlyCopyFromOneRestObjectToAnotherWithProperParameters() {
// given
MsoResponseWrapper testResponseWraper = new MsoResponseWrapper();
String rawTestString = "rawTestString";
int statusCode = 404;
- RestObject restObjectToCopyFrom = new RestObject<>();
+ RestObject<Object> restObjectToCopyFrom = new RestObject<>();
restObjectToCopyFrom.set(testResponseWraper);
restObjectToCopyFrom.setRaw(rawTestString);
restObjectToCopyFrom.setStatusCode(statusCode);
@@ -91,4 +91,4 @@ public class RestObjectTest {
// then
assertThat(toStringResponse).isEqualTo(properString);
}
-}
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
index 2a69e0e79..131e5dd46 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentActivateInfoTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,45 +20,48 @@
package org.onap.vid.mso.model;
-import org.junit.Test;
import org.onap.vid.controller.OperationalEnvironmentController;
-import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentActivateBody;
import org.onap.vid.controller.OperationalEnvironmentController.OperationalEnvironmentManifest;
+import org.testng.annotations.Test;
-public class OperationalEnvironmentActivateInfoTest {
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
- private OperationalEnvironmentActivateInfo createTestSubject() {
- OperationalEnvironmentController.OperationalEnvironmentActivateBody a = new OperationalEnvironmentActivateBody("a", "b", "c", new OperationalEnvironmentManifest());
- return new OperationalEnvironmentActivateInfo(a, "", "");
- }
+public class OperationalEnvironmentActivateInfoTest {
@Test
- public void testGetUserId() throws Exception {
- OperationalEnvironmentActivateInfo testSubject;
- String result;
+ public void shouldProperlyCreateOperationalEnvironmentActivateInfoWithParameters() {
+ // given
+ String relatedInstanceId = "testRelatedInstanceId";
+ String relatedInstanceName = "testRelatedInstanceName";
+ String workloadContext = "testWorkloadContext";
+ OperationalEnvironmentManifest manifest = new OperationalEnvironmentManifest();
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUserId();
- }
+ String userId = "testUserId";
+ String operationalEnvironmentId = "testOperationalEnvironmentId";
- @Test
- public void testGetOperationalEnvironmentId() throws Exception {
- OperationalEnvironmentActivateInfo testSubject;
- String result;
+ OperationalEnvironmentController.OperationalEnvironmentActivateBody operationalEnvironmentActivateBody =
+ new OperationalEnvironmentController.OperationalEnvironmentActivateBody
+ (relatedInstanceId,relatedInstanceName,workloadContext,manifest);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentId();
- }
+ // when
+ OperationalEnvironmentActivateInfo operationalEnvironmentActivateInfo =
+ new OperationalEnvironmentActivateInfo(operationalEnvironmentActivateBody, userId, operationalEnvironmentId);
- @Test
- public void testToString() throws Exception {
- OperationalEnvironmentActivateInfo testSubject;
- String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ // then
+ assertThat(operationalEnvironmentActivateInfo.getUserId()).isEqualTo(userId);
+ assertThat(operationalEnvironmentActivateInfo.getOperationalEnvironmentId()).isEqualTo(operationalEnvironmentId);
+
+ assertThat(operationalEnvironmentActivateInfo.toString()).isEqualToIgnoringWhitespace(
+ "OperationalEnvironmentActivateInfo{operationalEnvironmentId="+operationalEnvironmentId+"," +
+ " userId="+userId+"," +
+ " super=OperationalEnvironmentActivateInfo{" +
+ " relatedInstanceId="+relatedInstanceId+"," +
+ " relatedInstanceName="+relatedInstanceName+"," +
+ " workloadContext="+workloadContext+"," +
+ " manifest="+manifest.toString()+"}}"
+ );
+
}
-}
+
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java
index 22310d2e2..72fb9d6dc 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/model/OperationalEnvironmentDeactivateInfoTest.java
@@ -20,41 +20,31 @@
package org.onap.vid.mso.model;
-import org.junit.Test;
+import org.testng.annotations.Test;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
public class OperationalEnvironmentDeactivateInfoTest {
- private OperationalEnvironmentDeactivateInfo createTestSubject() {
- return new OperationalEnvironmentDeactivateInfo("", "");
- }
-
@Test
- public void testGetUserId() throws Exception {
- OperationalEnvironmentDeactivateInfo testSubject;
- String result;
+ public void shouldProperlyCreateOperationalEnvironmentActivateInfoWithParameters() {
+ // given
+ String userId = "testUserId";
+ String operationalEnvironmentId = "testOperationalEnvironmentId";
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUserId();
- }
- @Test
- public void testGetOperationalEnvironmentId() throws Exception {
- OperationalEnvironmentDeactivateInfo testSubject;
- String result;
+ // when
+ OperationalEnvironmentDeactivateInfo operationalEnvironmentDeactivateInfo =
+ new OperationalEnvironmentDeactivateInfo(userId, operationalEnvironmentId);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperationalEnvironmentId();
- }
- @Test
- public void testToString() throws Exception {
- OperationalEnvironmentDeactivateInfo testSubject;
- String result;
+ // then
+ assertThat(operationalEnvironmentDeactivateInfo.getUserId()).isEqualTo(userId);
+ assertThat(operationalEnvironmentDeactivateInfo.getOperationalEnvironmentId()).isEqualTo(operationalEnvironmentId);
+
+ assertThat(operationalEnvironmentDeactivateInfo.toString()).isEqualToIgnoringWhitespace(
+ "OperationalEnvironmentDeactivateInfo{operationalEnvironmentId="+operationalEnvironmentId+"," +
+ " userId="+userId+"}"
+ );
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
}
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ExtWorkflowServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowServiceImplTest.java
index d8d8552ec..160ba97a5 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/ExtWorkflowServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ExternalWorkflowServiceImplTest.java
@@ -38,13 +38,11 @@ import org.onap.vid.model.SOWorkflowType;
import org.onap.vid.model.SOWorkflows;
import org.onap.vid.mso.MsoResponseWrapper2;
import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
-import org.onap.vid.services.ExtWorkflowsServiceImpl.BadResponseFromMso;
+import org.onap.vid.services.ExternalWorkflowsServiceImpl.BadResponseFromMso;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-
-
-public class ExtWorkflowServiceImplTest {
+public class ExternalWorkflowServiceImplTest {
@Mock
private MockedWorkflowsRestClient client;
@@ -63,7 +61,7 @@ public class ExtWorkflowServiceImplTest {
@Test
public void shouldReturnWorkflowsOnValidResponse(){
// given
- ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
Mockito.when(response.getStatus()).thenReturn(200);
Mockito.when(response.getBody()).thenReturn(new SOWorkflows(Collections.singletonList(new SOWorkflow(1L, "xyz"))));
MsoResponseWrapper2<SOWorkflows> msoResponseStub = new MsoResponseWrapper2<>(response);
@@ -78,7 +76,7 @@ public class ExtWorkflowServiceImplTest {
@Test(expectedExceptions = BadResponseFromMso.class)
public void shouldThrowBadResponseOnInvalidResponse(){
// given
- ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
Mockito.when(response.getStatus()).thenReturn(500);
Mockito.when(response.getBody()).thenReturn(new SOWorkflows(Collections.singletonList(new SOWorkflow(1L, "xyz"))));
MsoResponseWrapper2<SOWorkflows> msoResponseStub = new MsoResponseWrapper2<>(response);
@@ -90,7 +88,7 @@ public class ExtWorkflowServiceImplTest {
@Test
public void shouldReturnWorkflowParametersOnValidResponse() {
SOWorkflowParameterDefinitions parameters = new SOWorkflowParameterDefinitions(Collections.singletonList(new SOWorkflowParameterDefinition(1L, "sample", "[0-9]", SOWorkflowType.STRING, true)));
- ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
Mockito.when(parameterDefinitionsHttpResponse.getStatus()).thenReturn(200);
Mockito.when(parameterDefinitionsHttpResponse.getBody()).thenReturn(parameters);
MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponseWrapper = new MsoResponseWrapper2<>(parameterDefinitionsHttpResponse);
@@ -104,7 +102,7 @@ public class ExtWorkflowServiceImplTest {
@Test
public void shouldProperlyHandleEmptyParametersList(){
- ExtWorkflowsService extWorkflowsService = new ExtWorkflowsServiceImpl(client);
+ ExternalWorkflowsService extWorkflowsService = new ExternalWorkflowsServiceImpl(client);
Mockito.when(parameterDefinitionsHttpResponse.getStatus()).thenReturn(200);
Mockito.when(parameterDefinitionsHttpResponse.getBody()).thenReturn(new SOWorkflowParameterDefinitions(Lists.newArrayList()));
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
index 7b51225f3..85cf23edd 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/JobsBrokerServiceTest.java
@@ -21,8 +21,45 @@
package org.onap.vid.services;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.stream.Collectors.toList;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.both;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED;
+import static org.onap.vid.job.Job.JobStatus.CREATING;
+import static org.onap.vid.job.Job.JobStatus.FAILED;
+import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.PAUSE;
+import static org.onap.vid.job.Job.JobStatus.PENDING;
+import static org.onap.vid.job.Job.JobStatus.RESOURCE_IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.STOPPED;
+import static org.onap.vid.utils.Streams.not;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.AssertJUnit.assertEquals;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.lang.reflect.Method;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+import javax.inject.Inject;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
@@ -53,27 +90,6 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import javax.inject.Inject;
-import java.lang.reflect.Method;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.stream.Collectors.toList;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.both;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.onap.vid.job.Job.JobStatus.*;
-import static org.onap.vid.utils.Streams.not;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.AssertJUnit.assertEquals;
-
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, JobAdapterConfig.class})
public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
@@ -85,7 +101,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
private final Set<Long> threadsIds = new ConcurrentSkipListSet<>();
- private final long FEW = 500;
+ private final long FEW = 1000;
private final String JOBS_SHOULD_MATCH = "the jobs that added and those that pulled must be the same";
private final String JOBS_PEEKED_SHOULD_MATCH = "the jobs that added and those that peeked must be the same";
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 e2effd5ca..3a7d4690d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
@@ -20,9 +20,32 @@
package org.onap.vid.testUtils;
+import static org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptors;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.RETURNS_DEFAULTS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.withSettings;
+import static org.testng.Assert.fail;
+
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
+import java.beans.PropertyDescriptor;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.json.JSONArray;
@@ -32,28 +55,11 @@ import org.mockito.MockSettings;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.onap.portalsdk.core.domain.support.DomainVo;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.beans.Service;
import org.springframework.mock.env.MockEnvironment;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-
-import static fj.parser.Parser.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
/**
* Created by Oren on 6/7/17.
*/
@@ -125,6 +131,12 @@ public class TestUtils {
valueType);
}
+ public static String[] allPropertiesOf(Class<DomainVo> aClass) {
+ return Arrays.stream(getPropertyDescriptors(aClass))
+ .map(PropertyDescriptor::getDisplayName)
+ .toArray(String[]::new);
+ }
+
public static class JavaxRsClientMocks {
private final javax.ws.rs.client.Client fakeClient;