diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
99 files changed, 4336 insertions, 1344 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/.gitignore b/mso-api-handlers/mso-api-handler-infra/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index f871e120e7..49590d3460 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -23,7 +23,6 @@ <reflections-version>0.9.9-RC1</reflections-version> <paranamer-version>2.5.2</paranamer-version> <scannotation-version>1.0.3</scannotation-version> - <jackson-version>1.9.2</jackson-version> <java.version>1.8</java.version> </properties> <dependencyManagement> @@ -108,18 +107,6 @@ <version>${json4s-core-version}</version> </dependency> <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - </dependency> - <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> @@ -132,16 +119,6 @@ <groupId>org.json</groupId> <artifactId>json</artifactId> </dependency> - <dependency> - <groupId>com.fasterxml.jackson.jaxrs</groupId> - <artifactId>jackson-jaxrs-base</artifactId> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.jaxrs</groupId> - <artifactId>jackson-jaxrs-providers</artifactId> - <version>2.9.2</version> - <type>pom</type> - </dependency> <!-- Dependencies on other MSO Projects --> <dependency> @@ -151,6 +128,11 @@ </dependency> <dependency> <groupId>org.onap.so</groupId> + <artifactId>mso-requests-db-repositories</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> <artifactId>mso-catalog-db</artifactId> <version>${project.version}</version> </dependency> @@ -319,4 +301,4 @@ </plugins> </build> <packaging>jar</packaging> -</project>
\ No newline at end of file +</project> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java index 5b08cc1b17..6013677684 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -43,5 +43,6 @@ public enum Action implements Actions{ compareModel, scaleInstance, deactivateAndCloudDelete, - scaleOut + scaleOut, + recreateInstance } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index e8a6beb278..1a95aa0e09 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -58,6 +58,7 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.OperationStatus; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; import org.onap.so.logger.MsoLogger; @@ -73,8 +74,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + @Component @Path("/e2eServiceInstances") diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index 1700e121f0..e6bbc4de4a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -29,7 +29,7 @@ import org.onap.so.apihandler.filters.RequestUriFilter; import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration; import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration; -import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging; +import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; import org.onap.so.web.exceptions.RuntimeExceptionMapper; import org.springframework.context.annotation.Configuration; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 4d8c4ffbd8..dcfe40aa51 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -61,7 +61,8 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.wordnik.swagger.annotations.ApiOperation; + +import io.swagger.annotations.ApiOperation; @Path("/tasks") diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 66afcf3738..753e712d71 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -62,6 +62,7 @@ import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType; import org.onap.so.apihandlerinfra.vnfbeans.VnfInputs; import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; @@ -741,4 +742,4 @@ public class MsoRequest { return vnfType; } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index 014739d581..50d2639b2d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -23,6 +23,7 @@ package org.onap.so.apihandlerinfra; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,6 +49,8 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.beans.RequestProcessingData; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; @@ -96,10 +99,11 @@ public class OrchestrationRequests { GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); - InfraActiveRequests requestDB = null; - + InfraActiveRequests infraActiveRequest = null; + List<org.onap.so.db.request.beans.RequestProcessingData> requestProcessingData = null; try { - requestDB = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); + infraActiveRequest = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); + requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(requestId); } catch (Exception e) { msoLogger.error(e); @@ -114,8 +118,8 @@ public class OrchestrationRequests { throw validateException; } - - if(requestDB == null) { + + if(infraActiveRequest == null) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build(); @@ -125,8 +129,11 @@ public class OrchestrationRequests { throw validateException; } - - Request request = mapInfraActiveRequestToRequest(requestDB); + + Request request = mapInfraActiveRequestToRequest(infraActiveRequest); + if(!requestProcessingData.isEmpty()){ + request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); + } request.setRequestId(requestId); orchestrationResponse.setRequest(request); @@ -170,8 +177,12 @@ public class OrchestrationRequests { List<RequestList> requestLists = new ArrayList<>(); for(InfraActiveRequests infraActive : activeRequests){ + List<RequestProcessingData> requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId()); RequestList requestList = new RequestList(); Request request = mapInfraActiveRequestToRequest(infraActive); + if(!requestProcessingData.isEmpty()){ + request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); + } requestList.setRequest(request); requestLists.add(requestList); } @@ -336,4 +347,46 @@ public class OrchestrationRequests { return request; } + + public List<org.onap.so.serviceinstancebeans.RequestProcessingData> mapRequestProcessingData(List<org.onap.so.db.request.beans.RequestProcessingData> processingData){ + List<org.onap.so.serviceinstancebeans.RequestProcessingData> addedRequestProcessingData = new ArrayList<>(); + org.onap.so.serviceinstancebeans.RequestProcessingData finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData(); + String currentGroupingId = null; + HashMap<String, String> tempMap = new HashMap<>(); + List<HashMap<String, String>> tempList = new ArrayList<>(); + for(RequestProcessingData data : processingData){ + String groupingId = data.getGroupingId(); + String tag = data.getTag(); + if(currentGroupingId == null || !currentGroupingId.equals(groupingId)){ + if(!tempMap.isEmpty()){ + tempList.add(tempMap); + finalProcessingData.setDataPairs(tempList); + addedRequestProcessingData.add(finalProcessingData); + } + finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData(); + if(groupingId != null){ + finalProcessingData.setGroupingId(groupingId); + } + if(tag != null){ + finalProcessingData.setTag(tag); + } + currentGroupingId = groupingId; + tempMap = new HashMap<>(); + tempList = new ArrayList<>(); + if(data.getName() != null && data.getValue() != null){ + tempMap.put(data.getName(), data.getValue()); + } + }else{ + if(data.getName() != null && data.getValue() != null){ + tempMap.put(data.getName(), data.getValue()); + } + } + } + if(tempMap.size() > 0){ + tempList.add(tempMap); + finalProcessingData.setDataPairs(tempList); + } + addedRequestProcessingData.add(finalProcessingData); + return addedRequestProcessingData; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java deleted file mode 100644 index 380ee2c6ad..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.so.apihandlerinfra; - -import org.apache.http.HttpStatus; -import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.beans.OperationStatus; -import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.stereotype.Component; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestTemplate; -import uk.co.blackpepper.bowman.Client; -import uk.co.blackpepper.bowman.ClientFactory; -import uk.co.blackpepper.bowman.Configuration; - -import javax.annotation.PostConstruct; -import javax.ws.rs.core.UriBuilder; -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Component("RequestDbClient") -public class RequestsDbClient { - - private static final String SERVICE_ID = "SERVICE_ID"; - private static final String OPERATION_ID = "OPERATION_ID"; - - private Client<InfraActiveRequests> infraActiveRequestClient; - private Client<OperationStatus> operationStatusClient; - - @Value("${mso.adapters.requestDb.endpoint}") - private String endpoint; - - @Value("${mso.adapters.requestDb.auth}") - private String msoAdaptersAuth; - - private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/"; - private static final String OPERATION_STATUS_REPOSITORY_SEARCH = "/operationStatusRepository/search"; - - private String checkVnfIdStatus = "/infraActiveRequests/checkVnfIdStatus/"; - - private String infraActiveRequestURI = "/infraActiveRequests/"; - - private String checkInstanceNameDuplicate = "/infraActiveRequests/checkInstanceNameDuplicate"; - - private String findOneByServiceIdAndOperationIdURI = "/findOneByServiceIdAndOperationId"; - - private String cloudOrchestrationFiltersFromInfraActive = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive"; - - private HttpHeaders headers; - - @Autowired - private RestTemplate restTemplate; - - @PostConstruct - public void init() { - getOrchestrationFilterURI = endpoint + getOrchestrationFilterURI; - infraActiveRequestURI = endpoint + infraActiveRequestURI; - checkVnfIdStatus = endpoint + checkVnfIdStatus; - checkInstanceNameDuplicate = endpoint + checkInstanceNameDuplicate; - cloudOrchestrationFiltersFromInfraActive = endpoint + cloudOrchestrationFiltersFromInfraActive; - findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_REPOSITORY_SEARCH + findOneByServiceIdAndOperationIdURI; - headers = new HttpHeaders(); - headers.set("Authorization", msoAdaptersAuth); - } - - public RequestsDbClient() { - ClientFactory clientFactory = Configuration.builder().setRestTemplateConfigurer(restTemplate -> restTemplate.getInterceptors().add((request, body, execution) -> { - request.getHeaders().add("Authorization", msoAdaptersAuth); - return execution.execute(request, body); - })).build().buildClientFactory(); - infraActiveRequestClient = clientFactory.create(InfraActiveRequests.class); - operationStatusClient = clientFactory.create(OperationStatus.class); - - } - public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap){ - URI uri = getUri(cloudOrchestrationFiltersFromInfraActive); - HttpEntity<Map> entity = new HttpEntity<>(orchestrationMap, headers); - try{ - return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); - }catch(HttpClientErrorException e){ - if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ - return null; - } - throw e; - } - } - public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) { - return this.getSingleInfraActiveRequests(this.getUri(endpoint + "/infraActiveRequests/" + requestId)); - } - - public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(Map<String, List<String>> orchestrationMap) { - URI uri = getUri(getOrchestrationFilterURI); - HttpEntity<Map<String, List<String>>> entity = new HttpEntity<>(orchestrationMap, headers); - return restTemplate.exchange(uri, HttpMethod.POST, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {}).getBody(); - } - - public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) { - URI uri = getUri(checkVnfIdStatus + operationalEnvironmentId); - return restTemplate.exchange(uri, HttpMethod.GET, HttpEntity.EMPTY, InfraActiveRequests.class).getBody(); - } - public InfraActiveRequests checkInstanceNameDuplicate(HashMap<String, String> instanceIdMap, String instanceName, String requestScope) { - URI uri = getUri(checkInstanceNameDuplicate); - HttpEntity<InstanceNameDuplicateCheckRequest> entity = new HttpEntity<>(new InstanceNameDuplicateCheckRequest(instanceIdMap, instanceName, requestScope), headers); - try{ - return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody(); - }catch(HttpClientErrorException e){ - if(HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()){ - return null; - } - throw e; - } - - } - - public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId){ - return this.getSingleOperationStatus(UriBuilder.fromUri(findOneByServiceIdAndOperationIdURI) - .queryParam(SERVICE_ID,serviceId) - .queryParam(OPERATION_ID,operationId) - .build()); - } - - public void save(InfraActiveRequests infraActiveRequests) { - URI uri = getUri(infraActiveRequestURI); - HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(infraActiveRequests, headers); - restTemplate.postForLocation(uri, entity); - } - - protected InfraActiveRequests getSingleInfraActiveRequests(URI uri) { - return infraActiveRequestClient.get(uri); - } - - public void updateInfraActiveRequests(InfraActiveRequests request) { - infraActiveRequestClient.put(request); - } - - public OperationStatus getSingleOperationStatus(URI uri){ - return operationStatusClient.get(uri); - } - - protected URI getUri(String uri) { - return URI.create(uri); - } - - @Bean - public RestTemplate restTemplate() { - return new RestTemplate( new HttpComponentsClientHttpRequestFactory()); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index ced69df55c..bb7df4b7be 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -22,27 +22,13 @@ package org.onap.so.apihandlerinfra; -import java.io.IOException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import javax.transaction.Transactional; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -70,18 +56,9 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository; -import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; -import org.onap.so.db.catalog.data.repository.ServiceRecipeRepository; -import org.onap.so.db.catalog.data.repository.ServiceRepository; -import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; -import org.onap.so.db.catalog.data.repository.VFModuleRepository; -import org.onap.so.db.catalog.data.repository.VnfComponentRecipeRepository; -import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository; -import org.onap.so.db.catalog.data.repository.VnfRecipeRepository; -import org.onap.so.db.catalog.data.repository.VnfResourceRepository; +import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; @@ -104,14 +81,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; @Component @Path("/onap/so/infra/serviceInstantiation") @@ -129,37 +117,10 @@ public class ServiceInstances { private RequestClientFactory reqClientFactory; @Autowired - private ServiceRepository serviceRepo; - - @Autowired - private ServiceRecipeRepository serviceRecipeRepo; - - @Autowired - private NetworkRecipeRepository networkRecipeRepo; - - @Autowired - private NetworkResourceCustomizationRepository networkCustomizationRepo; - - @Autowired - private VnfResourceRepository vnfRepo; - - @Autowired - private VnfCustomizationRepository vnfCustomRepo; - - @Autowired - private VnfRecipeRepository vnfRecipeRepo; - - @Autowired - private VFModuleCustomizationRepository vfModuleCustomRepo; - - @Autowired - private VFModuleRepository vfModuleRepo; - - @Autowired - private VnfComponentRecipeRepository vnfComponentRecipeRepo; - + private CatalogDbClient catalogDbClient; + @Autowired - private InfraActiveRequestsRepository iar; + private RequestsDbClient infraActiveRequestsClient; @Autowired private ResponseBuilder builder; @@ -411,6 +372,20 @@ public class ServiceInstances { instanceIdMap.put("vnfInstanceId", vnfInstanceId); return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, getRequestUri(requestContext)); } + + @POST + @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/recreate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value="Recreate VNF Instance",response=Response.class) + public Response recreateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext)); + } @DELETE @@ -702,14 +677,14 @@ public class ServiceInstances { // Get VF Module-specific base module indicator - VfModule vfm; + VfModule vfm = null; String modelVersionId = modelInfo.getModelVersionId(); if(modelVersionId != null) { - vfm = vfModuleRepo.findByModelUUID(modelVersionId); - } else { - vfm = vfModuleRepo.findByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), modelInfo.getModelVersion()); + vfm = catalogDbClient.getVfModuleByModelUUID(modelVersionId); + } else if(modelInfo.getModelInvariantId() != null && modelInfo.getModelVersion() != null){ + vfm = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), modelInfo.getModelVersion()); } if (vfm != null) { @@ -765,7 +740,7 @@ public class ServiceInstances { if (sir.getCorrelationId() != null) { correlationId = sir.getCorrelationId(); } - iar.save(currentActiveReq); + infraActiveRequestsClient.save(currentActiveReq); if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -870,9 +845,8 @@ public class ServiceInstances { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); - currentActiveReq.setRequestStatus(Status.FAILED.name()); - currentActiveReq.setStatusMessage(validateException.getMessage()); - throw validateException; + updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); + throw validateException; } // BPEL accepted the request, the request is in progress @@ -889,15 +863,14 @@ public class ServiceInstances { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); - currentActiveReq.setRequestStatus(Status.FAILED.name()); - currentActiveReq.setStatusMessage(validateException.getMessage()); + updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; } currentActiveReq.setRequestStatus(Status.IN_PROGRESS.name()); setInstanceId(currentActiveReq, requestScope, jsonResponse.getRequestReferences().getInstanceId(), new HashMap<>()); - iar.save(currentActiveReq); + infraActiveRequestsClient.save(currentActiveReq); return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion); } } @@ -1006,7 +979,7 @@ public class ServiceInstances { InfraActiveRequests dup = null; try { if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){ - dup = iar.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); + dup = infraActiveRequestsClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); } } catch (Exception e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); @@ -1036,32 +1009,12 @@ public class ServiceInstances { .errorInfo(errorLoggerInfo).build(); String requestScope = requestScopeFromUri(requestUri); - createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON); + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON); throw validateException; } } - //TODO MSO-4177 -- remove this and call the msoRequest instead - public void createErrorRequestRecord (Status status, String requestId, String errorMessage, Actions action, String requestScope, String requestJSON) { - try { - InfraActiveRequests request = new InfraActiveRequests(requestId); - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - request.setStartTime (startTimeStamp); - request.setRequestStatus(status.toString()); - request.setStatusMessage(errorMessage); - request.setProgress((long) 100); - request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); - request.setRequestAction(action.toString()); - request.setRequestScope(requestScope); - request.setRequestBody(requestJSON); - Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); - request.setEndTime(endTimeStamp); - iar.save(request); - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB"); - msoLogger.debug ("Exception: ", e); - } - } + private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version, String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException { int reqVersion = Integer.parseInt(version.substring(1)); @@ -1144,8 +1097,7 @@ public class ServiceInstances { } return recipeLookupResult; } - - + private RecipeLookupResult getServiceURI(ServiceInstancesRequest servInstReq, Actions action, boolean alaCarteFlag) throws IOException { // SERVICE REQUEST // Construct the default service name @@ -1158,18 +1110,18 @@ public class ServiceInstances { ServiceRecipe recipe = null; if(alaCarteFlag){ - serviceRecord = serviceRepo.findByModelNameOrderByModelVersionDesc(defaultServiceModelName); - if(serviceRecord !=null){ - recipe = serviceRecord.getRecipes().get(action.toString()); + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + if(serviceRecord !=null){ + recipe =catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(),action.toString()); } }else{ - serviceRecord = serviceRepo.findOneByModelUUID(modelInfo.getModelVersionId()); - recipe = serviceRecipeRepo.findFirstByServiceModelUUIDAndAction(modelInfo.getModelVersionId(), action.toString()); + serviceRecord = catalogDbClient.getServiceByID(modelInfo.getModelVersionId()); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(modelInfo.getModelVersionId(), action.toString()); if (recipe == null){ - serviceRecordList = serviceRepo.findByModelInvariantUUIDOrderByModelVersionDesc(modelInfo.getModelInvariantId()); + serviceRecordList = catalogDbClient.getServiceByModelInvariantUUIDOrderByModelVersionDesc(modelInfo.getModelInvariantId()); if(!serviceRecordList.isEmpty()){ for(org.onap.so.db.catalog.beans.Service record : serviceRecordList){ - recipe = record.getRecipes().get(action.toString()); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(record.getModelUUID(),action.toString()); if(recipe != null){ break; } @@ -1185,8 +1137,8 @@ public class ServiceInstances { } else if(!alaCarteFlag && recipe != null && Action.createInstance.equals(action)) { mapToLegacyRequest(requestDetails); }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default - serviceRecord = serviceRepo.findByModelNameOrderByModelVersionDesc(defaultServiceModelName); - recipe = serviceRecord.getRecipes().get( action.toString()); + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(),action.toString()); } if(modelInfo.getModelVersionId() == null) { modelInfo.setModelVersionId(serviceRecord.getModelUUID()); @@ -1381,14 +1333,14 @@ public class ServiceInstances { // Validation for vnfResource if(modelCustomizationId!=null) { - vrc = vnfCustomRepo.findOneByModelCustomizationUUID(modelCustomizationId); + vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelCustomizationId); if(vrc != null){ vnfResource = vrc.getVnfResources(); } } else { - org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(relatedInstanceModelVersionId); + org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(relatedInstanceModelVersionId); if(service == null) { - service = serviceRepo.findByModelVersionAndModelInvariantUUID(relatedInstanceVersion, relatedInstanceModelInvariantId); + service = catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(relatedInstanceVersion, relatedInstanceModelInvariantId); } if(service == null) { @@ -1420,12 +1372,12 @@ public class ServiceInstances { if(vrc != null) { String nfRole = vrc.getNfRole(); if(nfRole != null) { - vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString()); + vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString()); } } if(vnfRecipe == null) { - vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); } if (vnfRecipe == null) { @@ -1449,13 +1401,13 @@ public class ServiceInstances { VfModule vfModule = null; if(modelInfo.getModelCustomizationId() != null) { - vfmc = vfModuleCustomRepo.findByModelCustomizationUUID(modelInfo.getModelCustomizationId()); + vfmc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId()); } else { - vnfr = vnfRepo.findResourceByModelUUID(relatedInstanceModelVersionId); + vnfr = catalogDbClient.getVnfResourceByModelUUID(relatedInstanceModelVersionId); if(vnfr == null){ - vnfr = vnfRepo.findResourceByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); + vnfr = catalogDbClient.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); } - vnfrc = vnfCustomRepo.findByModelInstanceNameAndVnfResources(relatedInstanceModelCustomizationName, vnfr); + vnfrc = catalogDbClient.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources(relatedInstanceModelCustomizationName, vnfr); List<VfModuleCustomization> list = vnfrc.getVfModuleCustomizations(); @@ -1463,16 +1415,16 @@ public class ServiceInstances { for(VfModuleCustomization vf : list) { VfModuleCustomization vfmCustom; if(vfModuleModelUUID != null){ - vfmCustom = vfModuleCustomRepo.findByModelCustomizationUUIDAndVfModuleModelUUID(vf.getModelCustomizationUUID(), vfModuleModelUUID); + vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(vf.getModelCustomizationUUID(), vfModuleModelUUID); if(vfmCustom != null){ vfModule = vfmCustom.getVfModule(); } }else{ - vfmCustom = vfModuleCustomRepo.findByModelCustomizationUUID(vf.getModelCustomizationUUID()); + vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vf.getModelCustomizationUUID()); if(vfmCustom != null){ vfModule = vfmCustom.getVfModule(); }else{ - vfModule = vfModuleRepo.findByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); + vfModule = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); } } @@ -1495,12 +1447,12 @@ public class ServiceInstances { } - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(vfModule.getModelUUID(), vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(vfModule.getModelUUID(), vnfComponentType, action.toString()); if(recipe == null){ - List<VfModule> vfModuleRecords= vfModuleRepo.findByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID()); + List<VfModule> vfModuleRecords= catalogDbClient.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID()); if(!vfModuleRecords.isEmpty()){ for(VfModule record : vfModuleRecords){ - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(record.getModelUUID(), vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(record.getModelUUID(), vnfComponentType, action.toString()); if(recipe != null){ break; } @@ -1508,9 +1460,9 @@ public class ServiceInstances { } } if(recipe == null) { - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); if (recipe == null) { - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVnfComponentTypeAndAction(vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction(vnfComponentType, action.toString()); } if(recipe == null) { @@ -1521,12 +1473,12 @@ public class ServiceInstances { } else { if(modelInfo.getModelType().equals(ModelType.vnf)) { - recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + recipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); if (recipe == null) { return null; } } else { - recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); if (recipe == null) { return null; @@ -1541,7 +1493,7 @@ public class ServiceInstances { String defaultSource = getDefaultModel(sir); - VnfRecipe vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + VnfRecipe vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); if (vnfRecipe == null) { return null; @@ -1560,22 +1512,24 @@ public class ServiceInstances { Recipe recipe = null; if(modelInfo.getModelCustomizationId()!=null){ - NetworkResource networkResource = networkCustomizationRepo.findOneByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource(); + NetworkResource networkResource = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource(); if(networkResource!=null){ if(modelInfo.getModelVersionId() == null) { modelInfo.setModelVersionId(networkResource.getModelUUID()); } - recipe = networkRecipeRepo.findByModelNameAndAction(networkResource.getModelName(), action.toString()); + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString()); }else{ throw new ValidationException("no catalog entry found"); } }else{ //ok for version < 3 and action delete - recipe = networkRecipeRepo.findByModelNameAndAction(modelName, action.toString()); + if(modelName != null){ + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(modelName, action.toString()); + } } if(recipe == null){ - recipe = networkRecipeRepo.findByModelNameAndAction(defaultNetworkType, action.toString()); + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(defaultNetworkType, action.toString()); } return recipe !=null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null; @@ -1679,7 +1633,7 @@ public class ServiceInstances { if (sir.getCorrelationId() != null) { correlationId = sir.getCorrelationId(); } - iar.save(currentActiveReq); + infraActiveRequestsClient.save(currentActiveReq); if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -1706,7 +1660,6 @@ public class ServiceInstances { throw validateException; } } - //TODO MSO-4177 -- remove this and call the msoRequest instead public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage){ if ((status == Status.FAILED) || (status == Status.COMPLETE)) { aq.setStatusMessage (errorMessage); @@ -1714,7 +1667,7 @@ public class ServiceInstances { aq.setRequestStatus(status.toString()); Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); aq.setEndTime (endTimeStamp); - iar.save(aq); + infraActiveRequestsClient.save(aq); } } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java index 0a996dc3dc..6d61d3bb34 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ * 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 @@ -20,7 +22,6 @@ package org.onap.so.apihandlerinfra; -import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @@ -31,7 +32,7 @@ public class SpringContextHelper implements ApplicationContextAware { private static ApplicationContext context; @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + public void setApplicationContext(ApplicationContext applicationContext) { context = applicationContext; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index 910b9f70cb..d743c440e7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java @@ -40,7 +40,6 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.RequestsDbClient; import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; @@ -51,7 +50,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestReferences; import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantSyncResponse; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; @@ -238,4 +237,4 @@ public class CloudOrchestration { private String getRequestId(ContainerRequestContext requestContext) { return requestContext.getProperty("requestId").toString(); } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java index a9cf35796b..a35f40baf6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java @@ -20,22 +20,42 @@ package org.onap.so.apihandlerinfra.tenantisolation; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wordnik.swagger.annotations.Api; -import com.wordnik.swagger.annotations.ApiOperation; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.transaction.Transactional; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.Constants; import org.onap.so.apihandlerinfra.Messages; -import org.onap.so.apihandlerinfra.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; -import org.onap.so.apihandlerinfra.tenantisolationbeans.*; +import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList; +import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse; +import org.onap.so.apihandlerinfra.tenantisolationbeans.InstanceReferences; import org.onap.so.apihandlerinfra.tenantisolationbeans.Request; +import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails; +import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestStatus; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; @@ -44,15 +64,10 @@ import org.onap.so.utils.UUIDChecker; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.transaction.Transactional; -import javax.ws.rs.*; -import javax.ws.rs.core.*; +import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; @Component @Path("onap/so/infra/cloudResourcesRequests") @@ -279,4 +294,4 @@ public class CloudResourcesOrchestration { return request; } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java index b35b669208..855a5433f3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java @@ -30,7 +30,6 @@ import javax.ws.rs.core.MultivaluedMap; import org.apache.commons.lang3.StringUtils; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.RequestsDbClient; import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; @@ -44,6 +43,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.ResourceType; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; @@ -384,4 +384,4 @@ public class TenantIsolationRequest { public void setOperationalEnvironmentId(String operationalEnvironmentId) { this.operationalEnvironmentId = operationalEnvironmentId; } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java index 461acab96d..2427dd2734 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java @@ -32,8 +32,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.process.CreateVnfOperationalE import org.onap.so.apihandlerinfra.tenantisolation.process.DeactivateVnfOperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -46,7 +44,7 @@ import org.springframework.stereotype.Component; @Scope("prototype") public class TenantIsolationRunnable { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class); @Autowired private RequestsDBHelper requestDb; @@ -60,10 +58,6 @@ public class TenantIsolationRunnable { private DeactivateVnfOperationalEnvironment deactivateVnfOpEnv; @Autowired private ActivateVnfStatusOperationalEnvironment activateVnfStatusOpEnv; - @Autowired - private OperationalEnvDistributionStatusRepository distributionStatusRepository; - @Autowired - private OperationalEnvServiceModelStatusRepository modelStatusRepository; @Async public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException { @@ -83,11 +77,11 @@ public class TenantIsolationRunnable { throw validateException; } } else if(Action.activate.equals(action)) { - activateVnfOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository); + activateVnfOpEnv.execute(requestId, cor); } else if(Action.deactivate.equals(action)) { deactivateVnfOpEnv.execute(requestId, cor); } else if(Action.distributionStatus.equals(action)) { - activateVnfStatusOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository); + activateVnfStatusOpEnv.execute(requestId, cor); } else { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build(); ValidateException validateException = new ValidateException.Builder("Invalid Action specified: " + action, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index 903639c8f5..ac9a000d3b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -21,13 +21,13 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.List; -import java.util.Optional; import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -40,8 +40,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -53,7 +51,7 @@ import org.springframework.stereotype.Component; @Component public class ActivateVnfOperationalEnvironment { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class); private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; private static final String DISTRIBUTION_STATUS_SENT = "SENT"; @@ -69,16 +67,16 @@ public class ActivateVnfOperationalEnvironment { @Value("${mso.tenant.isolation.retry.count}") private String sdcRetryCount; + @Autowired + RequestsDbClient client; + /** * The Point-Of-Entry from APIH with VID request to send activate request * @param requestId - String * @param request - CloudOrchestrationRequest object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return void - nothing */ - public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{ + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{ String operationalEnvironmentId = request.getOperationalEnvironmentId(); String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); @@ -96,7 +94,7 @@ public class ActivateVnfOperationalEnvironment { HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); } - processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, distributionStatusRepository, modelStatusRepository); + processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext); } @@ -107,13 +105,11 @@ public class ActivateVnfOperationalEnvironment { * @param operationalEnvironmentId - String * @param serviceModelVersionIdList - List<ServiceModelList> list * @param workloadContext - String - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return jsonResponse - JSONObject object */ - public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, List<ServiceModelList> serviceModelVersionIdList, - String workloadContext, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, + List<ServiceModelList> serviceModelVersionIdList, + String workloadContext) throws ApiException { JSONObject jsonResponse = null; int retryCount = 0; @@ -137,7 +133,7 @@ public class ActivateVnfOperationalEnvironment { recoveryAction, retryCount, workloadContext); - modelStatusRepository.save(serviceModelStatus); + client.save(serviceModelStatus); String distributionId = ""; @@ -154,7 +150,7 @@ public class ActivateVnfOperationalEnvironment { requestId, DISTRIBUTION_STATUS_SENT, ""); - distributionStatusRepository.save(distStatus); + client.save(distStatus); } else { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java index 6a9bec5abb..66cfd349df 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java @@ -28,6 +28,7 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -38,8 +39,6 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -72,17 +71,16 @@ public class ActivateVnfStatusOperationalEnvironment { private RequestsDBHelper requestDb; @Autowired private SDCClientHelper sdcClientHelper; + @Autowired + private RequestsDbClient client; /** * The Point-Of-Entry from APIH with activate status from SDC * @param requestId - String * @param request - CloudOrchestrationRequest - object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository - object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository - object * @return void - nothing */ - public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { String operationalEnvironmentId = ""; @@ -91,18 +89,18 @@ public class ActivateVnfStatusOperationalEnvironment { Distribution sdcStatus = request.getDistribution(); // Distribution, Query for operationalEnvironmentId, serviceModelVersionId - this.queryDistributionDbResponse = distributionStatusRepository.findOne(sdcDistributionId); + this.queryDistributionDbResponse = client.getDistributionStatusById(sdcDistributionId); operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId(); // ServiceModel, Query for dbRequestId, recoveryAction, retryCountString - this.queryServiceModelResponse = modelStatusRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId()); + this.queryServiceModelResponse = client.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId()); this.origRequestId = this.queryServiceModelResponse.getRequestId(); - processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse, distributionStatusRepository, modelStatusRepository); + processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse); // After EVERY status processed, need to query the status of all service modelId // to determine the OVERALL status if "COMPLETE" or "FAILURE": - checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId, modelStatusRepository); + checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId); } @@ -112,13 +110,10 @@ public class ActivateVnfStatusOperationalEnvironment { * @param sdcStatus - Distribution object * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return void - nothing */ public void processActivateSDCStatus(String sdcDistributionId, Distribution sdcStatus, OperationalEnvDistributionStatus queryDistributionDbResponse, - OperationalEnvServiceModelStatus queryServiceModelResponse, OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + OperationalEnvServiceModelStatus queryServiceModelResponse) throws ApiException { String sdcStatusValue = sdcStatus.getStatus().toString(); String recoveryAction = queryServiceModelResponse.getRecoveryAction(); @@ -131,13 +126,13 @@ public class ActivateVnfStatusOperationalEnvironment { dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, sdcStatusValue, ""); - distributionStatusRepository.save(updateDistStatusOk); + client.save(updateDistStatusOk); // should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!) OperationalEnvServiceModelStatus updateRetryCountZeroAndStatusOk = dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, sdcStatusValue, RETRY_COUNT_ZERO); - modelStatusRepository.save(updateRetryCountZeroAndStatusOk); + client.save(updateRetryCountZeroAndStatusOk); } else { // "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY" @@ -145,8 +140,7 @@ public class ActivateVnfStatusOperationalEnvironment { // RESEND / RETRY serviceModelVersionId to SDC - JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus, - distributionStatusRepository, modelStatusRepository); + JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus); } else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP' @@ -168,13 +162,13 @@ public class ActivateVnfStatusOperationalEnvironment { dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, modifiedStatus, RETRY_COUNT_ZERO); - modelStatusRepository.save(updateRetryCountZeroAndStatus); + client.save(updateRetryCountZeroAndStatus); // should update 1 row, modified status OperationalEnvDistributionStatus updateDistStatus = dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, modifiedStatus, errorReason); - distributionStatusRepository.save(updateDistStatus); + client.save(updateDistStatus); } else { // RETRY & Count = 0 (do nothing!) } @@ -187,15 +181,11 @@ public class ActivateVnfStatusOperationalEnvironment { * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object * @param sdcStatus - Distribution object - * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return JSONObject object */ public JSONObject callSDClientForRetry(OperationalEnvDistributionStatus queryDistributionDbResponse, OperationalEnvServiceModelStatus queryServiceModelResponse, - Distribution sdcStatus, - OperationalEnvDistributionStatusRepository distributionStatusRepository, - OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException { + Distribution sdcStatus) throws ApiException { JSONObject jsonResponse = null; @@ -218,7 +208,7 @@ public class ActivateVnfStatusOperationalEnvironment { originalRequestId, DISTRIBUTION_STATUS_SENT, ""); - distributionStatusRepository.save(insertNewDistributionId); + client.save(insertNewDistributionId); // update retryCount (less 1) for the serviceModelServiceId retryCount = retryCount - 1; @@ -227,14 +217,14 @@ public class ActivateVnfStatusOperationalEnvironment { dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, DISTRIBUTION_STATUS_SENT, retryCount); - modelStatusRepository.save(updateRetryCountAndStatus); + client.save(updateRetryCountAndStatus); // should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!). OperationalEnvDistributionStatus updateStatus = dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, DISTRIBUTION_STATUS_ERROR, sdcStatus.getErrorReason()); - distributionStatusRepository.save(updateStatus); + client.save(updateStatus); } else { String dbErrorMessage = "Failure calling SDC: statusCode: " + statusCode + "; messageId: " + jsonResponse.get("messageId") + @@ -255,12 +245,11 @@ public class ActivateVnfStatusOperationalEnvironment { * The Method to check the overall status of the Activation for an operationalEnvironmentId * @param operationalEnvironmentId - string * @param origRequestId - string - * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object * @return void - nothing */ - public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId, OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{ + public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId) throws ApiException{ - List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = modelStatusRepository.findAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId); + List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = client.getAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId); String status = "Waiting"; int count = 0; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java index c16f7bb9ef..b09bbae0ad 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java @@ -76,8 +76,8 @@ public class CreateEcompOperationalEnvironment { requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, request.getOperationalEnvironmentId()); throw validateException; } - //Update request database - requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId()); + //Update request database + requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId()); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java index f366c7e74b..b0ea85779c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java @@ -56,6 +56,9 @@ public class CloudConfigurationValidation implements ValidationRule{ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){ throw new ValidationException("cloudConfiguration"); } + if(requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance){ + throw new ValidationException("cloudConfiguration", true); + } } if (cloudConfiguration == null && ((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase (ModelType.service.name ()) && reqVersion < 5)) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java index edd1b1a10e..8fdb43f20c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java @@ -41,7 +41,7 @@ public class ConfigurationParametersValidation implements ValidationRule{ String requestScope = info.getRequestScope(); Actions action = info.getAction(); - if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && configParams.isEmpty()){ + if(configParams.isEmpty() && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut){ throw new ValidationException("configuration parameters"); } return info; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java index aa98d2abf2..c6fae6e872 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java @@ -60,7 +60,7 @@ public class ModelInfoValidation implements ValidationRule{ } // modelCustomizationId or modelCustomizationName are required for VNF Replace - if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance) { + if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) { if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) { throw new ValidationException("modelCustomizationId or modelCustomizationName"); } @@ -77,14 +77,16 @@ public class ModelInfoValidation implements ValidationRule{ if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){ throw new ValidationException("modelInvariantId"); } - + if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ + throw new ValidationException("modelInvariantId", true); + } if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) { throw new ValidationException ("modelInvariantId format"); } if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance || - action == Action.addRelationships || action == Action.removeRelationships || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){ - throw new ValidationException ("modelName"); + action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){ + throw new ValidationException ("modelName", true); } if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && @@ -92,6 +94,10 @@ public class ModelInfoValidation implements ValidationRule{ && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) { throw new ValidationException ("modelVersion"); } + + if(empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ + throw new ValidationException("modelVersion", true); + } // is required for serviceInstance delete macro when aLaCarte=false in v4 if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || @@ -99,6 +105,9 @@ public class ModelInfoValidation implements ValidationRule{ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) { throw new ValidationException ("modelVersionId"); } + if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ + throw new ValidationException("modelVersionId", true); + } if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){ throw new ValidationException("modelVersionId"); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java deleted file mode 100644 index 95daf2e501..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.so.apihandlerinfra; - - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.StringStartsWith.startsWith; -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyObject; - -import java.io.IOException; - -import javax.ws.rs.core.Response; - -import org.apache.http.HttpStatus; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.so.apihandler.common.ErrorNumbers; -import org.onap.so.apihandlerinfra.exceptions.ApiException; -import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper; -import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; -import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException; -import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; -import org.onap.so.apihandlerinfra.exceptions.ValidateException; -import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ApiExceptionMapperTest extends BaseTest { - - ApiExceptionMapper mapper = new ApiExceptionMapper(); - - - @Test - public void testObjectMapperError() throws JsonProcessingException { - ObjectMapper mockedMapper = Mockito.mock(ObjectMapper.class); - Mockito.when(mockedMapper.writeValueAsString(anyObject())).thenThrow(JsonProcessingException.class); - ValidateException validateException = new ValidateException.Builder("Test", 0 , null).build(); - ApiExceptionMapper mockedException = Mockito.spy(new ApiExceptionMapper()); - Mockito.doReturn(mockedMapper).when(mockedException).createObjectMapper(); - Response resp = mockedException.toResponse((ApiException) validateException); - - /// assertEquals(resp.getStatus(), HttpStatus.SC_BAD_REQUEST); - assertThat(resp.getEntity().toString(),startsWith("Exception in buildServiceErrorResponse writing exceptionType to string")); - } - - @Test - public void testValidateResponse(){ - ValidateException validateException = new ValidateException.Builder("Test Message", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).build(); - Response resp = mapper.toResponse((ApiException) validateException); - - assertEquals(resp.getStatus(), HttpStatus.SC_BAD_REQUEST); - } - - @Test - public void testBPMNFailureResponse(){ - BPMNFailureException bpmnException = new BPMNFailureException.Builder("Test Message", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).build(); - Response resp = mapper.toResponse((ApiException) bpmnException); - - assertEquals(resp.getStatus(), HttpStatus.SC_NOT_FOUND); - } - @Test - public void testClientConnectionResponse(){ - ClientConnectionException clientConnectionException = new ClientConnectionException.Builder("test", HttpStatus.SC_INTERNAL_SERVER_ERROR,ErrorNumbers.SVC_BAD_PARAMETER).build(); - Response resp = mapper.toResponse((ApiException) clientConnectionException); - - assertEquals(resp.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR); - } - @Test - public void testVFModuleResponse() { - VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_CONFLICT,ErrorNumbers.SVC_BAD_PARAMETER).build(); - Response resp = mapper.toResponse((ApiException) vfModuleException); - - assertEquals(resp.getStatus(), HttpStatus.SC_CONFLICT); - } - @Test - public void testDuplicateRequestResponse() throws IOException { - DuplicateRequestException duplicateRequestException = new DuplicateRequestException.Builder("Test1", "Test2","Test3","Test4", HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_BAD_PARAMETER).build(); - Response resp = mapper.toResponse((ApiException) duplicateRequestException); - - assertEquals(resp.getStatus(), HttpStatus.SC_BAD_GATEWAY); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java index d2730406e6..4072613d09 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java @@ -28,7 +28,6 @@ import com.github.tomakehurst.wiremock.client.WireMock; import org.junit.After; import org.junit.BeforeClass; import org.junit.runner.RunWith; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.onap.so.logger.MsoLogger; import org.onap.so.logger.MsoLogger.Catalog; import org.springframework.beans.factory.annotation.Autowired; @@ -45,8 +44,7 @@ import org.springframework.test.context.jdbc.Sql.ExecutionPhase; import org.springframework.test.context.junit4.SpringRunner; import javax.transaction.Transactional; -import java.io.File; -import java.io.IOException; + import java.nio.file.Files; import java.nio.file.Paths; @@ -55,36 +53,24 @@ import java.nio.file.Paths; @ActiveProfiles("test") @ContextConfiguration @Transactional -@Sql(executionPhase=ExecutionPhase.AFTER_TEST_METHOD,scripts="classpath:InfraActiveRequestsReset.sql") +//@Sql(executionPhase=ExecutionPhase.AFTER_TEST_METHOD,scripts="classpath:InfraActiveRequestsReset.sql") @AutoConfigureWireMock(port = 0) public abstract class BaseTest { protected MsoLogger logger = MsoLogger.getMsoLogger(Catalog.GENERAL, BaseTest.class); protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); - protected HttpHeaders headers = new HttpHeaders(); - @Autowired protected Environment env; - - @Autowired - protected InfraActiveRequestsRepository iar; - + @LocalServerPort private int port; - protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{ - ObjectMapper mapper = new ObjectMapper(); - JsonNode jsonNode = mapper.readTree(new File(fileLocation)); - return jsonNode.asText(); - } - protected String createURLWithPort(String uri) { return "http://localhost:" + port + uri; } @After public void tearDown(){ - iar.deleteAll(); WireMock.reset(); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java index a63b778a1f..66e29a8117 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java @@ -20,7 +20,12 @@ package org.onap.so.apihandlerinfra; -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -30,11 +35,9 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; @@ -44,10 +47,12 @@ import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.serviceinstancebeans.RequestError; import org.onap.so.serviceinstancebeans.ServiceException; import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.http.Fault; @@ -87,7 +92,8 @@ private final ObjectMapper mapper = new ObjectMapper(); JsonInput = "src/test/resources/E2EServiceInstancesTest" + JsonInput; return new String(Files.readAllBytes(Paths.get(JsonInput))); } - public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){ + public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){ + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type",MediaType.APPLICATION_JSON); @@ -154,6 +160,9 @@ private final ObjectMapper mapper = new ObjectMapper(); @Test public void getE2EServiceInstanceNullOperationalStatus() throws IOException{ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/operations/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; + stubFor(get(urlPathEqualTo("/operationStatus/search/findOneByServiceIdAndOperationId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.GET); assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatusCode().value()); @@ -187,7 +196,7 @@ private final ObjectMapper mapper = new ObjectMapper(); OperationStatus status = new OperationStatus(); status.setOperationId("operationId"); status.setServiceId("9b9f02c0-298b-458a-bc9c-be3692e4f35e"); - stubFor(get(urlPathEqualTo("/operationStatusRepository/search/findOneByServiceIdAndOperationId")) + stubFor(get(urlPathEqualTo("/operationStatus/search/findOneByServiceIdAndOperationId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(status)) .withStatus(HttpStatus.SC_OK))); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java index e16f265a2e..8b4d353a56 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/HealthCheckHandlerTest.java @@ -39,7 +39,7 @@ public class HealthCheckHandlerTest extends BaseTest{ @Test public void testHealthcheckGet() throws JSONException { - + HttpHeaders headers = new HttpHeaders(); HttpEntity<String> entity = new HttpEntity<String>(null, headers); ResponseEntity<String> response = restTemplate.exchange( diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java index 5d6aa43a9b..eec68d8079 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java @@ -32,13 +32,12 @@ import static org.junit.Assert.assertThat; import java.io.IOException; import java.util.Map; -import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; -import org.apache.log4j.MDC; import org.junit.Test; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandlerinfra.tasksbeans.RequestDetails; import org.onap.so.apihandlerinfra.tasksbeans.RequestInfo; import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference; @@ -46,6 +45,7 @@ import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest; import org.onap.so.apihandlerinfra.tasksbeans.ValidResponses; import org.onap.so.logger.MsoLogger; import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; @@ -81,7 +81,7 @@ public class ManualTasksTest extends BaseTest{ //expected response TaskRequestReference expectedResponse = new TaskRequestReference(); expectedResponse.setTaskId(taskId); - + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321"); @@ -110,8 +110,8 @@ public class ManualTasksTest extends BaseTest{ logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(MsoLogger.BEGINTIME)); - assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME)); @@ -119,9 +119,9 @@ public class ManualTasksTest extends BaseTest{ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); assertNotNull(mdc.get(MsoLogger.ENDTIME)); - assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); assertEquals("202",mdc.get(MsoLogger.RESPONSECODE)); assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java index 63dc96f485..fa3ce07d70 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java @@ -193,6 +193,7 @@ public class MsoRequestTest extends BaseTest { {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6}, {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateAndCloudDelete, 7}, {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/ScaleOutNoCloudConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, + {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/VnfRecreateCloudConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.recreateInstance, 7}, {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyLcpCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6}, {"No valid tenantId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, @@ -207,6 +208,7 @@ public class MsoRequestTest extends BaseTest { {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 6}, {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 6}, {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 5}, + {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/VnfRecreateNoModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.recreateInstance, 7}, {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid model-info is specified", mapper.readValue(inputStream("/ModelInfo/ModelInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelInvariantId format is specified", mapper.readValue(inputStream("/ModelInfo/InvalidModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 2}, @@ -218,13 +220,16 @@ public class MsoRequestTest extends BaseTest { {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v5DeactivateModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 5}, {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v3UpdateNetworkBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 4}, {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, + {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/VnfRecreateModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.recreateInstance, 7}, {"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/VfModuleModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, 4}, {"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, + {"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/VnfRecreateModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.recreateInstance, 7}, {"No valid modelType is specified", mapper.readValue(inputStream("/ModelInfo/ModelTypeNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3}, {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3}, {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionServiceCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3}, {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelVersion.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, + {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/VnfRecreateModelVersion.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.recreateInstance, 7}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ConfigurationModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 4}, @@ -235,6 +240,7 @@ public class MsoRequestTest extends BaseTest { {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionIdCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v5ActivateModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, + {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/VnfRecreateModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.recreateInstance, 7}, //ValidationException for Platform and LineOfBusiness {"No valid lineOfBusinessName is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/EmptyLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid platform is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/Platform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 6}, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index de7f560020..ea2261a94a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -20,49 +20,63 @@ package org.onap.so.apihandlerinfra; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.any; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.apache.http.HttpStatus; import org.junit.Ignore; import org.junit.Test; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.serviceinstancebeans.*; +import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse; +import org.onap.so.serviceinstancebeans.GetOrchestrationResponse; +import org.onap.so.serviceinstancebeans.Request; +import org.onap.so.serviceinstancebeans.RequestError; +import org.onap.so.serviceinstancebeans.RequestProcessingData; +import org.onap.so.serviceinstancebeans.ServiceException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; public class OrchestrationRequestsTest extends BaseTest { @Autowired - private InfraActiveRequestsRepository iar; - - @Autowired private RequestsDbClient requestsDbClient; + + @Autowired + private OrchestrationRequests orchReq; - private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>"; private static final GetOrchestrationListResponse ORCHESTRATION_LIST = generateOrchestrationList(); private static final String INVALID_REQUEST_ID = "invalid-request-id"; @@ -91,7 +105,7 @@ public class OrchestrationRequestsTest extends BaseTest { Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest(); testResponse.setRequest(request); String testRequestId = request.getRequestId(); - + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<Request> entity = new HttpEntity<Request>(null, headers); @@ -122,6 +136,7 @@ public class OrchestrationRequestsTest extends BaseTest { testResponse.setRequest(request); String testRequestId = request.getRequestId(); + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<Request> entity = new HttpEntity<Request>(null, headers); @@ -144,9 +159,10 @@ public class OrchestrationRequestsTest extends BaseTest { @Test public void testGetOrchestrationRequestNoRequestID() { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", "application/json; charset=UTF-8"); + headers.set("Content-Type", "application/json; charset=UTF-8"); HttpEntity<Request> entity = new HttpEntity<Request>(null, headers); - headers.set("Accept", MediaType.APPLICATION_JSON); - UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/")); @@ -161,21 +177,30 @@ public class OrchestrationRequestsTest extends BaseTest { List<String> values = new ArrayList<>(); values.add("EQUALS"); values.add("vfModule"); + + ObjectMapper mapper = new ObjectMapper(); + GetOrchestrationListResponse testResponse = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json"), + GetOrchestrationListResponse.class); Map<String, List<String>> orchestrationMap = new HashMap<>(); orchestrationMap.put("modelType", values); + List<GetOrchestrationResponse> testResponses = new ArrayList<>(); List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap); - HttpEntity<Request> entity = new HttpEntity<Request>(null, headers); + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); - + HttpEntity<Request> entity = new HttpEntity<Request>(null, headers); + UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule")); ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationListResponse.class); + assertThat(response.getBody(), + sameBeanAs(testResponse).ignoring("requestList.request.startTime").ignoring("requestList.request.requestStatus.finishTime")); assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); assertEquals(requests.size(), response.getBody().getRequestList().size()); + } @Test @@ -184,7 +209,7 @@ public class OrchestrationRequestsTest extends BaseTest { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json"))); - + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers); @@ -218,7 +243,7 @@ public class OrchestrationRequestsTest extends BaseTest { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json"))); - + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers); @@ -252,7 +277,7 @@ public class OrchestrationRequestsTest extends BaseTest { setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING"); ObjectMapper mapper = new ObjectMapper(); String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json"))); - + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers); @@ -283,7 +308,7 @@ public class OrchestrationRequestsTest extends BaseTest { String json = mapper.writeValueAsString(requests); requestsDbClient.save(requests); - + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<Request> entity = new HttpEntity<Request>(null, headers); @@ -314,8 +339,8 @@ public class OrchestrationRequestsTest extends BaseTest { requests.setRequestId("requestId"); requests.setRequestScope("service"); requests.setRequestType("createInstance"); - iar.save(requests); - +// iar.save(requests); + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<Request> entity = new HttpEntity<Request>(null, headers); @@ -333,12 +358,48 @@ public class OrchestrationRequestsTest extends BaseTest { assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0)); assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0)); } + @Test + public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException{ + RequestProcessingData entry = new RequestProcessingData(); + RequestProcessingData secondEntry = new RequestProcessingData(); + List<HashMap<String, String>> expectedList = new ArrayList<>(); + HashMap<String, String> expectedMap = new HashMap<>(); + List<HashMap<String, String>> secondExpectedList = new ArrayList<>(); + HashMap<String, String> secondExpectedMap = new HashMap<>(); + List<RequestProcessingData> expectedDataList = new ArrayList<>(); + entry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714"); + entry.setTag("pincFabricConfigRequest"); + expectedMap.put("requestAction", "assign"); + expectedMap.put("pincFabricId", "testId"); + expectedList.add(expectedMap); + entry.setDataPairs(expectedList); + secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715"); + secondEntry.setTag("pincFabricConfig"); + secondExpectedMap.put("requestAction", "unassign"); + secondExpectedList.add(secondExpectedMap); + secondEntry.setDataPairs(secondExpectedList); + expectedDataList.add(entry); + expectedDataList.add(secondEntry); + + List<org.onap.so.db.request.beans.RequestProcessingData> processingData = new ArrayList<>(); + List<RequestProcessingData> actualProcessingData = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + processingData = mapper.readValue(new File("src/test/resources/OrchestrationRequest/RequestProcessingData.json"), + new TypeReference<List<org.onap.so.db.request.beans.RequestProcessingData>>(){}); + actualProcessingData = orchReq.mapRequestProcessingData(processingData); + assertThat(actualProcessingData,sameBeanAs(expectedDataList)); + } public void setupTestGetOrchestrationRequest() throws Exception{ //For testGetOrchestrationRequest stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json")))) .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/")) + .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json")))) + .withStatus(HttpStatus.SC_OK))); } private void setupTestGetOrchestrationRequestRequestDetails(String requestId, String status) throws Exception{ @@ -378,4 +439,4 @@ public class OrchestrationRequestsTest extends BaseTest { .withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestDetailsFilter.json")))) .withStatus(HttpStatus.SC_OK))); } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 48d424c8d1..f726194fb7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -22,32 +22,34 @@ package org.onap.so.apihandlerinfra; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; import java.util.Map; -import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.apache.log4j.MDC; -import org.junit.Ignore; +import org.apache.http.HttpStatus; +import org.junit.Before; import org.junit.Test; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; @@ -57,15 +59,16 @@ import org.onap.so.serviceinstancebeans.RequestReferences; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.util.ResourceUtils; import org.springframework.web.util.UriComponentsBuilder; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.http.Fault; @@ -74,33 +77,60 @@ import ch.qos.logback.classic.spi.ILoggingEvent; public class ServiceInstancesTest extends BaseTest{ - @Autowired - private InfraActiveRequestsRepository iar; - + private final ObjectMapper mapper = new ObjectMapper(); + @Autowired private ServiceInstances servInstances; + @Value("${wiremock.server.port}") + private String wiremockPort; + private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/"; private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/"; private String uri; + @Before + public void beforeClass() { + stubFor(post(urlMatching(".*/infraActiveRequests.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + } + public String inputStream(String JsonInput)throws IOException{ JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput; - String input = new String(Files.readAllBytes(Paths.get(JsonInput))); - return input; - } - - public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){ - headers.set("Accept", MediaType.APPLICATION_JSON); - headers.set("Content-Type",MediaType.APPLICATION_JSON); + return new String(Files.readAllBytes(Paths.get(JsonInput))); + } + + private String getWiremockResponseForCatalogdb(String file) { + try { + File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file); + return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + } + + public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){ + + if (!headers.containsKey(HttpHeaders.ACCEPT)) { + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); + } + if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) { + headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON); + } UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath)); - HttpEntity<String> request = new HttpEntity<String>(requestJson, headers); - ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), - reqMethod, request, String.class); + HttpEntity<String> request = new HttpEntity<>(requestJson, headers); - return response; + return restTemplate.exchange(builder.toUriString(), + reqMethod, request, String.class); + } + + public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){ + return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders()); } @Test @@ -118,13 +148,34 @@ public class ServiceInstancesTest extends BaseTest{ } @Test - public void createServiceInstanceVIDDefault() throws JsonParseException, JsonMappingException, IOException{ + public void createServiceInstanceVIDDefault() throws IOException{ TestAppender.events.clear(); + + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + HttpHeaders headers = new HttpHeaders(); + headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); headers.set(MsoLogger.CLIENT_ID, "VID"); //expect ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -132,7 +183,7 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -149,8 +200,8 @@ public class ServiceInstancesTest extends BaseTest{ logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(MsoLogger.BEGINTIME)); - assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME)); @@ -158,9 +209,9 @@ public class ServiceInstancesTest extends BaseTest{ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); assertNotNull(mdc.get(MsoLogger.ENDTIME)); - assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); assertEquals("202",mdc.get(MsoLogger.RESPONSECODE)); assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); @@ -171,33 +222,33 @@ public class ServiceInstancesTest extends BaseTest{ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0)); } - - //ExpectedRecord - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("IN_PROGRESS"); - expectedRecord.setRequestBody(inputStream("/ServiceInstanceDefault.json")); - expectedRecord.setAction("createInstance"); - expectedRecord.setSource("VID"); - expectedRecord.setVnfId("1882938"); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setServiceInstanceId("1882939"); - expectedRecord.setServiceInstanceName("testService9"); - expectedRecord.setRequestScope("service"); - expectedRecord.setRequestorId("xxxxxx"); - expectedRecord.setRequestAction("createInstance"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("modifyTime").toString()); - } @Test - public void createServiceInstanceServiceInstancesUri() throws JsonParseException, JsonMappingException, IOException{ + public void createServiceInstanceServiceInstancesUri() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + //expect ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -215,10 +266,31 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createServiceInstanceBpelStatusError() throws JsonParseException, JsonMappingException, IOException{ + public void createServiceInstanceBpelStatusError() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY))); + + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST); @@ -226,19 +298,28 @@ public class ServiceInstancesTest extends BaseTest{ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test - public void createServiceInstanceBadGateway() throws JsonParseException, JsonMappingException, IOException{ + public void createServiceInstanceBadGateway() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}"))); + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void createServiceInstanceBadData() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{I AM REALLY BAD}"))); + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST); @@ -246,56 +327,99 @@ public class ServiceInstancesTest extends BaseTest{ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } @Test - public void createServiceInstanceEmptyResponse() throws JsonParseException, JsonMappingException, IOException{ + public void createServiceInstanceEmptyResponse() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE))); - + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST); assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value()); } @Test - public void activateServiceInstanceNoRecipeALaCarte() throws JsonParseException, JsonMappingException, IOException{ + public void activateServiceInstanceNoRecipeALaCarte() throws IOException{ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; + HttpHeaders headers = new HttpHeaders(); headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, headers); - //ExpectedRecord - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("FAILED"); - expectedRecord.setAction("activateInstance"); - expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB."); - expectedRecord.setProgress(new Long(100)); - expectedRecord.setSource("VID"); - expectedRecord.setVnfId("1882938"); - expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7968"); - expectedRecord.setServiceInstanceName("testService7"); - expectedRecord.setRequestScope("service"); - expectedRecord.setRequestAction("activateInstance"); - expectedRecord.setRequestorId("xxxxxx"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + + stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_NOT_FOUND))); - //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString()); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); } @Test - public void activateServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{ + public void activateServiceInstanceNoRecipe() throws IOException{ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_NOT_FOUND))); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST); assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); } @Test - public void activateServiceInstance() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void activateServiceInstance() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + HttpHeaders headers = new HttpHeaders(); headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -303,7 +427,7 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -313,10 +437,36 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void deactivateServiceInstance() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/DeactivateInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void deactivateServiceInstance() throws IOException{ + + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -333,10 +483,34 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void deleteServiceInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/DeleteInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void deleteServiceInstance() throws IOException { + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -353,10 +527,34 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void assignServiceInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/AssignServiceInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void assignServiceInstance() throws IOException { + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -374,10 +572,34 @@ public class ServiceInstancesTest extends BaseTest{ } @Test - public void unassignServiceInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/UnassignServiceInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void unassignServiceInstance() throws IOException { + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/search/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -394,10 +616,11 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createPortConfiguration() throws JsonParseException, JsonMappingException, IOException { + public void createPortConfiguration() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + HttpHeaders headers = new HttpHeaders(); headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -405,7 +628,7 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -416,18 +639,19 @@ public class ServiceInstancesTest extends BaseTest{ assertTrue(response.getBody().contains("1882939")); } @Test - public void createPortConfigurationEmptyProductFamilyId() throws JsonParseException, JsonMappingException, IOException { + public void createPortConfigurationEmptyProductFamilyId() throws IOException { uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); } @Test - public void deletePortConfiguration() throws JsonParseException, JsonMappingException, IOException { + public void deletePortConfiguration() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + HttpHeaders headers = new HttpHeaders(); headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -435,7 +659,7 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -445,9 +669,9 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void enablePort() throws JsonParseException, JsonMappingException, IOException { + public void enablePort() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -465,9 +689,9 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void disablePort() throws JsonParseException, JsonMappingException, IOException { + public void disablePort() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -485,9 +709,9 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void activatePort() throws JsonParseException, JsonMappingException, IOException { + public void activatePort() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -505,9 +729,9 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void deactivatePort() throws JsonParseException, JsonMappingException, IOException { + public void deactivatePort() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -525,9 +749,9 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void addRelationships() throws JsonParseException, JsonMappingException, IOException { + public void addRelationships() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response @@ -546,9 +770,9 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void removeRelationships() throws JsonParseException, JsonMappingException, IOException { + public void removeRelationships() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response @@ -567,11 +791,27 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createVnfInstanceNoALaCarte() throws JsonParseException, JsonMappingException, IOException { + public void createVnfInstanceNoALaCarte() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -588,12 +828,33 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createVnfInstance() throws JsonParseException, JsonMappingException, IOException { + public void createVnfInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3"; + HttpHeaders headers = new HttpHeaders(); headers.set(MsoLogger.ONAP_REQUEST_ID, requestId); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -601,27 +862,25 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; - ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - InfraActiveRequests record = iar.findOneByRequestId(requestId); assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); assertTrue(response.getBody().contains("1882939")); - assertEquals(record.getVnfType(), "vSAMP12/test"); } @Test - public void createVnfWithServiceRelatedInstanceFail() throws JsonParseException, JsonMappingException, IOException { + public void createVnfWithServiceRelatedInstanceFail() throws IOException { uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs"; ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); } @Test - public void createVnfInstanceInvalidVnfResource() throws JsonParseException, JsonMappingException, IOException { + public void createVnfInstanceInvalidVnfResource() throws IOException { uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST); @@ -631,14 +890,28 @@ public class ServiceInstancesTest extends BaseTest{ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertTrue(realResponse.getServiceException().getText().equals("No valid vnfResource is specified")); + assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText()); } @Test - public void replaceVnfInstance() throws JsonParseException, JsonMappingException, IOException { + public void replaceVnfInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -655,11 +928,26 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void replaceVnfRecreateInstance() throws JsonParseException, JsonMappingException, IOException { + public void replaceVnfRecreateInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -676,11 +964,63 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void updateVnfInstance() throws JsonParseException, JsonMappingException, IOException { + public void recreateVnfInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate"; + ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST); + logger.debug(response.getBody()); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void updateVnfInstance() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" + + "[?]nfRole=GR-API-DEFAULT&action=updateInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -697,12 +1037,20 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void applyUpdatedConfig() throws JsonParseException, JsonMappingException, IOException { + public void applyUpdatedConfig() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" + + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5"; + HttpHeaders headers = new HttpHeaders(); headers.set(MsoLogger.ONAP_REQUEST_ID, requestId); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -710,23 +1058,26 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig"; - ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - InfraActiveRequests record = iar.findOneByRequestId(requestId); assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertNull(record.getVnfType()); } @Test - public void deleteVnfInstanceV5() throws JsonParseException, JsonMappingException, IOException { + public void deleteVnfInstanceV5() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" + + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -743,11 +1094,32 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void createVfModuleInstance() throws IOException { + + stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -765,11 +1137,50 @@ public class ServiceInstancesTest extends BaseTest{ assertTrue(response.getBody().contains("1882939")); } @Test - public void createVfModuleInstanceNoModelCustomization() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void createVfModuleInstanceNoModelCustomization() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" + + "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" + + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" + + "[?]vnfComponentType=vfModule&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -783,11 +1194,47 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void deleteVfModuleInstanceNoMatchingModelUUD() throws JsonParseException, JsonMappingException, IOException { + public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vnfResource/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -802,22 +1249,56 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createVfModuleInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException { - uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules"; + public void createVfModuleInstanceNoRecipe() throws IOException { + + stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" + + "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" + + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules"; ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertTrue(realResponse.getServiceException().getText().equals("No valid vfModuleCustomization is specified")); + assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText()); } @Test - public void replaceVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + public void replaceVfModuleInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - + + stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" + + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -834,11 +1315,32 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void updateVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + public void updateVfModuleInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -856,13 +1358,14 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{ + public void createVfModuleNoModelType() throws IOException{ + HttpHeaders headers = new HttpHeaders(); headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); InfraActiveRequests expectedRecord = new InfraActiveRequests(); expectedRecord.setRequestStatus("FAILED"); expectedRecord.setAction("createInstance"); expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified"); - expectedRecord.setProgress(new Long(100)); + expectedRecord.setProgress(100L); expectedRecord.setSource("VID"); expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json")); expectedRecord.setLastModifiedBy("APIH"); @@ -876,19 +1379,21 @@ public class ServiceInstancesTest extends BaseTest{ expectedRecord.setVnfType(""); uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules"; - ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers); //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString()); - assertNotNull(requestRecord.getStartTime()); - assertNotNull(requestRecord.getEndTime()); } @Test - public void inPlaceSoftwareUpdate() throws JsonParseException, JsonMappingException, IOException { + public void inPlaceSoftwareUpdate() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" + + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -905,59 +1410,59 @@ public class ServiceInstancesTest extends BaseTest{ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } - + @Test - public void inPlaceSoftwareUpdateDuplicate() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void deleteVfModuleInstance() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - InfraActiveRequests req = new InfraActiveRequests(); - req.setRequestStatus("IN_PROGRESS"); - req.setAction("inPlaceSoftwareUpdate"); - req.setProgress(new Long(10)); - req.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); - req.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7908"); - req.setVnfId("ff305d54-75b4-431b-adb2-eb6b9e5ff033"); - req.setRequestScope("vnf"); - req.setVnfName("duplicateCheck123"); - req.setRequestAction("inPlaceSoftwareUpdate"); - req.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - iar.save(req); + stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" + + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7908/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff033/inPlaceSoftwareUpdate"; - ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate2.json"), uri, HttpMethod.POST); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value()); - - InfraActiveRequests newRecord = iar.findOneByRequestBody(inputStream("/InPlaceSoftwareUpdate2.json")); - - assertNotNull(newRecord.getServiceInstanceId()); - assertNotNull(newRecord.getVnfId()); - + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } - @Test - public void deleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + public void deleteVfModuleNoModelInvariantId() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE); + uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72"; + ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -967,11 +1472,23 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void deactivateAndCloudDeleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + public void deactivateAndCloudDeleteVfModuleInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" + + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -988,11 +1505,27 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { + public void createVolumeGroupInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1010,11 +1543,27 @@ public class ServiceInstancesTest extends BaseTest{ assertTrue(response.getBody().contains("1882939")); } @Test - public void updateVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { + public void updateVolumeGroupInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1031,11 +1580,31 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void deleteVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { + public void deleteVolumeGroupInstance() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1052,12 +1621,29 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void createNetworkInstance() throws JsonParseException, JsonMappingException, IOException { + public void createNetworkInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=GR-API-DEFAULT&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4"; + HttpHeaders headers = new HttpHeaders(); headers.set(MsoLogger.ONAP_REQUEST_ID, requestId); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); @@ -1065,23 +1651,36 @@ public class ServiceInstancesTest extends BaseTest{ requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - InfraActiveRequests record = iar.findOneByRequestId(requestId); assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertEquals(record.getNetworkType(), "TestNetworkType"); } @Test - public void updateNetworkInstance() throws JsonParseException, JsonMappingException, IOException { + public void updateNetworkInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=GR-API-DEFAULT&action=updateInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1099,11 +1698,27 @@ public class ServiceInstancesTest extends BaseTest{ assertTrue(response.getBody().contains("1882939")); } @Test - public void deleteNetworkInstance() throws JsonParseException, JsonMappingException, IOException { + public void deleteNetworkInstance() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=VNF-API-DEFAULT&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1120,11 +1735,18 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void deleteNetworkInstanceNoReqParams() throws JsonParseException, JsonMappingException, IOException { + public void deleteNetworkInstanceNoReqParams() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=GR-API-DEFAULT&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1141,13 +1763,14 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } @Test - public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException { + public void convertJsonToServiceInstanceRequestFail() throws IOException { + HttpHeaders headers = new HttpHeaders(); headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); //ExpectedRecord InfraActiveRequests expectedRecord = new InfraActiveRequests(); expectedRecord.setRequestStatus("FAILED"); expectedRecord.setStatusMessage("Error mapping request: "); - expectedRecord.setProgress(new Long(100)); + expectedRecord.setProgress(100L); expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json")); expectedRecord.setLastModifiedBy("APIH"); expectedRecord.setRequestScope("network"); @@ -1155,19 +1778,14 @@ public class ServiceInstancesTest extends BaseTest{ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; - ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE); + ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers); //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - assertThat(expectedRecord, sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").ignoring("statusMessage")); - assertThat(requestRecord.getStatusMessage(), containsString("Error mapping request: ")); - assertNotNull(requestRecord.getStartTime()); - assertNotNull(requestRecord.getEndTime()); } @Test - public void convertJsonToServiceInstanceRequestConfigurationFail() throws JsonParseException, JsonMappingException, IOException { + public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException { uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort"; ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST); @@ -1177,9 +1795,28 @@ public class ServiceInstancesTest extends BaseTest{ @Test public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + uri = servInstanceuri + "v7" + "/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST); @@ -1200,9 +1837,25 @@ public class ServiceInstancesTest extends BaseTest{ @Test public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=GR-API-DEFAULT&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST); @@ -1223,7 +1876,7 @@ public class ServiceInstancesTest extends BaseTest{ @Test public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; @@ -1244,9 +1897,25 @@ public class ServiceInstancesTest extends BaseTest{ @Test public void createNetworkInstanceTestApiGrApi() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=GR-API-DEFAULT&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST); @@ -1267,9 +1936,25 @@ public class ServiceInstancesTest extends BaseTest{ @Test public void createNetworkInstanceTestApiVnfApi() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=VNF-API-DEFAULT&action=createInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST); @@ -1288,42 +1973,43 @@ public class ServiceInstancesTest extends BaseTest{ } @Test - public void activateServiceInstanceRequestStatus() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void activateServiceInstanceRequestStatus() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + HttpHeaders headers = new HttpHeaders(); headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("FAILED"); - expectedRecord.setAction("activateInstance"); - expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB."); - expectedRecord.setProgress(new Long(100)); - expectedRecord.setSource("VID"); - expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7999"); - expectedRecord.setServiceInstanceName("testService1234"); - expectedRecord.setRequestScope("service"); - expectedRecord.setRequestAction("activateInstance"); - expectedRecord.setRequestorId("xxxxxx"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + //expect ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); requestReferences.setInstanceId("1882939"); expectedResponse.setRequestReferences(requestReferences); uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - //then - assertEquals(Status.IN_PROGRESS.name(), requestRecord.getRequestStatus()); assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); @@ -1332,20 +2018,41 @@ public class ServiceInstancesTest extends BaseTest{ @Test public void invalidRequestId() throws IOException { String illegalRequestId = "1234"; - headers.set("X-ECOMP-RequestID", illegalRequestId); + HttpHeaders headers = new HttpHeaders(); + headers.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId); uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers); assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID")); } @Test public void invalidBPELResponse() throws IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); @@ -1357,13 +2064,69 @@ public class ServiceInstancesTest extends BaseTest{ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText()); } + @Test + public void unauthorizedBPELResponse() throws IOException{ + + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED))); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); + } @Test public void invalidBPELResponse2() throws IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); uri = servInstanceuri + "v5/serviceInstances"; ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); @@ -1377,11 +2140,34 @@ public class ServiceInstancesTest extends BaseTest{ } @Test - public void createMacroServiceInstance() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + public void createMacroServiceInstance() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + //expect ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1400,7 +2186,7 @@ public class ServiceInstancesTest extends BaseTest{ } @Test - public void testUserParams() throws JsonParseException, JsonMappingException, IOException { + public void testUserParams() throws IOException { ObjectMapper mapper = new ObjectMapper(); ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class); RequestParameters requestParameters = request.getRequestDetails().getRequestParameters(); @@ -1411,7 +2197,7 @@ public class ServiceInstancesTest extends BaseTest{ assertTrue(userParams.size() > 0); assertTrue(userParams.get(0).containsKey("name")); assertTrue(userParams.get(0).containsKey("value")); - assertTrue(userParamsTxt.replaceAll("\\s+","").equals(userParams.toString().replaceAll("\\s+",""))); + assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", "")); } @Test @@ -1434,11 +2220,36 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(request, sameBeanAs(expected)); } @Test - public void scaleOutVfModule() throws JsonParseException, JsonMappingException, IOException { + public void scaleOutVfModule() throws IOException { stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + + stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" + + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); RequestReferences requestReferences = new RequestReferences(); @@ -1455,4 +2266,40 @@ public class ServiceInstancesTest extends BaseTest{ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); assertTrue(response.getBody().contains("1882939")); } + @Test + public void createServiceInstanceBadResponse() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); + } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java index 459214b4ce..fa323a12c2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/TasksHandlerTest.java @@ -34,7 +34,6 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.List; -import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -45,6 +44,7 @@ import org.onap.so.apihandlerinfra.tasksbeans.TaskList; import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse; import org.onap.so.apihandlerinfra.tasksbeans.ValidResponses; import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; @@ -93,7 +93,7 @@ public class TasksHandlerTest extends BaseTest{ taskList.add(taskList1); expectedResponse.setTaskList(taskList); - + HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<String>(null, headers); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java index e759752c33..1e11b74215 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java @@ -30,7 +30,6 @@ import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantIsolationRequest; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java index 5f18e28ba6..8ac84d6598 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java @@ -25,9 +25,6 @@ import org.junit.Before; import org.junit.Test; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -44,15 +41,8 @@ import static org.junit.Assert.assertTrue; public class CloudResourcesOrchestrationTest extends BaseTest{ - @Autowired - private InfraActiveRequestsRepository iarRepo; private String requestJSON = "{\"requestDetails\":{\"requestInfo\":{\"source\":\"VID\",\"requestorId\":\"xxxxxx\" } } }"; private static final String path = "/onap/so/infra/cloudResourcesRequests"; - - @LocalServerPort - private int port; - - HttpHeaders headers = new HttpHeaders(); @Before @@ -275,8 +265,6 @@ public class CloudResourcesOrchestrationTest extends BaseTest{ iar.setRequestStatus("COMPLETE"); iar.setRequestAction("TEST"); - iarRepo.saveAndFlush(iar); - headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<>("", headers); @@ -303,8 +291,6 @@ public class CloudResourcesOrchestrationTest extends BaseTest{ iar.setRequestStatus("COMPLETE"); iar.setRequestAction("TEST"); - iarRepo.saveAndFlush(iar); - headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); HttpEntity<String> entity = new HttpEntity<>(null, headers); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java index 3c991ef0c5..c36eb2b063 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java @@ -25,70 +25,81 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpStatus; import org.json.JSONObject; -import org.junit.After; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.onap.so.apihandlerinfra.BaseTest; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; -import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; -import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; +import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction; +import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; import org.onap.so.client.aai.AAIVersion; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; -import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.springframework.beans.factory.annotation.Autowired; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ - @Autowired - private OperationalEnvDistributionStatusRepository distributionDbRepository; - @Autowired - private OperationalEnvServiceModelStatusRepository serviceModelDbRepository; + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Autowired private ActivateVnfOperationalEnvironment activateVnf; @Autowired - private InfraActiveRequestsRepository infraActiveRequestsRepository; - @Autowired private AAIClientHelper clientHelper; - String requestId = "TEST_requestId"; - String operationalEnvironmentId = "EMOE-001"; - CloudOrchestrationRequest request = new CloudOrchestrationRequest(); - String workloadContext = "PVT"; + private final String requestId = "TEST_requestId"; + private final String operationalEnvironmentId = "1dfe7154-eae0-44f2-8e7a-8e5e7882e55d"; + private final CloudOrchestrationRequest request = new CloudOrchestrationRequest(); + private final String workloadContext = "PVT"; String recoveryActionRetry = "RETRY"; - String serviceModelVersionId = "TEST_serviceModelVersionId"; + private final String serviceModelVersionId = "TEST_serviceModelVersionId"; int retryCount = 3; - String sdcDistributionId = "TEST_distributionId"; - String statusSent = "SENT"; - - @After - public void after() throws Exception { - distributionDbRepository.deleteAll(); - serviceModelDbRepository.deleteAll(); + private final String sdcDistributionId = "TEST_distributionId"; + private final String statusSent = "SENT"; + private final ObjectMapper mapper = new ObjectMapper(); + + @Before + public void init(){ + stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestId\",\"operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":3,\"workloadContext\":\"PVT\",\"createTime\":null,\"modifyTime\":null}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) + .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestId\",\"distributionIdStatus\":\"SENT\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); } + @Test - public void getAAIOperationalEnvironmentTest() throws Exception { + public void getAAIOperationalEnvironmentTest() { - AAIOperationalEnvironment aaiOpEnv = null; + AAIOperationalEnvironment aaiOpEnv; stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); @@ -104,7 +115,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ @Test public void executionTest() throws Exception { - List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>(); + List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>(); ServiceModelList serviceModelList1 = new ServiceModelList(); serviceModelList1.setRecoveryAction(RecoveryAction.retry); serviceModelList1.setServiceModelVersionId(serviceModelVersionId); @@ -130,22 +141,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); - - - activateVnf.execute(requestId, request, distributionDbRepository, serviceModelDbRepository); - - // insert record, status sent - OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId()); - assertEquals(statusSent, distStatus.getDistributionIdStatus()); - - // insert record, status sent - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus()); - assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId()); - + activateVnf.execute(requestId, request); } @Test @@ -159,7 +155,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ jsonObject.put("distributionId", distributionId); // prepare request detail - List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>(); + List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>(); ServiceModelList serviceModelList1 = new ServiceModelList(); serviceModelList1.setRecoveryAction(RecoveryAction.retry); serviceModelList1.setServiceModelVersionId(serviceModelVersionId); @@ -168,25 +164,11 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); - activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, - distributionDbRepository, serviceModelDbRepository); - - // insert record, status sent - OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId()); - assertEquals(statusSent, distStatus.getDistributionIdStatus()); - - // insert record, status sent - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus()); - assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId()); - + activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext); } - @Test - public void processActivateSDCRequestTest_409() throws Exception { + @Test + public void processActivateSDCRequestTest_409() throws ApiException, JsonProcessingException { // ERROR in asdc JSONObject jsonMessages = new JSONObject(); @@ -200,7 +182,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ jsonErrorResponse.put("requestError", jsonServException); // prepare request detail - List<ServiceModelList> serviceModelVersionIdList = new ArrayList<ServiceModelList>(); + List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>(); ServiceModelList serviceModelList1 = new ServiceModelList(); serviceModelList1.setRecoveryAction(RecoveryAction.retry); serviceModelList1.setServiceModelVersionId(serviceModelVersionId); @@ -209,30 +191,20 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestId); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); - + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonErrorResponse.toString()).withStatus(HttpStatus.SC_CONFLICT))); - - try { - activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, - distributionDbRepository, serviceModelDbRepository); - - } catch (Exception ex) { - - // insert record, status sent - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus()); - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE")); - assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED")); - - } - - infraActiveRequestsRepository.delete(requestId); + stubFor(post(urlPathEqualTo("/infraActiveRequests/")) + .withRequestBody(containing("operationalEnvId\":\"1dfe7154-eae0-44f2-8e7a-8e5e7882e55d\"")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + thrown.expect(ValidateException.class); + + activateVnf.processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java index 3dcac0da18..9a5334081f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java @@ -21,78 +21,68 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.containing; import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; + import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpStatus; import org.json.JSONObject; -import org.junit.After; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; +import org.junit.Ignore; import org.junit.rules.ExpectedException; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; -import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper; import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus; import org.onap.so.apihandlerinfra.tenantisolationbeans.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; -import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository; -import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository; import org.springframework.beans.factory.annotation.Autowired; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ @Autowired - private OperationalEnvDistributionStatusRepository distributionDbRepository; - @Autowired - private OperationalEnvServiceModelStatusRepository serviceModelDbRepository; - @Autowired private ActivateVnfStatusOperationalEnvironment activateVnfStatus; - @Autowired - private InfraActiveRequestsRepository infraActiveRequestsRepository; - @Autowired - private ActivateVnfDBHelper dbHelper; @Rule public ExpectedException thrown = ExpectedException.none(); - private String requestId = "TEST_requestId"; - private String requestIdOrig = "TEST_requestIdOrig"; - private String operationalEnvironmentId = "TEST_operationalEnvironmentId"; - private CloudOrchestrationRequest request = new CloudOrchestrationRequest(); - private String workloadContext = "TEST_workloadContext"; - private String recoveryActionRetry = "RETRY"; - private String recoveryActionAbort = "ABORT"; - private String recoveryActionSkip = "SKIP"; - private String serviceModelVersionId = "TEST_serviceModelVersionId"; - private String serviceModelVersionId1 = "TEST_serviceModelVersionId1"; - private int retryCountThree = 3; - private int retryCountTwo = 2; - private int retryCountZero = 0; - private String sdcDistributionId = "TEST_distributionId"; - private String sdcDistributionId1 = "TEST_distributionId1"; - private String statusOk = Status.DISTRIBUTION_COMPLETE_OK.toString(); - private String statusError = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(); - private String statusSent = "SENT"; - - @After - public void after() throws Exception { - distributionDbRepository.deleteAll(); - serviceModelDbRepository.deleteAll(); - } + private final String requestId = "TEST_requestId"; + private final String requestIdOrig = "TEST_requestIdOrig"; + private final String operationalEnvironmentId = "TEST_operationalEnvironmentId"; + private final CloudOrchestrationRequest request = new CloudOrchestrationRequest(); + private final String workloadContext = "TEST_workloadContext"; + private final String recoveryActionRetry = "RETRY"; + private final String recoveryActionAbort = "ABORT"; + private final String recoveryActionSkip = "SKIP"; + private final String serviceModelVersionId = "TEST_serviceModelVersionId"; + private final String serviceModelVersionId1 = "TEST_serviceModelVersionId1"; + private final int retryCountThree = 3; + private final int retryCountTwo = 2; + private final int retryCountZero = 0; + private final String sdcDistributionId = "TEST_distributionId"; + private final String sdcDistributionId1 = "TEST_distributionId1"; + private final String statusOk = Status.DISTRIBUTION_COMPLETE_OK.toString(); + private final String statusError = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(); + private final String statusSent = "SENT"; + + private final ObjectMapper mapper = new ObjectMapper(); @Test public void checkOrUpdateOverallStatusTest_Ok() throws Exception { @@ -106,7 +96,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountZero); serviceModelDb.setServiceModelVersionDistrStatus(statusOk); - serviceModelDbRepository.saveAndFlush(serviceModelDb); serviceModelDb.setRequestId(requestIdOrig); serviceModelDb.setServiceModelVersionId(serviceModelVersionId1); @@ -115,27 +104,27 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountZero); serviceModelDb.setServiceModelVersionDistrStatus(statusOk); - serviceModelDbRepository.saveAndFlush(serviceModelDb); - + InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); + + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); - activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository); + activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig); // overall is success - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL")); - assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE")); - - // cleanup - infraActiveRequestsRepository.delete(requestIdOrig); } @Test - public void checkOrUpdateOverallStatusTest_Error() throws Exception { + public void checkOrUpdateOverallStatusTest_Error() throws JsonProcessingException { OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus(); serviceModelDb.setRequestId(requestIdOrig); @@ -145,29 +134,28 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountZero); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - serviceModelDbRepository.saveAndFlush(serviceModelDb); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); + + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); try { - activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository); + activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig); }catch(ApiException e){ assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. ")); assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST); assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR); } - // overall is failure - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE")); - assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED")); - - // cleanup - infraActiveRequestsRepository.delete(requestIdOrig); } @Test @@ -181,13 +169,13 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountTwo); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - serviceModelDbRepository.saveAndFlush(serviceModelDb); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); - activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig, serviceModelDbRepository); - - // do nothing, waiting for more - assertNull(infraActiveRequestsRepository.findOne(requestIdOrig)); - } + activateVnfStatus.checkOrUpdateOverallStatus(operationalEnvironmentId, requestIdOrig); + } @Test public void executionTest_Ok() throws Exception { @@ -200,7 +188,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountThree); serviceModelDb.setServiceModelVersionDistrStatus(statusSent); - serviceModelDbRepository.saveAndFlush(serviceModelDb); OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus(); distributionDb.setDistributionId(sdcDistributionId); @@ -209,9 +196,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ distributionDb.setDistributionIdStatus(statusSent); distributionDb.setServiceModelVersionId(serviceModelVersionId); distributionDb.setDistributionIdErrorReason(null); - distributionDbRepository.saveAndFlush(distributionDb); - - // prepare distribution obj Distribution distribution = new Distribution(); @@ -223,32 +207,30 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); - - activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository); - - // status ok - OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId()); - assertEquals(statusOk, distStatus.getDistributionIdStatus()); - assertEquals("", distStatus.getDistributionIdErrorReason()); - - // status ok - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId()); - assertEquals(statusOk, servStatus.getServiceModelVersionDistrStatus()); - assertEquals(new Integer(retryCountZero), servStatus.getRetryCount()); - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL")); - assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE")); - - // cleanup - infraActiveRequestsRepository.delete(requestIdOrig); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(distributionDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"RETRY\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) + .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + activateVnfStatus.execute(requestId, request); } @Test @@ -262,7 +244,10 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountThree); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - serviceModelDbRepository.saveAndFlush(serviceModelDb); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus(); distributionDb.setDistributionId(sdcDistributionId); @@ -271,7 +256,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ distributionDb.setDistributionIdStatus(statusError); distributionDb.setServiceModelVersionId(serviceModelVersionId); distributionDb.setDistributionIdErrorReason(null); - distributionDbRepository.saveAndFlush(distributionDb); + @@ -291,37 +276,34 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); - - activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository); - - // old distributionId, status error - OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId()); - assertEquals(statusError, distStatus.getDistributionIdStatus()); - assertEquals("Unable to process.", distStatus.getDistributionIdErrorReason()); - - // new distributionId, status sent - OperationalEnvDistributionStatus newDistStatus = distributionDbRepository.findOne(sdcDistributionId1); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, newDistStatus.getOperationalEnvId()); - assertEquals(statusSent, newDistStatus.getDistributionIdStatus()); - assertEquals("", newDistStatus.getDistributionIdErrorReason()); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(distributionDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) + .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_ERROR\",\"distributionIdErrorReason\":\"Unable to process.\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); - // count is less 1, status sent - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId()); - assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus()); - assertEquals(new Integer(retryCountTwo), servStatus.getRetryCount()); - - // no update - assertNull(infraActiveRequestsRepository.findOne(requestIdOrig)); + stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) + .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId1\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"SENT\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + activateVnfStatus.execute(requestId, request); } @Test - public void executionTest_ERROR_Status_And_RETRY_And_RetryZero() throws Exception { + public void executionTest_ERROR_Status_And_RETRY_And_RetryZero() throws JsonProcessingException { OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus(); serviceModelDb.setRequestId(requestIdOrig); @@ -331,7 +313,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountZero); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - serviceModelDbRepository.saveAndFlush(serviceModelDb); OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus(); distributionDb.setDistributionId(sdcDistributionId); @@ -340,7 +321,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ distributionDb.setDistributionIdStatus(statusError); distributionDb.setServiceModelVersionId(serviceModelVersionId); distributionDb.setDistributionIdErrorReason(null); - distributionDbRepository.saveAndFlush(distributionDb); @@ -359,44 +339,41 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); + + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(distributionDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); + stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"SENT\",\"recoveryAction\":\"RETRY\",\"retryCount\":2,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + try { - activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository); + activateVnfStatus.execute(requestId, request); }catch(ApiException e){ assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. ")); assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST); assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR); } - OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId()); - assertEquals(statusError, distStatus.getDistributionIdStatus()); - assertEquals(null, distStatus.getDistributionIdErrorReason()); - - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId()); - assertEquals(statusError, servStatus.getServiceModelVersionDistrStatus()); - assertEquals(new Integer(retryCountZero), servStatus.getRetryCount()); - - // Retry count is zero, no more retry. all retry failed. - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE")); - assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED")); - - // cleanup - infraActiveRequestsRepository.delete(requestIdOrig); } @Test - public void executionTest_ERROR_Status_And_RETRY_And_ErrorSdc() throws Exception { + public void executionTest_ERROR_Status_And_RETRY_And_ErrorSdc() throws JsonProcessingException { OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus(); serviceModelDb.setRequestId(requestIdOrig); @@ -406,7 +383,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountThree); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - serviceModelDbRepository.saveAndFlush(serviceModelDb); OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus(); distributionDb.setDistributionId(sdcDistributionId); @@ -415,7 +391,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ distributionDb.setDistributionIdStatus(statusError); distributionDb.setServiceModelVersionId(serviceModelVersionId); distributionDb.setDistributionIdErrorReason(null); - distributionDbRepository.saveAndFlush(distributionDb); @@ -441,41 +416,33 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(distributionDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/infraActiveRequests/")) + .withRequestBody(containing("operationalEnvId\":\"TEST_operationalEnvironmentId\"")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonMessages.toString()).withStatus(HttpStatus.SC_CONFLICT))); try { - activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository); + activateVnfStatus.execute(requestId, request); }catch(ApiException e){ assertThat(e.getMessage(), startsWith("Failure calling SDC: statusCode: ")); assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST); assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR); } - // status as-is / no changes - OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId()); - assertEquals(statusError, distStatus.getDistributionIdStatus()); - assertEquals(null, distStatus.getDistributionIdErrorReason()); - - // status as-is / no changes - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId()); - assertEquals(statusError, servStatus.getServiceModelVersionDistrStatus()); - assertEquals(new Integer(retryCountThree), servStatus.getRetryCount()); - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE")); - assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED")); - assertTrue(infraActiveRequest.getStatusMessage().contains("Undefined Error Message!")); - - // cleanup - infraActiveRequestsRepository.delete(requestIdOrig); - } @Test @@ -489,8 +456,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountThree); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - serviceModelDbRepository.saveAndFlush(serviceModelDb); - + OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus(); distributionDb.setDistributionId(sdcDistributionId); distributionDb.setRequestId(requestIdOrig); @@ -498,36 +464,48 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ distributionDb.setDistributionIdStatus(statusError); distributionDb.setServiceModelVersionId(serviceModelVersionId); distributionDb.setDistributionIdErrorReason(null); - distributionDbRepository.saveAndFlush(distributionDb); - - // prepare distribution obj + OperationalEnvDistributionStatus distributionStatus = new OperationalEnvDistributionStatus(sdcDistributionId,operationalEnvironmentId,serviceModelVersionId); + distributionStatus.setDistributionIdStatus(Status.DISTRIBUTION_COMPLETE_ERROR.name()); + Distribution distribution = new Distribution(); distribution.setStatus(Status.DISTRIBUTION_COMPLETE_ERROR); request.setDistribution(distribution); request.setDistributionId(sdcDistributionId); request.setOperationalEnvironmentId(operationalEnvironmentId); - InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); - activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(distributionDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) + .withRequestBody(equalTo("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"recoveryAction\":\"SKIP\",\"retryCount\":0,\"workloadContext\":\"TEST_workloadContext\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) + .withRequestBody(equalTo("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_OK\",\"distributionIdErrorReason\":\"\",\"createTime\":null,\"modifyTime\":null,\"handler\":{}}")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + activateVnfStatus.execute(requestId, request); - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL")); - assertTrue(infraActiveRequest.getRequestStatus().contains("COMPLETE")); - - // cleanup - infraActiveRequestsRepository.delete(requestIdOrig); - } @Test - public void executionTest_ERROR_Status_And_ABORT() throws Exception { + public void executionTest_ERROR_Status_And_ABORT() throws JsonProcessingException { OperationalEnvServiceModelStatus serviceModelDb = new OperationalEnvServiceModelStatus(); serviceModelDb.setRequestId(requestIdOrig); @@ -537,7 +515,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountThree); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - serviceModelDbRepository.saveAndFlush(serviceModelDb); OperationalEnvDistributionStatus distributionDb = new OperationalEnvDistributionStatus(); distributionDb.setDistributionId(sdcDistributionId); @@ -546,7 +523,6 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ distributionDb.setDistributionIdStatus(statusError); distributionDb.setServiceModelVersionId(serviceModelVersionId); distributionDb.setDistributionIdErrorReason(null); - distributionDbRepository.saveAndFlush(distributionDb); @@ -560,23 +536,36 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - infraActiveRequestsRepository.saveAndFlush(iar); + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceModelDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/operationalEnvDistributionStatus/"+sdcDistributionId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(distributionDb)) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestIdOrig)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(post(urlPathEqualTo("/operationalEnvDistributionStatus/")) + .withRequestBody(containing("{\"distributionId\":\"TEST_distributionId\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"requestId\":\"TEST_requestIdOrig\",\"distributionIdStatus\":\"DISTRIBUTION_COMPLETE_ERROR\"")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + stubFor(post(urlPathEqualTo("/operationalEnvServiceModelStatus/")) + .withRequestBody(containing("{\"requestId\":\"TEST_requestIdOrig\",\"operationalEnvId\":\"TEST_operationalEnvironmentId\",\"serviceModelVersionId\":\"TEST_serviceModelVersionId\",\"serviceModelVersionDistrStatus\":\"DISTRIBUTION_COMPLETE_ERROR\"")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); try { - activateVnfStatus.execute(requestId, request, distributionDbRepository, serviceModelDbRepository); - }catch(ApiException e){ - assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. ")); - assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST); - assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR); - } - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestIdOrig); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE")); - assertTrue(infraActiveRequest.getRequestStatus().contains("FAILED")); - - // cleanup - infraActiveRequestsRepository.delete(requestIdOrig); + activateVnfStatus.execute(requestId, request); + }catch(ApiException e) { + assertThat(e.getMessage(), startsWith("Overall Activation process is a Failure. ")); + assertEquals(e.getHttpResponseCode(), HttpStatus.SC_BAD_REQUEST); + assertEquals(e.getMessageID(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR); + } } @@ -617,24 +606,11 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); - JSONObject jsonResponse = activateVnfStatus.callSDClientForRetry(distributionDb, serviceModelDb, distribution, - distributionDbRepository, serviceModelDbRepository); + JSONObject jsonResponse = activateVnfStatus.callSDClientForRetry(distributionDb, serviceModelDb, distribution); assertEquals("TEST_distributionId1", jsonResponse.get("distributionId")); assertEquals("Success", jsonResponse.get("message")); assertEquals("202", jsonResponse.get("statusCode")); - // insert new record, status sent - OperationalEnvDistributionStatus distStatus = distributionDbRepository.findOne(sdcDistributionId1); - assertNotNull(distStatus); - assertEquals(operationalEnvironmentId, distStatus.getOperationalEnvId()); - assertEquals(statusSent, distStatus.getDistributionIdStatus()); - - // insert new record, status sent - OperationalEnvServiceModelStatus servStatus = serviceModelDbRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, serviceModelVersionId); - assertNotNull(servStatus); - assertEquals(statusSent, servStatus.getServiceModelVersionDistrStatus()); - assertEquals(operationalEnvironmentId, servStatus.getOperationalEnvId()); - - } + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java index d64cf6106a..585eff23c4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironmentTest.java @@ -20,16 +20,12 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - +import java.util.UUID; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpStatus; import org.junit.Test; import org.onap.so.apihandler.common.ErrorNumbers; @@ -44,19 +40,20 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters; import org.onap.so.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + public class CreateEcompOperationalEnvironmentTest extends BaseTest{ @Autowired private CreateEcompOperationalEnvironment createEcompOpEn; - @Autowired - private InfraActiveRequestsRepository infraActiveRequestsRepository; - + private final ObjectMapper mapper = new ObjectMapper(); + public CloudOrchestrationRequest getCloudOrchestrationRequest() { CloudOrchestrationRequest request = new CloudOrchestrationRequest(); RequestDetails reqDetails = new RequestDetails(); @@ -75,7 +72,7 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{ } @Test - public void testProcess() throws ApiException { + public void testProcess() throws ApiException, JsonProcessingException { stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); stubFor(post(urlPathMatching("/events/.*")) @@ -87,18 +84,20 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{ iar.setRequestScope("create"); iar.setRequestStatus("PENDING"); iar.setRequestAction("UNKNOWN"); - infraActiveRequestsRepository.saveAndFlush(iar); + stubFor(get(urlPathEqualTo("/infraActiveRequests/123")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/infraActiveRequests/")) + .withRequestBody(containing("{\"requestId\":\"123\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL, operationalEnvironmentId - operationalEnvId; Success Message: SUCCESSFULLY Created ECOMP OperationalEnvironment.\",\"progress\":100")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); createEcompOpEn.execute("123", getCloudOrchestrationRequest()); - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOneByRequestId("123"); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS")); - assertTrue(infraActiveRequest.getRequestStatus().equals("COMPLETE")); } @Test - public void testProcessException() { + public void testProcessException() throws JsonProcessingException { stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); stubFor(post(urlPathMatching("/events/.*")) @@ -108,23 +107,26 @@ public class CreateEcompOperationalEnvironmentTest extends BaseTest{ .errorInfo(errorLoggerInfo).build(); InfraActiveRequests iar = new InfraActiveRequests(); - iar.setRequestId("123"); + String uuid = UUID.randomUUID().toString(); + iar.setRequestId(uuid); iar.setOperationalEnvName("myOpEnv"); iar.setRequestScope("create"); iar.setRequestStatus("PENDING"); iar.setRequestAction("UNKNOWN"); - infraActiveRequestsRepository.saveAndFlush(iar); - + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+uuid)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/infraActiveRequests/")) + .withRequestBody(containing("{\"requestId\":\""+uuid+ "\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE, operationalEnvironmentId - operationalEnvId; Error message:")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + try { - createEcompOpEn.execute("123", getCloudOrchestrationRequest()); + createEcompOpEn.execute(uuid, getCloudOrchestrationRequest()); }catch(ApiException e){ assertThat(e, sameBeanAs((ApiException) expectedException).ignoring("cause")); } - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOneByRequestId("123"); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("FAILURE")); - assertTrue(infraActiveRequest.getRequestStatus().equals("FAILED")); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java index 8fe40f31a4..809e39c772 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java @@ -20,21 +20,15 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import java.io.File; import java.nio.file.Files; import java.util.List; import java.util.UUID; +import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; @@ -46,11 +40,13 @@ import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.client.grm.beans.Property; import org.onap.so.client.grm.beans.ServiceEndPointList; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.databind.ObjectMapper; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + public class CreateVnfOperationalEnvironmentTest extends BaseTest{ @@ -59,9 +55,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{ @Autowired private CreateVnfOperationalEnvironment createVnfOpEnv; - @Autowired - private InfraActiveRequestsRepository infraActiveRequestsRepository; - + @Before public void testSetUp() throws Exception { ObjectMapper mapper = new ObjectMapper(); @@ -70,7 +64,6 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{ String jsonServiceEndpoints = getFileContentsAsString("__files/vnfoperenv/endpoints.json"); serviceEndpoints = mapper.readValue(jsonServiceEndpoints, ServiceEndPointList.class); } - @Test public void testGetEcompManagingEnvironmentId() throws Exception { createVnfOpEnv.setRequest(request); @@ -84,7 +77,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{ } @Test - public void testGetEnvironmentName() throws Exception { + public void testGetEnvironmentName() { createVnfOpEnv.setRequest(request); List<Property> props = serviceEndpoints.getServiceEndPointList().get(0).getProperties(); assertEquals("DEV", createVnfOpEnv.getEnvironmentName(props)); @@ -120,7 +113,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{ } @Test - public void testExecute() throws ApiException{ + public void testExecute() throws ApiException, JsonProcessingException { stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); stubFor(post(urlPathMatching("/GRMLWPService/v1/serviceEndPoint/findRunning")) @@ -136,11 +129,16 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{ iar.setRequestScope("create"); iar.setRequestStatus("PENDING"); iar.setRequestAction("UNKNOWN"); - infraActiveRequestsRepository.saveAndFlush(iar); + ObjectMapper mapper = new ObjectMapper(); + stubFor(post(urlPathEqualTo("/infraActiveRequests/")) + .withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); createVnfOpEnv.execute(requestId, request); - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS")); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java index a9be10c3f4..7c24050775 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironmentTest.java @@ -20,19 +20,14 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.HttpStatus; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -42,9 +37,11 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.client.aai.AAIVersion; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.springframework.beans.factory.annotation.Autowired; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{ @Rule @@ -52,13 +49,20 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{ @Autowired private DeactivateVnfOperationalEnvironment deactivate; - @Autowired - private InfraActiveRequestsRepository infraActiveRequestsRepository; - + private CloudOrchestrationRequest request = new CloudOrchestrationRequest(); private String operationalEnvironmentId = "ff3514e3-5a33-55df-13ab-12abad84e7ff"; private String requestId = "ff3514e3-5a33-55df-13ab-12abad84e7fe"; + private ObjectMapper mapper = new ObjectMapper(); + + @Before + public void init(){ + stubFor(post(urlPathEqualTo("/infraActiveRequests/")) + .withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"COMPLETE\",\"statusMessage\":\"SUCCESSFUL")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + } @Test public void testDeactivateOperationalEnvironment() throws Exception { request.setOperationalEnvironmentId(operationalEnvironmentId); @@ -79,14 +83,11 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{ iar.setRequestScope("create"); iar.setRequestStatus("PENDING"); iar.setRequestAction("UNKNOWN"); - infraActiveRequestsRepository.saveAndFlush(iar); - + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); deactivate.execute(requestId, request); - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESSFUL")); - } @Test @@ -110,8 +111,15 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{ iar.setRequestScope("create"); iar.setRequestStatus("PENDING"); iar.setRequestAction("UNKNOWN"); - infraActiveRequestsRepository.saveAndFlush(iar); - + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/infraActiveRequests/")) + .withRequestBody(containing("{\"requestId\":\""+ requestId+"\",\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"FAILURE")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + deactivate.execute(requestId, request); } @@ -131,13 +139,12 @@ public class DeactivateVnfOperationalEnvironmentTest extends BaseTest{ iar.setRequestScope("create"); iar.setRequestStatus("PENDING"); iar.setRequestAction("UNKNOWN"); - infraActiveRequestsRepository.saveAndFlush(iar); + stubFor(get(urlPathEqualTo("/infraActiveRequests/"+requestId)) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(iar)) + .withStatus(HttpStatus.SC_OK))); deactivate.execute(requestId, request); - - InfraActiveRequests infraActiveRequest = infraActiveRequestsRepository.findOne(requestId); - assertNotNull(infraActiveRequest); - assertTrue(infraActiveRequest.getStatusMessage().contains("SUCCESS")); } @Test diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json index 47b2e309d3..18d03f1472 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json @@ -5,7 +5,7 @@ }, "requestInfo": { "source": "VID", - "requestorId": "az2016" + "requestorId": "xxxxxx" } } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/VnfRecreateCloudConfig.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/VnfRecreateCloudConfig.json new file mode 100644 index 0000000000..5d64500e10 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/VnfRecreateCloudConfig.json @@ -0,0 +1,21 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vnf", + "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"254583ad-b38c-498b-bdbd-b8de5e07541b", + "modelName":"vSAMP12", + "modelVersion":"2.0", + "modelCustomizationName":"vSAMP12 1", + "modelCustomizationId":"c539433a-84a6-4082-a12e-5c9b00c3b960" + }, + "requestInfo":{ + "source":"source", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "rebuildVolumeGroups":false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelInvariantId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelInvariantId.json new file mode 100644 index 0000000000..15ec1a006f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelInvariantId.json @@ -0,0 +1,24 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vnf", + "modelVersionId":"254583ad-b38c-498b-bdbd-b8de5e07541b", + "modelName":"vSAMP12", + "modelVersion":"2.0", + "modelCustomizationName":"vSAMP12 1", + "modelCustomizationId":"c539433a-84a6-4082-a12e-5c9b00c3b960" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "source":"source", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "rebuildVolumeGroups":false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelName.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelName.json new file mode 100644 index 0000000000..caa7458f9f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelName.json @@ -0,0 +1,24 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vnf", + "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"254583ad-b38c-498b-bdbd-b8de5e07541b", + "modelVersion":"2.0", + "modelCustomizationName":"vSAMP12 1", + "modelCustomizationId":"c539433a-84a6-4082-a12e-5c9b00c3b960" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "source":"source", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "rebuildVolumeGroups":false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelVersion.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelVersion.json new file mode 100644 index 0000000000..5049be6bca --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelVersion.json @@ -0,0 +1,24 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vnf", + "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"254583ad-b38c-498b-bdbd-b8de5e07541b", + "modelName":"vSAMP12", + "modelCustomizationName":"vSAMP12 1", + "modelCustomizationId":"c539433a-84a6-4082-a12e-5c9b00c3b960" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "source":"source", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "rebuildVolumeGroups":false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelVersionId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelVersionId.json new file mode 100644 index 0000000000..99ee762da1 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateModelVersionId.json @@ -0,0 +1,24 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vnf", + "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelName":"vSAMP12", + "modelVersion":"2.0", + "modelCustomizationName":"vSAMP12 1", + "modelCustomizationId":"c539433a-84a6-4082-a12e-5c9b00c3b960" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "source":"source", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "rebuildVolumeGroups":false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateNoModelCustomizationId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateNoModelCustomizationId.json new file mode 100644 index 0000000000..d98a9bc30b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/VnfRecreateNoModelCustomizationId.json @@ -0,0 +1,23 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vnf", + "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"254583ad-b38c-498b-bdbd-b8de5e07541b", + "modelName":"vSAMP12", + "modelVersion":"2.0" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "source":"source", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "rebuildVolumeGroups":false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json new file mode 100644 index 0000000000..561ed0d31f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json @@ -0,0 +1,189 @@ +{ + "requestList": [ + { + "request": { + "requestId": "001619d2-a297-4a4b-a9f5-e2823c88458f", + "startTime": "Fri, 01 Jul 2016 04:41:42 GMT", + "requestScope": "vfModule", + "requestType": "createInstance", + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "test::base::module-0" + }, + "requestInfo": { + "source": "VID", + "suppressRollback": false + }, + "cloudConfiguration": { + "tenantId": "6accefef3cb442ff9e644d589fb04107", + "lcpCloudRegionId": "n6" + }, + "instanceName": [] + }, + "instanceReferences": { + "vnfInstanceName": "test-vscp", + "vfModuleInstanceName": "MODULENAME1" + }, + "requestStatus": { + "requestState": "COMPLETE", + "statusMessage": "COMPLETED", + "percentProgress": 100, + "finishTime": "Tue, 02 May 2017 06:33:34 GMT" + } + } + }, + { + "request": { + "requestId": "00032ab7-3fb3-42e5-965d-8ea592502017", + "startTime": "Thu, 22 Dec 2016 08:29:54 GMT", + "requestScope": "vfModule", + "requestType": "deleteInstance", + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "test::base::module-0" + }, + "requestInfo": { + "source": "VID", + "suppressRollback": false + }, + "cloudConfiguration": { + "tenantId": "6accefef3cb442ff9e644d589fb04107", + "lcpCloudRegionId": "n6" + }, + "instanceName": [] + }, + "instanceReferences": { + "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc", + "vnfInstanceId": "b92f60c8-8de3-46c1-8dc1-e4390ac2b005", + "vfModuleInstanceId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992" + }, + "requestStatus": { + "requestState": "COMPLETE", + "statusMessage": "Vf Module has been deleted successfully.", + "percentProgress": 100, + "finishTime": "Thu, 22 Dec 2016 08:30:28 GMT" + } + } + }, + { + "request": { + "requestId": "00032ab7-na18-42e5-965d-8ea592502018", + "startTime": "Thu, 22 Dec 2016 08:29:54 GMT", + "requestScope": "vfModule", + "requestType": "deleteInstance", + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "test::base::module-0" + }, + "requestInfo": { + "source": "VID", + "suppressRollback": false + }, + "cloudConfiguration": { + "tenantId": "6accefef3cb442ff9e644d589fb04107", + "lcpCloudRegionId": "n6" + }, + "instanceName": [] + }, + "instanceReferences": { + "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc", + "vnfInstanceId": "b92f60c8-8de3-46c1-8dc1-e4390ac2b005", + "vfModuleInstanceId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992" + }, + "requestStatus": { + "requestState": "PENDING", + "statusMessage": "Vf Module deletion pending.", + "percentProgress": 0, + "finishTime": "Thu, 22 Dec 2016 08:30:28 GMT" + } + } + }, + { + "request": { + "requestId": "5ffbabd6-b793-4377-a1ab-082670fbc7ac", + "startTime": "Thu, 22 Dec 2016 08:29:54 GMT", + "requestScope": "vfModule", + "requestType": "deleteInstance", + "requestDetails": { + "modelInfo": { + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelType": "vfModule", + "modelId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelName": "test::base::module-0", + "modelVersion": "2", + "modelCustomizationUuid": "cb82ffd8-252a-11e7-93ae-92361f002671", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671", + "modelUuid": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantUuid": "78ca26d0-246d-11e7-93ae-92361f002671" + }, + "requestInfo": { + "source": "VID", + "instanceName": "MSO-DEV-VF-1806BB-v10-base-it2-1", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "76fa8849-4c98-473f-b431-2590b192a653", + "modelInfo": { + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelType": "service", + "modelId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelName": "Infra_v10_Service", + "modelVersion": "1.0", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelUuid": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantUuid": "9647dfc4-2083-11e7-93ae-92361f002671" + } + } + }, + { + "relatedInstance": { + "instanceId": "d57970e1-5075-48a5-ac5e-75f2d6e10f4c", + "modelInfo": { + "modelCustomizationName": "v10 1", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelType": "vnf", + "modelId": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelName": "v10", + "modelVersion": "1.0", + "modelCustomizationUuid": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelVersionId": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelUuid": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInvariantUuid": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelInstanceName": "v10 1" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8", + "lcpCloudRegionId": "n6" + }, + "requestParameters": { + "userParams": [], + "usePreload": true + }, + "instanceName": [] + }, + "instanceReferences": { + "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc", + "vnfInstanceId": "b92f60c8-8de3-46c1-8dc1-e4390ac2b005", + "vfModuleInstanceId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992" + }, + "requestStatus": { + "requestState": "UNLOCKED", + "statusMessage": "Vf Module deletion pending.", + "percentProgress": 0, + "finishTime": "Thu, 22 Dec 2016 08:30:28 GMT" + } + } + } + ] +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json index 124513de0d..1b1530d3a6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json @@ -1 +1,298 @@ -{"requestList":[{"request":{"requestId":"00032ab7-3fb3-42e5-965d-8ea592502017","requestScope":"vfModule","requestType":"deleteInstance","requestDetails":{"modelInfo":{"modelType":"vfModule","modelName":"test::base::module-0"},"requestInfo":{"source":"VID","suppressRollback":false},"cloudConfiguration":{"tenantId":"6accefef3cb442ff9e644d589fb04107","lcpCloudRegionId":"n6"}},"instanceReferences":{"serviceInstanceId":"e3b5744d-2ad1-4cdd-8390-c999a38829bc","vnfInstanceId":"b92f60c8-8de3-46c1-8dc1-e4390ac2b005","vfModuleInstanceId":"c7d527b1-7a91-49fd-b97d-1c8c0f4a7992"},"requestStatus":{"requestState":"COMPLETE","statusMessage":"Vf Module has been deleted successfully.","percentProgress":100}}},{"request":{"requestId":"00032ab7-na18-42e5-965d-8ea592502018","requestScope":"vfModule","requestType":"deleteInstance","requestDetails":{"modelInfo":{"modelType":"vfModule","modelName":"test::base::module-0"},"requestInfo":{"source":"VID","suppressRollback":false},"cloudConfiguration":{"tenantId":"6accefef3cb442ff9e644d589fb04107","lcpCloudRegionId":"n6"}},"instanceReferences":{"serviceInstanceId":"e3b5744d-2ad1-4cdd-8390-c999a38829bc","vnfInstanceId":"b92f60c8-8de3-46c1-8dc1-e4390ac2b005","vfModuleInstanceId":"c7d527b1-7a91-49fd-b97d-1c8c0f4a7992"},"requestStatus":{"requestState":"PENDING","statusMessage":"Vf Module deletion pending.","percentProgress":0}}},{"request":{"requestId":"00093944-bf16-4373-ab9a-3adfe730ff2d","requestScope":"service","requestType":"createInstance","requestDetails":{"modelInfo":{"modelInvariantId":"9647dfc4-2083-11e7-93ae-92361f002671","modelType":"service","modelName":"MSOTADevInfra_v10_Service","modelVersion":"1.0","modelVersionId":"5df8b6de-2083-11e7-93ae-92361f002671"},"requestInfo":{"source":"VID","instanceName":"MSODEV_1707_SI_v10_011-4","suppressRollback":false,"requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"n6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true}},"instanceReferences":{},"requestStatus":{"requestState":"FAILED","statusMessage":"Error: Locked instance - This service (MSODEV_1707_SI_v10_011-4) already has a request being worked with a status of IN_PROGRESS (RequestId - 278e83b1-4f9f-450e-9e7d-3700a6ed22f4). The existing request must finish or be cleaned up before proceeding.","percentProgress":100}}},{"request":{"requestId":"001619d2-a297-4a4b-a9f5-e2823c88458f","requestScope":"vfModule","requestType":"createInstance","instanceReferences":{},"requestStatus":{"requestState":"COMPLETE","statusMessage":"COMPLETED","percentProgress":100}}},{"request":{"requestId":"00164b9e-784d-48a8-8973-bbad6ef818ed","requestScope":"service","requestType":"createInstance","requestDetails":{"modelInfo":{"modelInvariantId":"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f","modelType":"service","modelName":"MSO Test Network","modelVersion":"1.0","modelVersionId":"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e"},"requestInfo":{"source":"VID","instanceName":"DEV-n6-3100-0927-1","suppressRollback":false,"requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"n6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true}},"instanceReferences":{"serviceInstanceId":"b2f59173-b7e5-4e0f-8440-232fd601b865"},"requestStatus":{"requestState":"COMPLETE","statusMessage":"Service Instance was created successfully.","percentProgress":100}}},{"request":{"requestId":"00173cc9-5ce2-4673-a810-f87fefb2829e","requestScope":"service","requestType":"createInstance","requestDetails":{"modelInfo":{"modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51","modelType":"service","modelName":"ConstraintsSrvcVID","modelVersion":"2.0","modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656"},"requestInfo":{"productFamilyId":"LRSI-OSPF","source":"VID","suppressRollback":false,"requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"},"cloudConfiguration":{"tenantId":"a259ae7b7c3f493cb3d91f95a7c18149","lcpCloudRegionId":"mtn16"},"requestParameters":{"subscriptionServiceType":"Mobility","userParams":[{"name":"neutronport6_name","value":"8"},{"name":"neutronnet5_network_name","value":"8"},{"name":"contrailv2vlansubinterface3_name","value":"false"}]}},"instanceReferences":{},"requestStatus":{"requestState":"FAILED","statusMessage":"Error parsing request. No valid instanceName is specified","percentProgress":100}}},{"request":{"requestId":"0017f68c-eb2d-45bb-b7c7-ec31b37dc349","requestScope":"configuration","requestType":"activateInstance","requestDetails":{"modelInfo":{"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671"},"requestInfo":{"source":"VID","suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a"}}}],"cloudConfiguration":{"lcpCloudRegionId":"n6"},"requestParameters":{"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true}},"instanceReferences":{"serviceInstanceId":"9e15a443-af65-4f05-9000-47ae495e937d"},"requestStatus":{"requestState":"UNLOCKED","percentProgress":20}}},{"request": {"requestId":"0017f68c-eb2d-45bb-b7c7-ec31b37dc350","requestScope":"service","requestType":"createInstance","requestStatus": {"requestState": "IN_PROGRESS", "statusMessage": "Error parsing request.\n\tNo valid instanceName is specified"}}}]}
\ No newline at end of file +{ + "requestList":[ + { + "request":{ + "requestId":"00032ab7-3fb3-42e5-965d-8ea592502017", + "requestScope":"vfModule", + "requestType":"deleteInstance", + "requestDetails":{ + "modelInfo":{ + "modelType":"vfModule", + "modelName":"test::base::module-0" + }, + "requestInfo":{ + "source":"VID", + "suppressRollback":false + }, + "cloudConfiguration":{ + "tenantId":"6accefef3cb442ff9e644d589fb04107", + "lcpCloudRegionId":"n6" + } + }, + "instanceReferences":{ + "serviceInstanceId":"e3b5744d-2ad1-4cdd-8390-c999a38829bc", + "vnfInstanceId":"b92f60c8-8de3-46c1-8dc1-e4390ac2b005", + "vfModuleInstanceId":"c7d527b1-7a91-49fd-b97d-1c8c0f4a7992" + }, + "requestStatus":{ + "requestState":"COMPLETE", + "statusMessage":"Vf Module has been deleted successfully.", + "percentProgress":100 + } + } + }, + { + "request":{ + "requestId":"00032ab7-na18-42e5-965d-8ea592502018", + "requestScope":"vfModule", + "requestType":"deleteInstance", + "requestDetails":{ + "modelInfo":{ + "modelType":"vfModule", + "modelName":"test::base::module-0" + }, + "requestInfo":{ + "source":"VID", + "suppressRollback":false + }, + "cloudConfiguration":{ + "tenantId":"6accefef3cb442ff9e644d589fb04107", + "lcpCloudRegionId":"n6" + } + }, + "instanceReferences":{ + "serviceInstanceId":"e3b5744d-2ad1-4cdd-8390-c999a38829bc", + "vnfInstanceId":"b92f60c8-8de3-46c1-8dc1-e4390ac2b005", + "vfModuleInstanceId":"c7d527b1-7a91-49fd-b97d-1c8c0f4a7992" + }, + "requestStatus":{ + "requestState":"PENDING", + "statusMessage":"Vf Module deletion pending.", + "percentProgress":0 + } + } + }, + { + "request":{ + "requestId":"00093944-bf16-4373-ab9a-3adfe730ff2d", + "requestScope":"service", + "requestType":"createInstance", + "requestDetails":{ + "modelInfo":{ + "modelInvariantId":"9647dfc4-2083-11e7-93ae-92361f002671", + "modelType":"service", + "modelName":"MSOTADevInfra_v10_Service", + "modelVersion":"1.0", + "modelVersionId":"5df8b6de-2083-11e7-93ae-92361f002671" + }, + "requestInfo":{ + "source":"VID", + "instanceName":"MSODEV_1707_SI_v10_011-4", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "subscriberInfo":{ + "globalSubscriberId":"MSO_1610_dev", + "subscriberName":"MSO_1610_dev" + }, + "cloudConfiguration":{ + "tenantId":"19123c2924c648eb8e42a3c1f14b7682", + "lcpCloudRegionId":"n6" + }, + "requestParameters":{ + "subscriptionServiceType":"MSO-dev-service-type", + "userParams":[ + { + "name":"someUserParam", + "value":"someValue" + } + ], + "aLaCarte":true, + "autoBuildVfModules":false, + "cascadeDelete":false, + "usePreload":true + } + }, + "instanceReferences":{ + + }, + "requestStatus":{ + "requestState":"FAILED", + "statusMessage":"Error: Locked instance - This service (MSODEV_1707_SI_v10_011-4) already has a request being worked with a status of IN_PROGRESS (RequestId - 278e83b1-4f9f-450e-9e7d-3700a6ed22f4). The existing request must finish or be cleaned up before proceeding.", + "percentProgress":100 + } + } + }, + { + "request":{ + "requestId":"001619d2-a297-4a4b-a9f5-e2823c88458f", + "requestScope":"vfModule", + "requestType":"createInstance", + "instanceReferences":{ + + }, + "requestStatus":{ + "requestState":"COMPLETE", + "statusMessage":"COMPLETED", + "percentProgress":100 + } + } + }, + { + "request":{ + "requestId":"00164b9e-784d-48a8-8973-bbad6ef818ed", + "requestScope":"service", + "requestType":"createInstance", + "requestDetails":{ + "modelInfo":{ + "modelInvariantId":"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", + "modelType":"service", + "modelName":"MSO Test Network", + "modelVersion":"1.0", + "modelVersionId":"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e" + }, + "requestInfo":{ + "source":"VID", + "instanceName":"DEV-n6-3100-0927-1", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "subscriberInfo":{ + "globalSubscriberId":"MSO_1610_dev", + "subscriberName":"MSO_1610_dev" + }, + "cloudConfiguration":{ + "tenantId":"19123c2924c648eb8e42a3c1f14b7682", + "lcpCloudRegionId":"n6" + }, + "requestParameters":{ + "subscriptionServiceType":"MSO-dev-service-type", + "userParams":[ + { + "name":"someUserParam", + "value":"someValue" + } + ], + "aLaCarte":true, + "autoBuildVfModules":false, + "cascadeDelete":false, + "usePreload":true + } + }, + "instanceReferences":{ + "serviceInstanceId":"b2f59173-b7e5-4e0f-8440-232fd601b865" + }, + "requestStatus":{ + "requestState":"COMPLETE", + "statusMessage":"Service Instance was created successfully.", + "percentProgress":100 + } + } + }, + { + "request":{ + "requestId":"00173cc9-5ce2-4673-a810-f87fefb2829e", + "requestScope":"service", + "requestType":"createInstance", + "requestDetails":{ + "modelInfo":{ + "modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51", + "modelType":"service", + "modelName":"ConstraintsSrvcVID", + "modelVersion":"2.0", + "modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656" + }, + "requestInfo":{ + "productFamilyId":"LRSI-OSPF", + "source":"VID", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "subscriberInfo":{ + "globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration":{ + "tenantId":"a259ae7b7c3f493cb3d91f95a7c18149", + "lcpCloudRegionId":"mtn16" + }, + "requestParameters":{ + "subscriptionServiceType":"Mobility", + "userParams":[ + { + "name":"neutronport6_name", + "value":"8" + }, + { + "name":"neutronnet5_network_name", + "value":"8" + }, + { + "name":"contrailv2vlansubinterface3_name", + "value":"false" + } + ] + } + }, + "instanceReferences":{ + + }, + "requestStatus":{ + "requestState":"FAILED", + "statusMessage":"Error parsing request. No valid instanceName is specified", + "percentProgress":100 + } + } + }, + { + "request":{ + "requestId":"0017f68c-eb2d-45bb-b7c7-ec31b37dc349", + "requestScope":"configuration", + "requestType":"activateInstance", + "requestDetails":{ + "modelInfo":{ + "modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39", + "modelType":"configuration", + "modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455", + "modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671" + }, + "requestInfo":{ + "source":"VID", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "relatedInstanceList":[ + { + "relatedInstance":{ + "instanceId":"9e15a443-af65-4f05-9000-47ae495e937d", + "modelInfo":{ + "modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a", + "modelType":"service", + "modelName":"MSOTADevInfra_Configuration_Service", + "modelVersion":"1.0", + "modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a" + } + } + } + ], + "cloudConfiguration":{ + "lcpCloudRegionId":"n6" + }, + "requestParameters":{ + "aLaCarte":false, + "autoBuildVfModules":false, + "cascadeDelete":false, + "usePreload":true + } + }, + "instanceReferences":{ + "serviceInstanceId":"9e15a443-af65-4f05-9000-47ae495e937d" + }, + "requestStatus":{ + "requestState":"UNLOCKED", + "percentProgress":20 + } + } + }, + { + "request":{ + "requestId":"0017f68c-eb2d-45bb-b7c7-ec31b37dc350", + "requestScope":"service", + "requestType":"createInstance", + "requestStatus":{ + "requestState":"IN_PROGRESS", + "statusMessage":"Error parsing request.\n\tNo valid instanceName is specified" + } + } + } + ] +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json new file mode 100644 index 0000000000..79caa33419 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/RequestProcessingData.json @@ -0,0 +1,24 @@ +[ + { + "id": 1, + "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", + "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714", + "name": "requestAction", + "value": "assign", + "tag": "pincFabricConfigRequest" + },{ + "id": 2, + "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", + "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714", + "name": "pincFabricId", + "value": "testId", + "tag": "pincFabricConfigRequest" + },{ + "id": 3, + "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", + "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca715", + "name": "requestAction", + "value": "unassign", + "tag": "pincFabricConfig" + } +]
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json new file mode 100644 index 0000000000..af28007900 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getRequestProcessingData.json @@ -0,0 +1,8 @@ +{ + "id": 1, + "soRequestId": "00032ab7-na18-42e5-965d-8ea592502018", + "groupingId": "7d2e8c07-4d10-456d-bddc-37abf38ca714", + "name": "requestAction", + "value": "assign", + "tag": "pincFabricConfigRequest" +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeactivateAndCloudDeleteVfModule.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeactivateAndCloudDeleteVfModule.json index 58db9d4f76..b721583d29 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeactivateAndCloudDeleteVfModule.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeactivateAndCloudDeleteVfModule.json @@ -1,7 +1,9 @@ { "requestDetails": { "modelInfo": { - "modelType": "vfModule" + "modelType": "vfModule", + "modelInvariantId":"78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2" }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", @@ -9,7 +11,7 @@ }, "requestInfo": { "source": "VID", - "requestorId": "az2016" + "requestorId": "xxxxxx" } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeleteVfModule.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeleteVfModule.json index d612dd9704..34c28d3f7c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeleteVfModule.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeleteVfModule.json @@ -16,8 +16,8 @@ }, "modelInfo":{ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7968", - "modelVersion":"1", - "modelVersionId":"test", + "modelVersion":"2", + "modelVersionId":"78ca26d0-246d-11e7-93ae-92361f002671", "modelType":"vfModule", "modelName":"serviceModel", "modelCustomizationId": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7" diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeleteVfModuleNoModelInvariantId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeleteVfModuleNoModelInvariantId.json new file mode 100644 index 0000000000..64c60b871e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/DeleteVfModuleNoModelInvariantId.json @@ -0,0 +1,23 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vfModule", + "modelName":"InframsoVsamp1214..vSAMP12_base..module-0" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mtn6", + "tenantId":"0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo":{ + "instanceName":"bdb-vSAMP12_14_1.0-VF-Base-1810-est01-VNF_API-10201", + "source":"VID", + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "testApi":"VNF_API", + "userParams":[ + + ] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json index 993310d48f..a37fe050eb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json @@ -1,45 +1,18 @@ { - "requestDetails": { - "cloudConfiguration": { - "lcpCloudRegionId": "mtn6", - "tenantId": "19123c2924c648eb8e42a3c1f14b7682" - }, - "modelInfo": { - "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", - "modelName": "TestNetworkType", - "modelType": "network", - "modelVersion": "2.0", - "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", - "modelCustomizationId": "3bdbb104-476c-483e-9f8b-c095b3d308ac" - }, - "requestInfo": { - "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "requestorId": "xxxxxx", - "source": "VID", - "suppressRollback": false, - "instanceName": "tested" - }, - "requestParameters": { - "aLaCarte" : true, - "autoBuildVfModules": false, - "subscriptionServiceType": "MSO-dev-service-type", - "userParams": [ - { - "name": "aic_zone", - "value": "mtn6" - } - ] - }, - "subscriberInfo": { - "globalSubscriberId": "MSO_1610_dev", - "subscriberName": "MSO_1610_dev" - }, - "project": { - "projectName": "projectName" - }, - "owningEntity": { - "owningEntityId": "oeId", - "owningEntityName": "oeName" - } - } + "requestDetails":{ + "modelInfo":{ + "modelType":"network" + }, + "requestInfo":{ + "source":"VID", + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "testApi":"VNF_API" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"cloudRegionId", + "tenantId":"821553e85fd2461ab205bcd45cc3eeda" + } + } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstanceNoReqParams.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstanceNoReqParams.json index cfd19ff0ca..6f4d0f9070 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstanceNoReqParams.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstanceNoReqParams.json @@ -1,7 +1,8 @@ { "requestDetails": { "modelInfo": { - "modelType": "network" + "modelType": "network", + "modelName": "CONTRAIL30_GNDIRECT" }, "cloudConfiguration": { "lcpCloudRegionId": "mtn6", diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModule.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModule.json index 967250a0da..d8de481633 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModule.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ReplaceVfModule.json @@ -16,8 +16,8 @@ }, "modelInfo":{ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7968", - "modelVersion":"1", - "modelVersionId":"test", + "modelVersion":"2", + "modelVersionId":"78ca26d0-246d-11e7-93ae-92361f002671", "modelType":"vfModule", "modelName":"serviceModel", "modelCustomizationId": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7" diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json index ba5a8a92e5..809e8bcc1c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json @@ -4,7 +4,7 @@ "modelType":"vfModule", "modelInvariantId":"ff5256d2-5a33-55df-13ab-12abad84e7ff", "modelVersionId":"fe6478e5-ea33-3346-ac12-ab121484a3fe", - "modelCustomizationId":"cb82ffd8-252a-11e7-93ae-92361f002672", + "modelCustomizationId":"cb82ffd8-252a-11e7-93ae-92361f002671", "modelName":"vSAMP12..base..module-0", "modelVersion":"1" }, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceActivate.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceActivate.json index d675c79f06..90d5cebb6b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceActivate.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceActivate.json @@ -19,7 +19,7 @@ "modelInfo":{ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965", "modelVersion": "1.0", - "modelVersionId":"1", + "modelVersionId":"d88da85c-d9e8-4f73-b837-3a72a431622b", "modelType":"service", "modelName":"serviceModel" }, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVfModule.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVfModule.json index c3039a59f0..147754657f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVfModule.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVfModule.json @@ -17,10 +17,10 @@ "modelInfo":{ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7968", "modelVersion":"1", - "modelVersionId":"test", + "modelVersionId":"20c4431c-246d-11e7-93ae-92361f002671", "modelType":"vfModule", "modelName":"serviceModel", - "modelCustomizationId": "b4ea86b4-253f-11e7-93ae-92361f002671" + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" }, "subscriberInfo": { "globalSubscriberId": "MSO_1610_dev", diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVnf.json index ec2916f0da..723a709927 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVnf.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/UpdateVnf.json @@ -7,7 +7,7 @@ "modelName": "vSAMP12..base..module-0", "modelVersion": "1", "modelVersionId": "1", - "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671" + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002674" }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfRecreate.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfRecreate.json new file mode 100644 index 0000000000..7a76c6bfee --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VnfRecreate.json @@ -0,0 +1,25 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vnf", + "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"254583ad-b38c-498b-bdbd-b8de5e07541b", + "modelName":"vSAMP12", + "modelVersion":"2.0", + "modelCustomizationName":"vSAMP12 1", + "modelCustomizationId":"c539433a-84a6-4082-a12e-5c9b00c3b960" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "source":"source", + "suppressRollback":false, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "rebuildVolumeGroups":false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/TestBadResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/TestBadResponse.json new file mode 100644 index 0000000000..231bb679f9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/TestBadResponse.json @@ -0,0 +1,7 @@ +{ + "response": "{\"test\"}}", + "messageCode": "1", + "message": "Success", + "processInstanceID": "1", + "variables": "null" +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/UnauthorizedResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/UnauthorizedResponse.json new file mode 100644 index 0000000000..d6273bbcfd --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/UnauthorizedResponse.json @@ -0,0 +1,7 @@ +{ + "timestamp": 1533899092159, + "status": 401, + "error": "Unauthorized", + "message": "Bad credentials", + "path": "/onap/so/infra/serviceInstances/v7" +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UpdateVnfRecipe_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UpdateVnfRecipe_Response.json new file mode 100644 index 0000000000..425ae1a81a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UpdateVnfRecipe_Response.json @@ -0,0 +1,20 @@ +{ + "id": 10008, + "nfRole": "GR-API-DEFAULT", + "paramXsd": null, + "vfModuleId": null, + "action": "updateInstance", + "description": "Gr api recipe to update vnf", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "serviceType": null, + "created": "2018-08-20T08:10:21.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/10008" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/10008" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkRecipeVNF_API_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkRecipeVNF_API_Response.json new file mode 100644 index 0000000000..5a3e875a76 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkRecipeVNF_API_Response.json @@ -0,0 +1,19 @@ +{ + "id": 16, + "action": "createInstance", + "description": "Vnf api recipe to create network", + "orchestrationUri": "/mso/async/services/CreateNetworkInstance", + "recipeTimeout": 180, + "serviceType": null, + "modelName": "VNF-API-DEFAULT", + "paramXsd": null, + "created": "2017-10-05T13:22:03.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/networkRecipe/16" + }, + "networkRecipe": { + "href": "http://localhost:8090/networkRecipe/16" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkRecipe_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkRecipe_Response.json new file mode 100644 index 0000000000..94311cc886 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkRecipe_Response.json @@ -0,0 +1,19 @@ +{ + "id": 180, + "action": "deleteInstance", + "description": "Gr api recipe to delete network", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "serviceType": null, + "modelName": "GR-API-DEFAULT", + "paramXsd": null, + "created": "2018-08-23T05:09:35.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/networkRecipe/180" + }, + "networkRecipe": { + "href": "http://localhost:8090/networkRecipe/180" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkResourceCustomization_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkResourceCustomization_Response.json new file mode 100644 index 0000000000..ec35e581ae --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkResourceCustomization_Response.json @@ -0,0 +1,21 @@ +{ + "modelCustomizationUUID": "3bdbb104-476c-483e-9f8b-c095b3d308ac", + "modelInstanceName": "CONTRAIL30_GNDIRECT 9", + "created": "2017-04-19T08:58:32.000+0000", + "networkTechnology": "", + "networkType": "", + "networkScope": "", + "networkRole": "", + "_links": { + "self": { + "href": "http://localhost:8090/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac" + }, + "networkResourceCustomization": { + "href": "http://localhost:8090/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac{?projection}", + "templated": true + }, + "networkResource": { + "href": "http://localhost:8090/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkResource_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkResource_Response.json new file mode 100644 index 0000000000..f2579f147d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/networkResource_Response.json @@ -0,0 +1,34 @@ +{ + "modelUUID": "10b36f65-f4e6-4be6-ae49-9596dc1c47fc", + "orchestrationMode": "HEAT", + "description": "Contrail 30 GNDIRECT NW", + "neutronNetworkType": "BASIC", + "aicVersionMin": "3.0", + "aicVersionMax": "", + "modelName": "CONTRAIL30_GNDIRECT", + "modelInvariantUUID": "ce4ff476-9641-4e60-b4d5-b4abbec1271d", + "modelVersion": "1.0", + "toscaNodeType": "", + "category": null, + "subCategory": null, + "created": "2017-01-17T15:05:05.000+0000", + "handler": {}, + "hibernateLazyInitializer": {}, + "_links": { + "self": { + "href": "http://localhost:8090/networkResources/10b36f65-f4e6-4be6-ae49-9596dc1c47fc" + }, + "networkResource": { + "href": "http://localhost:8090/networkResources/10b36f65-f4e6-4be6-ae49-9596dc1c47fc" + }, + "collectionNetworkResourceCustomization": { + "href": "http://localhost:8090/networkResources/10b36f65-f4e6-4be6-ae49-9596dc1c47fc/collectionNetworkResourceCustomization" + }, + "heatTemplate": { + "href": "http://localhost:8090/networkResources/10b36f65-f4e6-4be6-ae49-9596dc1c47fc/heatTemplate" + }, + "networkResourceCustomization": { + "href": "http://localhost:8090/networkResources/10b36f65-f4e6-4be6-ae49-9596dc1c47fc/networkResourceCustomization" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/serviceVnf_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/serviceVnf_Response.json new file mode 100644 index 0000000000..440b1db489 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/serviceVnf_Response.json @@ -0,0 +1,46 @@ +{ + "modelName": "Infra_v10_Service", + "description": "MSO aLaCarte Vfmodule with addon", + "modelUUID": "5df8b6de-2083-11e7-93ae-92361f002672", + "modelInvariantUUID": "9647dfc4-2083-11e7-93ae-92361f002671", + "created": "2017-04-14 08:12:39.000", + "modelVersion": "2.0", + "serviceType": "NA", + "serviceRole": "NA", + "environmentContext": "Luna", + "workloadContext": "Oxygen", + "category": null, + "_links": { + "self": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672" + }, + "service": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672{?projection}", + "templated": true + }, + "serviceProxyCustomizations": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/serviceProxyCustomizations" + }, + "csar": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/csar" + }, + "vnfCustomizations": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations" + }, + "configurationCustomizations": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/configurationCustomizations" + }, + "collectionResourceCustomizations": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/collectionResourceCustomizations" + }, + "networkCustomizations": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/networkCustomizations" + }, + "recipes": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/recipes" + }, + "allottedCustomizations": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/allottedCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/service_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/service_Response.json new file mode 100644 index 0000000000..545095e5d1 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/service_Response.json @@ -0,0 +1,177 @@ +{ + "modelName": "GR-API-DEFAULT", + "description": "Gr api service for VID to use for infra APIH orchestration", + "modelUUID": "d88da85c-d9e8-4f73-b837-3a72a431622b", + "modelInvariantUUID": "944862ae-bb65-4429-8330-a6c9170d6672", + "created": "2018-08-10 09:49:12.000", + "modelVersion": "1.0", + "serviceType": null, + "serviceRole": null, + "environmentContext": null, + "workloadContext": null, + "category": null, + "_embedded": { + "networkCustomizations": [ + { + "description": "Contrail 30 GNDIRECT NW", + "modelName": "CONTRAIL30_GNDIRECT", + "networkScope": "", + "networkRole": "", + "modelUUID": "10b36f65-f4e6-4be6-ae49-9596dc1c47fc", + "created": "2017-01-17T15:05:05.000+0000", + "networkType": "", + "modelVersion": "1.0", + "toscaNodeType": "", + "aicVersionMin": "3.0", + "aicVersionMax": "", + "modelCustomizationUUID": "3bdbb104-476c-483e-9f8b-c095b3d308ac", + "modelInstanceName": "CONTRAIL30_GNDIRECT 9", + "modelInvariantUUID": "ce4ff476-9641-4e60-b4d5-b4abbec1271d", + "orchestrationMode": "HEAT", + "neutronNetworkType": "BASIC", + "networkTechnology": "", + "_links": { + "self": { + "href": "http://localhost:8090/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac{?projection}", + "templated": true + }, + "networkResource": { + "href": "http://localhost:8090/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource" + } + } + } + ], + "vnfCustomizations": [ + { + "description": "1607 v10 - inherent network1", + "modelName": "v10", + "modelUUID": "ff2ae348-214a-11e7-93ae-92361f002672", + "nfNamingCode": "vSAMP", + "created": "2017-04-14 21:46:28.0", + "nfRole": "vSAMP", + "modelVersion": "2.0", + "toscaNodeType": "VF", + "aicVersionMin": "", + "aicVersionMax": "", + "minInstances": "0", + "maxInstances": "0", + "nfFunction": "vSAMP", + "nfType": "vSAMP", + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002672", + "modelInstanceName": "test", + "vfModuleCustomizations": [ + { + "description": "v10 DEV PCM", + "modelName": "test::PCM::module-1", + "modelUUID": "066de97e-253e-11e7-93ae-92361f002672", + "created": "2016-09-14 18:19:56.0", + "modelVersion": "2", + "minInstances": "0", + "maxInstances": "0", + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002672", + "modelInvariantUUID": "64efd51a-2544-11e7-93ae-92361f002671", + "isBase": false, + "initialCount": "0", + "label": "PCM", + "availabilityZoneCount": "0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/heatEnvironment" + } + } + }, + { + "description": "v10 DEV Base", + "modelName": "test::base::module-0", + "modelUUID": "20c4431c-246d-11e7-93ae-92361f002672", + "created": "2016-09-14 18:19:56.0", + "modelVersion": "2", + "minInstances": "0", + "maxInstances": "0", + "modelCustomizationUUID": "cb82ffd8-252a-11e7-93ae-92361f002672", + "modelInvariantUUID": "78ca26d0-246d-11e7-93ae-92361f002671", + "isBase": true, + "initialCount": "1", + "label": "base", + "availabilityZoneCount": "0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/vfModule" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/heatEnvironment" + } + } + } + ], + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "availabilityZoneMaxCount": "0", + "multiStageDesign": null, + "orchestrationMode": "HEAT", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672{?projection}", + "templated": true + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vfModuleCustomizations" + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfcInstanceGroupCustomizations" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b" + }, + "service": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b{?projection}", + "templated": true + }, + "networkCustomizations": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/networkCustomizations" + }, + "collectionResourceCustomizations": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/collectionResourceCustomizations" + }, + "recipes": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/recipes" + }, + "vnfCustomizations": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/vnfCustomizations" + }, + "allottedCustomizations": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/allottedCustomizations" + }, + "serviceProxyCustomizations": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/serviceProxyCustomizations" + }, + "configurationCustomizations": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/configurationCustomizations" + }, + "csar": { + "href": "http://localhost:8090/service/d88da85c-d9e8-4f73-b837-3a72a431622b/csar" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationPCM_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationPCM_Response.json new file mode 100644 index 0000000000..895c905ec9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationPCM_Response.json @@ -0,0 +1,26 @@ +{ + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002672", + "label": "PCM", + "minInstances": 0, + "maxInstances": 0, + "initialCount": 0, + "availabilityZoneCount": 0, + "created": "2017-05-26 09:38:23.000", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationVolGrp_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationVolGrp_Response.json new file mode 100644 index 0000000000..dd7fbe1a84 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationVolGrp_Response.json @@ -0,0 +1,26 @@ +{ + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002671", + "label": "PCM", + "minInstances": 0, + "maxInstances": 0, + "initialCount": 0, + "availabilityZoneCount": 0, + "created": "2017-05-26 09:38:23.000", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/volumeHeatEnv" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/heatEnvironment" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomization_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomization_Response.json new file mode 100644 index 0000000000..a3ace2b24c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomization_Response.json @@ -0,0 +1,26 @@ +{ + "modelCustomizationUUID": "cb82ffd8-252a-11e7-93ae-92361f002671", + "label": "base", + "minInstances": 0, + "maxInstances": 0, + "initialCount": 1, + "availabilityZoneCount": 0, + "created": "2017-05-26 09:38:23.000", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/volumeHeatEnv" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/heatEnvironment" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationsPCM_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationsPCM_Response.json new file mode 100644 index 0000000000..4743bd39b2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleCustomizationsPCM_Response.json @@ -0,0 +1,37 @@ +{ + "_embedded": { + "vfModuleCustomization": [ + { + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002672", + "label": "PCM", + "minInstances": 0, + "maxInstances": 0, + "initialCount": 0, + "availabilityZoneCount": 0, + "created": "2017-05-26 09:38:23.000", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModulePCM_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModulePCM_Response.json new file mode 100644 index 0000000000..d4693bd075 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModulePCM_Response.json @@ -0,0 +1,30 @@ +{ + "modelUUID": "066de97e-253e-11e7-93ae-92361f002672", + "modelInvariantUUID": "64efd51a-2544-11e7-93ae-92361f002671", + "modelName": "test::PCM::module-1", + "modelVersion": "2", + "description": "v10 DEV PCM", + "isBase": false, + "created": "2016-09-14 12:49:56.000", + "heatFiles": [], + "_links": { + "self": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002672" + }, + "vfModule": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002672" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002672/vfModuleCustomization" + }, + "volumeHeatTemplate": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002672/volumeHeatTemplate" + }, + "vnfResources": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002672/vnfResources" + }, + "moduleHeatTemplate": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002672/moduleHeatTemplate" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleVolGroup_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleVolGroup_Response.json new file mode 100644 index 0000000000..6e429391d8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModuleVolGroup_Response.json @@ -0,0 +1,41 @@ +{ + "modelUUID": "066de97e-253e-11e7-93ae-92361f002671", + "modelInvariantUUID": "64efd51a-2544-11e7-93ae-92361f002671", + "modelName": "test::PCM::module-1", + "modelVersion": "2", + "description": "v10 DEV PCM", + "isBase": false, + "created": "2016-09-14 12:49:56.000", + "heatFiles": [ + { + "artifactUuid": "00535bdd-0878-4478-b95a-c575c742bfb0", + "description": "created from csar", + "fileName": "nimbus-ethernet-gw", + "fileBody": "DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n", + "created": "2017-01-21T18:26:43.000+0000", + "artifactChecksum": "MANUAL RECORD", + "version": "1", + "asdcUuid": "00535bdd-0878-4478-b95a-c575c742bfb0" + } + ], + "_links": { + "self": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002671" + }, + "vfModule": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002671" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002671/vfModuleCustomization" + }, + "volumeHeatTemplate": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002671/volumeHeatTemplate" + }, + "moduleHeatTemplate": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002671/moduleHeatTemplate" + }, + "vnfResources": { + "href": "http://localhost:8090/vfModule/066de97e-253e-11e7-93ae-92361f002671/vnfResources" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModule_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModule_Response.json new file mode 100644 index 0000000000..db26575fcd --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModule_Response.json @@ -0,0 +1,41 @@ +{ + "modelUUID": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantUUID": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelName": "test::base::module-0", + "modelVersion": "2", + "description": "v10 DEV Base", + "isBase": true, + "created": "2016-09-14 12:49:56.000", + "heatFiles": [ + { + "artifactUuid": "00535bdd-0878-4478-b95a-c575c742bfb0", + "description": "created from csar", + "fileName": "nimbus-ethernet-gw", + "fileBody": "DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n", + "created": "2017-01-21T18:26:43.000+0000", + "artifactChecksum": "MANUAL RECORD", + "version": "1", + "asdcUuid": "00535bdd-0878-4478-b95a-c575c742bfb0" + } + ], + "_links": { + "self": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671" + }, + "vfModule": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671" + }, + "moduleHeatTemplate": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/moduleHeatTemplate" + }, + "volumeHeatTemplate": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/volumeHeatTemplate" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/vfModuleCustomization" + }, + "vnfResources": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/vnfResources" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModulesListByInvariantId_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModulesListByInvariantId_Response.json new file mode 100644 index 0000000000..1a17c3f6f9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vfModulesListByInvariantId_Response.json @@ -0,0 +1,82 @@ +{ + "_embedded": { + "vfModule": [ + { + "modelUUID": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantUUID": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelName": "test::base::module-0", + "modelVersion": "2", + "description": "v10 DEV Base", + "isBase": true, + "created": "2016-09-14 12:49:56.000", + "heatFiles": [ + { + "artifactUuid": "00535bdd-0878-4478-b95a-c575c742bfb0", + "description": "created from csar", + "fileName": "nimbus-ethernet-gw", + "fileBody": "DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n", + "created": "2017-01-21T18:26:43.000+0000", + "artifactChecksum": "MANUAL RECORD", + "version": "1", + "asdcUuid": "00535bdd-0878-4478-b95a-c575c742bfb0" + } + ], + "_links": { + "self": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671" + }, + "vfModule": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671" + }, + "moduleHeatTemplate": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/moduleHeatTemplate" + }, + "vnfResources": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/vnfResources" + }, + "volumeHeatTemplate": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/volumeHeatTemplate" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002671/vfModuleCustomization" + } + } + }, + { + "modelUUID": "20c4431c-246d-11e7-93ae-92361f002672", + "modelInvariantUUID": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelName": "test::base::module-0", + "modelVersion": "2", + "description": "v10 DEV Base", + "isBase": true, + "created": "2016-09-14 12:49:56.000", + "heatFiles": [], + "_links": { + "self": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002672" + }, + "vfModule": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002672" + }, + "moduleHeatTemplate": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002672/moduleHeatTemplate" + }, + "vnfResources": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002672/vnfResources" + }, + "volumeHeatTemplate": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002672/volumeHeatTemplate" + }, + "vfModuleCustomization": { + "href": "http://localhost:8090/vfModule/20c4431c-246d-11e7-93ae-92361f002672/vfModuleCustomization" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc?modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeDeactivate_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeDeactivate_Response.json new file mode 100644 index 0000000000..a8adf9e26b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeDeactivate_Response.json @@ -0,0 +1,19 @@ +{ + "id": 36, + "action": "deactivateAndCloudDelete", + "description": "Gr api recipe to soft delete vf-module", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "vnfType": null, + "paramXsd": null, + "vnfComponentType": "vfModule", + "vfModuleModelUUID": "GR-API-DEFAULT", + "_links": { + "self": { + "href": "http://localhost:8090/vnfComponentsRecipe/36" + }, + "vnfComponentsRecipe": { + "href": "http://localhost:8090/vnfComponentsRecipe/36" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeDeleteVfModule_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeDeleteVfModule_Response.json new file mode 100644 index 0000000000..c0a40cc834 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeDeleteVfModule_Response.json @@ -0,0 +1,19 @@ +{ + "id": 33, + "action": "deleteInstance", + "description": "Gr api recipe to delete vf-module", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "vnfType": null, + "paramXsd": null, + "vnfComponentType": "vfModule", + "vfModuleModelUUID": "GR-API-DEFAULT", + "_links": { + "self": { + "href": "http://localhost:8090/vnfComponentsRecipe/33" + }, + "vnfComponentsRecipe": { + "href": "http://localhost:8090/vnfComponentsRecipe/33" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVNF_API_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVNF_API_Response.json new file mode 100644 index 0000000000..dc63699fd2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVNF_API_Response.json @@ -0,0 +1,19 @@ +{ + "id": 10, + "action": "createInstance", + "description": "VID_DEFAULT recipe t", + "orchestrationUri": "/mso/async/services/CreateVfModuleInfra", + "recipeTimeout": 180, + "vnfType": null, + "paramXsd": null, + "vnfComponentType": "vfModule", + "vfModuleModelUUID": "VNF-API-DEFAULT", + "_links": { + "self": { + "href": "http://localhost:8090/vnfComponentsRecipe/10" + }, + "vnfComponentsRecipe": { + "href": "http://localhost:8090/vnfComponentsRecipe/10" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVfModuleScaleOut_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVfModuleScaleOut_Response.json new file mode 100644 index 0000000000..1f7c778d2b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVfModuleScaleOut_Response.json @@ -0,0 +1,19 @@ +{ + "id": 37, + "action": "scaleOut", + "description": "Gr api recipe to scale out vfModule", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "vnfType": null, + "paramXsd": null, + "vnfComponentType": "vfModule", + "vfModuleModelUUID": "GR-API-DEFAULT", + "_links": { + "self": { + "href": "http://localhost:8090/vnfComponentsRecipe/37" + }, + "vnfComponentsRecipe": { + "href": "http://localhost:8090/vnfComponentsRecipe/37" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVolGrp_GRAPI_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVolGrp_GRAPI_Response.json new file mode 100644 index 0000000000..2c8c1f2318 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipeVolGrp_GRAPI_Response.json @@ -0,0 +1,19 @@ +{ + "id": 29, + "action": "createInstance", + "description": "Gr api recipe to create volume-group", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "vnfType": null, + "paramXsd": null, + "vnfComponentType": "volumeGroup", + "vfModuleModelUUID": "GR-API-DEFAULT", + "_links": { + "self": { + "href": "http://localhost:8090/vnfComponentsRecipe/29" + }, + "vnfComponentsRecipe": { + "href": "http://localhost:8090/vnfComponentsRecipe/29" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipe_GRAPI_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipe_GRAPI_Response.json new file mode 100644 index 0000000000..8317d9f002 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipe_GRAPI_Response.json @@ -0,0 +1,19 @@ +{ + "id": 34, + "action": "updateInstance", + "description": "Gr api recipe to update vf-module", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "vnfType": null, + "paramXsd": null, + "vnfComponentType": "vfModule", + "vfModuleModelUUID": "GR-API-DEFAULT", + "_links": { + "self": { + "href": "http://localhost:8090/vnfComponentsRecipe/34" + }, + "vnfComponentsRecipe": { + "href": "http://localhost:8090/vnfComponentsRecipe/34" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipe_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipe_Response.json new file mode 100644 index 0000000000..c47d0aad99 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfComponentRecipe_Response.json @@ -0,0 +1,19 @@ +{ + "id": 19, + "action": "createInstance", + "description": "VID_DEFAULT recipe to create vf-module if no custom BPMN flow is found", + "orchestrationUri": "/mso/async/services/CreateVfModuleInfra", + "recipeTimeout": 180, + "vnfType": "vfModule", + "paramXsd": "", + "vnfComponentType": "vfModule", + "vfModuleModelUUID": "20c4431c-246d-11e7-93ae-92361f002671", + "_links": { + "self": { + "href": "http://localhost:8090/vnfComponentsRecipe/19" + }, + "vnfComponentsRecipe": { + "href": "http://localhost:8090/vnfComponentsRecipe/19" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeApplyUpdatedConfig_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeApplyUpdatedConfig_Response.json new file mode 100644 index 0000000000..bde4541f6e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeApplyUpdatedConfig_Response.json @@ -0,0 +1,20 @@ +{ + "id": 10011, + "nfRole": "GR-API-DEFAULT", + "paramXsd": null, + "vfModuleId": null, + "action": "applyUpdatedConfig", + "description": "Gr api recipe to apply updated config", + "orchestrationUri": "/mso/async/services/VnfConfigUpdate", + "recipeTimeout": 180, + "serviceType": null, + "created": "2018-08-10T09:49:12.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/10011" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/10011" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeCreateInstance_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeCreateInstance_Response.json new file mode 100644 index 0000000000..99bbf122ad --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeCreateInstance_Response.json @@ -0,0 +1,20 @@ +{ + "id": 10006, + "nfRole": "GR-API-DEFAULT", + "paramXsd": null, + "vfModuleId": null, + "action": "createInstance", + "description": "Gr api recipe to create vnf", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "serviceType": null, + "created": "2018-08-10T09:49:12.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/10006" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/10006" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeDelete_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeDelete_Response.json new file mode 100644 index 0000000000..33d7f4799c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeDelete_Response.json @@ -0,0 +1,20 @@ +{ + "id": 10007, + "nfRole": "GR-API-DEFAULT", + "paramXsd": null, + "vfModuleId": null, + "action": "deleteInstance", + "description": "Gr api recipe to delete vnf", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "serviceType": null, + "created": "2018-08-10T09:49:12.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/10007" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/10007" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeInPlaceUpdate_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeInPlaceUpdate_Response.json new file mode 100644 index 0000000000..9364fe76b3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeInPlaceUpdate_Response.json @@ -0,0 +1,20 @@ +{ + "id": 10010, + "nfRole": "GR-API-DEFAULT", + "paramXsd": null, + "vfModuleId": null, + "action": "inPlaceSoftwareUpdate", + "description": "Gr api recipe to do an in place software update", + "orchestrationUri": "/mso/async/services/VnfInPlaceUpdate", + "recipeTimeout": 180, + "serviceType": null, + "created": "2018-08-20T08:10:21.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/10010" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/10010" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeReplaceInstance_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeReplaceInstance_Response.json new file mode 100644 index 0000000000..13e9a5937f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipeReplaceInstance_Response.json @@ -0,0 +1,20 @@ +{ + "id": 10009, + "nfRole": "GR-API-DEFAULT", + "paramXsd": null, + "vfModuleId": null, + "action": "replaceInstance", + "description": "Gr api recipe to replace vnf", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "serviceType": null, + "created": "2018-08-20T08:10:21.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/10009" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/10009" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipe_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipe_Response.json new file mode 100644 index 0000000000..53f4ddfbb5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipe_Response.json @@ -0,0 +1,20 @@ +{ + "id": 21, + "nfRole": "TEST", + "paramXsd": "", + "vfModuleId": "1882934", + "action": "replaceInstance", + "description": "custom bpmn for vnf recreate", + "orchestrationUri": "/mso/async/services/RecreateInfraVce", + "recipeTimeout": 180, + "serviceType": "VID_DEFAULT", + "created": "2016-06-03T04:44:10.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/21" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/21" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipe_ResponseWorkflowAction.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipe_ResponseWorkflowAction.json new file mode 100644 index 0000000000..c755714633 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfRecipe_ResponseWorkflowAction.json @@ -0,0 +1,20 @@ +{ + "id": 21, + "nfRole": "GR-API-DEFAULT", + "paramXsd": "", + "vfModuleId": "1882934", + "action": "recreateInstance", + "description": "gr-api-default for vnf recreate", + "orchestrationUri": "/mso/async/services/WorkflowActionBB", + "recipeTimeout": 180, + "serviceType": "GR-API-DEFAULT", + "created": "2016-06-03T04:44:10.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfRecipe/21" + }, + "vnfRecipe": { + "href": "http://localhost:8090/vnfRecipe/21" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomizationForVfModule_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomizationForVfModule_Response.json new file mode 100644 index 0000000000..85a02e76ba --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomizationForVfModule_Response.json @@ -0,0 +1,32 @@ +{ + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002673", + "modelInstanceName": "test", + "created": "2017-05-26 09:38:24.000", + "minInstances": 0, + "maxInstances": 0, + "availabilityZoneMaxCount": 0, + "nfFunction": "vSAMP", + "nfType": "vSAMP", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "multiStageDesign": null, + "creationTimestamp": "2017-05-26T09:38:24.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673" + }, + "vnfResourceCustomization": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673{?projection}", + "templated": true + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vnfcInstanceGroupCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomization_ReplaceVnf_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomization_ReplaceVnf_Response.json new file mode 100644 index 0000000000..97e2be4a6a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomization_ReplaceVnf_Response.json @@ -0,0 +1,32 @@ +{ + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelInstanceName": "v10 1", + "created": "2017-05-26 09:38:24.000", + "minInstances": 0, + "maxInstances": 0, + "availabilityZoneMaxCount": 0, + "nfFunction": "vSAMP", + "nfType": "vSAMP", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "multiStageDesign": null, + "creationTimestamp": "2017-05-26T09:38:24.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671" + }, + "vnfResourceCustomization": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671{?projection}", + "templated": true + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vfModuleCustomizations" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfcInstanceGroupCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomization_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomization_Response.json new file mode 100644 index 0000000000..e83ad10245 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomization_Response.json @@ -0,0 +1,32 @@ +{ + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002674", + "modelInstanceName": "test", + "created": "2017-05-26 09:38:24.000", + "minInstances": 0, + "maxInstances": 0, + "availabilityZoneMaxCount": 0, + "nfFunction": "", + "nfType": "", + "nfRole": "TEST", + "nfNamingCode": "", + "multiStageDesign": null, + "creationTimestamp": "2017-05-26T09:38:24.000+0000", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674" + }, + "vnfResourceCustomization": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674{?projection}", + "templated": true + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfcInstanceGroupCustomizations" + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vfModuleCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomizationsList_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomizationsList_Response.json new file mode 100644 index 0000000000..7b6b5cde21 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceCustomizationsList_Response.json @@ -0,0 +1,140 @@ +{ + "_embedded": { + "vnfResourceCustomization": [ + { + "description": "1607 v10 - inherent network1", + "modelName": "v10", + "modelUUID": "ff2ae348-214a-11e7-93ae-92361f002672", + "modelInstanceName": "test", + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002672", + "orchestrationMode": "HEAT", + "multiStageDesign": null, + "availabilityZoneMaxCount": "0", + "vfModuleCustomizations": [ + { + "description": "v10 DEV PCM", + "modelName": "test::PCM::module-1", + "availabilityZoneCount": "0", + "isBase": true, + "initialCount": "1", + "label": "base", + "modelUUID": "test", + "modelCustomizationUUID": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7", + "modelInvariantUUID": "f7ce78bb-423b-11e7-93f8-0050569a7968", + "maxInstances": "0", + "modelVersion": "1", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7/vfModule" + } + } + }, + { + "description": "v10 DEV PCM", + "modelName": "test::PCM::module-1", + "availabilityZoneCount": "0", + "isBase": false, + "initialCount": "0", + "label": "PCM", + "modelUUID": "066de97e-253e-11e7-93ae-92361f002672", + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002672", + "modelInvariantUUID": "64efd51a-2544-11e7-93ae-92361f002671", + "maxInstances": "0", + "modelVersion": "2", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule" + } + } + }, + { + "description": "v10 DEV Base", + "modelName": "test::base::module-0", + "availabilityZoneCount": "0", + "isBase": true, + "initialCount": "1", + "label": "base", + "modelUUID": "20c4431c-246d-11e7-93ae-92361f002672", + "modelCustomizationUUID": "cb82ffd8-252a-11e7-93ae-92361f002672", + "modelInvariantUUID": "78ca26d0-246d-11e7-93ae-92361f002671", + "maxInstances": "0", + "modelVersion": "2", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/vfModule" + } + } + } + ], + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "maxInstances": "0", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "toscaNodeType": "VF", + "nfType": "vSAMP", + "modelVersion": "2.0", + "minInstances": "0", + "aicVersionMax": "", + "nfFunction": "vSAMP", + "aicVersionMin": "", + "created": "2017-04-14 21:46:28.0", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672" + }, + "vnfResourceCustomization": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672{?projection}", + "templated": true + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vfModuleCustomizations" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfcInstanceGroupCustomizations" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceForVfModule_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceForVfModule_Response.json new file mode 100644 index 0000000000..a4e8424e0c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourceForVfModule_Response.json @@ -0,0 +1,101 @@ +{ + "modelUUID": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUUID": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelName": "vSAMP12", + "modelVersion": "1.0", + "toscaNodeType": "VF", + "description": "1607 vSAMP10a - inherent network", + "orchestrationMode": "HEAT", + "aicVersionMin": "", + "aicVersionMax": "", + "category": null, + "subCategory": null, + "created": "2017-04-14T16:16:28.000+0000", + "modelInvariantId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "_embedded": { + "vnfResourceCustomizations": [ + { + "description": "1607 vSAMP10a - inherent network", + "modelName": "vSAMP12", + "modelUUID": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelInstanceName": "test", + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002673", + "orchestrationMode": "HEAT", + "multiStageDesign": null, + "availabilityZoneMaxCount": "0", + "vfModuleCustomizations": [ + { + "description": "v10 DEV PCM", + "modelName": "test::PCM::module-1", + "availabilityZoneCount": "0", + "isBase": false, + "initialCount": "0", + "label": "PCM", + "modelUUID": "066de97e-253e-11e7-93ae-92361f002672", + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002672", + "modelInvariantUUID": "64efd51a-2544-11e7-93ae-92361f002671", + "maxInstances": "0", + "modelVersion": "2", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule" + } + } + } + ], + "modelInvariantUUID": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "maxInstances": "0", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "toscaNodeType": "VF", + "nfType": "vSAMP", + "modelVersion": "1.0", + "minInstances": "0", + "aicVersionMax": "", + "nfFunction": "vSAMP", + "aicVersionMin": "", + "created": "2017-04-14 21:46:28.0", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673{?projection}", + "templated": true + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vnfcInstanceGroupCustomizations" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe" + }, + "vnfResource": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe" + }, + "heatTemplates": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe/heatTemplates" + }, + "vnfResourceCustomizations": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe/vnfResourceCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourcesCreateVnf_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourcesCreateVnf_Response.json new file mode 100644 index 0000000000..79b2727ffe --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResourcesCreateVnf_Response.json @@ -0,0 +1,197 @@ +{ + "modelUUID": "ff2ae348-214a-11e7-93ae-92361f002672", + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelName": "v10", + "modelVersion": "2.0", + "toscaNodeType": "VF", + "description": "1607 v10 - inherent network1", + "orchestrationMode": "HEAT", + "aicVersionMin": "", + "aicVersionMax": "", + "category": null, + "subCategory": null, + "created": "2017-04-14T16:16:28.000+0000", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "_embedded": { + "vnfResourceCustomizations": [ + { + "description": "1607 v10 - inherent network1", + "modelName": "v10", + "modelUUID": "ff2ae348-214a-11e7-93ae-92361f002672", + "modelInstanceName": "test", + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002672", + "orchestrationMode": "HEAT", + "multiStageDesign": null, + "availabilityZoneMaxCount": "0", + "vfModuleCustomizations": [ + { + "description": "v10 DEV PCM", + "modelName": "test::PCM::module-1", + "availabilityZoneCount": "0", + "isBase": true, + "initialCount": "1", + "label": "base", + "modelUUID": "test", + "modelCustomizationUUID": "a7f1d08e-b02d-11e6-80f5-76304dec7eb7", + "modelInvariantUUID": "f7ce78bb-423b-11e7-93f8-0050569a7968", + "maxInstances": "0", + "modelVersion": "1", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/a7f1d08e-b02d-11e6-80f5-76304dec7eb7/vfModule" + } + } + }, + { + "description": "v10 DEV PCM", + "modelName": "test::PCM::module-1", + "availabilityZoneCount": "0", + "isBase": false, + "initialCount": "0", + "label": "PCM", + "modelUUID": "066de97e-253e-11e7-93ae-92361f002672", + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002672", + "modelInvariantUUID": "64efd51a-2544-11e7-93ae-92361f002671", + "maxInstances": "0", + "modelVersion": "2", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule" + } + } + }, + { + "description": "v10 DEV Base", + "modelName": "test::base::module-0", + "availabilityZoneCount": "0", + "isBase": true, + "initialCount": "1", + "label": "base", + "modelUUID": "20c4431c-246d-11e7-93ae-92361f002672", + "modelCustomizationUUID": "cb82ffd8-252a-11e7-93ae-92361f002672", + "modelInvariantUUID": "78ca26d0-246d-11e7-93ae-92361f002671", + "maxInstances": "0", + "modelVersion": "2", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002672/vfModule" + } + } + } + ], + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "maxInstances": "0", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "toscaNodeType": "VF", + "nfType": "vSAMP", + "modelVersion": "2.0", + "minInstances": "0", + "aicVersionMax": "", + "nfFunction": "vSAMP", + "aicVersionMin": "", + "created": "2017-04-14 21:46:28.0", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672{?projection}", + "templated": true + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vfModuleCustomizations" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfcInstanceGroupCustomizations" + } + } + }, + { + "description": "1607 v10 - inherent network1", + "modelName": "v10", + "modelUUID": "ff2ae348-214a-11e7-93ae-92361f002672", + "modelInstanceName": "test", + "modelCustomizationUUID": "f78914d9-423b-11e7-93f8-0050569a7967", + "orchestrationMode": "HEAT", + "multiStageDesign": null, + "availabilityZoneMaxCount": "0", + "vfModuleCustomizations": [], + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "maxInstances": "0", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "toscaNodeType": "VF", + "nfType": "vSAMP", + "modelVersion": "2.0", + "minInstances": "0", + "aicVersionMax": "", + "nfFunction": "vSAMP", + "aicVersionMin": "", + "created": "2017-04-14 21:46:28.0", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/f78914d9-423b-11e7-93f8-0050569a7967{?projection}", + "templated": true + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/f78914d9-423b-11e7-93f8-0050569a7967/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/f78914d9-423b-11e7-93f8-0050569a7967/vfModuleCustomizations" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/f78914d9-423b-11e7-93f8-0050569a7967/vnfcInstanceGroupCustomizations" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002672" + }, + "vnfResource": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002672" + }, + "heatTemplates": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002672/heatTemplates" + }, + "vnfResourceCustomizations": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002672/vnfResourceCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResources_ReplaceVnf_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResources_ReplaceVnf_Response.json new file mode 100644 index 0000000000..303275a713 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResources_ReplaceVnf_Response.json @@ -0,0 +1,130 @@ +{ + "modelUUID": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelName": "v10", + "modelVersion": "1.0", + "toscaNodeType": "VF", + "description": "1607 v10 - inherent network", + "orchestrationMode": "HEAT", + "aicVersionMin": "", + "aicVersionMax": "", + "category": null, + "subCategory": null, + "created": "2017-04-14T16:16:28.000+0000", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "_embedded": { + "vnfResourceCustomizations": [ + { + "description": "1607 v10 - inherent network", + "modelName": "v10", + "modelUUID": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInstanceName": "v10 1", + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002671", + "orchestrationMode": "HEAT", + "multiStageDesign": null, + "availabilityZoneMaxCount": "0", + "vfModuleCustomizations": [ + { + "description": "v10 DEV PCM", + "modelName": "test::PCM::module-1", + "availabilityZoneCount": "0", + "isBase": false, + "initialCount": "0", + "label": "PCM", + "modelUUID": "066de97e-253e-11e7-93ae-92361f002671", + "modelCustomizationUUID": "b4ea86b4-253f-11e7-93ae-92361f002671", + "modelInvariantUUID": "64efd51a-2544-11e7-93ae-92361f002671", + "maxInstances": "0", + "modelVersion": "2", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule" + } + } + }, + { + "description": "v10 DEV Base", + "modelName": "test::base::module-0", + "availabilityZoneCount": "0", + "isBase": true, + "initialCount": "1", + "label": "base", + "modelUUID": "20c4431c-246d-11e7-93ae-92361f002671", + "modelCustomizationUUID": "cb82ffd8-252a-11e7-93ae-92361f002671", + "modelInvariantUUID": "78ca26d0-246d-11e7-93ae-92361f002671", + "maxInstances": "0", + "modelVersion": "2", + "minInstances": "0", + "created": "2016-09-14 18:19:56.0", + "_links": { + "self": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "volumeHeatEnv": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/volumeHeatEnv" + }, + "heatEnvironment": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/heatEnvironment" + }, + "vfModule": { + "href": "http://localhost:8090/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule" + } + } + } + ], + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "maxInstances": "0", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "toscaNodeType": "VF", + "nfType": "vSAMP", + "modelVersion": "1.0", + "minInstances": "0", + "aicVersionMax": "", + "nfFunction": "vSAMP", + "aicVersionMin": "", + "created": "2017-04-14 21:46:28.0", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671{?projection}", + "templated": true + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources" + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vfModuleCustomizations" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfcInstanceGroupCustomizations" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002671" + }, + "vnfResource": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002671" + }, + "heatTemplates": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002671/heatTemplates" + }, + "vnfResourceCustomizations": { + "href": "http://localhost:8090/vnfResource/ff2ae348-214a-11e7-93ae-92361f002671/vnfResourceCustomizations" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResources_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResources_Response.json new file mode 100644 index 0000000000..e95ead4435 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/vnfResources_Response.json @@ -0,0 +1,71 @@ +{ + "modelUUID": "fe6478e4-ea33-3346-ac12-ab121484a3fw", + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelName": "vSAMP10a", + "modelVersion": "1.0", + "toscaNodeType": "VF", + "description": "1607 vSAMP10a - inherent network", + "orchestrationMode": "HEAT", + "aicVersionMin": "", + "aicVersionMax": "", + "category": null, + "subCategory": null, + "created": "2017-04-14T16:16:28.000+0000", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "_embedded": { + "vnfResourceCustomizations": [ + { + "description": "1607 vSAMP10a - inherent network", + "modelName": "vSAMP10a", + "modelUUID": "fe6478e4-ea33-3346-ac12-ab121484a3fw", + "multiStageDesign": null, + "modelInvariantUUID": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelInstanceName": "test", + "availabilityZoneMaxCount": "0", + "vfModuleCustomizations": [], + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002674", + "orchestrationMode": "HEAT", + "nfFunction": "", + "modelVersion": "1.0", + "aicVersionMax": "", + "nfRole": "TEST", + "nfNamingCode": "", + "toscaNodeType": "VF", + "minInstances": "0", + "aicVersionMin": "", + "maxInstances": "0", + "created": "2017-04-14 21:46:28.0", + "nfType": "", + "_links": { + "self": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674{?projection}", + "templated": true + }, + "vfModuleCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vfModuleCustomizations" + }, + "vnfResources": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources" + }, + "vnfcInstanceGroupCustomizations": { + "href": "http://localhost:8090/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfcInstanceGroupCustomizations" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fw" + }, + "vnfResource": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fw" + }, + "vnfResourceCustomizations": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fw/vnfResourceCustomizations" + }, + "heatTemplates": { + "href": "http://localhost:8090/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fw/heatTemplates" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 3540110351..381330b928 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -770,6 +770,77 @@ FOREIGN KEY (`NB_REQ_REF_LOOKUP_ID`) REFERENCES `northbound_request_ref_lookup` ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB DEFAULT CHARACTER SET = latin1; +CREATE TABLE IF NOT EXISTS vnfc_customization ( +`MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, +`MODEL_UUID` VARCHAR(200) NOT NULL, +`MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL, +`MODEL_VERSION` VARCHAR(20) NOT NULL, +`MODEL_NAME` VARCHAR(200) NOT NULL, +`TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL, +`DESCRIPTION` VARCHAR(1200) NULL DEFAULT NULL, +`CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)) +ENGINE = InnoDB +AUTO_INCREMENT = 20654 +DEFAULT CHARACTER SET = latin1; + +CREATE TABLE IF NOT EXISTS cvnfc_customization ( +`ID` INT(11) NOT NULL AUTO_INCREMENT, +`MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, +`MODEL_UUID` VARCHAR(200) NOT NULL, +`MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL, +`MODEL_VERSION` VARCHAR(20) NOT NULL, +`MODEL_NAME` VARCHAR(200) NOT NULL, +`TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL, +`DESCRIPTION` VARCHAR(1200) NULL DEFAULT NULL, +`NFC_FUNCTION` VARCHAR(200) NULL, +`NFC_NAMING_CODE` VARCHAR(200) NULL, +`CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, +`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, +`VNFC_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, PRIMARY KEY (`ID`), INDEX `fk_cvnfc_customization__vf_module_customization1_idx` (`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnfc_customization1_idx` (`VNFC_CUST_MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnf_resource_customization1_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), UNIQUE INDEX `UK_cvnfc_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC, `VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` ASC, `MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnf_vfmod_cvnfc_config_cust1_idx` (`MODEL_CUSTOMIZATION_UUID` ASC), CONSTRAINT `fk_cvnfc_customization__vf_module_customization1` FOREIGN KEY (`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`) ON +DELETE CASCADE ON +UPDATE CASCADE, CONSTRAINT `fk_cvnfc_customization__vnfc_customization1` FOREIGN KEY (`VNFC_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vnfc_customization` (`MODEL_CUSTOMIZATION_UUID`) ON +DELETE CASCADE ON +UPDATE CASCADE, CONSTRAINT `fk_cvnfc_customization__vnf_resource_customization1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`) ON +DELETE CASCADE ON +UPDATE CASCADE) ENGINE = InnoDB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = latin1; + +CREATE TABLE IF NOT EXISTS vnf_vfmodule_cvnfc_configuration_customization ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `VF_MODULE_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `CVNFC_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, + `CONFIGURATION_TYPE` VARCHAR(200) NULL, + `CONFIGURATION_ROLE` VARCHAR(200) NULL, + `CONFIGURATION_FUNCTION` VARCHAR(200) NULL, + `POLICY_NAME` VARCHAR(200) NULL, + `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CONFIGURATION_MODEL_UUID` VARCHAR(200) NOT NULL, + PRIMARY KEY (`ID`), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__configuration_idx` (`CONFIGURATION_MODEL_UUID` ASC), + UNIQUE INDEX `UK_vnf_vfmodule_cvnfc_configuration_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC , `VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC , `CVNFC_MODEL_CUSTOMIZATION_UUID` ASC , `MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__cvnfc_cust1_idx` (`CVNFC_MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vf_module_cust_idx` (`VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vnf_res_cust_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), + CONSTRAINT `fk_vnf_vfmod_cvnfc_config_cust__configuration_resource` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`) + REFERENCES `configuration` (`MODEL_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_cvnfc_configuration_customization__cvnfc_customization1` FOREIGN KEY (`CVNFC_MODEL_CUSTOMIZATION_UUID`) + REFERENCES `cvnfc_customization` (`MODEL_CUSTOMIZATION_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_vnf_configuration_cvnfc_customization__vf_module_customiza1` FOREIGN KEY (`VF_MODULE_MODEL_CUSTOMIZATION_UUID`) + REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_vfmodule_cvnfc_configuration_customization__vnf_resource_c1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`) + REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=INNODB AUTO_INCREMENT=20654 DEFAULT CHARACTER SET=LATIN1; + --------START Request DB SCHEMA -------- CREATE DATABASE requestdb; USE requestdb; |