summaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rwxr-xr-xvid-app-common/pom.xml2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java27
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java29
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt9
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt158
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/Action.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java1
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java23
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java32
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java54
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java4
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js1
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js12
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js32
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js12
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/directives/popupWindowDirective.js6
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/directives/progressBarDirective.js8
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html2
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/view-models/change-management.html2
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java47
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java12
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java13
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java304
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/PromiseEcompRequestIdFilterTest.java15
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java161
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java20
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java7
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java63
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java7
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java47
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java441
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java112
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java37
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/utils/TreeTest.java8
-rw-r--r--vid-app-common/src/test/resources/WEB-INF/conf/system.properties8
-rw-r--r--vid-app-common/src/test/resources/mso.properties17
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json25
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json3
-rwxr-xr-xvid-app-common/version.properties2
47 files changed, 1346 insertions, 465 deletions
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index 1d2a2ad5d..b2167da92 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -9,7 +9,7 @@
inherit from a parent maven module. -->
<groupId>org.onap.vid</groupId>
<artifactId>vid-app-common</artifactId>
- <version>5.0.1-SNAPSHOT</version>
+ <version>5.0.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>VID Common</name>
<description>VID Common code for opensource version</description>
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index 8e47bbae5..c43779df1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -440,6 +440,8 @@ public class AaiClient implements AaiClientInterface {
}
protected Stream<ModelVer> toModelVerStream(ModelVersions modelVersions) {
+ if (modelVersions == null)
+ return null;
if (modelVersions == null)
return null;
@@ -454,7 +456,6 @@ public class AaiClient implements AaiClientInterface {
}
protected ModelVer maxModelVer(Stream<ModelVer> modelVerStream) {
-
if (modelVerStream == null)
return null;
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index 01b005c4b..6bd98fff6 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -20,10 +20,13 @@
package org.onap.vid.controller;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+
+import java.util.List;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.exceptions.AccessDeniedException;
-import org.onap.vid.exceptions.OperationNotAllowedException;
-import org.onap.vid.model.ExceptionResponse;
import org.onap.vid.model.JobAuditStatus;
import org.onap.vid.model.ServiceInfo;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
@@ -34,16 +37,14 @@ import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AuditService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
import org.togglz.core.manager.FeatureManager;
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.UUID;
-
-import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
-import static org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED;
-
@RestController
@RequestMapping(AsyncInstantiationController.ASYNC_INSTANTIATION)
@@ -69,12 +70,6 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
this.systemPropertiesWrapper = systemPropertiesWrapper;
}
- @ExceptionHandler(OperationNotAllowedException.class)
- @ResponseStatus(value=METHOD_NOT_ALLOWED)
- public ExceptionResponse illegalStateExceptionHandler(Exception e) {
- return ControllersUtils.handleException(e, LOGGER);
- }
-
/**
* Gets the new services status.
* @param request the request
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
index 0fe7255c4..2b6b57ade 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
@@ -21,8 +21,10 @@
package org.onap.vid.job.command;
import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.aai.model.ModelVer;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.model.ServiceModel;
+import org.onap.vid.services.AaiService;
import org.onap.vid.services.VidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -31,18 +33,16 @@ import org.springframework.stereotype.Component;
public class CommandUtils {
private final VidService vidService;
+ private final AaiService aaiService;
@Autowired
- public CommandUtils(VidService vidService) {
+ public CommandUtils(VidService vidService, AaiService aaiService) {
this.vidService = vidService;
+ this.aaiService = aaiService;
}
public boolean isVfModuleBaseModule(String serviceModelUuid, String vfModuleModelUUID) throws AsdcCatalogException{
- ServiceModel serviceModel = vidService.getService(serviceModelUuid);
-
- if (serviceModel==null) {
- throw new AsdcCatalogException("Failed to retrieve model with uuid "+serviceModelUuid +" from SDC");
- }
+ ServiceModel serviceModel = getServiceModel(serviceModelUuid);
if (serviceModel.getVfModules() == null) {
throw createAsdcCatalogVfModuleModelUUIDNotFoundException(serviceModelUuid, vfModuleModelUUID);
@@ -58,6 +58,23 @@ public class CommandUtils {
.getBaseModule();
}
+ public ServiceModel getServiceModel(String serviceModelUuid) throws AsdcCatalogException{
+ ServiceModel serviceModel = vidService.getService(serviceModelUuid);
+
+ if (serviceModel==null) {
+ throw new AsdcCatalogException("Failed to retrieve model with uuid "+serviceModelUuid +" from SDC");
+ }
+
+ return serviceModel;
+ }
+
+ public String getNewestModelUuid(String serviceModelInvariantId)
+ {
+ ModelVer serviceModelLatestVersion = aaiService.getNewestModelVersionByInvariantId(serviceModelInvariantId);
+
+ return serviceModelLatestVersion.getModelVersionId();
+ }
+
private AsdcCatalogException createAsdcCatalogVfModuleModelUUIDNotFoundException(String serviceModelUuid, String vfModuleModelUUID) {
return new AsdcCatalogException("Failed to find vfModuleModelUUID: " + vfModuleModelUUID +
"in model with uuid: " + serviceModelUuid);
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 0e9ab7b7a..2c50e03cd 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
@@ -222,11 +222,16 @@ abstract class ResourceCommand(
else -> InternalState.IN_PROGRESS
}
+ InternalState.REPLACE_MYSELF -> when (jobStatus) {
+ JobStatus.IN_PROGRESS -> InternalState.REPLACE_MYSELF
+ else -> InternalState.IN_PROGRESS
+ }
+
InternalState.IN_PROGRESS -> {
when {
jobStatus != JobStatus.COMPLETED -> InternalState.IN_PROGRESS
isDescendantHasAction(Action.Create) -> InternalState.CREATING_CHILDREN
- isDescendantHasAction(Action.Replace) -> InternalState.CREATING_CHILDREN
+ isDescendantHasAction(Action.Upgrade) -> InternalState.CREATING_CHILDREN
else -> InternalState.TERMINAL
}
}
@@ -284,7 +289,7 @@ abstract class ResourceCommand(
isNeedToResumeMySelf() -> InternalState.RESUME_MYSELF
isNeedToReplaceMySelf() -> InternalState.REPLACE_MYSELF
isDescendantHasAction(phase) -> InternalState.CREATING_CHILDREN
- isDescendantHasAction(Action.Replace) -> InternalState.CREATING_CHILDREN
+ isDescendantHasAction(Action.Upgrade) -> InternalState.CREATING_CHILDREN
else -> InternalState.TERMINAL
}
else -> throw IllegalStateException("state $internalState is not supported yet")
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
index af52fa049..276b00e6f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/VfmoduleCommand.kt
@@ -5,9 +5,10 @@ import org.onap.vid.job.Job
import org.onap.vid.job.JobAdapter
import org.onap.vid.job.JobCommand
import org.onap.vid.job.JobsBrokerService
-import org.onap.vid.model.Action
+import org.onap.vid.model.*
import org.onap.vid.model.serviceInstantiation.VfModule
import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.mso.model.ModelInfo
import org.onap.vid.services.AsyncInstantiationBusinessLogic
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -16,6 +17,8 @@ import org.springframework.http.HttpMethod
import org.springframework.stereotype.Component
import java.util.*
+typealias ToscaVfm = org.onap.vid.model.VfModule
+
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
class VfmoduleCommand @Autowired constructor(
@@ -45,7 +48,7 @@ class VfmoduleCommand @Autowired constructor(
val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
val vgInstaceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VG_INSTANCE_ID)
- val instantiatePath = asyncInstantiationBL.getVfmoduleInstantiationPath(serviceInstanceId, vnfInstanceId)
+ val instantiatePath = asyncInstantiationBL.getVfmoduleInstantiationPath(serviceInstanceId, vnfInstanceId)
val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
request as VfModule,
@@ -75,14 +78,16 @@ class VfmoduleCommand @Autowired constructor(
return false
}
- private fun planReplaceMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
+ private fun planReplaceMyselfRestCall3(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
val replacePath = asyncInstantiationBL.getVfModuleReplacePath(serviceInstanceId, vnfInstanceId, getRequest().instanceId)
- val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
+ amendModelInfoWithNewestModel(serviceModelInfo, vnfModelInfo, (request as VfModule).modelInfo)
+
+ val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
request as VfModule, serviceModelInfo, serviceInstanceId,vnfModelInfo, vnfInstanceId,null,userId, testApi)
val actionDescription = "replace vfmodule ${request.instanceId}"
@@ -90,9 +95,142 @@ class VfmoduleCommand @Autowired constructor(
return MsoRestCallPlan(HttpMethod.POST, replacePath, Optional.of(requestDetailsWrapper), Optional.of(userId), actionDescription)
}
+ private fun planReplaceMyselfRestCall(commandParentData: CommandParentData): MsoRestCallPlan {
+
+ val newestModel = fetchNewestServiceModel()
+
+ val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+ val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
+
+ val (serviceModelInfo, vnfModelInfo, vfmModelInfo) = newestSelector(newestModel, commandParentData);
+
+ val originalRequestWithNewestVfmModelInfo = getRequest().cloneWith(vfmModelInfo)
+
+ val requestDetailsWrapper = msoRequestBuilder.generateVfModuleInstantiationRequest(
+ originalRequestWithNewestVfmModelInfo, serviceModelInfo, serviceInstanceId,
+ vnfModelInfo, vnfInstanceId, null, sharedData.userId, sharedData.testApi)
+
+
+ val replacePath = asyncInstantiationBL.getVfModuleReplacePath(serviceInstanceId, vnfInstanceId, getRequest().instanceId)
+
+ return MsoRestCallPlan(HttpMethod.POST, replacePath, Optional.of(requestDetailsWrapper), Optional.of(sharedData.userId),
+ "replace vfmodule ${getRequest().instanceId}")
+ }
+
+ data class ModelsInfoTriplet(val serviceModelInfo: ModelInfo, val vnfModelInfo: ModelInfo, val vfmModelInfo: ModelInfo)
+
+ private fun newestSelector(newestModel: ServiceModel, commandParentData: CommandParentData): ModelsInfoTriplet {
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+ val vfmModelInfo = getRequest().modelInfo
+ val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
+
+ val newestServiceModelInfo = newestServiceModelInfo(newestModel)
+ val newestVfmModelInfo = newestVfmModelInfo(newestModel)
+ val newestVnfModelInfo = newestVnfModelInfo(newestModel, commandParentData)
+
+ return if (newestServiceModelInfo == null || newestVfmModelInfo == null || newestVnfModelInfo == null) {
+ ModelsInfoTriplet(serviceModelInfo, vnfModelInfo, vfmModelInfo)
+ } else {
+ ModelsInfoTriplet(newestServiceModelInfo, newestVnfModelInfo, newestVfmModelInfo)
+ }
+ }
+
+ private fun newestServiceModelInfo(newestModel: ServiceModel) = toModelInfo(newestModel.service)
+
+ private fun newestVfmModelInfo(newestModel: ServiceModel): ModelInfo? {
+ val vfmModelInfo = getRequest().modelInfo
+ val newestVfm = selectVfm(newestModel, vfmModelInfo)
+ return toModelInfo(newestVfm)
+ }
+
+ private fun newestVnfModelInfo(newestModel: ServiceModel, commandParentData: CommandParentData): ModelInfo? {
+ val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
+ val newestVnf = selectVnf(newestModel, vnfModelInfo)
+ return toModelInfo(newestVnf)
+ }
+
+ private fun selectVfm(newestModel: ServiceModel, modelInfo: ModelInfo) = newestModel.vfModules[modelInfo.modelCustomizationId]
+
+ private fun selectVnf(newestModel: ServiceModel, modelInfo: ModelInfo) = newestModel.vnfs[modelInfo.modelCustomizationId]
+
+ private fun toModelInfo(toBeConverted: VNF?): ModelInfo? = toBeConverted?.let { toModelInfo(it, "vnf") }
+
+ private fun toModelInfo(toBeConverted: ToscaVfm?): ModelInfo? = toBeConverted?.let { toModelInfo(it, "vfModule") }
+
+ private fun toModelInfo(toBeConverted: MinimalNode, modelType: String): ModelInfo {
+ val targetModelInfo = ModelInfo()
+
+ targetModelInfo.modelType = modelType
+ targetModelInfo.modelName = toBeConverted.name
+ targetModelInfo.modelNameVersionId = null
+ targetModelInfo.modelVersion = toBeConverted.version
+ targetModelInfo.modelVersionId = toBeConverted.uuid
+ targetModelInfo.modelInvariantId = toBeConverted.invariantUuid
+
+ targetModelInfo.modelCustomizationId = when (toBeConverted) {
+ is VNF -> toBeConverted.customizationUuid
+ is ToscaVfm -> toBeConverted.customizationUuid
+ else -> throw IllegalArgumentException()
+ }
+
+ targetModelInfo.modelCustomizationName = when (toBeConverted) {
+ is VNF -> toBeConverted.modelCustomizationName
+ is ToscaVfm -> toBeConverted.modelCustomizationName
+ else -> throw IllegalArgumentException()
+ }
+
+ return targetModelInfo
+ }
+
+ private fun toModelInfo(toBeConverted: Service?): ModelInfo? {
+
+ if (toBeConverted == null)
+ return null
+
+ val targetModelInfo = ModelInfo()
+
+ targetModelInfo.modelVersionId = toBeConverted.uuid
+ targetModelInfo.modelInvariantId = toBeConverted.invariantUuid
+ targetModelInfo.modelVersion = toBeConverted.version
+ //targetModelInfo.modelCustomizationId = toBeConverted.customizationUuid
+ //targetModelInfo.modelCustomizationName = toBeConverted.modelCustomizationName
+ targetModelInfo.modelType = "service"
+ targetModelInfo.modelName = toBeConverted.name
+
+ return targetModelInfo
+ }
+
+ private fun amendModelInfoWithNewestModel(serviceModelInfo: ModelInfo, vnfModelInfo: ModelInfo, vfmModelInfo: ModelInfo) {
+ val newestModel = fetchNewestServiceModel()
+ val newestService = newestModel.service
+
+ val newestVfm = newestModel.vfModules[vfmModelInfo.modelCustomizationId]
+ val newestVnf = newestModel.vnfs[vnfModelInfo.modelCustomizationId]
+
+ if (!(newestService == null || newestVnf == null || newestVfm == null)) {
+
+ serviceModelInfo.modelName = newestService.name
+ serviceModelInfo.modelVersionId = newestService.uuid
+ serviceModelInfo.modelVersion = newestService.version
+
+ vnfModelInfo.modelName = newestVnf.name
+ vnfModelInfo.modelVersionId = newestVnf.uuid
+ vnfModelInfo.modelVersion = newestVnf.version
+ vnfModelInfo.modelCustomizationId = newestVnf.customizationUuid
+ vnfModelInfo.modelCustomizationName = newestVnf.modelCustomizationName
+
+ vfmModelInfo.modelName = newestVfm.name
+ vfmModelInfo.modelVersionId = newestVfm.uuid
+ vfmModelInfo.modelVersion = newestVfm.version
+ vfmModelInfo.modelCustomizationId = newestVfm.customizationUuid
+ vfmModelInfo.modelCustomizationName = newestVfm.modelCustomizationName
+ }
+ }
+
+
override fun replaceMyself(): Job.JobStatus {
try {
- val replaceMyselfCommand = planReplaceMyselfRestCall(commandParentData, sharedData.request, sharedData.userId, sharedData.testApi )
+ val replaceMyselfCommand = planReplaceMyselfRestCall(commandParentData)
return executeAndHandleMsoInstanceRequest(replaceMyselfCommand)
} catch (exception: Exception) {
LOGGER.error("Failed to replace instanceId ${getRequest().instanceId} ", exception)
@@ -101,6 +239,14 @@ class VfmoduleCommand @Autowired constructor(
}
override fun isNeedToReplaceMySelf(): Boolean {
- return getActionType() == Action.Replace
+ return getActionType() == Action.Upgrade
+ }
+
+ private fun fetchNewestServiceModel(): ServiceModel {
+ val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+ var modelNewestUuid = commandUtils.getNewestModelUuid(serviceModelInfo.modelInvariantId);
+ var serviceNewestModel = commandUtils.getServiceModel(modelNewestUuid);
+
+ return serviceNewestModel;
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Action.java b/vid-app-common/src/main/java/org/onap/vid/model/Action.java
index c0d4fae6a..930f97073 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/Action.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/Action.java
@@ -25,7 +25,7 @@ public enum Action {
Delete(ServiceInfo.ServiceAction.DELETE),
None(ServiceInfo.ServiceAction.UPDATE),
Resume(ServiceInfo.ServiceAction.RESUME),
- Replace(ServiceInfo.ServiceAction.REPLACE);
+ Upgrade(ServiceInfo.ServiceAction.UPGRADE);
private final ServiceInfo.ServiceAction serviceAction;
Action(ServiceInfo.ServiceAction serviceAction){
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
index 70f7b5aa2..219b4893c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
@@ -55,6 +55,7 @@ public class CategoryParameterOption extends DomainVo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CATEGORY_OPT_DB_ID")
+ @Override
public Long getId() {
return id;
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java b/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java
index 645934530..012db5a31 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java
@@ -24,6 +24,7 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Locale;
import java.util.TimeZone;
import java.util.UUID;
import javax.persistence.Column;
@@ -100,7 +101,7 @@ public class JobAuditStatus extends VidBaseEntity {
return null;
}
- DateFormat format = new SimpleDateFormat(defaultFormat);
+ DateFormat format = new SimpleDateFormat(defaultFormat, Locale.US);
format.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = null ;
try {
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
index 1e1e6c2a7..85c83eb98 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java
@@ -22,18 +22,25 @@ package org.onap.vid.model;
import com.fasterxml.jackson.annotation.JsonProperty;
-import org.hibernate.annotations.DynamicUpdate;
-import org.hibernate.annotations.SelectBeforeUpdate;
-import org.hibernate.annotations.Type;
-import org.onap.portalsdk.core.domain.support.DomainVo;
-import org.onap.vid.job.Job;
-
-import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import org.hibernate.annotations.DynamicUpdate;
+import org.hibernate.annotations.SelectBeforeUpdate;
+import org.hibernate.annotations.Type;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+import org.onap.vid.job.Job;
/*
The following 2 annotations let hibernate to update only fields that actually have been changed.
@@ -51,7 +58,7 @@ public class ServiceInfo extends DomainVo {
DELETE,
UPDATE,
RESUME,
- REPLACE
+ UPGRADE
}
private UUID jobId;
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 926dc3cdc..75658f2b1 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
@@ -65,7 +65,7 @@ public abstract class BaseResource implements JobAdapter.AsyncJobRequest {
.put("Update_Delete", Action.Delete)
.put("None_Delete", Action.Delete)
.put("Resume", Action.Resume)
- .put("Replace", Action.Replace)
+ .put("Upgrade", Action.Upgrade)
.build();
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 97b23af20..233850d58 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
@@ -20,18 +20,17 @@
package org.onap.vid.model.serviceInstantiation;
+import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
-import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.JobType;
-import org.onap.vid.mso.model.ModelInfo;
-
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-
-import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
+import org.onap.vid.job.JobAdapter;
+import org.onap.vid.job.JobType;
+import org.onap.vid.mso.model.ModelInfo;
/**
* The Class VfModule.
@@ -91,4 +90,25 @@ public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest
public JobType getJobType() {
return JobType.VfmoduleInstantiation;
}
+
+ public VfModule cloneWith(ModelInfo modelInfo) {
+ return new VfModule(
+ modelInfo,
+ this.getInstanceName(),
+ this.getVolumeGroupInstanceName(),
+ this.getAction().toString(),
+ this.getLcpCloudRegionId(),
+ this.getLcpCloudRegionId(),
+ this.getTenantId(),
+ this.getInstanceParams(),
+ this.getSupplementaryParams(),
+ this.isRollbackOnFailure(),
+ this.isUsePreload(),
+ this.getInstanceId(),
+ this.getTrackById(),
+ this.getIsFailed(),
+ this.getStatusMessage()
+ );
+
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index 4d0d4ee74..3d980dce8 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -140,7 +140,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
public MsoResponseWrapper createSvcInstance(RequestDetails msoRequest) {
logInvocationInDebug("createSvcInstance");
- String endpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String endpoint = validateEndpointPath(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
return msoClientInterface.createSvcInstance(msoRequest, endpoint);
}
@@ -260,7 +260,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logInvocationInDebug("deleteSvcInstance");
String endpoint;
- endpoint = validateEndpointPath(MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE);
+ endpoint = validateEndpointPath(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
if (shouldUnassignService(serviceStatus)){
logger.debug(EELFLoggerDelegate.debugLogger, "unassign service");
String svcEndpoint = endpoint + "/" + serviceInstanceId + "/unassign";
@@ -470,7 +470,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
String methodName = "activateServiceInstance";
logInvocationInDebug(methodName);
try {
- String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
String activateServicePath = serviceEndpoint + "/" + serviceInstanceId + ACTIVATE;
RestObject<String> restObjStr = new RestObject<>();
@@ -534,7 +534,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
@Override
public String getActivateFabricConfigurationPath(String serviceInstanceId) {
- String path = validateEndpointPath(MsoProperties.MSO_REST_API_SERVICE_INSTANCE_CREATE);
+ String path = validateEndpointPath(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
path += "/" + serviceInstanceId + ACTIVATE_FABRIC_CONFIGURATION;
return path;
@@ -684,7 +684,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logInvocationInDebug("setServiceInstanceStatus");
String methodName = "setServiceInstanceStatus";
try {
- String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String serviceEndpoint = validateEndpointPath(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
String endpoint = serviceEndpoint + "/" + serviceInstanceId;
String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE);
@@ -822,7 +822,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
public MsoResponseWrapper removeRelationshipFromServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
logInvocationInDebug("removeRelationshipFromServiceInstance");
- String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
String removeRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/removeRelationships";
return msoClientInterface.removeRelationshipFromServiceInstance(requestDetails, removeRelationshipsPath);
@@ -832,7 +832,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
public MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String serviceInstanceId) {
logInvocationInDebug("addRelationshipToServiceInstance");
- String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String serviceEndpoint = SystemProperties.getProperty(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
String addRelationshipsPath = serviceEndpoint + "/" + serviceInstanceId + "/addRelationships";
return msoClientInterface.addRelationshipToServiceInstance(requestDetails, addRelationshipsPath);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
index 4e6258c16..81566aae1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
@@ -69,10 +69,7 @@ public class MsoProperties extends SystemProperties {
public static final String MSO_REST_API_E2E_SVC_INSTANCE = "mso.restapi.svc.e2einstance"; // /e2eServiceInstances/v3
/** The Constant MSO_REST_API_SVC_INSTANCE. */
- public static final String MSO_REST_API_SVC_INSTANCE = "mso.restapi.svc.instance"; // /serviceInstances/v2
-
- /** The Constant MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE. */
- public static final String MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE = "mso.restapi.svc.instance.deleteAndUnassign";
+ public static final String MSO_RESTAPI_SERVICE_INSTANCE = "mso.restapi.service.instance"; // /serviceInstances/v2
/** The Constant MSO_REST_API_VNF_INSTANCE. */
public static final String MSO_REST_API_VNF_INSTANCE = "mso.restapi.vnf.instance";
@@ -120,9 +117,6 @@ public class MsoProperties extends SystemProperties {
/** The Constant MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS */
public static final String MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS = "mso.restapi.operationalEnvironment.cloudResourcesRequests.status";
- /** The Constant MSO_REST_API_SERVICE_INSTANCE_CREATE */
- public static final String MSO_REST_API_SERVICE_INSTANCE_CREATE = "mso.restapi.serviceInstanceCreate";
-
/** The Constant MSO_REST_API_SERVICE_INSTANCE_ASSIGN */
public static final String MSO_REST_API_SERVICE_INSTANCE_ASSIGN = "mso.restapi.serviceInstanceAssign";
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index cc6d6123d..4b8a974e3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -20,6 +20,8 @@
*/
package org.onap.vid.mso.rest;
+import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import io.joshworks.restclient.http.HttpResponse;
@@ -177,7 +179,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
logger.debug(EELFLoggerDelegate.debugLogger, methodName + START);
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), requestDetails, String.class);
return MsoUtil.wrapResponse(response);
}
@@ -221,7 +223,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
public HttpResponseWithRequestInfo<String> getOrchestrationRequest(String endpoint, boolean warpException) {
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
+ HttpResponse<String> response = client.get(path, getHeaders(), new HashMap<>(), String.class);
return new HttpResponseWithRequestInfo<>(response, path, HttpMethod.GET);
}
@@ -229,7 +231,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
public MsoResponseWrapper getOrchestrationRequest(String endpoint) {
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
+ HttpResponse<String> response = client.get(path, getHeaders(), new HashMap<>(), String.class);
return MsoUtil.wrapResponse(response);
}
@@ -241,7 +243,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
try {
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class);
+ HttpResponse<String> response = client.get(path, getHeaders(), new HashMap<>(), String.class);
MsoResponseWrapper w = MsoUtil.wrapResponse(response);
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse());
@@ -261,7 +263,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
try {
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), requestDetails, String.class);
MsoResponseWrapper w = MsoUtil.wrapResponse(response);
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse());
@@ -302,7 +304,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ methodName + " calling change configuration active status, path =[" + path + "]");
- HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), request, String.class);
return MsoUtil.wrapResponse(response);
} catch (Exception e) {
logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString());
@@ -320,7 +322,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
String path = baseUrl + endpoint;
logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ methodName + " calling change port configuration status, path =[" + path + "]");
- HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), request, String.class);
return MsoUtil.wrapResponse(response);
} catch (Exception e) {
logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString());
@@ -332,7 +334,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
@Override
public MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint) {
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), requestDetails, String.class);
return MsoUtil.wrapResponse2(response, RequestReferencesContainer.class);
}
@@ -345,7 +347,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
requestDetailsWrapper.requestDetails = new MsoRequestDetails(request);
- HttpResponse<String> response = client.post(path, commonHeaders, requestDetailsWrapper, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), requestDetailsWrapper, String.class);
MsoResponseWrapper msoResponseWrapperObject = MsoUtil.wrapResponse(response);
int status = msoResponseWrapperObject.getStatus();
if (status == 202) {
@@ -386,7 +388,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
RequestDetailsWrapper requestDetailsWrapper = new RequestDetailsWrapper();
requestDetailsWrapper.requestDetails = new MsoRequestDetails(request);
- HttpResponse<String> response = client.put(path, commonHeaders, requestDetailsWrapper, String.class);
+ HttpResponse<String> response = client.put(path, getHeaders(), requestDetailsWrapper, String.class);
MsoResponseWrapper w = MsoUtil.wrapResponse(response);
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse());
@@ -406,7 +408,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start ");
try {
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), requestDetails, String.class);
MsoResponseWrapper w = MsoUtil.wrapResponse(response);
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w =" + w.getResponse());
return w;
@@ -426,7 +428,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
try {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Remove relationship from service instance, path =[" + endpoint + "]");
String path = baseUrl + endpoint;
- HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), requestDetails, String.class);
return MsoUtil.wrapResponse(response);
} catch (Exception e) {
logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString());
@@ -444,7 +446,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Add relationship to service instance, path =[" + addRelationshipsPath + "]");
String path = baseUrl + addRelationshipsPath;
- HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), requestDetails, String.class);
return MsoUtil.wrapResponse(response);
} catch (Exception e) {
logger.info(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString());
@@ -458,7 +460,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
String path = baseUrl + invokeWorkflowsPath;
Map<String, String> finalHeader = new HashMap<>();
- finalHeader.putAll(commonHeaders);
+ finalHeader.putAll(getHeaders());
finalHeader.putAll(extraHeaders);
RequestDetailsWrapper<WorkflowRequestDetail> requestDetailsWrapper = new RequestDetailsWrapper<>(workflowRequestDetail);
@@ -470,36 +472,36 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
@Override
public <T> HttpResponse<T> get(String endpoint, Class<T> responseClass) {
String path = baseUrl + endpoint;
- return client.get(path, commonHeaders, new HashMap<>(), responseClass);
+ return client.get(path, getHeaders(), new HashMap<>(), responseClass);
}
@Override
public <T> HttpResponse<T> post(String endpoint, RequestDetailsWrapper<?> requestDetailsWrapper, Class<T> responseClass) {
String path = baseUrl + endpoint;
- return client.post(path, commonHeaders, requestDetailsWrapper, responseClass);
+ return client.post(path, getHeaders(), requestDetailsWrapper, responseClass);
}
@Override
public <T> HttpResponse<T> post(String endpoint, RequestDetails requestDetails, Class<T> responseClass) {
String path = baseUrl + endpoint;
- return client.post(path, commonHeaders, requestDetails, responseClass);
+ return client.post(path, getHeaders(), requestDetails, responseClass);
}
public HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint){
String path = baseUrl + endpoint;
- return client.get(path, commonHeaders, Maps.newHashMap(), SOWorkflowList.class);
+ return client.get(path, getHeaders(), Maps.newHashMap(), SOWorkflowList.class);
}
- private MsoResponseWrapper createInstance(Object request, String path) {
+ protected MsoResponseWrapper createInstance(Object request, String path) {
String methodName = "createInstance";
logger.debug(methodName + START);
try {
- HttpResponse<String> response = client.post(path, commonHeaders, request, String.class);
+ HttpResponse<String> response = client.post(path, getHeaders(), request, String.class);
return MsoUtil.wrapResponse(response);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString());
@@ -523,7 +525,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
try {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " calling Delete, path =[" + path + "]");
- HttpResponse<String> response = client.delete(path, commonHeaders, request, String.class);
+ HttpResponse<String> response = client.delete(path, getHeaders(), request, String.class);
MsoResponseWrapper w = MsoUtil.wrapResponse(response);
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse());
@@ -537,6 +539,15 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
}
+ private Map<String, String> getHeaders() {
+ Map<String, String> map = new HashMap<>();
+ map.putAll(commonHeaders);
+ String requestIdValue = Logging.extractOrGenerateRequestId();
+ map.put(SystemProperties.ECOMP_REQUEST_ID, requestIdValue);
+ map.put(ONAP_REQUEST_ID_HEADER_KEY, requestIdValue);
+ return map;
+ }
+
private Map<String, String> initCommonHeaders() {
String username = systemProperties.getProperty(MsoProperties.MSO_USER_NAME);
String password = systemProperties.getProperty(MsoProperties.MSO_PASSWORD);
@@ -552,7 +563,6 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
map.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
map.put(X_FROM_APP_ID, systemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME));
- map.put(SystemProperties.ECOMP_REQUEST_ID, Logging.extractOrGenerateRequestId());
map.put(X_ONAP_PARTNER_NAME, "VID");
return ImmutableMap.copyOf(map);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
index d7b3ac602..c77eb8230 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java
@@ -247,13 +247,13 @@ public class AsyncInstantiationBusinessLogicImpl implements
//in case pause flag is true - use assign , else - use create.
return MsoBusinessLogicImpl.validateEndpointPath(
serviceInstantiationRequest.isPause() ?
- MsoProperties.MSO_REST_API_SERVICE_INSTANCE_ASSIGN : MsoProperties.MSO_REST_API_SERVICE_INSTANCE_CREATE
+ MsoProperties.MSO_REST_API_SERVICE_INSTANCE_ASSIGN : MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE
);
}
@Override
public String getServiceDeletionPath(String serviceInstanceId) {
- return MsoBusinessLogicImpl.validateEndpointPath( MsoProperties.MSO_DELETE_OR_UNASSIGN_REST_API_SVC_INSTANCE) + "/" + serviceInstanceId;
+ return MsoBusinessLogicImpl.validateEndpointPath( MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE) + "/" + serviceInstanceId;
}
@Override
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
index 01b8e8acf..0c6d1d74f 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
@@ -262,6 +262,7 @@ appDS2
FLAG_VF_MODULE_RESUME_STATUS_CREATE: "FLAG_VF_MODULE_RESUME_STATUS_CREATE",
FLAG_1908_RELEASE_TENANT_ISOLATION: "FLAG_1908_RELEASE_TENANT_ISOLATION",
FLAG_FLASH_REPLACE_VF_MODULE: "FLAG_FLASH_REPLACE_VF_MODULE",
+ FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT: "FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT",
}
};
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js
index 7fa312ed9..b3afcd864 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/InstantiationController.js
@@ -225,12 +225,20 @@
};
$scope.allowTransferToNewScreenAndShowButton = function (){
- if(featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_FLASH_REPLACE_VF_MODULE)) {
- return $scope.isPermitted && !($scope.isMacro());
+ if(featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT)) {
+ return $scope.isPermitted;
}
return false;
};
+ $scope.navigateToNewEditViewScreen = function(){
+ window.location.href = 'serviceModels.htm#/servicePlanning/EDIT?' +
+ 'serviceModelId=' + _.get($scope, 'service.model.service.uuid') +
+ '&subscriberId=' + $location.search().subscriberId +
+ '&serviceType=' + $location.search().serviceType +
+ '&serviceInstanceId=' + $location.search().serviceInstanceId;
+ };
+
$scope.deleteService = function (serviceObject, serviceOrchestrationStatus) {
var serviceInstance = serviceObject.object;
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js
index 3403cc2af..b83774889 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js
@@ -81,7 +81,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
// $scope.deleteServiceInstance();
// $scope.generateInvalidUrl405();
}, 100);
- }
+ };
$scope.autoGetSubDetails = function() {
/*
@@ -93,7 +93,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
// $scope.deleteServiceInstance();
// $scope.generateInvalidUrl405();
}, 100);
- }
+ };
$scope.autoPopulateViewEdit = function() {
/*
@@ -105,7 +105,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
// $scope.deleteServiceInstance();
// $scope.generateInvalidUrl405();
}, 100);
- }
+ };
$scope.refreshSubs = function() {
/*
@@ -117,7 +117,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
// $scope.deleteServiceInstance();
// $scope.generateInvalidUrl405();
}, 100);
- }
+ };
$scope.autoStartQueryTest = function() {
/*
@@ -127,7 +127,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
$timeout(function() {
// $scope.queryServiceInstance();
}, 100);
- }
+ };
$scope.queryServiceInstance = function() {
/*
@@ -136,7 +136,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
$scope.$broadcast(COMPONENT.QUERY_SERVICE_INSTANCE, {
serviceInstanceId: COMPONENT.SERVICE_INSTANCE_ID_1
});
- }
+ };
$scope.getSubscribers = function() {
/*
@@ -146,7 +146,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
url : FIELD.ID.AAI_GET_SUBSCRIBERS,
requestDetails : createServiceRequestDetails
});
- }
+ };
$scope.getSubDetails = function() {
/*
@@ -156,7 +156,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
url : FIELD.ID.AAI_SUB_DETAILS,
requestDetails : createServiceRequestDetails
});
- }
+ };
$scope.getComponentList = function() {
/*
@@ -166,7 +166,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
url : FIELD.ID.AAI_SUB_VIEWEDIT,
requestDetails : createServiceRequestDetails
});
- }
+ };
$scope.refreshSubscribers = function() {
@@ -177,7 +177,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
url : FIELD.ID.AAI_REFRESH_SUBSCRIBERS,
requestDetails : createServiceRequestDetails
});
- }
+ };
$scope.deleteServiceInstance = function() {
/*
@@ -187,21 +187,21 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
url : COMPONENT.MSO_DELETE_SVC_INSTANCE_PATH + COMPONENT.SERVICE_INSTANCE_ID_1,
requestDetails : deleteServiceRequestDetails
});
- }
+ };
$scope.createNetworkInstance = function() {
$scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {
url : COMPONENT.MSO_CREATE_NW_INSTANCE,
requestDetails : createNetworkRequestDetails
});
- }
+ };
$scope.deleteNetworkInstance = function() {
$scope.$broadcast(COMPONENT.MSO_DELETE_REQ, {
url : COMPONENT.MSO_CREATE_NW_INSTANCE_PATH + COMPONENT.SERVICE_INSTANCE_ID_1 + COMPONENT.FORWARD_SLASH + COMPONENT.NETWORKS + COMPONENT.FORWARD_SLASH + COMPONENT.DELETE_INSTANCE_ID_1,
requestDetails : deleteNetworkRequestDetails
});
- }
+ };
$scope.generateError = function(testName) {
// Clone example request object
@@ -211,7 +211,7 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
url : COMPONENT.MSO_CREATE_SVC_INSTANCE,
requestDetails : request
});
- }
+ };
$scope.generateInvalidUrl404 = function() {
var properties = UtilityService.getProperties(properties);
@@ -227,14 +227,14 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
properties.msoDefaultBaseUrl = $scope.baseUrl;
UtilityService.setProperties(properties);
$scope.$broadcast(COMPONENT.REFRESH_PROPERTIES);
- }
+ };
$scope.generateInvalidUrl405 = function() {
$scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {
url : COMPONENT.INVALID_STRING_MSO_CREATE_SVC_INSTANCE,
requestDetails : createServiceRequestDetails
});
- }
+ };
/*
* Test data objects:
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js
index 5b8cb7445..bf4941f28 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/directives/parameterBlockDirective.js
@@ -397,7 +397,7 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService, $compile
element.find("input, select").bind("change.namespace2", function() {
callback(this, scope);
});
- }
+ };
control.getList = function(expectedId) {
var parameterList = new Array();
@@ -411,7 +411,7 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService, $compile
parameterList.push({id: key, value: value});
});
return parameterList;
- }
+ };
control.getRequiredFields = function() {
var requiredFields = "";
@@ -433,10 +433,10 @@ var parameterBlockDirective = function($log, PARAMETER, UtilityService, $compile
} else {
return requiredFields + " and " + count + " other fields";
}
- }
+ };
}
}
-}
+};
appDS2.directive('parameterBlock', [ "$log", "PARAMETER", "UtilityService", "$compile",
parameterBlockDirective ]);
@@ -469,7 +469,7 @@ appDS2.directive('onlyIntegers', function () {
}
});
}
- }
+ };
});
appDS2.directive('onlyFloat', function () {
@@ -487,5 +487,5 @@ appDS2.directive('onlyFloat', function () {
}
});
}
- }
+ };
});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/directives/popupWindowDirective.js b/vid-app-common/src/main/webapp/app/vid/scripts/directives/popupWindowDirective.js
index 1ca32034c..a26744d38 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/directives/popupWindowDirective.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/directives/popupWindowDirective.js
@@ -64,7 +64,7 @@ var popupWindowDirective = function($log, $window) {
scrollPosition = {
x : $window.pageXOffset,
y : $window.pageYOffset
- }
+ };
$window.scrollTo(0, 0);
element.css("display", "table");
element.prev().css("display", "block");
@@ -74,7 +74,7 @@ var popupWindowDirective = function($log, $window) {
$window.scrollTo(scrollPosition.x, scrollPosition.y);
}
});
- }
+ };
return {
restrict : "EA",
@@ -83,6 +83,6 @@ var popupWindowDirective = function($log, $window) {
link : link,
template : '<table style="display: none; position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-collapse: collapse; margin: 0; padding: 0"> <tr><td align="center" style="vertical-align: top; padding: 10px"><div style="display: inline-block; padding: 5px; background-color: white" ng-transclude></div></td></tr></table>'
};
-}
+};
appDS2.directive("popupWindow", [ "$log", "$window", popupWindowDirective ]);
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/directives/progressBarDirective.js b/vid-app-common/src/main/webapp/app/vid/scripts/directives/progressBarDirective.js
index 2f60d65dc..8294597bd 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/directives/progressBarDirective.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/directives/progressBarDirective.js
@@ -127,7 +127,7 @@ var progressBarDirective = function() {
*/
element.html("");
}
- }
+ };
return {
restrict : "EA",
@@ -153,7 +153,7 @@ var progressBarDirective = function() {
control.reset = function() {
previousValue = 0;
updateProgress(element, attrs, 0);
- }
+ };
attrs.$observe("value", function(valueString) {
updateProgress(element, attrs, valueString);
@@ -167,7 +167,7 @@ var progressBarDirective = function() {
}
});
}
- }
-}
+ };
+};
appDS2.directive("progressBar", progressBarDirective);
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 3f4a94ee0..de0ec4026 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
@@ -24,7 +24,7 @@
<span ng-click="vm.close()" class="pull-right modal-close" aria-hidden="true">&times;</span>
<div ng-if="vm.errorMsg!==''"><font color='red'>{{vm.errorMsg.message}}</font></div>
</div>
-<form class="form-create" name="newChangeManagement" ng-submit="vm.openModal();vm.close();" novalidate>
+<form class="form-create" data-tests-id="newChangeManagementForm" name="newChangeManagement" ng-submit="vm.openModal();vm.close();" novalidate>
<div class="modal-body step1" ng-show="vm.wizardStep === 1" >
<div class="form-group">
<label class="control-label">Subscriber</label>
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/change-management.html
index 1d8b39c80..194df6e4d 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/change-management.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/change-management.html
@@ -25,7 +25,7 @@
<div class="header">
<span id="change-management-headline">VNF Changes</span>
<span class="separator"></span>
- <div class="button-container" ng-click="vm.createNewChange()">
+ <div data-tests-id="create-new-change-management" class="button-container" ng-click="vm.createNewChange()">
<div class="icon-svg" id="change-management-new-button">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 55.47337 55.63023"><path class="icon-filling" d="M27.7367.07843A27.73669,27.73669,0,1,0,55.4734,27.81512,27.73757,27.73757,0,0,0,27.7367.07843ZM40.18824,29.6178H29.53938V40.26666a1.80267,1.80267,0,0,1-3.60535,0V29.6178H15.28516a1.80267,1.80267,0,0,1,0-3.60535H25.934V15.36359a1.80267,1.80267,0,0,1,3.60535,0V26.01245H40.18824a1.80267,1.80267,0,1,1,0,3.60535Z"/></svg>
</div>
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm
index f80f924b3..6399065f8 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/view-models/instantiate.htm
@@ -41,7 +41,9 @@
<h1 class="heading1" style="margin-top: 20px;">{{isPermitted ? "View/Edit" : "View"}} Service Instance</h1>
<a class="btn btn-primary btn-xs pull-right" ng-click="reloadRoute();"><span
class="glyphicon glyphicon-refresh"></span></a>
-
+ <a class="pull-right btn btn-primary btn-xs" data-nodrag
+ data-tests-id="show-new-screen" ng-if="allowTransferToNewScreenAndShowButton()"
+ ng-click="navigateToNewEditViewScreen()" style="margin-right: 8px;">More actions</a>
<br>
<center>
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
index 5c37bb1ee..777729c03 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java
@@ -56,7 +56,6 @@ import java.net.URI;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Map;
-import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Stream;
@@ -756,51 +755,6 @@ public class AaiClientTest {
};
}
- @Test
- public void testGetLatestVersionByInvariantId() throws IOException {
-
- ModelVersions modelVersions = JACKSON_OBJECT_MAPPER.readValue("" +
- "{\n" +
- " \"results\": [\n" +
- " {\n" +
- " \"model\": {\n" +
- " \"model-invariant-id\": \"f6342be5-d66b-4d03-a1aa-c82c3094c4ea\",\n" +
- " \"model-type\": \"service\",\n" +
- " \"resource-version\": \"1534274421300\"\n" +
- " }\n" +
- " },\n" +
- " {\n" +
- " \"model-ver\": {\n" +
- " \"model-version-id\": \"a92f899d-a3ec-465b-baed-1663b0a5aee1\",\n" +
- " \"model-name\": \"NCM_VLAN_SVC_ym161f\",\n" +
- " \"model-version\": \"bbb\",\n" +
- " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
- " \"model-description\": \"Network Collection service for vLAN tagging\",\n" +
- " \"resource-version\": \"1534788756086\"\n" +
- " }\n" +
- " },\n" +
- " {\n" +
- " \"model-ver\": {\n" +
- " \"model-version-id\": \"d2fda667-e92e-4cfa-9620-5da5de01a319\",\n" +
- " \"model-name\": \"NCM_VLAN_SVC_ym161f\",\n" +
- " \"model-version\": \"aaa\",\n" +
- " \"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\",\n" +
- " \"model-description\": \"Network Collection service for vLAN tagging\",\n" +
- " \"resource-version\": \"1534444087221\"\n" +
- " }\n" +
- " }]}", ModelVersions.class);
-
-
- final AaiClient aaiClient = new AaiClient(null, null, null);
-
- assertThat(aaiClient.toModelVerStream(modelVersions).collect(toList()),
- containsInAnyOrder(
- hasProperty("modelVersionId", is("a92f899d-a3ec-465b-baed-1663b0a5aee1")),
- hasProperty("modelVersionId", is("d2fda667-e92e-4cfa-9620-5da5de01a319"))
- ));
-
- }
-
@DataProvider
public static Object[][] versionsDataProvider() {
return new Object[][] {
@@ -984,5 +938,4 @@ public class AaiClientTest {
));
}
-
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
index 045488605..c85c96b6d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiResponseTranslatorTest.java
@@ -21,18 +21,19 @@
package org.onap.vid.aai;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataError;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataOk;
import org.testng.annotations.Test;
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
public class AaiResponseTranslatorTest {
private static final ObjectMapper objectMapper = new ObjectMapper();
@@ -116,6 +117,7 @@ public class AaiResponseTranslatorTest {
}
+ @Test
public void extractPortMirroringConfigData_givenAaiResponseWithoutRegionIdName_yieldException() throws IOException {
final JsonNode aaiPayload = objectMapper.readTree("" +
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
index aeb010071..10f272a36 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
@@ -127,6 +127,19 @@ public class ToscaParserImpl2Test {
assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedService), om.writeValueAsString(actualService));
}
+
+ @Test
+ public void testScalingPolicyOfGroup() throws AsdcCatalogException, SdcToscaParserException {
+ String vnfGroupingUuid = "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc";
+ ISdcCsarHelper sdcCsarHelper = toscaParserImpl2.getSdcCsarHelper(getCsarPath(vnfGroupingUuid));
+ Map<String, Integer> policiesTargets = toscaParserImpl2.extractScalingPolicyOfGroup(sdcCsarHelper);
+
+ assertThat(policiesTargets, is(ImmutableMap.of(
+ "vdorothea_svc_vprs_proxy 0", 2,
+ "groupingservicefortest..ResourceInstanceGroup..1", 3
+ )));
+ }
+
@Test(dataProvider = "expectedServiceModel")
public void assertEqualBetweenObjects(String uuid, ToscaParserMockHelper mockHelper) throws Exception {
final Path csarPath = getCsarPath(mockHelper.getUuid());
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 b51bbdc31..f9a374948 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
@@ -21,6 +21,8 @@
package org.onap.vid.controller;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
@@ -45,8 +47,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.vid.aai.AaiResponse;
+import org.onap.vid.aai.AaiResponseTranslator;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataError;
import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataOk;
@@ -94,7 +98,7 @@ public class AaiControllerTest {
@Before
public void setUp() {
aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper,
- featureManager);
+ featureManager);
mockMvc = MockMvcBuilders.standaloneSetup(aaiController).build();
}
@@ -108,12 +112,12 @@ public class AaiControllerTest {
given(aaiService.getAicZoneForPnf(globalCustomerId, serviceType, serviceId)).willReturn(aaiResponse);
mockMvc.perform(
- get("/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}", globalCustomerId, serviceType,
- serviceId)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody)));
+ get("/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}", globalCustomerId, serviceType,
+ serviceId)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody)));
}
@Test
@@ -124,10 +128,10 @@ public class AaiControllerTest {
given(aaiService.getInstanceGroupsByVnfInstanceId(vnfInstanceId)).willReturn(aaiResponse);
mockMvc.perform(get("/aai_get_instance_groups_by_vnf_instance_id/{vnfInstanceId}", vnfInstanceId)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody)));
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody)));
}
@Test
@@ -140,17 +144,17 @@ public class AaiControllerTest {
given(response.getStatus()).willReturn(HttpStatus.OK.value());
given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI(
- "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
- + serviceInstanceId)),
- eq(false)).getResponse()).willReturn(response);
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+ + serviceInstanceId)),
+ eq(false)).getResponse()).willReturn(response);
mockMvc
- .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId,
- serviceInstanceType)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(expectedResponseBody));
+ .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId,
+ serviceInstanceType)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponseBody));
}
@Test
@@ -163,17 +167,17 @@ public class AaiControllerTest {
given(response.getStatus()).willReturn(HttpStatus.OK.value());
given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI(
- "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
- + serviceInstanceId)),
- eq(false)).getResponse()).willReturn(response);
+ "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
+ + serviceInstanceId)),
+ eq(false)).getResponse()).willReturn(response);
mockMvc
- .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId,
- serviceInstanceType)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(expectedResponseBody));
+ .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId,
+ serviceInstanceType)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponseBody));
}
@Test
@@ -186,21 +190,21 @@ public class AaiControllerTest {
given(response.getStatus()).willReturn(HttpStatus.OK.value());
given(aaiRestInterface.RestGet(
- eq("VidAaiController"),
- anyString(),
- eq(Unchecked.toURI(
- "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
- + serviceSubscriptionId + "?depth=0")),
- eq(false)).getResponse()).willReturn(response);
+ eq("VidAaiController"),
+ anyString(),
+ eq(Unchecked.toURI(
+ "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
+ + serviceSubscriptionId + "?depth=0")),
+ eq(false)).getResponse()).willReturn(response);
mockMvc
- .perform(
- get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId,
- serviceSubscriptionId)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(expectedResponseBody));
+ .perform(
+ get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId,
+ serviceSubscriptionId)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponseBody));
}
@Test
@@ -209,21 +213,21 @@ public class AaiControllerTest {
String serviceSubscriptionId = "testServiceSubscriptionId";
String expectedResponseBody = "Failed to fetch data from A&AI, check server logs for details.";
given(aaiRestInterface.RestGet(
- eq("VidAaiController"),
- anyString(),
- eq(Unchecked.toURI(
- "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
- + serviceSubscriptionId + "?depth=0")),
- eq(false)).getResponse()).willReturn(null);
+ eq("VidAaiController"),
+ anyString(),
+ eq(Unchecked.toURI(
+ "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
+ + serviceSubscriptionId + "?depth=0")),
+ eq(false)).getResponse()).willReturn(null);
mockMvc
- .perform(
- get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId,
- serviceSubscriptionId)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isInternalServerError())
- .andExpect(content().string(expectedResponseBody));
+ .perform(
+ get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId,
+ serviceSubscriptionId)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isInternalServerError())
+ .andExpect(content().string(expectedResponseBody));
}
@Test
@@ -231,18 +235,18 @@ public class AaiControllerTest {
PortMirroringConfigDataOk okConfigData = new PortMirroringConfigDataOk("foo");
PortMirroringConfigDataError errorConfigData = new PortMirroringConfigDataError("bar", "{ baz: qux }");
Map<String, PortMirroringConfigData> expectedJson = ImmutableMap.of(
- ID_1, okConfigData,
- ID_2, errorConfigData);
+ ID_1, okConfigData,
+ ID_2, errorConfigData);
given(aaiService.getPortMirroringConfigData(ID_1)).willReturn(okConfigData);
given(aaiService.getPortMirroringConfigData(ID_2)).willReturn(errorConfigData);
mockMvc
- .perform(get("/aai_getPortMirroringConfigsData")
- .param("configurationIds", ID_1, ID_2)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().json(objectMapper.writeValueAsString(expectedJson)));
+ .perform(get("/aai_getPortMirroringConfigsData")
+ .param("configurationIds", ID_1, ID_2)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().json(objectMapper.writeValueAsString(expectedJson)));
}
@Test
@@ -250,18 +254,18 @@ public class AaiControllerTest {
PortDetailsOk portDetailsOk = new PortDetailsOk("foo", "testInterface", true);
PortDetailsError portDetailsError = new PortDetailsError("bar", "{ baz: qux }");
Multimap<String, PortDetails> expectedJson = ImmutableMultimap.of(
- ID_1, portDetailsOk,
- ID_2, portDetailsError);
+ ID_1, portDetailsOk,
+ ID_2, portDetailsError);
given(aaiService.getPortMirroringSourcePorts(ID_1)).willReturn(Lists.newArrayList(portDetailsOk));
given(aaiService.getPortMirroringSourcePorts(ID_2)).willReturn(Lists.newArrayList(portDetailsError));
mockMvc
- .perform(get("/aai_getPortMirroringSourcePorts")
- .param("configurationIds", ID_1, ID_2)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().json(objectMapper.writeValueAsString(expectedJson.asMap())));
+ .perform(get("/aai_getPortMirroringSourcePorts")
+ .param("configurationIds", ID_1, ID_2)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().json(objectMapper.writeValueAsString(expectedJson.asMap())));
}
@Test
@@ -275,15 +279,15 @@ public class AaiControllerTest {
String expectedResponseBody = "myResponse";
AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value());
given(aaiService
- .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion))
- .willReturn(aaiResponse);
+ .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion))
+ .willReturn(aaiResponse);
mockMvc
- .perform(get(urlTemplate, globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion)
- .contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(expectedResponseBody));
+ .perform(get(urlTemplate, globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string(expectedResponseBody));
}
@Test
@@ -292,45 +296,45 @@ 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
public void getAicZones_shouldReturnErrorResponse_whenAaiHttpStatusOtherThanOK() throws Exception {
String expectedErrorMessage = "Calling AAI Failed";
given(aaiService.getAaiZones())
- .willReturn(new AaiResponse(null, expectedErrorMessage, HttpStatus.INTERNAL_SERVER_ERROR.value()));
+ .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
@@ -340,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 {
@@ -359,16 +363,16 @@ public class AaiControllerTest {
AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value());
given(aaiService
- .getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor,
- equipModel)).willReturn(aaiResponse);
+ .getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor,
+ 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
@@ -379,20 +383,20 @@ public class AaiControllerTest {
Response response = mock(Response.class);
given(response.readEntity(String.class)).willReturn(expectedResponse);
given(aaiService
- .getVersionByInvariantId(request.versions)).willReturn(response);
+ .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
public void getSubscriberDetails_shouldOmitServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsTrue()
- throws Exception {
+ throws Exception {
boolean isFeatureActive = true;
boolean omitServiceInstances = true;
@@ -401,21 +405,21 @@ public class AaiControllerTest {
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 getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsFalse()
- throws Exception {
+ throws Exception {
boolean isFeatureActive = true;
boolean omitServiceInstances = false;
@@ -424,7 +428,7 @@ public class AaiControllerTest {
@Test
public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsTrue()
- throws Exception {
+ throws Exception {
boolean isFeatureActive = false;
boolean omitServiceInstances = true;
@@ -432,30 +436,52 @@ 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");
+
+ Mockito
+ .doReturn(toBeReturnedForA)
+ .doReturn(toBeReturnedForB)
+ .doReturn(toBeReturnedForC)
+ .when(aaiService).getPortMirroringConfigData(Mockito.anyString());
+
+ final Map<String, AaiResponseTranslator.PortMirroringConfigData> result = aaiController.getPortMirroringConfigsData(ImmutableList.of("a", "b", "c"));
+
+ assertThat(result, is(ImmutableMap.of(
+ "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)));
}
}
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/PromiseEcompRequestIdFilterTest.java
index f44099569..39638c305 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/PromiseEcompRequestIdFilterTest.java
@@ -67,6 +67,21 @@ public class PromiseEcompRequestIdFilterTest {
buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(someTxId));
}
+
+ @Test
+ public void givenRequestIdHeaderThatIsNotAUUID_headerValueChanged() throws IOException, ServletException {
+
+ final String someTxId = "863850e28544efd94b8afba5f52b3d5";
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ anotherHeader, anotherValue,
+ ECOMP_REQUEST_ID, someTxId
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, UserUtils::getRequestId);
+ }
+
+
@Test
public void givenMixedCaseRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
index 498708d06..fdc416a3b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
@@ -20,9 +20,66 @@
package org.onap.vid.job.impl;
+import static java.util.stream.Collectors.counting;
+import static java.util.stream.Collectors.groupingBy;
+import static java.util.stream.Collectors.joining;
+import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartMatches;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.core.Every.everyItem;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.endsWith;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_ERRORS;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_NO_ACTION;
+import static org.onap.vid.job.Job.JobStatus.FAILED;
+import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.PAUSE;
+import static org.onap.vid.job.Job.JobStatus.PENDING;
+import static org.onap.vid.job.Job.JobStatus.PENDING_RESOURCE;
+import static org.onap.vid.job.Job.JobStatus.RESOURCE_IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.STOPPED;
+import static org.onap.vid.job.impl.JobSchedulerInitializer.WORKERS_TOPICS;
+import static org.onap.vid.model.JobAuditStatus.SourceStatus.VID;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Stack;
+import java.util.UUID;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+import javax.inject.Inject;
+import javax.ws.rs.ProcessingException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.mutable.MutableInt;
import org.jetbrains.annotations.NotNull;
@@ -33,13 +90,24 @@ import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.config.DataSourceConfig;
+import org.onap.vid.config.JobCommandsConfigWithMockedMso;
+import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
import org.onap.vid.job.Job;
import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.job.JobType;
import org.onap.vid.job.JobsBrokerService;
import org.onap.vid.job.command.CommandUtils;
import org.onap.vid.job.command.InternalState;
-import org.onap.vid.model.*;
+import org.onap.vid.model.Action;
+import org.onap.vid.model.JobAuditStatus;
+import org.onap.vid.model.NameCounter;
+import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.Service;
+import org.onap.vid.model.ServiceInfo;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.VNF;
+import org.onap.vid.model.VfModule;
import org.onap.vid.model.serviceInstantiation.BaseResource;
import org.onap.vid.model.serviceInstantiation.InstanceGroup;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
@@ -49,15 +117,12 @@ import org.onap.vid.mso.model.RequestReferences;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.AsyncRequestStatusList;
import org.onap.vid.properties.Features;
+import org.onap.vid.services.AsyncInstantiationBaseTest;
import org.onap.vid.services.AsyncInstantiationBusinessLogic;
import org.onap.vid.services.AuditService;
import org.onap.vid.services.VersionService;
-import org.onap.vid.utils.DaoUtils;
-import org.onap.vid.config.DataSourceConfig;
-import org.onap.vid.config.JobCommandsConfigWithMockedMso;
-import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
-import org.onap.vid.services.AsyncInstantiationBaseTest;
import org.onap.vid.testUtils.TestUtils;
+import org.onap.vid.utils.DaoUtils;
import org.springframework.http.HttpMethod;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
@@ -66,34 +131,6 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.togglz.core.manager.FeatureManager;
-import javax.inject.Inject;
-import javax.ws.rs.ProcessingException;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.*;
-import java.util.function.BiConsumer;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-import static java.util.stream.Collectors.*;
-import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
-import static net.javacrumbs.jsonunit.JsonMatchers.*;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.core.Every.everyItem;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.endsWith;
-import static org.mockito.ArgumentMatchers.*;
-import static org.mockito.Mockito.*;
-import static org.onap.vid.job.Job.JobStatus.*;
-import static org.onap.vid.job.impl.JobSchedulerInitializer.WORKERS_TOPICS;
-import static org.onap.vid.model.JobAuditStatus.SourceStatus.VID;
-import static org.testng.AssertJUnit.*;
-
//it's more like integration test than UT
//But it's very hard to test in API test so I use UT
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class, JobCommandsConfigWithMockedMso.class})
@@ -1203,12 +1240,18 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
}
@Test
- public void whenUpgradingAvfModule_thanExpectedReplaceRequestSent() throws IOException {
- String instanceId = "5d49c3b1-fc90-4762-8c98-e800170baa55"; //from feRequestResumeMacroService.json
+ public void whenUpgradingAvfModule_thanExpectedReplaceRequestSent() throws IOException, AsdcCatalogException {
+ String instanceId = "5d49c3b1-fc90-4762-8c98-e800170baa55"; //from replace_vfmodule_fe_input.json
String replaceRequestId = randomUuid();
String userId = "az2016";
+ //prepare mocks for newest model
+ String newestModelUuid = "newest-model-uuid";
+ when(commandUtils.getNewestModelUuid(eq("b16a9398-ffa3-4041-b78c-2956b8ad9c7b"))).thenReturn(newestModelUuid);
+
+ when(commandUtils.getServiceModel(eq(newestModelUuid))).thenReturn(generateMockLatestModelForUpgrade());
+
//prepare mocks resume request
when(restMso.restCall(eq(HttpMethod.POST), eq(RequestReferencesContainer.class), any(), eq("/serviceInstantiation/v7/serviceInstances/e9993045-cc96-4f3f-bf9a-71b2a400a956/vnfs/5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5/vfModules/5d49c3b1-fc90-4762-8c98-e800170baa55/replace"), eq(Optional.of(userId))))
.thenReturn(createResponse(202, instanceId, replaceRequestId));
@@ -1235,7 +1278,53 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
requestCaptor.getAllValues().forEach(x->assertJsonEquals(expectedJson, x));
}
+ private ServiceModel generateMockLatestModelForUpgrade() {
+ ServiceModel expectedNewestModel = new ServiceModel();
+
+
+ VfModule vfm = new VfModule();
+ vfm.setModelCustomizationName("newest-model-customization-name-vfm");
+ vfm.setCustomizationUuid("newest-model-customization-uuid-vfm");
+ vfm.setVersion("newest-model-version-vfm");
+ vfm.setUuid("newest-model-uuid-vfm");
+ vfm.setName("newest-model-name-vfm");
+ vfm.setInvariantUuid("f7a867f2-596b-4f4a-a128-421e825a6190");
+
+
+ Map<String,VfModule> vfms = new HashMap<>();
+ vfms.put("074c64d0-7e13-4bcc-8bdb-ea922331102d", vfm);
+
+
+ VNF vnf = new VNF();
+ vnf.setModelCustomizationName("newest-model-customization-name-vnf");
+ vnf.setCustomizationUuid("newest-model-customization-uuid-vnf");
+ vnf.setVersion("newest-model-version-vnf");
+ vnf.setUuid("newest-model-uuid-vnf");
+ vnf.setName("newest-model-name-vnf");
+ vnf.setInvariantUuid("23122c9b-dd7f-483f-bf0a-e069303db2f7");
+ vnf.setVfModules(vfms);
+ expectedNewestModel.setVfModules(vfms);
+
+ Map<String,VNF> vnfs = new HashMap<>();
+ vnfs.put("96c23a4a-6887-4b2c-9cce-1e4ea35eaade", vnf);
+
+ Service svc = new Service();
+ svc.setInvariantUuid("b16a9398-ffa3-4041-b78c-2956b8ad9c7b");
+ svc.setUuid("newest-model-uuid-service");
+ svc.setVersion("newest-model-version-service");
+ svc.setName("newest-model-name-service");
+
+ expectedNewestModel.setService(svc);
+
+ expectedNewestModel.setVnfs(vnfs);
+
+ return expectedNewestModel;
+
+
+ }
+
private ServiceInstantiation generateReplaceVfModulePayload() throws IOException {
return TestUtils.readJsonResourceFileAsObject("/payload_jsons/vfmodule/replace_vfmodule_fe_input.json", ServiceInstantiation.class);
}
+
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index 2ea37f4bc..558dc269f 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -138,7 +138,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
public void shouldProperlyCreateConfigurationInstanceWithCorrectServiceInstanceId() throws Exception {
// given
String serviceInstanceId = "3f93c7cb-2fd0-4557-9514-e189b7b04f9d";
- String endpointTemplate = String.format("/serviceInstances/v6/%s/configurations", serviceInstanceId);
+ String endpointTemplate = String.format("/serviceInstantiation/v7/serviceInstances/%s/configurations", serviceInstanceId);
RequestDetailsWrapper requestDetailsWrapper = createRequestDetails();
MsoResponseWrapper expectedResponse = createOkResponse();
given(msoInterface.createConfigurationInstance(requestDetailsWrapper, endpointTemplate))
@@ -184,7 +184,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
public void shouldProperlyCreateSvcInstanceWithProperParameters() {
MsoResponseWrapper expectedResponse = createOkResponse();
- String svcEndpoint = SystemProperties.getProperty(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String svcEndpoint = SystemProperties.getProperty(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
given(msoInterface.createSvcInstance(msoRequest, svcEndpoint)).willReturn(expectedResponse);
MsoResponseWrapper response = msoBusinessLogic.createSvcInstance(msoRequest);
@@ -833,7 +833,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
public void shouldProperlyGetActivateFabricConfigurationPathWithProperParameters() {
// given
String serviceInstanceId = "testServiceId";
- String path = validateEndpointPath(MsoProperties.MSO_REST_API_SERVICE_INSTANCE_CREATE);
+ String path = validateEndpointPath(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
path += "/" + serviceInstanceId + "/activateFabricConfiguration";
// when
@@ -845,20 +845,14 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
@Test
public void shouldProperlyGetDeactivateAndCloudDeletePathWithProperParameters() {
- // given
- String serviceInstanceId = "testServiceId";
- String vnfInstanceId = "testVnfInstanceId";
- String vfModuleInstanceId = "testVfModuleInstanceId";
- String path = validateEndpointPath(MsoProperties.MSO_REST_API_VF_MODULE_INSTANCE);
- path = path.replaceFirst(SVC_INSTANCE_ID, serviceInstanceId);
- path = path.replaceFirst(VNF_INSTANCE_ID, vnfInstanceId);
- path += "/" + vfModuleInstanceId + "/deactivateAndCloudDelete";
// when
- String response = msoBusinessLogic.getDeactivateAndCloudDeletePath(serviceInstanceId, vnfInstanceId, vfModuleInstanceId);
+ String response = msoBusinessLogic.getDeactivateAndCloudDeletePath("testServiceId", "testVnfInstanceId", "testVfModuleInstanceId");
// then
- assertThat(response).isEqualTo(path);
+ String expectedPath = "/serviceInstantiation/v7/serviceInstances/testServiceId/vnfs/testVnfInstanceId/"+
+ "vfModules/testVfModuleInstanceId/deactivateAndCloudDelete";
+ assertThat(response).isEqualTo(expectedPath);
}
@Test
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
index c47e7ce4e..65cfcc18d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
@@ -46,7 +46,6 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.portalsdk.core.util.SystemProperties;
-import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.controller.MsoController;
import org.onap.vid.controller.WebConfig;
@@ -196,7 +195,7 @@ public class MsoRestClientNewTest {
@Ignore
@Test
public void testDeleteSvcInstance() throws Exception {
- String endpoint = props.getString(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String endpoint = props.getString(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
endpoint = endpoint.replaceFirst(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
@@ -360,7 +359,7 @@ public class MsoRestClientNewTest {
@Test
public void testSetConfigurationActiveStatus() throws Exception {
- String endpoint = "/serviceInstances/v7/<service_instance_id>/configurations/<configuration_id>";
+ String endpoint = "/serviceInstantiation/v7/serviceInstances/<service_instance_id>/configurations/<configuration_id>";
endpoint = endpoint.replace(MsoController.SVC_INSTANCE_ID, SERVICE_INSTANCE_ID);
endpoint = endpoint.replace(MsoController.CONFIGURATION_ID, SAMPLE_CONFIGURATION_ID);
endpoint = endpoint + "/activate";
@@ -432,7 +431,7 @@ public class MsoRestClientNewTest {
@Test
public void testRemoveRelationshipFromServiceInstance() throws Exception {
- String serviceEndpoint = props.getString(MsoProperties.MSO_REST_API_SVC_INSTANCE);
+ String serviceEndpoint = props.getString(MsoProperties.MSO_RESTAPI_SERVICE_INSTANCE);
String removeRelationshipsPath = serviceEndpoint + "/" + SERVICE_INSTANCE_ID + "/removeRelationships";
try (MsoRestClientTestUtil closure = new MsoRestClientTestUtil(
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
index c91e88be7..78982ef24 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
@@ -25,18 +25,32 @@ import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.hasEntry;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.refEq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
+import static org.mockito.hamcrest.MockitoHamcrest.argThat;
+import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
+import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.AssertJUnit.assertEquals;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonMapper;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.message.BasicStatusLine;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.aai.HttpResponseWithRequestInfo;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
@@ -54,17 +68,11 @@ import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.http.HttpMethod;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.mockito.ArgumentMatchers.refEq;
-import static org.mockito.hamcrest.MockitoHamcrest.argThat;
-import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
-
@ContextConfiguration(classes = {LocalWebConfig.class, SystemProperties.class})
@WebAppConfiguration
@@ -139,6 +147,45 @@ public class MsoRestClientTest {
}
@Test
+ public void whenCreateInstanceTwice_thenRequestIdHeaderIsDifferentEachTime() {
+
+ RequestAttributes prevRequestAttributes = RequestContextHolder.getRequestAttributes();
+
+ try {
+ //given
+ Mockito.reset(client);
+
+ //mocking syncRestClient
+ RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
+ HttpResponse<String> httpResponse = HttpResponse.fallback("testOkResponse");
+ when( client.post( anyString() ,anyMap(), any(RequestDetails.class), eq(String.class) ) ).thenReturn(httpResponse);
+
+ //when
+ //create different ECOMP_REQUEST_ID header in Spring HttpServlet each time
+ OutgoingRequestHeadersTest.putRequestInSpringContext();
+ restClient.createInstance(requestDetails, "someEndPoint");
+
+ OutgoingRequestHeadersTest.putRequestInSpringContext();
+ restClient.createInstance(requestDetails, "someEndPoint");
+
+ //then
+ ArgumentCaptor<Map<String, String>> requestCaptor = ArgumentCaptor.forClass(Map.class);
+ verify(client, times(2)).post(anyString(), requestCaptor.capture(), any(RequestDetails.class), eq(String.class));
+ assertEquals(2, requestCaptor.getAllValues().size());
+ assertNotEquals(requestCaptor.getAllValues().get(0).get(SystemProperties.ECOMP_REQUEST_ID),
+ requestCaptor.getAllValues().get(1).get(SystemProperties.ECOMP_REQUEST_ID),
+ SystemProperties.ECOMP_REQUEST_ID + " headers are the same");
+ assertNotEquals(requestCaptor.getAllValues().get(0).get(ONAP_REQUEST_ID_HEADER_KEY),
+ requestCaptor.getAllValues().get(1).get(ONAP_REQUEST_ID_HEADER_KEY),
+ ONAP_REQUEST_ID_HEADER_KEY + " headers are the same");
+ }
+ finally {
+ //make sure other test keep go smooth
+ RequestContextHolder.setRequestAttributes(prevRequestAttributes);
+ }
+ }
+
+ @Test
public void shouldProperlyCreateVnf() {
// given
RequestDetails requestDetails = MsoRestClientTestUtil.generateMockMsoRequest();
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
index f66235728..ac82a6e53 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTestUtil.java
@@ -32,6 +32,8 @@ import static com.xebialabs.restito.semantics.Condition.post;
import static com.xebialabs.restito.semantics.Condition.uri;
import static com.xebialabs.restito.semantics.Condition.withHeader;
import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
+import static org.onap.vid.mso.rest.MsoRestClientNew.X_ONAP_PARTNER_NAME;
+import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.semantics.Action;
@@ -233,7 +235,10 @@ class MsoRestClientTestUtil implements AutoCloseable {
withHeader(HttpHeaders.ACCEPT),
withHeader(HttpHeaders.CONTENT_TYPE),
withHeader(MsoRestClientNew.X_FROM_APP_ID),
- withHeader(SystemProperties.ECOMP_REQUEST_ID));
+ withHeader(X_ONAP_PARTNER_NAME, "VID"),
+ withHeader(SystemProperties.ECOMP_REQUEST_ID),
+ withHeader(ONAP_REQUEST_ID_HEADER_KEY)
+ );
}
private Action jsonContent(String str) {
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 316f200de..b70ba063f 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
@@ -20,9 +20,33 @@
package org.onap.vid.mso.rest;
+import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasToString;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import java.util.UUID;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MultivaluedMap;
import org.apache.commons.lang3.reflect.FieldUtils;
-import org.mockito.*;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+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;
@@ -37,21 +61,6 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.MultivaluedMap;
-import java.util.Set;
-import java.util.UUID;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-import static org.mockito.Mockito.when;
-
public class OutgoingRequestHeadersTest {
@@ -78,7 +87,11 @@ public class OutgoingRequestHeadersTest {
}
@BeforeMethod
- private void putRequestInSpringContext() {
+ private void setup() {
+ putRequestInSpringContext();
+ }
+
+ public static void putRequestInSpringContext() {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes((HttpServletRequest) PromiseEcompRequestIdFilter.wrapIfNeeded(new MockHttpServletRequest())));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java
new file mode 100644
index 000000000..8c33e7f64
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceTreeIntegrativeTest.java
@@ -0,0 +1,441 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.vid.services;
+
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertNull;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.ws.rs.core.Response;
+import org.mockito.Mock;
+import org.onap.vid.aai.AaiClientInterface;
+import org.onap.vid.aai.ExceptionWithRequestInfo;
+import org.onap.vid.aai.util.AAITreeConverter;
+import org.onap.vid.asdc.AsdcCatalogException;
+import org.onap.vid.asdc.parser.ServiceModelInflator;
+import org.onap.vid.exceptions.GenericUncheckedException;
+import org.onap.vid.model.Action;
+import org.onap.vid.model.ServiceModel;
+import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.FailureAAITreeNode;
+import org.onap.vid.model.aaiTree.ServiceInstance;
+import org.onap.vid.model.aaiTree.Vnf;
+import org.onap.vid.testUtils.TestUtils;
+import org.springframework.http.HttpMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class AAIServiceTreeIntegrativeTest {
+
+ @Mock
+ private AaiClientInterface aaiClient;
+
+ @Mock
+ private Response aaiGetVersionByInvariantIdResponse;
+
+ @Mock
+ ExceptionWithRequestInfo exceptionWithRequestInfo;
+
+ @Mock
+ VidService sdcService;
+
+ @Mock
+ ServiceModelInflator serviceModelInflator;
+
+ private AAITreeNodeBuilder aaiTreeNodeBuilder;
+
+ private AAITreeConverter aaiTreeConverter = new AAITreeConverter();
+
+ private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ private String globalCustomerID = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
+ private String serviceType = "vWINIFRED";
+ private String serviceInstanceId = "62888f15-6d24-4f7b-92a7-c3f35beeb215";
+
+ //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
+ private String serviceInstanceRequestUri = "business/customers/customer/" +
+ globalCustomerID +
+ "/service-subscriptions/service-subscription/" +
+ serviceType +
+ "/service-instances/service-instance/" +
+ serviceInstanceId;
+
+ private static String ServiceInstanceResponseString = "{\"service-instance-id\":\"62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
+ "\"service-instance-name\": \"Dror123\"," +
+ "\"environment-context\": \"null\"," +
+ "\"workload-context\": \"null\"," +
+ "\"model-invariant-id\": \"35340388-0b82-4d3a-823d-cbddf842be52\"," +
+ "\"model-version-id\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"," +
+ "\"resource-version\": \"1515515088894\"," +
+ "\"orchestration-status\": \"Active\"," +
+ "\"relationship-list\": {" +
+ "\"relationship\": [{" +
+ "\"related-to\": \"project\"," +
+ "\"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
+ "\"related-link\": \"/aai/v12/business/projects/project/DFW\"," +
+ "\"relationship-data\": [{" +
+ "\"relationship-key\": \"project.project-name\"," +
+ "\"relationship-value\": \"WATKINS\"}]},{" +
+ "\"related-to\": \"generic-vnf\"," +
+ "\"relationship-label\": \"org.onap.relationships.inventory.ComposedOf\"," +
+ "\"related-link\": \"/aai/v12/network/generic-vnfs/generic-vnf/59bde732-9b84-46bd-a59a-3c45fee0538b\"," +
+ "\"relationship-data\": [{" +
+ "\"relationship-key\": \"generic-vnf.vnf-id\"," +
+ "\"relationship-value\": \"59bde732-9b84-46bd-a59a-3c45fee0538b\"}]," +
+ "\"related-to-property\": [{" +
+ "\"property-key\": \"generic-vnf.vnf-name\"," +
+ "\"property-value\": \"DROR_vsp\"}]},{" +
+ "\"related-to\": \"owning-entity\"," +
+ "\"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," +
+ "\"related-link\": \"/aai/v12/business/owning-entities/owning-entity/43b8a85a-0421-4265-9069-117dd6526b8a\"," +
+ "\"relationship-data\": [{" +
+ "\"relationship-key\": \"owning-entity.owning-entity-id\"," +
+ "\"relationship-value\": \"43b8a85a-0421-4265-9069-117dd6526b8a\"}]}]}}";
+
+ //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
+ private static String genericVnfRequestUri = "/aai/v12/network/generic-vnfs/generic-vnf/59bde732-9b84-46bd-a59a-3c45fee0538b";
+
+ private String genericVnfResponseString(boolean isDuplicatedKeysInTenantRelation) {
+
+ return
+ "{\"nf-role\":\"\"," +
+ "\"service-id\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," +
+ "\"relationship-list\":{" +
+ "\"relationship\":[{" +
+ "\"related-to\":\"service-instance\"," +
+ "\"relationship-data\":[{" +
+ "\"relationship-value\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," +
+ "\"relationship-key\":\"customer.global-customer-id\"},{" +
+ "\"relationship-value\":\"vWINIFRED\"," +
+ "\"relationship-key\":\"service-subscription.service-type\"},{" +
+ "\"relationship-value\":\"62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
+ "\"relationship-key\":\"service-instance.service-instance-id\"}]," +
+ "\"related-link\":\"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vWINIFRED/service-instances/service-instance/62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
+ "\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\"," +
+ "\"related-to-property\":[{" +
+ "\"property-key\":\"service-instance.service-instance-name\"," +
+ "\"property-value\":\"Dror123\"}]},{" +
+ "\"related-to\":\"platform\"," +
+ "\"relationship-data\":[{" +
+ "\"relationship-value\":\"platformY\"," +
+ "\"relationship-key\":\"platform.platform-name\"}]," +
+ "\"related-link\":\"/aai/v12/business/platforms/platform/platformY\"," +
+ "\"relationship-label\":\"org.onap.relationships.inventory.Uses\"},{" +
+ "\"related-to\":\"line-of-business\"," +
+ "\"relationship-data\":[{" +
+ "\"relationship-value\":\"lob1, lobX\"," +
+ "\"relationship-key\":\"line-of-business.line-of-business-name\"}]," +
+ "\"related-link\":\"/aai/v12/business/lines-of-business/line-of-business/lob1%2C%20lobX\"," +
+ "\"relationship-label\":\"org.onap.relationships.inventory.Uses\"}," +
+ " {" +
+ " \"related-to\": \"tenant\"," +
+ " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
+ " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region\"," +
+ " \"relationship-data\": [" +
+ " {" +
+ " \"relationship-key\": \"cloud-region.cloud-owner\"," +
+ " \"relationship-value\": \"irma-aic\"" +
+ " }," +
+ " {" +
+ " \"relationship-key\": \"cloud-region.cloud-region-id\"," +
+ " \"relationship-value\": \"aCloudRegionId\"" +
+ " }," +
+ " {" +
+ " \"relationship-key\": \"tenant.tenant-id\"," +
+ " \"relationship-value\": \"someTenantId123\"" +
+ " }," +
+ (isDuplicatedKeysInTenantRelation ? "{\"relationship-key\": \"tenant.tenant-id\", \"relationship-value\": \"someTenantId456\"}, " : "" ) +
+ " {" +
+ " \"relationship-key\": \"vserver.vserver-id\"," +
+ " \"relationship-value\": \"5eef9f6d-9933-4bc6-9a1a-862d61309437\"" +
+ " }" +
+ " ]," +
+ " \"related-to-property\": [" +
+ " {" +
+ " \"property-key\": \"vserver.vserver-name\"," +
+ " \"property-value\": \"zolson5bfapn01dns002\"" +
+ " }" +
+ " ]" +
+ " }" +
+ "]}," +
+ "\"vnf-id\":\"59bde732-9b84-46bd-a59a-3c45fee0538b\",\n" +
+ "\"nf-type\":\"\"," +
+ "\"prov-status\":\"PREPROV\"," +
+ "\"vnf-type\":\"Lital--1707097/Lital-VSP-1707097 0\"," +
+ "\"orchestration-status\":\"Created\"," +
+ "\"nf-naming-code\":\"\"," +
+ "\"in-maint\":true," +
+ "\"nf-function\":\"\"," +
+ "\"model-version-id\":\"11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0\"," +
+ "\"resource-version\":\"1522431420767\"," +
+ "\"model-customization-id\":\"14992bf5-d585-4b54-8101-7cf76774337a\"," +
+ "\"model-invariant-id\":\"55628ce3-ed56-40bd-9b27-072698ce02a9\"," +
+ "\"vnf-name\":\"DROR_vsp\"," +
+ "\"is-closed-loop-disabled\":true}";
+ }
+
+ private List<String> invariantIDs = Arrays.asList("35340388-0b82-4d3a-823d-cbddf842be52",
+ "55628ce3-ed56-40bd-9b27-072698ce02a9");
+
+ private static String getVersionByInvariantIdResponseString = "{" +
+ "\"model\": [{" +
+ "\"model-invariant-id\": \"55628ce3-ed56-40bd-9b27-072698ce02a9\"," +
+ "\"model-type\": \"resource\"," +
+ "\"resource-version\": \"1499690926297\"," +
+ "\"model-vers\": {" +
+ "\"model-ver\": [{" +
+ "\"model-version-id\": \"11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0\"," +
+ "\"model-name\": \"Lital-VSP-1707097\"," +
+ "\"model-version\": \"2.0\",\n" +
+ "\"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\"," +
+ "\"model-description\": \"Lital-VSP-1707097-NEW\"," +
+ "\"resource-version\": \"1499690926298\"," +
+ "\"model-elements\": {" +
+ "\"model-element\": [{" +
+ "\"model-element-uuid\": \"a4f14ef7-daa2-4257-9b81-b4558dc4beaa\"," +
+ "\"new-data-del-flag\": \"T\"," +
+ "\"cardinality\": \"unbounded\"," +
+ "\"resource-version\": \"1499690926300\"," +
+ "\"relationship-list\": {" +
+ "\"relationship\": [{" +
+ "\"related-to\": \"model-ver\"," +
+ "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
+ "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," +
+ "\"relationship-data\": [{" +
+ "\"relationship-key\": \"model.model-invariant-id\"," +
+ "\"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"},{" +
+ "\"relationship-key\": \"model-ver.model-version-id\"," +
+ "\"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"}]," +
+ "\"related-to-property\": [{" +
+ "\"property-key\": \"model-ver.model-name\"," +
+ "\"property-value\": \"generic-vnf\"}]}]}}]}," +
+ "\"relationship-list\": {" +
+ "\"relationship\": [{" +
+ "\"related-to\": \"model-element\"," +
+ "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
+ "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/35340388-0b82-4d3a-823d-cbddf842be52/model-vers/model-ver/4e799efd-fd78-444d-bc25-4a3cde2f8cb0/model-elements/model-element/344e8713-f0af-423a-b96d-f45b3a479d11/model-elements/model-element/9e8c8885-601a-4fd6-8424-c233a5333db6\"," +
+ "\"relationship-data\": [{" +
+ "\"relationship-key\": \"model.model-invariant-id\"," +
+ "\"relationship-value\": \"35340388-0b82-4d3a-823d-cbddf842be52\"},{" +
+ "\"relationship-key\": \"model-ver.model-version-id\"," +
+ "\"relationship-value\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"},{" +
+ "\"relationship-key\": \"model-element.model-element-uuid\"," +
+ "\"relationship-value\": \"344e8713-f0af-423a-b96d-f45b3a479d11\"},{" +
+ "\"relationship-key\": \"model-element.model-element-uuid\"," +
+ "\"relationship-value\": \"9e8c8885-601a-4fd6-8424-c233a5333db6\"}]}]}}]}},{" +
+ "\"model-invariant-id\": \"35340388-0b82-4d3a-823d-cbddf842be52\"," +
+ "\"model-type\": \"service\"," +
+ "\"resource-version\": \"1499690928188\"," +
+ "\"model-vers\": {" +
+ "\"model-ver\": [{" +
+ "\"model-version-id\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"," +
+ "\"model-name\": \"Lital--1707097\"," +
+ "\"model-version\": \"1.0\"," +
+ "\"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\"," +
+ "\"model-description\": \"Lital--1707097\"," +
+ "\"resource-version\": \"1499690928190\"," +
+ "\"model-elements\": {" +
+ "\"model-element\": [{" +
+ "\"model-element-uuid\": \"344e8713-f0af-423a-b96d-f45b3a479d11\"," +
+ "\"new-data-del-flag\": \"T\"," +
+ "\"cardinality\": \"unbounded\"," +
+ "\"resource-version\": \"1499690928191\"," +
+ "\"relationship-list\": {" +
+ "\"relationship\": [{" +
+ "\"related-to\": \"model-ver\"," +
+ "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
+ "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9\"," +
+ "\"relationship-data\": [{" +
+ "\"relationship-key\": \"model.model-invariant-id\"," +
+ "\"relationship-value\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\"},{" +
+ "\"relationship-key\": \"model-ver.model-version-id\"," +
+ "\"relationship-value\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"}]," +
+ "\"related-to-property\": [{" +
+ "\"property-key\": \"model-ver.model-name\"," +
+ "\"property-value\": \"service-instance\"}]}]}}]}}]}}]}";
+
+ @BeforeMethod
+ public void initMocks() {
+ TestUtils.initMockitoMocks(this);
+ aaiTreeNodeBuilder = new AAITreeNodeBuilder(aaiClient);
+ }
+
+ public void getServiceInstanceTreeAndAssert(boolean isDuplicatedKeysInTenantRelation) throws IOException, AsdcCatalogException {
+ when(aaiClient.typedAaiRest(URI.create(serviceInstanceRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(mapper.readTree(ServiceInstanceResponseString));
+ when(aaiClient.typedAaiRest(URI.create(genericVnfRequestUri), JsonNode.class, null, HttpMethod.GET, false)).
+ thenReturn(mapper.readTree(genericVnfResponseString(isDuplicatedKeysInTenantRelation)));
+ when(aaiClient.getVersionByInvariantId(invariantIDs)).thenReturn(aaiGetVersionByInvariantIdResponse);
+
+ when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
+
+ when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
+ when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of(
+ "11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", new ServiceModelInflator.Names("vnf-model-customization-name", "vnf-key-in-model")
+ ));
+
+ ServiceInstance root = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
+ .getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
+
+ assertServiceNode(root, 1);
+
+ assertEquals(0, root.getExistingNetworksCounterMap().size());
+ assertEquals(1, root.getExistingVNFCounterMap().size());
+ assertEquals((Long)1L, root.getExistingVNFCounterMap().get("14992bf5-d585-4b54-8101-7cf76774337a"));
+
+ assertVnfNode(root, isDuplicatedKeysInTenantRelation);
+ }
+
+ @Test
+ public void getServiceInstanceTreeTestHappyFlow() throws IOException, AsdcCatalogException {
+ getServiceInstanceTreeAndAssert(false);
+ }
+
+ @Test
+ public void whenDuplicatedKeyInRelationshipData_thenVnfIsParsedButWithoutPlacement() throws IOException, AsdcCatalogException {
+ getServiceInstanceTreeAndAssert(true);
+ }
+
+ private void mockAaiGetCall(String aaiPath, String jsonFilePath) {
+ try {
+ when(aaiClient.typedAaiRest(URI.create(aaiPath), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(TestUtils.readJsonResourceFileAsObject(jsonFilePath, JsonNode.class));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Test
+ public void whenGetServiceInstanceWithCR_thenResultAreAsExpected() throws Exception {
+
+ List<String> modelInvIds = ImmutableList.of(
+ "868b109c-9481-4a18-891b-af974db7705a",
+ "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
+ "f6342be5-d66b-4d03-a1aa-c82c3094c4ea");
+
+ mockAaiGetCall("business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/a565e6ad-75d1-4493-98f1-33234b5c17e2",
+ "/getTopology/serviceWithCR/serviceWithCR.json");
+ mockAaiGetCall("/aai/v14/network/collections/collection/84a351ae-3601-45e2-98df-878d6c816abc",
+ "/getTopology/serviceWithCR/CR.json");
+
+ mockAaiGetCall("/aai/v14/network/instance-groups/instance-group/6b3536cf-3a12-457f-abb5-fa2203e0d923",
+ "/getTopology/serviceWithCR/instanceGroup-NCF.json");
+
+ when(aaiClient.getVersionByInvariantId(modelInvIds)).thenReturn(aaiGetVersionByInvariantIdResponse);
+
+ when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).
+ thenReturn(TestUtils.readFileAsString("/getTopology/serviceWithCR/service-design-and-creation.json"));
+
+ when(sdcService.getService(any())).thenReturn(
+ TestUtils.readJsonResourceFileAsObject("/getTopology/serviceWithCR/serviceWithCRModel.json", ServiceModel.class));
+
+ ServiceInstance serviceInstance = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, new ServiceModelInflator(), executorService)
+ .getServiceInstanceTopology("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", "Emanuel", "a565e6ad-75d1-4493-98f1-33234b5c17e2");
+
+ String expected = TestUtils.readFileAsString("/getTopology/serviceWithCR/getTopologyWithCR.json");
+ assertThat(serviceInstance, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
+ }
+
+ protected void assertVnfNode(ServiceInstance root, boolean isExpectToPlacement) {
+ Vnf vnf = root.getVnfs().get("59bde732-9b84-46bd-a59a-3c45fee0538b");
+ assertEquals(Action.None, vnf.getAction());
+ assertEquals("Created", vnf.getOrchStatus());
+ assertEquals("PREPROV", vnf.getProvStatus());
+ assertEquals(true, vnf.getInMaint());
+ assertEquals("11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", vnf.getModelInfo().getModelVersionId());
+ assertEquals("14992bf5-d585-4b54-8101-7cf76774337a", vnf.getModelInfo().getModelCustomizationId());
+ assertEquals("55628ce3-ed56-40bd-9b27-072698ce02a9", vnf.getModelInfo().getModelInvariantId());
+ assertEquals("Lital-VSP-1707097", vnf.getModelInfo().getModelName());
+ assertEquals("vnf-model-customization-name", vnf.getModelInfo().getModelCustomizationName());
+ assertEquals("2.0", vnf.getModelInfo().getModelVersion());
+ assertEquals("vnf", vnf.getModelInfo().getModelType());
+ assertEquals("59bde732-9b84-46bd-a59a-3c45fee0538b", vnf.getInstanceId());
+ assertEquals("DROR_vsp", vnf.getInstanceName());
+ assertEquals("Lital--1707097/Lital-VSP-1707097 0", vnf.getInstanceType());
+ assertEquals("11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", vnf.getUuid());
+ assertEquals("59bde732-9b84-46bd-a59a-3c45fee0538b", vnf.getTrackById());
+ assertEquals(0, vnf.getVfModules().size());
+ assertEquals(0, vnf.getNetworks().size());
+ if (!isExpectToPlacement) {
+ assertEquals("aCloudRegionId", vnf.getLcpCloudRegionId());
+ assertEquals("someTenantId123", vnf.getTenantId());
+ assertEquals("irma-aic", vnf.getCloudOwner());
+ }
+ else {
+ assertNull(vnf.getLcpCloudRegionId());
+ assertNull(vnf.getTenantId());
+ assertNull(vnf.getCloudOwner());
+ }
+ }
+
+ protected void assertServiceNode(ServiceInstance root, int expectedVnfSize) {
+ assertEquals(Action.None, root.getAction());
+ assertEquals("Active", root.getOrchStatus());
+ assertEquals("4e799efd-fd78-444d-bc25-4a3cde2f8cb0", root.getModelInfo().getModelVersionId());
+ assertEquals(null, root.getModelInfo().getModelCustomizationId());
+ assertEquals("35340388-0b82-4d3a-823d-cbddf842be52", root.getModelInfo().getModelInvariantId());
+ assertEquals("1.0", root.getModelInfo().getModelVersion());
+ assertEquals("Lital--1707097", root.getModelInfo().getModelName());
+ assertEquals("service", root.getModelInfo().getModelType());
+ assertEquals("62888f15-6d24-4f7b-92a7-c3f35beeb215", root.getInstanceId());
+ assertEquals("Dror123", root.getInstanceName());
+ assertEquals(expectedVnfSize, root.getVnfs().size());
+ assertEquals(0, root.getNetworks().size());
+ //future - after add additional properties - assert it
+ }
+
+ @Test(expectedExceptions = GenericUncheckedException.class ,expectedExceptionsMessageRegExp = "AAI node fetching failed.")
+ public void getServiceInstanceTreeTest_errorCreatingVnfNode() throws IOException, AsdcCatalogException {
+ when(aaiClient.typedAaiRest(URI.create(serviceInstanceRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(mapper.readTree(ServiceInstanceResponseString));
+ when(aaiClient.typedAaiRest(URI.create(genericVnfRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenThrow(exceptionWithRequestInfo);
+ when(aaiClient.getVersionByInvariantId(any())).thenReturn(aaiGetVersionByInvariantIdResponse);
+ when(exceptionWithRequestInfo.toString()).thenReturn("this is a fetching node exception");
+
+ when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
+
+ when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
+ when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of());
+
+ new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
+ .getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
+ }
+
+ @Test(expectedExceptions = GenericUncheckedException.class ,expectedExceptionsMessageRegExp = "AAI node fetching failed.")
+ public void testCreateFailureNode() {
+ AAITreeNode failureNode = FailureAAITreeNode.of(new RuntimeException("Failed to retrieve node data."));
+ failureNode.getId();
+ }
+}
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 69458aa86..9cc97116b 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
@@ -183,7 +183,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
}
protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName, String lcpCloudRegionId, String tenantId) {
- return new VfModule( vfModuleModelInfo, instanceName, null, Action.Replace.name(), lcpCloudRegionId, null, tenantId,
+ return new VfModule( vfModuleModelInfo, instanceName, null, Action.Upgrade.name(), lcpCloudRegionId, null, tenantId,
null, null, true, null, null, UUID.randomUUID().toString(), null, null);
}
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 e2d182c06..2b4f4be62 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
@@ -20,9 +20,80 @@
package org.onap.vid.services;
+import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
+import static net.javacrumbs.jsonunit.JsonAssert.whenIgnoringPaths;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasProperty;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.core.Every.everyItem;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_ERRORS;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_NO_ACTION;
+import static org.onap.vid.job.Job.JobStatus.FAILED;
+import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.PAUSE;
+import static org.onap.vid.job.Job.JobStatus.PENDING;
+import static org.onap.vid.job.Job.JobStatus.STOPPED;
+import static org.onap.vid.testUtils.TestUtils.generateRandomAlphaNumeric;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import javax.inject.Inject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.SessionFactory;
@@ -54,7 +125,11 @@ import org.onap.vid.job.command.MsoRequestBuilder;
import org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator;
import org.onap.vid.job.impl.JobDaoImpl;
import org.onap.vid.job.impl.JobSharedData;
-import org.onap.vid.model.*;
+import org.onap.vid.model.Action;
+import org.onap.vid.model.JobAuditStatus;
+import org.onap.vid.model.NameCounter;
+import org.onap.vid.model.ResourceInfo;
+import org.onap.vid.model.ServiceInfo;
import org.onap.vid.model.serviceInstantiation.BaseResource;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.model.serviceInstantiation.Vnf;
@@ -71,34 +146,11 @@ import org.onap.vid.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
-import org.testng.annotations.*;
-
-import javax.inject.Inject;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.time.*;
-import java.util.Optional;
-import java.util.*;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
-import static net.javacrumbs.jsonunit.JsonAssert.whenIgnoringPaths;
-import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-import static org.hamcrest.core.Every.everyItem;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-import static org.onap.vid.job.Job.JobStatus.*;
-import static org.onap.vid.testUtils.TestUtils.generateRandomAlphaNumeric;
-import static org.testng.Assert.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class})
public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseTest {
@@ -665,7 +717,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT
public static Object[][] isPauseAndPropertyDataProvider() {
return new Object[][]{
{true, "mso.restapi.serviceInstanceAssign"},
- {false, "mso.restapi.serviceInstanceCreate"},
+ {false, "mso.restapi.service.instance"},
};
}
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 311eb04cc..bd761f275 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
@@ -603,18 +603,18 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
when(featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(true);
when(aaiClient.getCloudOwnerByCloudRegionId("regionOne")).thenReturn("irma-aic");
- ModelInfo vfModuleModelInfo = createVfModuleModelInfo("VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0", "1", "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46",
- "f7a867f2-596b-4f4a-a128-421e825a6190", "074c64d0-7e13-4bcc-8bdb-ea922331102d",null );
+ ModelInfo vfModuleModelInfo = createVfModuleModelInfo("newest-model-name-vfm", "newest-model-version-vfm", "newest-model-uuid-vfm",
+ "f7a867f2-596b-4f4a-a128-421e825a6190", "newest-model-customization-uuid-vfm","newest-model-customization-name-vfm" );
VfModule vfModuleDetails = createVfModuleForReplace(vfModuleModelInfo, "replace_module", "regionOne", "0422ffb57ba042c0800a29dc85ca70f8");
- ModelInfo serviceModelInfo = createServiceModelInfo("Vf zolson5bpxmc02092017-Service", "1", "bad955c3-29b2-4a27-932e-28e942cc6480", "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", null, null );
+ ModelInfo serviceModelInfo = createServiceModelInfo("newest-model-name-service", "newest-model-version-service", "newest-model-uuid-service", "b16a9398-ffa3-4041-b78c-2956b8ad9c7b", null, null );
- ModelInfo vnfModelInfo = createVnfModelInfo("Vf zolson5bpxmc02092017-VF", "1", "d326f424-2312-4dd6-b7fe-364fadbd1ef5", "23122c9b-dd7f-483f-bf0a-e069303db2f7", "96c23a4a-6887-4b2c-9cce-1e4ea35eaade", "Vf zolson5bpxmc02092017-VF 0" );
+ ModelInfo vnfModelInfo = createVnfModelInfo("newest-model-name-vnf", "newest-model-version-vnf", "newest-model-uuid-vnf", "23122c9b-dd7f-483f-bf0a-e069303db2f7", "newest-model-customization-uuid-vnf", "newest-model-customization-name-vnf" );
RequestDetailsWrapper<VfModuleInstantiationRequestDetails> result =
msoRequestBuilder.generateVfModuleInstantiationRequest(vfModuleDetails, serviceModelInfo, "e9993045-cc96-4f3f-bf9a-71b2a400a956", vnfModelInfo, "5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5", null,"az2016", "GR_API");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
+ assertThat(result, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
}
} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
index 399274d69..66052adeb 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -46,11 +46,13 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
+import java.lang.reflect.Field;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import java.util.function.Predicate;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
@@ -60,6 +62,7 @@ import javax.ws.rs.core.Response;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.commons.text.RandomStringGenerator;
import org.apache.http.HttpResponseFactory;
@@ -71,8 +74,11 @@ import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Assert;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.mockito.MockSettings;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.OngoingStubbing;
@@ -176,6 +182,33 @@ public class TestUtils {
.collect(toList());
}
+ private static List<Field> allMockitoFieldsOf(Object object) {
+ final Predicate<Field> hasMockAnnotation = field -> field.getAnnotation(Mock.class) != null;
+ final Predicate<Field> hasInjectMocksAnnotation = field -> field.getAnnotation(InjectMocks.class) != null;
+
+ return Arrays.stream(FieldUtils.getAllFields(object.getClass()))
+ .filter(hasMockAnnotation.or(hasInjectMocksAnnotation))
+ .collect(toList());
+ }
+
+ /**
+ * Calls MockitoAnnotations.initMocks after nullifying any field which is annotated @Mocke or @InjectMock.
+ * This makes a "hard rest" to any mocked state or instance. Expected to be invoked between any @Tests in class, by
+ * being called in TestNG's @BeforeMethod (or equivalently JUnit's @BeforeTest).
+ */
+ public static void initMockitoMocks(Object testClass) {
+ for (Field field : allMockitoFieldsOf(testClass)) {
+ try {
+ // Write null to fields
+ FieldUtils.writeField(field, testClass, null, true);
+ } catch (ReflectiveOperationException e) {
+ ExceptionUtils.rethrow(e);
+ }
+ }
+
+ MockitoAnnotations.initMocks(testClass);
+ }
+
/**
* Sets each String property with a value equal to the name of
* the property; e.g.: { name: "name", city: "city" }
diff --git a/vid-app-common/src/test/java/org/onap/vid/utils/TreeTest.java b/vid-app-common/src/test/java/org/onap/vid/utils/TreeTest.java
index eaa9990c2..9b27f6e23 100644
--- a/vid-app-common/src/test/java/org/onap/vid/utils/TreeTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/utils/TreeTest.java
@@ -80,4 +80,12 @@ public class TreeTest {
assertTrue(subTree.isPathExist("d"));
assertFalse(subTree.isPathExist("b","c","d"));
}
+
+ @Test
+ public void getChildrenDepthTest() {
+ Tree<String> tree = buildTreeForTest();
+ assertEquals(3, tree.getChildrenDepth());
+ Tree<String> subTree = tree.getSubTree("b");
+ assertEquals(2, subTree.getChildrenDepth());
+ }
}
diff --git a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
index 33778babb..ecbc2373e 100644
--- a/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
+++ b/vid-app-common/src/test/resources/WEB-INF/conf/system.properties
@@ -155,26 +155,24 @@ mso.polling.interval.msecs=10000
mso.max.polls=10
mso.user.name=infraportal
mso.password.x=OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz
-mso.restapi.svc.instance=/serviceInstances/v7
-mso.restapi.svc.instance.deleteAndUnassign=/serviceInstantiation/v7/serviceInstances
+mso.restapi.service.instance=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances
mso.restapi.vnf.instance=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/<service_instance_id>/vnfs
mso.restapi.vnf.changemanagement.instance=/serviceInstances/v7/<service_instance_id>/vnfs/<vnf_instance_id>/<request_type>
mso.restapi.network.instance=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/<service_instance_id>/networks
mso.restapi.vf.module.scaleout=/serviceInstantiation/v7/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut
mso.restapi.vf.module.instance=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules
mso.restapi.workflow.invoke=/instanceManagement/v1/serviceInstances/<service_instance_id>/vnfs/<vnf_instance_id>/workflows/<workflow_UUID>
-mso.restapi.volume.group.instance=/serviceInstances/v7/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
+mso.restapi.volume.group.instance=${mso.restapi.vnf.instance}/<vnf_instance_id>/volumeGroups
mso.restapi.instance.group=${mso.restapi.serviceInstantiationApiRoot}/instanceGroups
mso.restapi.get.orc.req=/orchestrationRequests/v7
mso.restapi.get.orc.reqs=/orchestrationRequests/v7?
mso.restapi.resume.orc.req=/orchestrationRequests/v7/<request_id>/resume
mso.restapi.get.man.tasks=/tasks/v1
-mso.restapi.configurations=/serviceInstances/v6/<service_instance_id>/configurations
+mso.restapi.configurations=${mso.restapi.service.instance}/<service_instance_id>/configurations
mso.restapi.configuration.instance=${mso.restapi.configurations}<configuration_id>
mso.restapi.changeManagement.workflowSpecifications=/workflowSpecifications/v1/workflows?vnfModelVersionId=<model_version_id>
mso.restapi.serviceInstantiationApiRoot=/serviceInstantiation/v7
-mso.restapi.serviceInstanceCreate=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances
mso.restapi.serviceInstanceAssign=${mso.restapi.serviceInstantiationApiRoot}/serviceInstances/assign
mso.restapi.cloudResourcesApiRoot=/cloudResources/v1
diff --git a/vid-app-common/src/test/resources/mso.properties b/vid-app-common/src/test/resources/mso.properties
deleted file mode 100644
index d021ffde1..000000000
--- a/vid-app-common/src/test/resources/mso.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-mso.server.url=http://mtanjv9moah01-eth0.aic.cip.att.com:8080/ecomp/mso/infra
-mso.polling.interval.msecs=2000
-mso.max.polls=3
-mso.user.name=infraportal
-mso.password.x=OBF:1ghz1kfx1j1w1m7w1i271e8q1eas1hzj1m4i1iyy1kch1gdz
-mso.restapi.svc.instance=/serviceInstances/v3
-mso.restapi.vnf.instance=/serviceInstances/v3/<service_instance_id>/vnfs
-mso.restapi.network.instance=/serviceInstances/v3/<service_instance_id>/networks
-mso.restapi.vf.module.instance=/serviceInstantiation/v7/<service_instance_id>/vnfs/<vnf_instance_id>/vfModules/scaleOut
-mso.restapi.volume.group.instance=/serviceInstances/v3/<service_instance_id>/vnfs/<vnf_instance_id>/volumeGroups
-mso.restapi.configurations=/serviceInstances/v6/<service_instance_id>/configurations
-mso.restapi.get.orc.req=/orchestrationRequests/v3
-mso.restapi.get.orc.reqs=/orchestrationRequests/v3?
-mso.restapi.get.man.tasks=/tasks/v1
-mso.dme2.client.timeout=30000
-mso.dme2.client.read.timeout=120000
-mso.dme2.server.url=http://mso-api-handler-anap-v1.mso.ecomp.att.com/services/ecomp/mso?version=1607&envContext=TEST&routeOffer=st_mtsnj \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json
index c3ab694aa..103985c96 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule.json
@@ -10,9 +10,9 @@
"relatedInstance": {
"instanceId": "e9993045-cc96-4f3f-bf9a-71b2a400a956",
"modelInfo": {
- "modelVersionId": "bad955c3-29b2-4a27-932e-28e942cc6480",
- "modelVersion": "1",
- "modelName": "Vf zolson5bpxmc02092017-Service",
+ "modelVersionId": "newest-model-uuid-service",
+ "modelVersion": "newest-model-version-service",
+ "modelName": "newest-model-name-service",
"modelInvariantId": "b16a9398-ffa3-4041-b78c-2956b8ad9c7b",
"modelType": "service"
}
@@ -21,13 +21,13 @@
"relatedInstance": {
"instanceId": "5c9c2896-1fe6-4055-b7ec-d0a01e5f9bf5",
"modelInfo": {
- "modelName": "Vf zolson5bpxmc02092017-VF",
- "modelVersion": "1",
+ "modelName": "newest-model-name-vnf",
+ "modelVersion": "newest-model-version-vnf",
"modelInvariantId": "23122c9b-dd7f-483f-bf0a-e069303db2f7",
"modelType": "vnf",
- "modelCustomizationName": "Vf zolson5bpxmc02092017-VF 0",
- "modelVersionId": "d326f424-2312-4dd6-b7fe-364fadbd1ef5",
- "modelCustomizationId": "96c23a4a-6887-4b2c-9cce-1e4ea35eaade"
+ "modelCustomizationName": "newest-model-customization-name-vnf",
+ "modelVersionId": "newest-model-uuid-vnf",
+ "modelCustomizationId": "newest-model-customization-uuid-vnf"
}
}
}],
@@ -36,12 +36,13 @@
"testApi": "GR_API"
},
"modelInfo": {
- "modelName": "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0",
- "modelVersion": "1",
+ "modelName": "newest-model-name-vfm",
+ "modelVersion": "newest-model-version-vfm",
"modelInvariantId": "f7a867f2-596b-4f4a-a128-421e825a6190",
"modelType": "vfModule",
- "modelVersionId": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46",
- "modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d"
+ "modelVersionId": "newest-model-uuid-vfm",
+ "modelCustomizationId": "newest-model-customization-uuid-vfm",
+ "modelCustomizationName":"newest-model-customization-name-vfm"
},
"cloudConfiguration": {
"cloudOwner": "irma-aic",
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json
index 92ccfe541..8d30fd873 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/replace_vfmodule_fe_input.json
@@ -8,7 +8,7 @@
"VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0-?": {
"instanceName": "replace_module",
"instanceId": "5d49c3b1-fc90-4762-8c98-e800170baa55",
- "action": "Replace",
+ "action": "Upgrade",
"orchStatus": "Create",
"provStatus": "Prov Status",
"inMaint": false,
@@ -21,6 +21,7 @@
"modelName": "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0",
"modelVersion": "1",
"modelCustomizationId": "074c64d0-7e13-4bcc-8bdb-ea922331102d",
+ "modelCustomizationName" : "VfZrdm5bpxmc02092017Vf..CORNELIUS_base..module-0",
"uuid": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46"
},
"uuid": "eb5de6fb-9ecf-4009-b922-fae3a9ae7d46"
diff --git a/vid-app-common/version.properties b/vid-app-common/version.properties
index 60ac15449..443752c32 100755
--- a/vid-app-common/version.properties
+++ b/vid-app-common/version.properties
@@ -4,7 +4,7 @@
major=5
minor=0
-patch=1
+patch=2
base_version=${major}.${minor}.${patch}