diff options
30 files changed, 1615 insertions, 292 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java index 37622a215..ac93d8751 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseEcompRequestIdFilter.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java @@ -21,10 +21,18 @@ package org.onap.vid.controller.filter; -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang3.StringUtils; -import org.springframework.web.filter.GenericFilterBean; +import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; +import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; +import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID; +import com.google.common.collect.ImmutableList; +import java.io.IOException; +import java.util.Collections; +import java.util.Enumeration; +import java.util.UUID; +import java.util.function.Supplier; +import java.util.regex.Pattern; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.ServletRequest; @@ -33,18 +41,22 @@ import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Collections; -import java.util.Enumeration; -import java.util.UUID; - -import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID; +import javax.validation.constraints.NotNull; +import org.onap.vid.logging.Headers; +import org.springframework.web.filter.GenericFilterBean; @WebFilter(urlPatterns = "/*") -public class PromiseEcompRequestIdFilter extends GenericFilterBean { - +public class PromiseRequestIdFilter extends GenericFilterBean { + + // The wrapped request is guaranteed to have the transaction id as the value + // of the header PROMISED_HEADER_NAME. + // PROMISED_HEADER_NAME is set to ECOMP_REQUEST_ID as long as + // org.onap.portalsdk...UserUtils.getRequestId() is using the header + // "X-ECOMP-RequestID". + private static final String PROMISED_HEADER_NAME = ECOMP_REQUEST_ID; private static final String REQUEST_ID_RESPONSE_HEADER = ECOMP_REQUEST_ID + "-echo"; + private static final Pattern uuidRegex = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", Pattern.CASE_INSENSITIVE); @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) @@ -54,7 +66,7 @@ public class PromiseEcompRequestIdFilter extends GenericFilterBean { request = wrapIfNeeded(request); if (response instanceof HttpServletResponse) { - final String actualRequestId = ((HttpServletRequest) request).getHeader(ECOMP_REQUEST_ID); + final String actualRequestId = ((HttpServletRequest) request).getHeader(PROMISED_HEADER_NAME); ((HttpServletResponse) response).addHeader(REQUEST_ID_RESPONSE_HEADER, actualRequestId); } } @@ -62,30 +74,54 @@ public class PromiseEcompRequestIdFilter extends GenericFilterBean { chain.doFilter(request, response); } - public static ServletRequest wrapIfNeeded(ServletRequest request) { + public ServletRequest wrapIfNeeded(ServletRequest request) { final HttpServletRequest httpRequest = (HttpServletRequest) request; - final String originalRequestId = httpRequest.getHeader(ECOMP_REQUEST_ID); - if (StringUtils.isEmpty(originalRequestId) || !verifyAndValidateUuid(originalRequestId)) { - request = new PromiseEcompRequestIdRequestWrapper(httpRequest); + final String highestPriorityHeader = highestPriorityHeader(httpRequest); + final String originalRequestId = httpRequest.getHeader(highestPriorityHeader); + + if (isWrapNeeded(highestPriorityHeader, originalRequestId)) { + // Copy originalRequestId to the promised header value + request = new PromiseRequestIdRequestWrapper(httpRequest, toUuidOrElse(originalRequestId, UUID::randomUUID)); } return request; } - public static boolean verifyAndValidateUuid(String value) - { - String uuidRegex = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; - return value.matches(uuidRegex); + private boolean verifyAndValidateUuid(String value) { + return isNotEmpty(value) && uuidRegex.matcher(value).matches(); + } + + private boolean isWrapNeeded(String highestPriorityHeader, String originalRequestId) { + boolean headerExistsAndValid = + equalsIgnoreCase(highestPriorityHeader, PROMISED_HEADER_NAME) && verifyAndValidateUuid(originalRequestId); + + return !headerExistsAndValid; + } + + UUID toUuidOrElse(String uuid, Supplier<UUID> uuidSupplier) { + if (verifyAndValidateUuid(uuid)) { + try { + return UUID.fromString(uuid); + } catch (IllegalArgumentException e) { + return uuidSupplier.get(); + } + } else { + return uuidSupplier.get(); + } } - private static class PromiseEcompRequestIdRequestWrapper extends HttpServletRequestWrapper { + String highestPriorityHeader(HttpServletRequest httpRequest) { + return defaultIfNull(Headers.highestPriorityHeader(httpRequest), PROMISED_HEADER_NAME); + } + + private static class PromiseRequestIdRequestWrapper extends HttpServletRequestWrapper { private final UUID requestId; - PromiseEcompRequestIdRequestWrapper(HttpServletRequest request) { + PromiseRequestIdRequestWrapper(HttpServletRequest request, @NotNull UUID requestId) { super(request); - requestId = UUID.randomUUID(); + this.requestId = requestId; } @Override @@ -106,18 +142,18 @@ public class PromiseEcompRequestIdFilter extends GenericFilterBean { @Override public Enumeration<String> getHeaderNames() { - if (null == super.getHeader(ECOMP_REQUEST_ID)) { - return Collections.enumeration(ImmutableList.<String>builder() - .add(ECOMP_REQUEST_ID) + if (null == super.getHeader(PROMISED_HEADER_NAME)) { + return Collections.enumeration(ImmutableList.<String>builder() + .add(PROMISED_HEADER_NAME) .addAll(Collections.list(super.getHeaderNames())) .build()); - } + } return super.getHeaderNames(); } private boolean isRequestIdHeaderName(String name) { - return ECOMP_REQUEST_ID.equalsIgnoreCase(name); + return equalsIgnoreCase(name, PROMISED_HEADER_NAME); } } } diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt index 8c769d68d..ac5c2751c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt +++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt @@ -22,6 +22,7 @@ package org.onap.vid.job.command import com.fasterxml.jackson.module.kotlin.convertValue +import org.apache.commons.lang3.ObjectUtils.defaultIfNull import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate import org.onap.vid.changeManagement.RequestDetailsWrapper import org.onap.vid.exceptions.AbortingException diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt new file mode 100644 index 000000000..e710fd973 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt @@ -0,0 +1,18 @@ +@file:JvmName("Headers") + +package org.onap.vid.logging + +import org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID +import javax.servlet.http.HttpServletRequest + +fun prioritizedRequestIdHeaders() = listOf( + "X-ONAP-RequestID", + "X-RequestID", + "X-TransactionID", + ECOMP_REQUEST_ID +) + +fun highestPriorityHeader(httpRequest: HttpServletRequest): String? { + val headers = httpRequest.headerNames.asSequence().toSet().map { it.toUpperCase() } + return prioritizedRequestIdHeaders().firstOrNull { headers.contains(it.toUpperCase()) } +} 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 ea13a76a2..0930c89aa 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 @@ -72,6 +72,7 @@ data class SOWorkflowParameterDefinitions constructor( data class LocalWorkflowParameterDefinition @JvmOverloads constructor( val id: Long, val name: String, + val displayName: String, val required: Boolean, val type: LocalWorkflowType, val pattern: String? = null, diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java index 75658f2b1..642843a0c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java @@ -58,6 +58,9 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest { protected String statusMessage; + protected Integer position; + + private static final Map<String, Action> actionStingToEnumMap = ImmutableMap.<String, Action>builder() .put("Delete", Action.Delete) .put("Create", Action.Create) @@ -70,17 +73,18 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest { protected BaseResource(@JsonProperty("modelInfo") ModelInfo modelInfo, - @JsonProperty("instanceName") String instanceName, - @JsonProperty("action") String action, - @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, - @JsonProperty("legacyRegion") String legacyRegion, - @JsonProperty("tenantId") String tenantId, - @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, - @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, - @JsonProperty("instanceId") String instanceId, - @JsonProperty("trackById") String trackById, - @JsonProperty("isFailed") Boolean isFailed, - @JsonProperty("statusMessage") String statusMessage) { + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId, + @JsonProperty("trackById") String trackById, + @JsonProperty("isFailed") Boolean isFailed, + @JsonProperty("statusMessage") String statusMessage, + @JsonProperty("position") Integer position) { this.modelInfo = modelInfo; this.modelInfo.setModelType(getModelType()); this.rollbackOnFailure = rollbackOnFailure; @@ -93,6 +97,7 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest { this.trackById = trackById; this.isFailed = isFailed!= null ? isFailed: false; this.statusMessage = statusMessage; + this.position = position; } private Action actionStringToEnum(String actionAsString) { @@ -163,6 +168,14 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest { this.statusMessage = statusMessage; } + public Integer getPosition() { + return position; + } + + public void setPosition(Integer position) { + this.position = position; + } + @JsonIgnore public abstract Collection<? extends BaseResource> getChildren(); diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java index b945f1327..f23c2e73e 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java @@ -34,16 +34,18 @@ public class InstanceGroup extends BaseResource implements JobAdapter.AsyncJobRe private final Map<String, InstanceGroupMember> vnfGroupMembers; public InstanceGroup(@JsonProperty("modelInfo") ModelInfo modelInfo, - @JsonProperty("instanceName") String instanceName, - @JsonProperty("action") String action, - @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, - @JsonProperty("instanceId") String instanceId, - @JsonProperty("vnfs") Map<String, InstanceGroupMember> vnfGroupMembers, - @JsonProperty("trackById") String trackById, - @JsonProperty("isFailed") Boolean isFailed, - @JsonProperty("statusMessage") String statusMessage) { + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId, + @JsonProperty("vnfs") Map<String, InstanceGroupMember> vnfGroupMembers, + @JsonProperty("trackById") String trackById, + @JsonProperty("isFailed") Boolean isFailed, + @JsonProperty("statusMessage") String statusMessage, + @JsonProperty("position") Integer position) { - super(modelInfo, instanceName, action, null, null, null, null, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage); + super(modelInfo, instanceName, action, null, null, null, null, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage, + position); this.vnfGroupMembers = vnfGroupMembers; } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java index 7bfaf02b1..e9f34ccfb 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroupMember.java @@ -30,11 +30,13 @@ import org.onap.vid.mso.model.ModelInfo; public class InstanceGroupMember extends BaseResource implements JobAdapter.AsyncJobRequest{ public InstanceGroupMember(@JsonProperty("instanceId") String instanceId, - @JsonProperty("action") String action, - @JsonProperty("trackById") String trackById, - @JsonProperty("isFailed") Boolean isFailed, - @JsonProperty("statusMessage") String statusMessage) { - super(new ModelInfo(), null, action, null, null, null, null, false, instanceId, trackById, isFailed, statusMessage); + @JsonProperty("action") String action, + @JsonProperty("trackById") String trackById, + @JsonProperty("isFailed") Boolean isFailed, + @JsonProperty("statusMessage") String statusMessage, + @JsonProperty("position") Integer position) { + super(new ModelInfo(), null, action, null, null, null, null, false, instanceId, trackById, isFailed, statusMessage, + position); } @Override diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java index 797e28a02..b9a0aeb85 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java @@ -39,22 +39,24 @@ public class Network extends BaseResource implements JobAdapter.AsyncJobRequest private final String lineOfBusiness; public Network(@JsonProperty("modelInfo") ModelInfo modelInfo, - @JsonProperty("productFamilyId") String productFamilyId, - @JsonProperty("instanceName") String instanceName, - @JsonProperty("action") String action, - @JsonProperty("platformName") String platformName, - @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, - @JsonProperty("legacyRegion") String legacyRegion, - @JsonProperty("tenantId") String tenantId, - @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, - @JsonProperty("lineOfBusinessName") String lineOfBusiness, - @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, - @JsonProperty("instanceId") String instanceId, - @JsonProperty("trackById") String trackById, - @JsonProperty("isFailed") Boolean isFailed, - @JsonProperty("statusMessage") String statusMessage) { - - super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage); + @JsonProperty("productFamilyId") String productFamilyId, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("platformName") String platformName, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, + @JsonProperty("lineOfBusinessName") String lineOfBusiness, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId, + @JsonProperty("trackById") String trackById, + @JsonProperty("isFailed") Boolean isFailed, + @JsonProperty("statusMessage") String statusMessage, + @JsonProperty("position") Integer position) { + + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage, + position); this.productFamilyId = productFamilyId; this.platformName = platformName; this.lineOfBusiness = lineOfBusiness; diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java index afc8534a1..8828faf1d 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java @@ -104,7 +104,8 @@ public class ServiceInstantiation extends BaseResource implements JobAdapter.Asy @JsonProperty("isFailed") Boolean isFailed, @JsonProperty("statusMessage") String statusMessage, @JsonProperty("vidNotions") VidNotions vidNotions) { - super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage); + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage, + null); this.owningEntityId = owningEntityId; this.owningEntityName = owningEntityName; this.projectName = projectName; diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java index 233850d58..41da85e35 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java @@ -42,22 +42,24 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest @JsonInclude(NON_NULL) private Boolean usePreload; private Map<String, String> supplementaryParams; - public VfModule( @JsonProperty("modelInfo") ModelInfo modelInfo, - @JsonProperty("instanceName") String instanceName, - @JsonProperty("volumeGroupName") String volumeGroupInstanceName, - @JsonProperty("action") String action, - @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, - @JsonProperty("legacyRegion") String legacyRegion, - @JsonProperty("tenantId") String tenantId, - @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, - @JsonProperty("supplementaryFileContent") Map<String, String> supplementaryParams, - @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, - @JsonProperty("sdncPreLoad") Boolean usePreload, - @JsonProperty("instanceId") String instanceId, - @JsonProperty("trackById") String trackById, - @JsonProperty("isFailed") Boolean isFailed, - @JsonProperty("statusMessage") String statusMessage) { - super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage); + public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("volumeGroupName") String volumeGroupInstanceName, + @JsonProperty("action") String action, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, + @JsonProperty("supplementaryFileContent") Map<String, String> supplementaryParams, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("sdncPreLoad") Boolean usePreload, + @JsonProperty("instanceId") String instanceId, + @JsonProperty("trackById") String trackById, + @JsonProperty("isFailed") Boolean isFailed, + @JsonProperty("statusMessage") String statusMessage, + @JsonProperty("position") Integer position) { + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage, + position); this.volumeGroupInstanceName = volumeGroupInstanceName; this.usePreload = usePreload; this.supplementaryParams = supplementaryParams; @@ -107,8 +109,7 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest this.getInstanceId(), this.getTrackById(), this.getIsFailed(), - this.getStatusMessage() - ); - + this.getStatusMessage(), + this.getPosition()); } }
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java index 0da3f0695..fc71f279f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java @@ -44,23 +44,25 @@ public class Vnf extends BaseResource implements JobAdapter.AsyncJobRequest { private final Map<String, Map<String, VfModule>> vfModules; public Vnf(@JsonProperty("modelInfo") ModelInfo modelInfo, - @JsonProperty("productFamilyId") String productFamilyId, - @JsonProperty("instanceName") String instanceName, - @JsonProperty("action") String action, - @JsonProperty("platformName") String platformName, - @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, - @JsonProperty("legacyRegion") String legacyRegion, - @JsonProperty("tenantId") String tenantId, - @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, - @JsonProperty("lineOfBusinessName") String lineOfBusiness, - @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, - @JsonProperty("instanceId") String instanceId, - @JsonProperty("vfModules") Map<String, Map<String, VfModule>> vfModules, - @JsonProperty("trackById") String trackById, - @JsonProperty("isFailed") Boolean isFailed, - @JsonProperty("statusMessage") String statusMessage) { - - super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage); + @JsonProperty("productFamilyId") String productFamilyId, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("platformName") String platformName, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List<Map<String, String>> instanceParams, + @JsonProperty("lineOfBusinessName") String lineOfBusiness, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId, + @JsonProperty("vfModules") Map<String, Map<String, VfModule>> vfModules, + @JsonProperty("trackById") String trackById, + @JsonProperty("isFailed") Boolean isFailed, + @JsonProperty("statusMessage") String statusMessage, + @JsonProperty("position") Integer position) { + + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage, + position); this.productFamilyId = productFamilyId; this.platformName = platformName; this.lineOfBusiness = lineOfBusiness; 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 index 39d433d6a..71d577cd4 100644 --- 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 @@ -19,6 +19,8 @@ */ package org.onap.vid.services; +import static java.util.Collections.emptyList; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.Map; @@ -33,26 +35,31 @@ 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.text,".*") + new LocalWorkflowParameterDefinition(1, "configurationParameters", "Configuration Parameters", true, LocalWorkflowType.text,".*") ) )) .put("VNF In Place Software Update", new LocalWorkflowParameterDefinitions( ImmutableList.of( - new LocalWorkflowParameterDefinition(2, "Operations timeout",true, LocalWorkflowType.text,"[0-9]+"), - new LocalWorkflowParameterDefinition(3, "Existing software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+"), - new LocalWorkflowParameterDefinition(4, "New software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+") + new LocalWorkflowParameterDefinition(2, "operationTimeout", "Operations timeout", true, LocalWorkflowType.text,"[0-9]+"), + new LocalWorkflowParameterDefinition(3, "existingSoftwareVersion", "Existing software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+"), + new LocalWorkflowParameterDefinition(4, "newSoftwareVersion", "New software version", true, LocalWorkflowType.text, "[-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") + new LocalWorkflowParameterDefinition(5, "configUpdateFile", "Attach configuration file", true, LocalWorkflowType.FILE, ".*", "Invalid file type. Please select a file with a CSV extension.", "Invalid file structure.", ".csv") ) )) .build(); + + private LocalWorkflowParameterDefinitions defaultEmptyParams() { + return new LocalWorkflowParameterDefinitions(emptyList()); + } + @Override public LocalWorkflowParameterDefinitions getWorkflowParameterDefinitions(String workflowName) { - return WORKFLOWS_WITH_PARAMETERS.get(workflowName); + return WORKFLOWS_WITH_PARAMETERS.getOrDefault(workflowName, defaultEmptyParams()); } } 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 28b3eea5d..20e964c53 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 @@ -69,6 +69,10 @@ return (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH)); }; + $scope.removeVendorFromCloudOwner = function (cloudOwner) { + return AaiService.removeVendorFromCloudOwner(cloudOwner) + }; + vm.isDisabledVNFmodelVersion = function (vnfTypePristine) { if ($scope.isNewFilterChangeManagmentEnabled()) { return !vm.isSearchedVNF; @@ -225,7 +229,7 @@ $uibModalInstance.close(); }; - vm.uploadConfigFile = function (file) { + vm.uploadConfigFile = function (file, item) { var defer = $q.defer(); Upload.upload({ url: "change-management/uploadConfigUpdateFile", @@ -235,7 +239,7 @@ }] }) .then(function (configUpdateResponse) { - vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload; + item.value = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload; defer.resolve(true); }) .catch(function (error) { @@ -443,6 +447,19 @@ } }; + vm.collectWorkflowFieldsValues = function () { + /** + * Transforms items with name and value properties, to associative map, e.g the array + * [{name: foo, value: bar}, {name: baz, value: fiz}] will become the object {foo: bar, baz: fiz} + */ + return vm.getAllInternalWorkFlowParameters( + vm.changeManagement.workflow + ).reduce(function (result, item) { + result[item.name] = item.value; + return result; + }, {}); + }; + vm.scheduleWorkflow = function () { $scope.widgetParameter = ""; // needed by the scheduler? @@ -456,11 +473,18 @@ } var data = { widgetName: 'Portal-Common-Scheduler', - widgetData: vm.changeManagement, + widgetData: Object.assign({}, vm.changeManagement, vm.collectWorkflowFieldsValues()), widgetParameter: $scope.widgetParameter }; - window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL); + console.log("vm.scheduleWorkflow data:", data); + + if (window.parent !== window.self) { + window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL); + } else { + vm.errorMsg = {message: "Portal not found. Cannot send: " + JSON.stringify(data)}; + throw vm.errorMsg; // prevent popup closure + } }; vm.executeWorkflow = function () { @@ -517,8 +541,34 @@ }); }; + function isCompatibleVNFRole(vnf) { + + return vnf.properties['nf-role'] === vm.changeManagement['vnfType'] || !vm.changeManagement['vnfType']; + + } + + function isValidVnf(vnf) { + + let result = isCompatibleVNFRole(vnf) && vnf.properties["model-invariant-id"] + && vnf.properties["model-version-id"]; + + return result; + } + + function loadCloudRegions() { + AaiService.getLcpCloudRegionTenantList( + vm.changeManagement.subscriberId, + vm.changeManagement.serviceType["service-type"], + function (response) { + $scope.isFeatureFlagCloudOwner = featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST); + $scope.cloudRegionList = _.uniqBy(response, 'cloudRegionOptionId'); + }); + } + vm.serviceTypeChanged = function () { - if (!$scope.isNewFilterChangeManagmentEnabled()) { + if ($scope.isNewFilterChangeManagmentEnabled()) { + loadCloudRegions(); + } else { vm.searchVNFs(); } }; @@ -527,23 +577,30 @@ vm.vnfTypes = []; vm.vnfTypesTemp = []; vm.serviceInstances = []; + vm.fromVNFVersions=[]; + vm.vnfNames =[]; + vm.changeManagement.vnfNames =[]; var instances = vm.changeManagement.serviceType["service-instances"]["service-instance"]; // var promiseArrOfGetVnfs = preparePromiseArrOfGetVnfs(instances); vm.vnfs = []; vm.vfModules = []; - let vnfRole = $scope.isNewFilterChangeManagmentEnabled() ? vm.changeManagement.vnfType : null; + + let vnfRole = null; let cloudRegion = null; + if ($scope.isNewFilterChangeManagmentEnabled()) { + vnfRole = vm.changeManagement.vnfType ? vm.changeManagement.vnfType : null; + cloudRegion = vm.changeManagement.cloudRegion ? vm.changeManagement.cloudRegion : null; + } AaiService.getVnfsByCustomerIdAndServiceType( vm.changeManagement.subscriberId, vm.changeManagement.serviceType["service-type"], vnfRole, cloudRegion, - ). - then(function (response) { + ).then(function (response) { vm.isSearchedVNF = true; var vnfsData = response.data.results; if (vnfsData) { @@ -581,6 +638,9 @@ vm.vnfTypes.push(vnf.properties['nf-role']) }); } + if ($scope.isNewFilterChangeManagmentEnabled()) { + vm.loadVNFVersions(); + } } ); }; @@ -592,9 +652,7 @@ vm.serviceInstancesToGetVersions = []; var versions = []; _.forEach(vm.vnfs, function (vnf) { - if (vnf.properties['nf-role'] === vm.changeManagement['vnfType'] - && vnf.properties["model-invariant-id"] - && vnf.properties["model-version-id"]) { + if (isValidVnf(vnf)) { vm.serviceInstancesToGetVersions.push({ "model-invariant-id": vnf.properties["model-invariant-id"], "model-version-id": vnf.properties["model-version-id"] @@ -665,13 +723,15 @@ }; vm.loadVNFNames = function () { + vm.changeManagement.vnfNames =[]; vm.vnfNames = []; + const vnfs = vm.changeManagement.fromVNFVersion ? vm.vnfs : []; _.forEach(vnfs, function (vnf) { var selectedVersionNumber = getVersionNameForId(vm.changeManagement.fromVNFVersion); - if (vnf.properties['nf-role'] === vm.changeManagement.vnfType && + if (isCompatibleVNFRole(vnf) && selectedVersionNumber === getVersionNameForId(vnf.properties["model-version-id"])) { var vServer = {}; @@ -856,21 +916,23 @@ return form[itemName].$error.validateAsyncFn; }; - vm.getIdFor = function (type, id, name) { - return "internal-workflow-parameter-" + type + "-" + id + "-" + (name ? name.split(' ').join('-').toLowerCase() : ""); + vm.getIdFor = function (type, item) { + return "internal-workflow-parameter-" + type + "-" + item.id + "-" + (item.displayName ? item.displayName.split(' ').join('-').toLowerCase() : ""); }; - vm.getInternalWorkFlowParameters = function (workflow, type) { - if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type == type) != []) { - return vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type == type); + vm.getAllInternalWorkFlowParameters = function (workflow) { + if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow)) { + return vm.localWorkflowsParameters.get(workflow); } return []; }; + vm.getInternalWorkFlowParameters = function (workflow, type) { + return vm.getAllInternalWorkFlowParameters(workflow).filter(parameter => parameter.type === type); + }; + vm.getInternalWorkFlowParameter = function (workflow, type, parameterName) { - if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type == type) != []) { - return vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type == type).filter(parameter => parameter.name === parameterName)[0] - } + return vm.getInternalWorkFlowParameters(workflow, type).filter(parameter => parameter.displayName === parameterName)[0]; }; vm.getRemoteWorkflowSource = (workflow) => { 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 675c1b7c0..e8cba4aa8 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 @@ -318,6 +318,23 @@ describe('Testing workFlows from SO', () => { }); }); + test('Verify get internal workflow parameters should return an empty list if type exist but mapped to undefined', () => { + // given + $featureFlags.isOn = jestMock.fn(() => false); + let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data": undefined}); + + $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); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.css b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.css index 19b5f2b92..dda983409 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.css +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.css @@ -137,8 +137,8 @@ position: relative; } -.nf-role-input { - width: 50% +.new-filter-field { + width: 39% } /*LESS*/ 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 f06d88321..3f2489dbb 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 @@ -22,7 +22,7 @@ <div class="modal-header"> <h3 class="modal-title" id="modal-title">New VNF Change</h3> <span ng-click="vm.close()" class="pull-right modal-close" aria-hidden="true">×</span> - <div ng-if="vm.errorMsg!==''"><font color='red'>{{vm.errorMsg.message}}</font></div> + <div ng-if="vm.errorMsg!==''" style="max-height: 150px; overflow: auto;" data-tests-id="error-message"><font color='red'>{{vm.errorMsg.message}}</font></div> </div> <form class="form-create" data-tests-id="newChangeManagementForm" name="newChangeManagement" ng-submit="vm.openModal();vm.close();" novalidate> @@ -70,22 +70,37 @@ <div ng-if="isNewFilterChangeManagmentEnabled()"> <div class="form-group form-row"> - <div class="col nf-role-input"> + <div class="col new-filter-field"> <label class="control-label">NF Role</label> <input class="form-control" ng-model="vm.changeManagement.vnfType" - name="vnfType" id="vnfTypeInput" + name="vnfType" id="vnfTypeInput" data-tests-id="vnfType" data-ng-disabled="newChangeManagement.serviceType.$pristine"> </div> + <div class="col new-filter-field"> + <label class="control-label">Cloud Region</label> + <select name="cloudRegion" class="form-control" ng-model="vm.changeManagement.cloudRegion" data-tests-id="cloudRegion" id="cloudRegion" + data-ng-disabled="newChangeManagement.serviceType.$pristine"> + <option value="" >select cloud Region</option> + <option ng-repeat="option in cloudRegionList" value="{{option.tenantId}}" + data-ng-if="option.isPermitted && !isFeatureFlagCloudOwner">{{option.cloudRegionId}} + </option> + <option ng-repeat="option in cloudRegionList" value="{{option.tenantId}}" + data-ng-if="option.isPermitted && isFeatureFlagCloudOwner"> + {{option.cloudRegionId}} ({{removeVendorFromCloudOwner(option.cloudOwner).toUpperCase()}}) + </option> + </select> + </div> + <div class="col"> - <button class="search-vnf" type="button" id="searchVNF" name="searchVNFs" class="btn btn-primary" + <button class="btn btn-primary search-vnf" type="button" id="searchVNF" name="searchVNFs" ng-click="vm.searchVNFs()" - ng-disabled="newChangeManagement.subscriber.$pristine || newChangeManagement.serviceType.$pristine"> + ng-disabled="newChangeManagement.subscriber.$pristine || newChangeManagement.serviceType.$pristine" + data-tests-id="searchVNFs"> Search VNFs </button> </div> </div> - </div> @@ -142,16 +157,16 @@ <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> + <label class="control-label">{{item.displayName}}</label> <div class="file-wrapper"> - <input id="{{vm.getIdFor('file',item.id,item.name)}}" ng-change="vm.onChange(item)" class="file-input" - type="file" ngf-select ng-model="item.value" ngf-validate-async-fn="vm.uploadConfigFile($file)" + <input id="{{vm.getIdFor('file',item)}}" ng-change="vm.onChange(item)" class="file-input" + type="file" ngf-select ng-model="item.file" ngf-validate-async-fn="vm.uploadConfigFile($file, item)" ng-attr-name="{{'internal-workflow-parameter-file-name-' + item.id}}" accept="{{item.acceptableFileType}}" ngf-pattern="{{item.acceptableFileType}}" ng-required="{{item.required}}"/> - <label id="{{vm.getIdFor('file',item.id,item.name)}}-label" class="file-input-label"> - {{item.value&&item.value.name||"Select File"}} </label> - <label ng-attr-for="{{vm.getIdFor('file',item.id,item.name)}}"><span class="icon-browse"></span></label> + <label id="{{vm.getIdFor('file',item)}}-label" class="file-input-label"> + {{item.file&&item.file.name||"Select File"}} </label> + <label ng-attr-for="{{vm.getIdFor('file',item)}}"><span class="icon-browse"></span></label> </div> <label id="errorLabel" class="icon-alert error" ng-if="vm.hasPatternError(newChangeManagement, 'internal-workflow-parameter-file-name-' + item.id)">{{item.msgOnPatternError}}</label> @@ -161,8 +176,8 @@ <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'text')"> - <label ng-attr-for="{{vm.getIdFor('text',item.id,item.name)}}" class="control-label">{{item.name}}</label> - <input ng-model="item.value" type="text" id="{{vm.getIdFor('text',item.id,item.name)}}" + <label ng-attr-for="{{vm.getIdFor('text',item)}}" class="control-label">{{item.displayName}}</label> + <input ng-model="item.value" type="text" id="{{vm.getIdFor('text',item)}}" pattern="{{item.pattern}}" ng-required="{{item.required}}"> </div> diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js index 994a3e4ac..0e1beefb6 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js @@ -86,6 +86,23 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }).join("&"); } + function getConfigParams(vnfRole, cloudRegion) { + if (!featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH)) { + return null + } + + let data = { + vnfRole: vnfRole, + cloudRegion: cloudRegion, + }; + + let config = { + params: data + }; + + return config; + } + return { getSubscriberName: function (globalCustomerId, successCallbackFunction) { @@ -630,24 +647,17 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE }, getVnfsByCustomerIdAndServiceType: function (globalSubscriberId, serviceType, vnfRole, cloudRegion) { - var deferred = $q.defer(); + let deferred = $q.defer(); let url = globalSubscriberId + COMPONENT.FORWARD_SLASH + serviceType - if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH)){ - if (vnfRole) { - url + COMPONENT.FORWARD_SLASH + vnfRole - } - if (cloudRegion) { - url + COMPONENT.FORWARD_SLASH + cloudRegion; - } - } - + const path = COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + url; + let config = getConfigParams(vnfRole, cloudRegion); if (UtilityService.hasContents(globalSubscriberId) && UtilityService.hasContents(serviceType)) { - $http.get(COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + url) + $http.get(path, config) .success(function (response) { if (response) { deferred.resolve({data: response}); diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java index 3e38ba883..83cc61ea4 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java @@ -39,6 +39,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; +import java.util.List; import java.util.Map; import java.util.UUID; import javax.ws.rs.core.Response; @@ -295,10 +296,10 @@ public class AaiControllerTest { given(aaiService.getAaiZones()).willReturn(new AaiResponse(aicZones, "", HttpStatus.OK.value())); mockMvc.perform(get("/aai_get_aic_zones") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().json(objectMapper.writeValueAsString(aicZones))); + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(aicZones))); } @Test @@ -308,32 +309,32 @@ public class AaiControllerTest { .willReturn(new AaiResponse(null, expectedErrorMessage, HttpStatus.INTERNAL_SERVER_ERROR.value())); mockMvc.perform(get("/aai_get_aic_zones") - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isInternalServerError()) - .andExpect(content().string(expectedErrorMessage)); + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isInternalServerError()) + .andExpect(content().string(expectedErrorMessage)); } @Test public void getSpecificPnf_shouldReturnPnfObjectForPnfId() throws Exception { String pnfId = "MyPnfId"; Pnf pnf = Pnf.builder() - .withPnfId(pnfId) - .withPnfName("TestPnf") - .withPnfName2("pnfName2") - .withPnfName2Source("pnfNameSource") - .withEquipModel("model") - .withEquipType("type") - .withEquipVendor("vendor") - .build(); + .withPnfId(pnfId) + .withPnfName("TestPnf") + .withPnfName2("pnfName2") + .withPnfName2Source("pnfNameSource") + .withEquipModel("model") + .withEquipType("type") + .withEquipVendor("vendor") + .build(); AaiResponse<Pnf> aaiResponse = new AaiResponse<>(pnf, "", HttpStatus.OK.value()); given(aaiService.getSpecificPnf(pnfId)).willReturn(aaiResponse); mockMvc.perform(get("/aai_get_pnfs/pnf/{pnf_id}", pnfId) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().json(objectMapper.writeValueAsString(pnf))); + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(pnf))); } @Test @@ -343,10 +344,10 @@ public class AaiControllerTest { given(aaiService.getSpecificPnf(pnfId)).willThrow(new RuntimeException(expectedErrorMessage)); mockMvc.perform(get("/aai_get_pnfs/pnf/{pnf_id}", pnfId) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isInternalServerError()) - .andExpect(content().string(expectedErrorMessage)); + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isInternalServerError()) + .andExpect(content().string(expectedErrorMessage)); } public void getPNFInstances_shouldReturnOKResponseFromAAIService() throws Exception { @@ -366,12 +367,12 @@ public class AaiControllerTest { equipModel)).willReturn(aaiResponse); mockMvc.perform( - get(urlTemplate, globalCustomerId, serviceType, modelVersionId, - modelInvariantId, cloudRegion, equipVendor, equipModel) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(expectedResponseBody)); + get(urlTemplate, globalCustomerId, serviceType, modelVersionId, + modelInvariantId, cloudRegion, equipVendor, equipModel) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); } @Test @@ -385,12 +386,12 @@ public class AaiControllerTest { .getVersionByInvariantId(request.versions)).willReturn(response); mockMvc.perform( - post("/aai_get_version_by_invariant_id") - .content(objectMapper.writeValueAsString(request)) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(expectedResponse)); + post("/aai_get_version_by_invariant_id") + .content(objectMapper.writeValueAsString(request)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponse)); } @Test @@ -408,12 +409,12 @@ public class AaiControllerTest { .willReturn(aaiResponse); mockMvc.perform( - get("/aai_sub_details/{subscriberId}", subscriberId) - .param("omitServiceInstances", Boolean.toString(omitServiceInstances)) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody))); + get("/aai_sub_details/{subscriberId}", subscriberId) + .param("omitServiceInstances", Boolean.toString(omitServiceInstances)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody))); } @Test @@ -437,50 +438,98 @@ public class AaiControllerTest { @Test public void getPortMirroringConfigData_givenThreeIds_ReturnsThreeResults() { - final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForA = new AaiResponseTranslator.PortMirroringConfigDataOk("foobar"); - final AaiResponseTranslator.PortMirroringConfigDataError toBeReturnedForB = new AaiResponseTranslator.PortMirroringConfigDataError("foo", "{ baz: qux }"); - final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForC = new AaiResponseTranslator.PortMirroringConfigDataOk("corge"); + final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForA = new AaiResponseTranslator.PortMirroringConfigDataOk( + "foobar"); + final AaiResponseTranslator.PortMirroringConfigDataError toBeReturnedForB = new AaiResponseTranslator.PortMirroringConfigDataError( + "foo", "{ baz: qux }"); + final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForC = new AaiResponseTranslator.PortMirroringConfigDataOk( + "corge"); Mockito - .doReturn(toBeReturnedForA) - .doReturn(toBeReturnedForB) - .doReturn(toBeReturnedForC) - .when(aaiService).getPortMirroringConfigData(Mockito.anyString()); + .doReturn(toBeReturnedForA) + .doReturn(toBeReturnedForB) + .doReturn(toBeReturnedForC) + .when(aaiService).getPortMirroringConfigData(Mockito.anyString()); - final Map<String, AaiResponseTranslator.PortMirroringConfigData> result = aaiController.getPortMirroringConfigsData(ImmutableList.of("a", "b", "c")); + final Map<String, AaiResponseTranslator.PortMirroringConfigData> result = aaiController + .getPortMirroringConfigsData(ImmutableList.of("a", "b", "c")); assertThat(result, is(ImmutableMap.of( - "a", toBeReturnedForA, - "b", toBeReturnedForB, - "c", toBeReturnedForC + "a", toBeReturnedForA, + "b", toBeReturnedForB, + "c", toBeReturnedForC ))); } @Test public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsFalse() - throws Exception { + throws Exception { boolean isFeatureActive = false; boolean omitServiceInstances = false; getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances); } private void getSubscriberDetails_assertServiceInstancesInclusion(boolean isFeatureActive, - boolean omitServiceInstances) throws Exception { + boolean omitServiceInstances) throws Exception { String subscriberId = "subscriberId"; String okResponseBody = "OK_RESPONSE"; AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value()); given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive); given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class), - eq(isFeatureActive && omitServiceInstances))) - .willReturn(aaiResponse); + eq(isFeatureActive && omitServiceInstances))) + .willReturn(aaiResponse); mockMvc.perform( - get("/aai_sub_details/{subscriberId}", subscriberId) - .param("omitServiceInstances", Boolean.toString(omitServiceInstances)) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody))); + get("/aai_sub_details/{subscriberId}", subscriberId) + .param("omitServiceInstances", Boolean.toString(omitServiceInstances)) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody))); + } + + @Test + public void getSpecificConfiguration_shouldReturnOkResponse() throws Exception { + String configurationId = "testGlobalCustomerId"; + String expectedResponseBody = "OK_RESPONSE"; + Response response = mock(Response.class); + given(response.readEntity(String.class)).willReturn(expectedResponseBody); + given(response.getStatus()).willReturn(HttpStatus.OK.value()); + + given(aaiRestInterface.RestGet( + eq("VidAaiController"), + anyString(), + eq(Unchecked.toURI("network/configurations/configuration/" + configurationId)), + eq(false)).getResponse()).willReturn(response); + + mockMvc + .perform( + get("/aai_get_configuration/{configuration_id}", configurationId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(expectedResponseBody)); } + + @Test + public void getServiceInstanceAssociatedPnfs_shouldReturnPnfs() throws Exception { + String globalCustomerId = "testCustomerId"; + String serviceType = "testServiceType"; + String serviceInstanceId = "testServiceInstanceId"; + List<String> expectedPnfs = ImmutableList.of("pnf1", "pnf2", "pnf3"); + + given(aaiService.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId)) + .willReturn(expectedPnfs); + + mockMvc + .perform( + get("/aai_get_service_instance_pnfs/{globalCustomerId}/{serviceType}/{serviceInstanceId}", + globalCustomerId, serviceType, serviceInstanceId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(objectMapper.writeValueAsString(expectedPnfs))); + } + } diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java index a32450510..5aa6505d4 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java @@ -127,6 +127,137 @@ public class MsoControllerTest { } @Test + public void shouldCreateVfModuleInstance() throws Exception { + // given + RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class); + String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014"; + String vnfInstanceId = "fe9000-0009-9999"; + + MsoResponseWrapper expectedResponse = new MsoResponseWrapper(200, "test"); + given(msoBusinessLogic + .createVfModuleInstance(objectEqualTo(requestDetails), eq(serviceInstanceId), eq(vnfInstanceId))) + .willReturn(expectedResponse); + + // when & then + mockMvc.perform(post(format("/mso/mso_create_vfmodule_instance/%s/vnfs/%s", serviceInstanceId, vnfInstanceId)) + .content(asJson(requestDetails)) + .contentType(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(asJson(expectedResponse))); + + then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails)); + } + + @Test + public void shouldCreateConfigurationInstance() throws Exception { + // given + RequestDetailsWrapper requestDetails = modelGenerator.nextObject(RequestDetailsWrapper.class); + String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014"; + + MsoResponseWrapper expectedResponse = new MsoResponseWrapper(200, "test"); + given(msoBusinessLogic + .createConfigurationInstance(objectEqualTo(requestDetails), eq(serviceInstanceId))) + .willReturn(expectedResponse); + + // when & then + mockMvc.perform(post(format("/mso/mso_create_configuration_instance/%s/configurations/", serviceInstanceId)) + .content(asJson(requestDetails)) + .contentType(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(asJson(expectedResponse))); + + then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails.getRequestDetails())); + } + + @Test + public void shouldDeleteE2eSvcInstance() throws Exception { + // given + RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class); + String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014"; + String configurationId = "28630972-d548-4d5f-acc2-ad1d748d023d"; + + MsoResponseWrapper expectedResponse = new MsoResponseWrapper(200, "test"); + given(msoBusinessLogic + .setConfigurationActiveStatus(objectEqualTo(requestDetails), eq(serviceInstanceId), eq(configurationId), eq(true))) + .willReturn(expectedResponse); + + // when & then + mockMvc.perform(post(format("/mso/mso_activate_configuration/%s/configurations/%s", serviceInstanceId, configurationId)) + .content(asJson(requestDetails)) + .contentType(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(asJson(expectedResponse))); + + then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails)); + } + + @Test + public void shouldDeactivateConfiguration() throws Exception { + // given + RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class); + String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014"; + String configurationId = "28630972-d548-4d5f-acc2-ad1d748d023d"; + + MsoResponseWrapper expectedResponse = new MsoResponseWrapper(200, "test"); + given(msoBusinessLogic + .setConfigurationActiveStatus(objectEqualTo(requestDetails), eq(serviceInstanceId), eq(configurationId), eq(false))) + .willReturn(expectedResponse); + + // when & then + mockMvc.perform(post(format("/mso/mso_deactivate_configuration/%s/configurations/%s", serviceInstanceId, configurationId)) + .content(asJson(requestDetails)) + .contentType(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(asJson(expectedResponse))); + + then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails)); + } + + @Test + public void shouldDisablePortOnConfiguration() throws Exception { + // given + RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class); + String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014"; + String configurationId = "28630972-d548-4d5f-acc2-ad1d748d023d"; + + MsoResponseWrapper expectedResponse = new MsoResponseWrapper(200, "test"); + given(msoBusinessLogic + .setPortOnConfigurationStatus(objectEqualTo(requestDetails), eq(serviceInstanceId), eq(configurationId), eq(false))) + .willReturn(expectedResponse); + + // when & then + mockMvc.perform(post(format("/mso/mso_disable_port_configuration/%s/configurations/%s", serviceInstanceId, configurationId)) + .content(asJson(requestDetails)) + .contentType(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(asJson(expectedResponse))); + + then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails)); + } + + @Test + public void shouldEnablePortOnConfiguration() throws Exception { + // given + RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class); + String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014"; + String configurationId = "28630972-d548-4d5f-acc2-ad1d748d023d"; + + MsoResponseWrapper expectedResponse = new MsoResponseWrapper(200, "test"); + given(msoBusinessLogic + .setPortOnConfigurationStatus(objectEqualTo(requestDetails), eq(serviceInstanceId), eq(configurationId), eq(true))) + .willReturn(expectedResponse); + + // when & then + mockMvc.perform(post(format("/mso/mso_enable_port_configuration/%s/configurations/%s", serviceInstanceId, configurationId)) + .content(asJson(requestDetails)) + .contentType(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().json(asJson(expectedResponse))); + + then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails)); + } + + @Test public void shouldCreateVolumeInstance() throws Exception { // given RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class); diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java index 39638c305..5f80e04a0 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java @@ -18,42 +18,57 @@ * ============LICENSE_END========================================================= */ -package org.onap.vid.controller; +package org.onap.vid.controller.filter; -import com.google.common.collect.ImmutableMap; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.mockito.stubbing.Answer; -import org.onap.portalsdk.core.web.support.UserUtils; -import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter; -import org.springframework.mock.web.MockHttpServletResponse; -import org.testng.annotations.Test; +import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.emptyOrNullString; +import static org.hamcrest.Matchers.equalToIgnoringCase; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.not; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; +import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID; +import com.google.common.collect.ImmutableMap; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Map; +import java.util.UUID; +import java.util.function.Function; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; -import java.util.function.Function; - -import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.argThat; -import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +import org.mockito.stubbing.Answer; +import org.onap.portalsdk.core.web.support.UserUtils; +import org.springframework.mock.web.MockHttpServletResponse; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; @Test -public class PromiseEcompRequestIdFilterTest { +public class PromiseRequestIdFilterTest { private final String anotherHeader = "ANDREI_RUBLEV"; private final String anotherValue = "foo value"; private final String mixedCaseHeader = "x-ecomp-REQUESTID"; + private static final String onapRequestIdHeader = "x-onap-requestid"; + private static final String transactionIdHeader = "x-transactionid"; + private static final String requestIdHeader = "x-requestid"; + + private final PromiseRequestIdFilter promiseRequestIdFilter = new PromiseRequestIdFilter(); + @Test public void givenRequestIdHeader_headerValueNotChanged() throws IOException, ServletException { @@ -105,8 +120,119 @@ public class PromiseEcompRequestIdFilterTest { buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, UserUtils::getRequestId); } - - private void buildRequestThenRunThroughFilterAndAssertResultRequestHeaders( + @Test + public void givenTwoRequestIdHeader_onapHeaderValueIsUsed() throws IOException, ServletException { + + final String onapTxId = "863850e2-8545-4efd-94b8-AFBA5F52B3D5"; // note mixed case + final String ecompTxId = "6e8ff89e-88a4-4977-b63f-3142892b6e08"; + + final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of( + anotherHeader, anotherValue, + ECOMP_REQUEST_ID, ecompTxId, + onapRequestIdHeader, onapTxId + ); + + buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(onapTxId)); + } + + @Test + public void givenTwoRequestIdHeaderAndHigherPriorityIsMalformed_headerValueIsGenerated() throws IOException, ServletException { + + final String malformedTxId = "6e8ff89e-88a4-4977-b63f-3142892b6e08-"; + final String anotherTxId = "863850e2-8545-4efd-94b8-afba5f52b3d5"; + + final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of( + anotherHeader, anotherValue, + requestIdHeader, malformedTxId, // requestIdHeader as higher priority than transactionIdHeader + transactionIdHeader, anotherTxId + ); + + HttpServletRequest wrappedRequest = + buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, UserUtils::getRequestId); + + assertThat(UserUtils.getRequestId(wrappedRequest), + not(anyOf(equalTo(malformedTxId), equalTo(anotherTxId))) + ); + } + + + @Test + public void toUuidOrElse_givenValid_yieldSame() { + final String someTxId = "729bbd8d-b0c2-4809-a794-DCCCD9CDA2C0"; // note mixed case + UUID unexpected = UUID.randomUUID(); + assertThat(promiseRequestIdFilter.toUuidOrElse(someTxId, () -> unexpected), is(UUID.fromString(someTxId))); + } + + @Test + public void toUuidOrElse_givenNull_yieldSupplier() { + UUID expected = UUID.fromString("729bbd8d-b0c2-4809-a794-dcccd9cda2c0"); + assertThat(promiseRequestIdFilter.toUuidOrElse(null, () -> expected), is(expected)); + } + + @Test + public void toUuidOrElse_givenMalformed_yieldSupplier() { + UUID expected = UUID.fromString("729bbd8d-b0c2-4809-a794-dcccd9cda2c0"); + assertThat(promiseRequestIdFilter.toUuidOrElse("malformed uuid", () -> expected), is(expected)); + } + + @DataProvider + public static Object[][] severalRequestIdHeaders() { + String someTxId = "69fa2575-d7f2-482c-ad1b-53a63ca03617"; + String anotherTxId = "06de373b-7e19-4357-9bd1-ed95682ae3a4"; + + return new Object[][]{ + { + "header is selected when single", transactionIdHeader, + ImmutableMap.of( + transactionIdHeader, someTxId + ) + }, { + "header is selected when first", onapRequestIdHeader, + ImmutableMap.of( + onapRequestIdHeader, someTxId, + "noise-header", anotherTxId, + ECOMP_REQUEST_ID, anotherTxId + ) + }, { + "header is selected when last", onapRequestIdHeader, + ImmutableMap.of( + ECOMP_REQUEST_ID, anotherTxId, + "noise-header", anotherTxId, + onapRequestIdHeader, someTxId + ) + }, { + "header is selected when value is invalid uuid", onapRequestIdHeader, + ImmutableMap.of( + onapRequestIdHeader, "invalid-uuid" + ) + }, { + "header is selected when no ecomp-request-id", onapRequestIdHeader, + ImmutableMap.of( + requestIdHeader, anotherTxId, + onapRequestIdHeader, someTxId + ) + }, { + "ECOMP_REQUEST_ID is returned when no request-id header", ECOMP_REQUEST_ID, + ImmutableMap.of( + "tsamina-mina", anotherTxId, + "waka-waka", anotherTxId + ) + }, + }; + } + + @Test(dataProvider = "severalRequestIdHeaders") + public void highestPriorityHeader_givenSeveralRequestIdHeaders_correctHeaderIsUsed(String description, String expectedHeader, Map<String, String> incomingRequestHeaders) { + PromiseRequestIdFilter testSubject = promiseRequestIdFilter; + + HttpServletRequest mockedHttpServletRequest = createMockedHttpServletRequest(incomingRequestHeaders); + + assertThat(description, + testSubject.highestPriorityHeader(mockedHttpServletRequest), equalToIgnoringCase(expectedHeader)); + } + + + private HttpServletRequest buildRequestThenRunThroughFilterAndAssertResultRequestHeaders( ImmutableMap<String, String> originalRequestHeaders, Function<HttpServletRequest, String> txIdExtractor ) throws IOException, ServletException { @@ -119,7 +245,7 @@ public class PromiseEcompRequestIdFilterTest { // // doFilter() is the function under test // - new PromiseEcompRequestIdFilter().doFilter(servletRequest, servletResponse, capturingFilterChain); + promiseRequestIdFilter.doFilter(servletRequest, servletResponse, capturingFilterChain); // ////////////////// @@ -129,6 +255,8 @@ public class PromiseEcompRequestIdFilterTest { assertRequestObjectHeaders(capturedServletRequest, expectedTxId); assertResponseObjectHeaders(capturedServletResponse, expectedTxId); + + return (HttpServletRequest) capturedServletRequest; } @@ -142,14 +270,14 @@ public class PromiseEcompRequestIdFilterTest { final HttpServletRequest httpServletRequest = (HttpServletRequest) request; assertThat(Collections.list(httpServletRequest.getHeaderNames()), - containsInAnyOrder(equalToIgnoringCase(ECOMP_REQUEST_ID), equalToIgnoringCase(anotherHeader))); + hasItems(equalToIgnoringCase(ECOMP_REQUEST_ID), equalToIgnoringCase(anotherHeader))); assertThat(httpServletRequest.getHeader(anotherHeader), is(anotherValue)); - assertThat(httpServletRequest.getHeader(ECOMP_REQUEST_ID), is(expectedTxId)); - assertThat(httpServletRequest.getHeader(mixedCaseHeader), is(expectedTxId)); + assertThat(httpServletRequest.getHeader(ECOMP_REQUEST_ID), equalToIgnoringCase(expectedTxId)); + assertThat(httpServletRequest.getHeader(mixedCaseHeader), equalToIgnoringCase(expectedTxId)); - assertThat(UserUtils.getRequestId(httpServletRequest), is(expectedTxId)); + assertThat(UserUtils.getRequestId(httpServletRequest), equalToIgnoringCase(expectedTxId)); assertThat(UserUtils.getRequestId(httpServletRequest), is(not(emptyOrNullString()))); } @@ -158,7 +286,7 @@ public class PromiseEcompRequestIdFilterTest { final HttpServletResponse httpServletResponse = (HttpServletResponse) response; assertThat("header " + REQUEST_ID_HEADER_NAME_IN_RESPONSE.toLowerCase() + " in response must be provided", - httpServletResponse.getHeader(REQUEST_ID_HEADER_NAME_IN_RESPONSE), is(txId)); + httpServletResponse.getHeader(REQUEST_ID_HEADER_NAME_IN_RESPONSE), equalToIgnoringCase(txId)); } diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java index 2780e1515..9501614b7 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java @@ -273,30 +273,35 @@ public class ResourceCommandTest { } static InstanceGroup createGroup(List<InstanceGroupMember> groupMembers, Action action) { - return new InstanceGroup(mock(ModelInfo.class), null, action.name(), false, null, convertToMap(groupMembers), null, null, null); + return new InstanceGroup(mock(ModelInfo.class), null, action.name(), false, null, convertToMap(groupMembers), null, null, null, + null); } static InstanceGroupMember createMember(Action action) { - return new InstanceGroupMember(null, action.toString(), null, null, null); + return new InstanceGroupMember(null, action.toString(), null, null, null, null); } static Vnf createVnf(List<VfModule> vfModules, Action action) { Map<String, Map<String, VfModule>> vfModulesMap = new HashMap<>(); vfModulesMap.put("abc",convertToMap(vfModules)); - return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, vfModulesMap, null, null, null); + return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, vfModulesMap, null, null, null, + null); } static Vnf createVnf(Action action) { - return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null,null, null, null, null); + return new Vnf(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null,null, null, null, null, + null); } static VfModule createVfModule(Action action) { - return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, false, false, null, null, null, null); + return new VfModule(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, false, false, null, null, null, null, + null); } static Network createNetwork(Action action) { - return new Network(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, null, null, null); + return new Network(mock(ModelInfo.class), null, null, action.toString(), null, null, null, null, null, null, false, null, null, null, null, + null); } } diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java index 20a05e334..ac05ea706 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java @@ -50,7 +50,7 @@ import org.mockito.MockitoAnnotations; import org.onap.vid.aai.util.AAIRestInterface; import org.onap.vid.aai.util.ServletRequestHelper; import org.onap.vid.aai.util.SystemPropertyHelper; -import org.onap.vid.controller.filter.PromiseEcompRequestIdFilter; +import org.onap.vid.controller.filter.PromiseRequestIdFilter; import org.onap.vid.testUtils.TestUtils; import org.onap.vid.utils.Logging; import org.onap.vid.utils.Unchecked; @@ -65,6 +65,7 @@ import org.testng.annotations.Test; public class OutgoingRequestHeadersTest { + private static final PromiseRequestIdFilter promiseRequestIdFilter = new PromiseRequestIdFilter(); // @InjectMocks // private RestMsoImplementation restMsoImplementation; @@ -96,7 +97,8 @@ public class OutgoingRequestHeadersTest { } public static void putRequestInSpringContext() { - RequestContextHolder.setRequestAttributes(new ServletRequestAttributes((HttpServletRequest) PromiseEcompRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest()))); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes( + (HttpServletRequest) promiseRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest()))); } // @DataProvider diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java index 9cc97116b..9c0260e85 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java @@ -171,11 +171,12 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests vfModuleInfo.setModelInvariantId("22222222-f63c-463e-ba94-286933b895f9"); vfModuleInfo.setModelVersion("10.0"); return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), "mdt1", null, - "88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null, UUID.randomUUID().toString(), null, null); + "88a6ca3ee0394ade9403f075db23167e", instanceParams, supplementaryParams, false, true, null, UUID.randomUUID().toString(), null, null, + null); } return new VfModule(vfModuleInfo, instanceName, volumeGroupInstanceName, Action.Create.name(), null, null, null, - instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null, null); + instanceParams, supplementaryParams, false, false, null, UUID.randomUUID().toString(), null, null, null); } protected ModelInfo createVfModuleModelInfo(String modelName, String modelVersion, String modelVersionId, String modelInvariantId, String modelCustomizationId, String modelCustomizationName) { @@ -184,7 +185,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName, String lcpCloudRegionId, String tenantId) { return new VfModule( vfModuleModelInfo, instanceName, null, Action.Upgrade.name(), lcpCloudRegionId, null, tenantId, - null, null, true, null, null, UUID.randomUUID().toString(), null, null); + null, null, true, null, null, UUID.randomUUID().toString(), null, null, null); } protected ModelInfo createVnfModelInfo(boolean isAlacarte) { @@ -267,7 +268,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests Vnf vnf = new Vnf(vnfModelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", (isUserProvidedNaming ? VNF_NAME : null), Action.Create.name(), "platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", vnfInstanceParams,"lineOfBusinessName" , false, null, vfModules, - UUID.randomUUID().toString(), null, null); + UUID.randomUUID().toString(), null, null, null); vnfs.put(vnf.getModelInfo().getModelName(), vnf); return vnfs; @@ -320,7 +321,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests details->new Network(createNetworkModelInfo(isALaCarte, details.modelCustomizationId), "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", details.name, Action.Create.name(), "platformName", "mdt1", null, "88a6ca3ee0394ade9403f075db23167e", instanceParams,"lineOfBusinessName" , - false, null, UUID.randomUUID().toString(), null, null)); + false, null, UUID.randomUUID().toString(), null, null, null)); // I can't tell why compiler don't like the statement if it's only one line... return networkStream.collect(Collectors.toMap(network -> network.getModelInfo().getModelCustomizationId(), network -> network)); } @@ -335,7 +336,8 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests modelInfo.setModelInvariantId("11111111-f63c-463e-ba94-286933b895f9"); modelInfo.setModelVersion("10.0"); - return new InstanceGroup(modelInfo, (isUserProvidedNaming ? VNF_GROUP_NAME : null), action.name(), false, null, emptyMap(), UUID.randomUUID().toString(), null, null); + return new InstanceGroup(modelInfo, (isUserProvidedNaming ? VNF_GROUP_NAME : null), action.name(), false, null, emptyMap(), UUID.randomUUID().toString(), null, null, + null); } protected ModelInfo createServiceModelInfo() { diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java index ce0aa42f2..c1a6abc73 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java @@ -1048,7 +1048,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT public void whenLcpRegionNotEmpty_thenCloudRegionIdOfResourceIsLegacy() { String legacyCloudRegion = "legacyCloudRegion"; Vnf vnf = new Vnf(new ModelInfo(), null, null, Action.Create.name(), null, "anyCloudRegion", legacyCloudRegion, - null, null, null, false, null, null, UUID.randomUUID().toString(), null, null); + null, null, null, false, null, null, UUID.randomUUID().toString(), null, null, null); assertThat(vnf.getLcpCloudRegionId(), equalTo(legacyCloudRegion)); } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java index 2c70b3ddc..e28ea304f 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java @@ -533,7 +533,8 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest { " }" + "}"; Vnf vnfDetails = new Vnf(createVnfModelInfo(true), "productFamily", "instanceName", Action.Delete.name(), "platform", "AAIAIC25", null, - "092eb9e8e4b7412e8787dd091bc58e86", null, null, false, "VNF_INSTANCE_ID", null, UUID.randomUUID().toString(), null, null); + "092eb9e8e4b7412e8787dd091bc58e86", null, null, false, "VNF_INSTANCE_ID", null, UUID.randomUUID().toString(), null, null, + null); RequestDetailsWrapper<VnfInstantiationRequestDetails> result = msoRequestBuilder.generateDeleteVnfRequest(vnfDetails, "az2018"); MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result); diff --git a/vid-automation/src/main/java/vid/automation/test/Constants.java b/vid-automation/src/main/java/vid/automation/test/Constants.java index a81757ef6..689c46387 100644 --- a/vid-automation/src/main/java/vid/automation/test/Constants.java +++ b/vid-automation/src/main/java/vid/automation/test/Constants.java @@ -94,6 +94,9 @@ public class Constants { public static final String newModalSubscriberInputId = "subscriber"; public static final String newModalServiceTypeInputId = "serviceType"; public static final String newModalVNFTypeInputId = "vnfType"; + public static final String newModalVNFTypeInputId1 = "vnfTypeInput"; + public static final String newModalVNFCloudRegion = "cloudRegion"; + public static final String newModalVNFSearchVNF = "searchVNF"; public static final String newModalFromVNFVersionInputId = "fromVNFVersion"; public static final String newModalVNFNameInputId = "vnfName"; public static final String newModalWorkFlowInputId = "workflow"; diff --git a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java index 6b7fe1252..f69880aa5 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java @@ -1,16 +1,24 @@ package vid.automation.test.test; +import static java.util.Collections.emptyMap; +import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.everyItem; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.hamcrest.core.IsNot.not; +import static org.onap.simulator.presetGenerator.presets.aai.PresetBaseAAICustomQuery.FORMAT.SIMPLE; +import static org.onap.vid.api.BaseApiTest.getResourceAsString; +import static vid.automation.test.infra.Features.FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.Ints; import java.sql.Connection; @@ -19,13 +27,17 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import net.javacrumbs.jsonunit.core.Option; import org.json.JSONException; import org.junit.Assert; import org.onap.sdc.ci.tests.datatypes.UserCredentials; import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetTenants; +import org.onap.simulator.presetGenerator.presets.aai.PresetBaseAAICustomQuery; import org.onap.simulator.presetGenerator.presets.scheduler.PresetDeleteSchedulerChangeManagement; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; @@ -55,6 +67,7 @@ import vid.automation.test.utils.DB_CONFIG; public class ChangeManagementTest extends VidBaseTestCase { public static final String SCHEDULED_ID = "0b87fe60-50b0-4bac-a0a7-49e951b0ba9e"; + private final String SCHEDULE_ERROR_PREFIX = "Portal not found. Cannot send: "; @Test public void testLeftPanelChangeManagementButton() { @@ -76,7 +89,15 @@ public class ChangeManagementTest extends VidBaseTestCase { Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalSubscriberInputId)); Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalServiceTypeInputId)); Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFNameInputId)); - Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId)); + + if (Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH.isActive()) { + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId1)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFCloudRegion)); + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFSearchVNF)); + } else { + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId)); + } + Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalFromVNFVersionInputId)); Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalWorkFlowInputId)); Assert.assertTrue(Exists.byId(Constants.generalSubmitButtonId)); @@ -88,6 +109,7 @@ public class ChangeManagementTest extends VidBaseTestCase { String subscriberName = VNF_DATA_WITH_IN_PLACE.subscriberName; String serviceType = VNF_DATA_WITH_IN_PLACE.serviceType; String vnfType = VNF_DATA_WITH_IN_PLACE.vnfType; + String cloudRegion = VNF_DATA_WITH_IN_PLACE.cloudRegion; String vnfSourceVersion = VNF_DATA_WITH_IN_PLACE.vnfSourceVersion; ChangeManagementPage.openNewChangeManagementModal(); Wait.angularHttpRequestsLoaded(); @@ -98,8 +120,15 @@ public class ChangeManagementTest extends VidBaseTestCase { SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalServiceTypeInputId, serviceType); Wait.angularHttpRequestsLoaded(); - SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFTypeInputId, vnfType); + if (Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH.isActive()) { + Input.text(vnfType, Constants.ChangeManagement.newModalVNFTypeInputId); + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFCloudRegion, cloudRegion); + Click.byId(Constants.ChangeManagement.newModalVNFSearchVNF); + } else { + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFTypeInputId, vnfType); + } Wait.angularHttpRequestsLoaded(); + SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalFromVNFVersionInputId, vnfSourceVersion); Wait.angularHttpRequestsLoaded(); Click.byId(Constants.ChangeManagement.newModalVNFNameInputId); @@ -142,6 +171,7 @@ public class ChangeManagementTest extends VidBaseTestCase { static String subscriberName = "Emanuel"; static String serviceType = "vRichardson"; static String vnfType = "vMobileDNS"; + static String cloudRegion = "AAIAIC25 (AIC)"; static String vnfSourceVersion = "1.0"; static String vnfName = "zolson3amdns02test2"; static String vnfTargetVersion = "5.0"; @@ -176,7 +206,7 @@ public class ChangeManagementTest extends VidBaseTestCase { @BeforeClass protected void registerToSimulator() { SimulatorApi.clearAll(); - SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND, + SimulatorApi.registerExpectation(APPEND, "changeManagement/ecompportal_getSessionSlotCheckInterval.json" , "changeManagement/get_aai_sub_details.json" , "changeManagement/get_sdc_catalog_services_2f80c596.json" @@ -187,8 +217,36 @@ public class ChangeManagementTest extends VidBaseTestCase { , "changeManagement/mso_post_manual_task.json" , "changeManagement/mso_get_change_managements_scaleout.json" ); + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), APPEND); + if(FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG.isActive()){ + String AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS = "registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_with_modelVer.json"; + String globalCustomerId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"; + String serviceType = "vRichardson"; + SimulatorApi.registerExpectationFromPreset(new PresetBaseAAICustomQuery( + SIMPLE, + "/business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/" + + serviceType + "/service-instances", + "query/vnfs-fromServiceInstance-filter" + ) { + @Override + public Object getResponseBody() { + return getResourceAsString( + AAI_VNFS_FOR_CHANGE_MANAGEMENT_JSON_BY_PARAMS); + } + }, APPEND); + } + + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.APPEND); + if (Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH.isActive()) { + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetTenants( + VNF_DATA_WITH_IN_PLACE.subscriberId, + VNF_DATA_WITH_IN_PLACE.serviceType, + "presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json"), SimulatorApi.RegistrationStrategy.APPEND); + + } + registerDefaultTablesData(); resetGetServicesCache(); } @@ -200,7 +258,7 @@ public class ChangeManagementTest extends VidBaseTestCase { , "changeManagement/delete_scheduled_task.json"}, ImmutableMap.of( "<SCHEDULE_ID>", SCHEDULED_ID, - "<IN_PROGRESS_DATE>", "Fri, 08 Sep 2017 19:34:32 GMT"), SimulatorApi.RegistrationStrategy.APPEND + "<IN_PROGRESS_DATE>", "Fri, 08 Sep 2017 19:34:32 GMT"), APPEND ); } @@ -276,7 +334,7 @@ public class ChangeManagementTest extends VidBaseTestCase { @Test public void clickOnScheduledJob_SuccessfulMessageAppear() { - SimulatorApi.registerExpectationFromPreset(new PresetDeleteSchedulerChangeManagement(), SimulatorApi.RegistrationStrategy.APPEND); + SimulatorApi.registerExpectationFromPreset(new PresetDeleteSchedulerChangeManagement(), APPEND); ChangeManagementPage.openChangeManagementPage(); GeneralUIUtils.ultimateWait(); @@ -334,7 +392,7 @@ public class ChangeManagementTest extends VidBaseTestCase { public void updateSimulatorWithParametersOfScheduledJod(String jasonFile) { SimulatorApi.registerExpectation( new String[]{"changeManagement/" + jasonFile}, - ImmutableMap.of("<SCHEDULE_ID>", SCHEDULED_ID), SimulatorApi.RegistrationStrategy.APPEND + ImmutableMap.of("<SCHEDULE_ID>", SCHEDULED_ID), APPEND ); } @@ -463,10 +521,33 @@ public class ChangeManagementTest extends VidBaseTestCase { }; } - // Deleted testVidToMsoCallbackDataWithInPlaceSWUpdate test. It was using assertThatVidToMsoCallbackDataIsOk which is no longer valid. + @Test(dataProvider = "dataForUpdateWorkflowPartialWithInPlace") + public void testVidToMsoCallbackDataWithInPlaceSWUpdate(String operationsTimeout, String existingSwVersion, String newSwVersion) { + + openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate(); + fillVNFInPlace3Fields(operationsTimeout, existingSwVersion, newSwVersion); + + assertThatVidToPortalCallbackDataIsOk(VNF_DATA_WITH_IN_PLACE.workflowName, ImmutableMap.of( + "existingSoftwareVersion", existingSwVersion, + "newSoftwareVersion", newSwVersion, + "operationTimeout", operationsTimeout + )); + } + @Test + public void testUploadConfigUpdateFile() { + String fileName = "configuration_file.csv"; + updateConfigFile(fileName); + Assert.assertEquals(Get.byId(Constants.ChangeManagement.newModalConfigUpdateInputId + "-label").getText(), fileName); + Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled()); + assertThatVidToPortalCallbackDataIsOk("VNF Config Update", ImmutableMap.of( + "configUpdateFile", + "{\"request-parameters\":{\"vm\":[{\"vnfc\":[" + + "{\"vnfc-name\":\"ibcx0001vm001dbg001\",\"vnfc-function-code\":\"dbg\"}],\"vm-name\":\"ibcx0001vm001\"}," + + "{\"vnfc\":[{\"vnfc-name\":\"ibcx0001vm002dbg001\"}],\"vm-name\":\"ibcx0001vm002\"}]},\"configuration-parameters\":{\"node0_hostname\":\"dbtx0001vm001\"}}" + )); + } - // Deleted testUploadConfigUpdateFile test. It was using assertThatVidToMsoCallbackDataIsOk which is no longer valid. @FeatureTogglingTest(value = Features.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH, flagActive = false) @Test public void testUploadConfigUpdateNonCsvFile() { @@ -495,7 +576,14 @@ public class ChangeManagementTest extends VidBaseTestCase { }; } - // Deleted testVidToMsoCallbackData test. It was using assertThatVidToMsoCallbackDataIsOk which is no longer valid. + @Test + public void testVidToMsoCallbackData() { + String workflow = "Replace"; + + openAndFill1stScreen(VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, workflow); + + assertThatVidToPortalCallbackDataIsOk(workflow, emptyMap()); + } private void assertThatVidToMsoCallbackDataIsOk(String workflow, String payload) { Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled()); @@ -516,6 +604,42 @@ public class ChangeManagementTest extends VidBaseTestCase { Click.byId(Constants.generalCancelButtonId); } + private void assertThatVidToPortalCallbackDataIsOk(String workflowName, Map<String, String> workflowParams) { + Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled()); + Click.byId(Constants.generalSubmitButtonId); + + String errorMessage = GeneralUIUtils.getWebElementByTestID("error-message", 2).getText(); + + String modelInvariantId = "72e465fe-71b1-4e7b-b5ed-9496118ff7a8"; + String vnfInstanceId = "8e5e3ba1-3fe6-4d86-966e-f9f03dab4855"; + + assertThat(errorMessage, startsWith(SCHEDULE_ERROR_PREFIX)); + assertThat(errorMessage.replace(SCHEDULE_ERROR_PREFIX, ""), jsonEquals( + ImmutableMap.of( + "widgetName", "Portal-Common-Scheduler", + "widgetParameter", "", + "widgetData", ImmutableMap.builder() + .put("vnfNames", ImmutableList.of(ImmutableMap.of( + "id", vnfInstanceId, + "invariant-id", modelInvariantId + ))) + .put("workflowParameters", emptyMap()) + .put("subscriberId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + .put("fromVNFVersion", "" + "76e908e0-5201-44d2-a3e2-9e6128d05820" + "") + .put("workflow", "" + workflowName + "") + .put("policyYN", "Y") + .put("sniroYN", "Y") + .put("testApi", "VNF_API") + .put("vnfType", "vMobileDNS") + .putAll(workflowParams) + .build() + ) + ).when(Option.IGNORING_EXTRA_FIELDS)); + + + Click.byId(Constants.generalCancelButtonId); + } + @Test(enabled = false) public void testUpdateWorkflowNow() { diff --git a/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json b/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json new file mode 100644 index 000000000..8cd6d19a7 --- /dev/null +++ b/vid-automation/src/main/resources/presets_templates/PresetAAIGetTenants_service_type_vWINIFRED.json @@ -0,0 +1,128 @@ +{ + "service-type": "vWINIFRED", + "resource-version": "1494001841964", + "relationship-list": { + "relationship": [ + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/AAIAIC25/tenants/tenant/092eb9e8e4b7412e8787dd091bc58e86", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "irma-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIAIC25" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "092eb9e8e4b7412e8787dd091bc58e86" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "USP-SIP-IC-24335-T-01" + } + ] + }, + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/bae71557c5bb4d5aac6743a4e5f1d054", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "irma-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "hvf6" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "bae71557c5bb4d5aac6743a4e5f1d054" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "AIN Web Tool-15-D-testalexandria" + } + ] + }, + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/229bcdc6eaeb4ca59d55221141d01f8e", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "irma-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "hvf6" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "229bcdc6eaeb4ca59d55221141d01f8e" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "AIN Web Tool-15-D-STTest2" + } + ] + }, + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/cb42a77ff45b48a8b8deb83bb64acc74", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "irma-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "hvf6" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "cb42a77ff45b48a8b8deb83bb64acc74" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "ro-T11" + } + ] + }, + { + "related-to": "tenant", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/hvf6/tenants/tenant/fa45ca53c80b492fa8be5477cd84fc2b", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "irma-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "hvf6" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "fa45ca53c80b492fa8be5477cd84fc2b" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "ro-T112" + } + ] + } + ] + } +} diff --git a/vid-automation/src/main/resources/registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_with_modelVer.json b/vid-automation/src/main/resources/registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_with_modelVer.json new file mode 100644 index 000000000..70f9237e1 --- /dev/null +++ b/vid-automation/src/main/resources/registration_to_simulator/changeManagement/get_vnf_data_by_globalid_and_service_type_with_modelVer.json @@ -0,0 +1,556 @@ +{ + "results": [ + { + "id": "3400916992", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/66b13cb4-b575-449f-aa45-ffbfe005c7b1", + "properties": { + "service-instance-id": "66b13cb4-b575-449f-aa45-ffbfe005c7b1", + "service-instance-name": "CHARLOTTE_preload_1710_0914", + "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "model-version-id": "1525f534-99a2-408f-b847-ff636997d352", + "resource-version": "1505856078810", + "orchestration-status": "Active" + }, + "related-to": [ + { + "id": "10207440", + "node-type": "service-subscription", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" + }, + { + "id": "3481829392", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec" + } + ] + }, + { + "id": "890175488", + "node-type": "model-ver", + "url": "/aai/v17/service-design-and-creation/models/model/1525f534-99a2-408f-b847-ff636997d352model-vers/model-ver/modelVersionKey2-369-as988q", + "properties": { + "model-version-id": "1525f534-99a2-408f-b847-ff636997d352", + "model-name": "vnfc8", + "model-version": "1.1", + "resource-version": "1563820653007" + }, + "related-to": [ { + "id": "3400916992", + "relationship-label": "org.onap.relationships.inventory.BelongsTo", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/66b13cb4-b575-449f-aa45-ffbfe005c7b1" + }] + }, + { + "id": "3771572432", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/f195837b-ef28-42c3-8dea-47ad37eaed95", + "properties": { + "service-instance-id": "f195837b-ef28-42c3-8dea-47ad37eaed95", + "service-instance-name": "CHARLOTTE_preload_1710_0914_0920", + "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", + "resource-version": "1505964829466", + "orchestration-status": "Active" + }, + "related-to": [ + { + "id": "10207440", + "node-type": "service-subscription", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" + }, + { + "id": "3484520464", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1" + } + ] + }, + { + "id": "3775807704", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/9ad4ac55-a5e0-4b49-95c0-b2d846abf700", + "properties": { + "service-instance-id": "9ad4ac55-a5e0-4b49-95c0-b2d846abf700", + "service-instance-name": "CHARLOTTE_preload_1710_0914_100417", + "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", + "resource-version": "1507144734087", + "orchestration-status": "Active" + }, + "related-to": [ + { + "id": "10207440", + "node-type": "service-subscription", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" + }, + { + "id": "3783459064", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/54626a59-ec0d-4fa9-b0c2-08d008688165" + } + ] + }, + { + "id": "4178862184", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/599c7247-b083-447c-b6b1-0cdd5170dfd2", + "properties": { + "service-instance-id": "599c7247-b083-447c-b6b1-0cdd5170dfd2", + "service-instance-name": "CHARLOTTE_preload_1710_0914_1010", + "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", + "resource-version": "1507664240411", + "orchestration-status": "Active" + }, + "related-to": [ + { + "id": "10207440", + "node-type": "service-subscription", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" + }, + { + "id": "3892133896", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/d74503d8-abab-49c6-ba48-a6211eee9b7a" + } + ] + }, + { + "id": "3008335920", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08", + "properties": { + "service-instance-id": "97315a05-e6f3-4c47-ae7e-d850c327aa08", + "service-instance-name": "CHARLOTTE_preload_1710_0914_0927", + "model-invariant-id": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "model-version-id": "3915de55-a904-4cc6-8fc3-86f8bc316616", + "resource-version": "1506527653053", + "orchestration-status": "Active" + }, + "related-to": [ + { + "id": "10207440", + "node-type": "service-subscription", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson" + }, + { + "id": "3418898432", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855" + } + ] + }, + { + "id": "3481829392", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec", + "properties": { + "vnf-id": "0c465dd3-4151-4da9-92a2-541bb3174cec", + "vnf-name": "Eoghan Fausto", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1505856137206", + "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "model-version-id": "afacccf6-397d-45d6-b5ae-94c39734b168", + "model-customization-id": "b54689f8-45c5-4be2-9e91-f033e028feec", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vWheeler", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "3285635208", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec/vf-modules/vf-module/d49713bf-1bff-4eab-bed1-a8f1bb83aa98" + }, + { + "id": "3441209432", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec/vf-modules/vf-module/b8397fec-cf13-40b3-be8f-7d0912506419" + }, + { + "id": "3687522312", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0c465dd3-4151-4da9-92a2-541bb3174cec/vf-modules/vf-module/fd098a52-09be-4c48-a9e9-a565d1b39db3" + }, + { + "id": "3400916992", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/66b13cb4-b575-449f-aa45-ffbfe005c7b1" + }, + { + "id": "3477385312", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" + } + ] + }, + { + "id": "3484520464", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1", + "properties": { + "vnf-id": "c2d2d389-fa00-4fb4-a269-e46d495719e1", + "vnf-name": "Odell Romana", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1505964996823", + "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", + "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vMobileDNS", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "3447107680", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/c4711b5c-742e-4d03-8146-bff763f69fbd" + }, + { + "id": "3448307712", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/0ba3fcdd-0536-4ac7-a9ec-8d8622db7fb2" + }, + { + "id": "3692179528", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/6bb843eb-ef84-43b1-83b4-3154a7f9928c" + }, + { + "id": "3771588816", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/a4c008c6-cac0-4e3f-928f-90fa37dc8c4b" + }, + { + "id": "3904077944", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/eecb619c-a173-4ead-bf48-d4d09cbbdd5e" + }, + { + "id": "4027855088", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/1e29424e-2dca-45ac-b1df-59a8f74d0bc1" + }, + { + "id": "4390871192", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/b185220a-7f63-4b29-867d-1452813a4f09" + }, + { + "id": "4450529432", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/c2d2d389-fa00-4fb4-a269-e46d495719e1/vf-modules/vf-module/7a0c4b98-b3cc-490c-bbab-e2d7f169f2d7" + }, + { + "id": "3771572432", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/f195837b-ef28-42c3-8dea-47ad37eaed95" + } + ] + }, + { + "id": "3783459064", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/54626a59-ec0d-4fa9-b0c2-08d008688165", + "properties": { + "vnf-id": "54626a59-ec0d-4fa9-b0c2-08d008688165", + "vnf-name": "Dominika Fionnbharr", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1507144948937", + "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", + "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vMobileDNS", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "3775807704", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/9ad4ac55-a5e0-4b49-95c0-b2d846abf700" + } + ] + }, + { + "id": "3892133896", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/d74503d8-abab-49c6-ba48-a6211eee9b7a", + "properties": { + "vnf-id": "d74503d8-abab-49c6-ba48-a6211eee9b7a", + "vnf-name": "CHARLOTTE_PreloadTest_VNF", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1507664288548", + "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", + "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vMobileDNS", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "4178862184", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/599c7247-b083-447c-b6b1-0cdd5170dfd2" + } + ] + }, + { + "id": "1507690314", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/385548e2-3f31-4900-9437-317d0346e49a", + "properties": { + "vnf-id": "385548e2-3f31-4900-9437-317d0346e49a", + "vnf-name": "Senga Gabrielle", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "7788675952902", + "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "model-version-id": "b217c612-7fcf-484c-861b-df0a5c4b5bcb", + "model-customization-id": "ce15d245-763c-4079-ac82-fe93007adb69", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vMobileDNS", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "3664617648", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" + }, + { + "id": "3008335920", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" + }, + { + "id": "3477385312", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" + } + ] + }, + { + "id": "5278880615", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/0465e048-92a4-4a7f-bfe7-de39b32de4bd", + "properties": { + "vnf-id": "0465e048-92a4-4a7f-bfe7-de39b32de4bd", + "vnf-name": "Constantius Raghu", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "7788675952902", + "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "model-version-id": "afacccf6-397d-45d6-b5ae-94c39734b168", + "model-customization-id": "ce15d245-763c-4079-ac82-fe93007adb69", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vWheeler", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "3664617648", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" + }, + { + "id": "3008335920", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" + }, + { + "id": "3477385312", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" + } + ] + }, + { + "id": "3418898432", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855", + "properties": { + "vnf-id": "8e5e3ba1-3fe6-4d86-966e-f9f03dab4855", + "vnf-name": "zolson3amdns02test2", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1507132024933", + "model-invariant-id": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "model-version-id": "76e908e0-5201-44d2-a3e2-9e6128d05820", + "model-customization-id": "c00e8fc8-af39-4da8-8c78-a7efc2fe5994", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vMobileDNS", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "3664617648", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" + }, + { + "id": "3008335920", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" + }, + { + "id": "3477385312", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" + }, + { + "id": "3647635704", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/b30b17e9-10d0-4475-b558-7d18ae0aade0" + }, + { + "id": "3664621744", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/d3b293ba-85de-440e-904b-9dad160fbdce" + }, + { + "id": "3975352504", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/495a9a72-c9f6-41ed-93eb-065ebc2bfb1f" + }, + { + "id": "4059455552", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/b4b9f419-3ed4-4bd8-bb2e-32b0a98e80b7" + }, + { + "id": "4098130088", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/94c79f43-e76d-461e-b8df-8af2acb08e1e" + }, + { + "id": "4401291416", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/99cad3c6-1301-49c4-ad67-ae3c955de5f1" + }, + { + "id": "4458950808", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/mdt1/tenants/tenant/88a6ca3ee0394ade9403f075db23167e/vservers/vserver/047354dc-0244-4241-b24a-7d7b00413b82" + } + ] + }, + { + "id": "1024648346", + "node-type": "generic-vnf", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/a58bf551-a79c-42d1-83b4-ed9288036245", + "properties": { + "vnf-id": "a58bf551-a79c-42d1-83b4-ed9288036245", + "vnf-name": "Harrison Kris", + "vnf-type": "CHARLOTTE preload 1710 0914/CHARLOTTE preload 1710 0914 0", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "4679861552759", + "model-invariant-id": "00beb8f9-6d39-452f-816d-c709b9cbb87d", + "model-version-id": "0903e1c0-8e03-4936-b5c2-260653b96413", + "model-customization-id": "14e8057d-b22a-405c-84aa-90b82bfd6e46", + "nf-type": "DNS", + "nf-function": "Mobile DNS", + "nf-role": "vMobileDNS", + "nf-naming-code": "null" + }, + "related-to": [ + { + "id": "3664617648", + "node-type": "vf-module", + "url": "https://aai.onap.org:8443/aai/v10/network/generic-vnfs/generic-vnf/8e5e3ba1-3fe6-4d86-966e-f9f03dab4855/vf-modules/vf-module/788cde64-c288-4971-8e8c-77973c5009dc" + }, + { + "id": "3008335920", + "node-type": "service-instance", + "url": "https://aai.onap.org:8443/aai/v10/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vRichardson/service-instances/service-instance/97315a05-e6f3-4c47-ae7e-d850c327aa08" + }, + { + "id": "3477385312", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/8627b971-1032-420f-a044-6802f0ab6976" + }, + { + "id": "3647635704", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/b30b17e9-10d0-4475-b558-7d18ae0aade0" + }, + { + "id": "3664621744", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/d3b293ba-85de-440e-904b-9dad160fbdce" + }, + { + "id": "3975352504", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/495a9a72-c9f6-41ed-93eb-065ebc2bfb1f" + }, + { + "id": "4059455552", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/b4b9f419-3ed4-4bd8-bb2e-32b0a98e80b7" + }, + { + "id": "4098130088", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/94c79f43-e76d-461e-b8df-8af2acb08e1e" + }, + { + "id": "4401291416", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/99cad3c6-1301-49c4-ad67-ae3c955de5f1" + }, + { + "id": "4458950808", + "node-type": "vserver", + "url": "https://aai.onap.org:8443/aai/v10/cloud-infrastructure/cloud-regions/cloud-region/irma-aic/olson3/tenants/tenant/eecd15e8e7ee46c3bbc2096f0924f4c4/vservers/vserver/047354dc-0244-4241-b24a-7d7b00413b82" + } + ] + } + ] +}
\ No newline at end of file diff --git a/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java index 73ad53e19..fb710b324 100644 --- a/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java +++ b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java @@ -1,7 +1,18 @@ package org.onap.vid.more; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalToIgnoringCase; +import static org.onap.vid.api.CategoryParametersApiTest.MAINTENANCE_CATEGORY_PARAMETER; +import static org.onap.vid.api.pProbeMsoApiTest.MSO_CREATE_CONFIGURATION; +import static org.springframework.http.HttpHeaders.AUTHORIZATION; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import java.util.List; +import java.util.UUID; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.junit.Assert; @@ -10,21 +21,15 @@ import org.onap.simulator.presetGenerator.presets.aaf.AAFGetUrlServicePreset; import org.onap.vid.api.BaseApiTest; import org.onap.vid.api.OperationalEnvironmentControllerApiTest; import org.onap.vid.api.ServiceInstanceMsoApiTest; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import vid.automation.test.services.SimulatorApi; -import java.util.List; -import java.util.UUID; - -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.onap.vid.api.CategoryParametersApiTest.MAINTENANCE_CATEGORY_PARAMETER; -import static org.onap.vid.api.pProbeMsoApiTest.MSO_CREATE_CONFIGURATION; -import static org.springframework.http.HttpHeaders.AUTHORIZATION; -import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; - public class RequestIdFilterInstalled extends BaseApiTest { /* @@ -39,8 +44,8 @@ public class RequestIdFilterInstalled extends BaseApiTest { Clients unit-tests. */ - private static final String ECOMP_REQUEST_ID = "x-ecomp-requestid"; - private final String ECOMP_REQUEST_ID_ECHO = ECOMP_REQUEST_ID + "-echo"; + private static final String REQUEST_ID_HEADER = "x-onap-requestid"; + private final String ECOMP_REQUEST_ID_ECHO = "x-ecomp-requestid-echo"; @BeforeClass public void login() { @@ -148,8 +153,7 @@ public class RequestIdFilterInstalled extends BaseApiTest { // id" filter, which is great! Assert.assertNotNull(response); List<String> ecompRequestIdHeaderValues = response.getHeaders().get(ECOMP_REQUEST_ID_ECHO); - Assert.assertNotNull(ecompRequestIdHeaderValues); - Assert.assertTrue(ecompRequestIdHeaderValues.contains(uuid)); + Assert.assertThat(ecompRequestIdHeaderValues, hasItem(equalToIgnoringCase(uuid))); } private void assertThatTermIsInARecentLog(String uuid) { @@ -169,7 +173,7 @@ public class RequestIdFilterInstalled extends BaseApiTest { private Pair<HttpEntity, String> makeRequest(HttpMethod httpMethod, String url, String body, String expectationFilename) { final String uuid = UUID.randomUUID().toString(); final HttpHeaders headers = new HttpHeaders(); - headers.add(ECOMP_REQUEST_ID, uuid); + headers.add(REQUEST_ID_HEADER, uuid); headers.add(AUTHORIZATION, "Basic " + AAFGetBasicAuthPreset.VALID_AUTH_VALUE); headers.setContentType(MediaType.APPLICATION_JSON); |