2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.onap.so.logger.MdcConstants.ENDTIME;
26 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
27 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
28 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
29 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
30 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
31 import static org.onap.so.logger.MdcConstants.STATUSCODE;
33 import java.io.IOException;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
39 import org.json.JSONException;
40 import org.junit.Test;
41 import org.onap.logging.ref.slf4j.ONAPLogConstants;
42 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
43 import org.skyscreamer.jsonassert.JSONAssert;
44 import org.skyscreamer.jsonassert.JSONCompareMode;
45 import org.springframework.boot.test.web.client.TestRestTemplate;
46 import org.springframework.http.HttpEntity;
47 import org.springframework.http.HttpHeaders;
48 import org.springframework.http.HttpMethod;
49 import org.springframework.http.ResponseEntity;
50 import org.springframework.web.util.UriComponentsBuilder;
52 import ch.qos.logback.classic.spi.ILoggingEvent;
55 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
57 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
59 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources";
61 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
63 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
65 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
67 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
69 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
71 HttpHeaders headers = new HttpHeaders();
73 private final String expectedServiceResourceResponse = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}";
75 private final String expectedServiceResourceResponsev2 = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}";
78 private final String expectedServiceVnfResponse = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}";
80 private final String expectedServiceVnfResponseV3 = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}";
82 private final String expectedServiceNetworkResourceResponse = "{\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n]\r\n}";
84 private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
86 private final String expectedAllottedResponse = "{\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}";
88 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
90 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
92 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
94 /* Health Check Resources Endpoint */
97 public void testHealthcheck() throws JSONException {
99 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
101 ResponseEntity<String> response = restTemplate.exchange(
102 createURLWithPort("/manage/health"),
103 HttpMethod.GET, entity, String.class);
105 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
106 for(ILoggingEvent logEvent : TestAppender.events)
107 if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
108 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
110 Map<String,String> mdc = logEvent.getMDCPropertyMap();
111 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
112 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
113 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
114 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
115 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
116 assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
117 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
118 logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
119 Map<String,String> mdc = logEvent.getMDCPropertyMap();
120 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
121 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
122 assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
123 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
124 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
125 assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
129 /* Service Resources Endpoint */
132 public void testGetServiceModelUUID() throws JSONException {
133 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
134 headers.set("Accept", MediaType.APPLICATION_JSON);
136 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
137 .queryParam("serviceModelUuid", serviceUUID);
139 ResponseEntity<String> response = restTemplate.exchange(
140 builder.toUriString(),
141 HttpMethod.GET, entity, String.class);
143 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
144 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
148 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
149 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
150 headers.set("Accept", MediaType.APPLICATION_JSON);
151 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
152 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
154 ResponseEntity<String> response = restTemplate.exchange(
155 builder.toUriString(),
156 HttpMethod.GET, entity, String.class);
158 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
159 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
163 public void testGetServiceInvariantUUID() throws JSONException {
164 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
165 headers.set("Accept", MediaType.APPLICATION_JSON);
166 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
167 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
169 ResponseEntity<String> response = restTemplate.exchange(
170 builder.toUriString(),
171 HttpMethod.GET, entity, String.class);
173 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
174 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
178 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
179 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
180 headers.set("Accept", MediaType.APPLICATION_JSON);
181 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
182 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
184 ResponseEntity<String> response = restTemplate.exchange(
185 builder.toUriString(),
186 HttpMethod.GET, entity, String.class);
188 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
189 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
193 public void testGetServiceModelUUID404() throws JSONException {
194 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
195 headers.set("Accept", MediaType.APPLICATION_JSON);
196 String expectedResponse = "\"serviceResources\": null";
197 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
198 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
200 ResponseEntity<String> response = restTemplate.exchange(
201 builder.toUriString(),
202 HttpMethod.GET, entity, String.class);
204 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
205 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
209 public void testGetServiceBadQueryParams() throws JSONException {
210 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
211 headers.set("Accept", MediaType.APPLICATION_JSON);
212 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
213 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
215 ResponseEntity<String> response = restTemplate.exchange(
216 builder.toUriString(),
217 HttpMethod.GET, entity, String.class);
219 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
220 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
223 /* VNF Resources Endpoint */
226 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
227 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
228 headers.set("Accept", MediaType.APPLICATION_JSON);
229 String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}";
230 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
233 ResponseEntity<String> response = restTemplate.exchange(
234 builder.toUriString(),
235 HttpMethod.GET, entity, String.class);
237 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
238 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
244 public void testGetVNFResources404() throws JSONException {
245 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
246 headers.set("Accept", MediaType.APPLICATION_JSON);
248 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
251 ResponseEntity<String> response = restTemplate.exchange(
252 builder.toUriString(),
253 HttpMethod.GET, entity, String.class);
255 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
260 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
261 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
262 headers.set("Accept", MediaType.APPLICATION_JSON);
264 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
265 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
267 ResponseEntity<String> response = restTemplate.exchange(
268 builder.toUriString(),
269 HttpMethod.GET, entity, String.class);
271 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
272 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
276 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
277 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
278 headers.set("Accept", MediaType.APPLICATION_JSON);
280 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
281 .queryParam("serviceModelUuid", serviceUUID);
283 ResponseEntity<String> response = restTemplate.exchange(
284 builder.toUriString(),
285 HttpMethod.GET, entity, String.class);
287 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
288 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
292 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
293 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
294 headers.set("Accept", MediaType.APPLICATION_JSON);
296 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
297 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
298 .queryParam("serviceModelVersion", "1.0");
300 ResponseEntity<String> response = restTemplate.exchange(
301 builder.toUriString(),
302 HttpMethod.GET, entity, String.class);
304 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
305 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
309 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
310 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
311 headers.set("Accept", MediaType.APPLICATION_JSON);
313 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
314 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
315 .queryParam("serviceModelVersion", "");
317 ResponseEntity<String> response = restTemplate.exchange(
318 builder.toUriString(),
319 HttpMethod.GET, entity, String.class);
321 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
322 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
327 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
328 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
329 headers.set("Accept", MediaType.APPLICATION_JSON);
331 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
332 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
334 ResponseEntity<String> response = restTemplate.exchange(
335 builder.toUriString(),
336 HttpMethod.GET, entity, String.class);
338 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
339 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
343 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
344 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
345 headers.set("Accept", MediaType.APPLICATION_JSON);
347 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
348 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
350 ResponseEntity<String> response = restTemplate.exchange(
351 builder.toUriString(),
352 HttpMethod.GET, entity, String.class);
354 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
355 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
359 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
360 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
361 headers.set("Accept", MediaType.APPLICATION_JSON);
363 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
364 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
366 ResponseEntity<String> response = restTemplate.exchange(
367 builder.toUriString(),
368 HttpMethod.GET, entity, String.class);
370 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
371 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
375 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
376 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
377 headers.set("Accept", MediaType.APPLICATION_JSON);
379 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
380 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
382 ResponseEntity<String> response = restTemplate.exchange(
383 builder.toUriString(),
384 HttpMethod.GET, entity, String.class);
386 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
387 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
391 public void testSerfviceVNFResources404() throws JSONException {
392 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
393 headers.set("Accept", MediaType.APPLICATION_JSON);
395 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
396 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
398 ResponseEntity<String> response = restTemplate.exchange(
399 builder.toUriString(),
400 HttpMethod.GET, entity, String.class);
402 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
408 public void testSerfviceVNFBadParams() throws JSONException {
409 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
410 headers.set("Accept", MediaType.APPLICATION_JSON);
412 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
413 .queryParam("BadParamName", "BADNAME");
415 ResponseEntity<String> response = restTemplate.exchange(
416 builder.toUriString(),
417 HttpMethod.GET, entity, String.class);
418 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
419 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
426 /* Network Resources Endpoint */
429 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
430 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
431 headers.set("Accept", MediaType.APPLICATION_JSON);
432 String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}";
433 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
436 ResponseEntity<String> response = restTemplate.exchange(
437 builder.toUriString(),
438 HttpMethod.GET, entity, String.class);
440 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
441 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
447 public void testGetNetworkResources404() throws JSONException {
448 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
449 headers.set("Accept", MediaType.APPLICATION_JSON);
451 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"))
454 ResponseEntity<String> response = restTemplate.exchange(
455 builder.toUriString(),
456 HttpMethod.GET, entity, String.class);
458 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
462 /* Service Network Resources Endpoints */
465 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
466 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
467 headers.set("Accept", MediaType.APPLICATION_JSON);
469 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
470 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
472 ResponseEntity<String> response = restTemplate.exchange(
473 builder.toUriString(),
474 HttpMethod.GET, entity, String.class);
476 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
477 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
481 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
482 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
483 headers.set("Accept", MediaType.APPLICATION_JSON);
485 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
486 .queryParam("serviceModelUuid", serviceUUID);
488 ResponseEntity<String> response = restTemplate.exchange(
489 builder.toUriString(),
490 HttpMethod.GET, entity, String.class);
492 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
493 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
497 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
498 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
499 headers.set("Accept", MediaType.APPLICATION_JSON);
501 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
502 .queryParam("serviceModelUuid", "doesNotExist");
504 ResponseEntity<String> response = restTemplate.exchange(
505 builder.toUriString(),
506 HttpMethod.GET, entity, String.class);
508 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
513 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
514 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
515 headers.set("Accept", MediaType.APPLICATION_JSON);
517 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
518 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
520 ResponseEntity<String> response = restTemplate.exchange(
521 builder.toUriString(),
522 HttpMethod.GET, entity, String.class);
524 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
529 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
530 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
531 headers.set("Accept", MediaType.APPLICATION_JSON);
533 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
534 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
536 ResponseEntity<String> response = restTemplate.exchange(
537 builder.toUriString(),
538 HttpMethod.GET, entity, String.class);
540 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
541 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
545 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
546 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
547 headers.set("Accept", MediaType.APPLICATION_JSON);
549 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
550 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
551 .queryParam("serviceModelVersion", "2.0");
553 ResponseEntity<String> response = restTemplate.exchange(
554 builder.toUriString(),
555 HttpMethod.GET, entity, String.class);
557 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
558 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
562 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
563 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
564 headers.set("Accept", MediaType.APPLICATION_JSON);
566 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
567 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
568 .queryParam("serviceModelVersion", "");
569 ResponseEntity<String> response = restTemplate.exchange(
570 builder.toUriString(),
571 HttpMethod.GET, entity, String.class);
573 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
574 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
579 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
580 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
581 headers.set("Accept", MediaType.APPLICATION_JSON);
583 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
584 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
586 ResponseEntity<String> response = restTemplate.exchange(
587 builder.toUriString(),
588 HttpMethod.GET, entity, String.class);
590 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
591 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
595 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
596 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
597 headers.set("Accept", MediaType.APPLICATION_JSON);
599 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
600 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
602 ResponseEntity<String> response = restTemplate.exchange(
603 builder.toUriString(),
604 HttpMethod.GET, entity, String.class);
606 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
607 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
610 /* Allotted endpoints */
613 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
614 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
615 headers.set("Accept", MediaType.APPLICATION_JSON);
616 String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}";
618 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
621 ResponseEntity<String> response = restTemplate.exchange(
622 builder.toUriString(),
623 HttpMethod.GET, entity, String.class);
625 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
626 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
631 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
632 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
633 headers.set("Accept", MediaType.APPLICATION_JSON);
635 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
636 .queryParam("serviceModelUuid",serviceUUID);
638 ResponseEntity<String> response = restTemplate.exchange(
639 builder.toUriString(),
640 HttpMethod.GET, entity, String.class);
642 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
643 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
647 public void testResourceReceipe() throws JSONException {
648 String expectedResourceRecipe = "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
650 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
651 headers.set("Accept", MediaType.APPLICATION_JSON);
653 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
654 .queryParam("resourceModelUuid", arResourceUUID)
655 .queryParam("action", "createInstance");
657 ResponseEntity<String> response = restTemplate.exchange(
658 builder.toUriString(),
659 HttpMethod.GET, entity, String.class);
661 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
662 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
666 public void testResourceReceipeNotMatched() throws JSONException {
668 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
669 headers.set("Accept", MediaType.APPLICATION_JSON);
671 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
672 .queryParam("resourceModelUuid", arResourceUUID)
673 .queryParam("action", "invalid_action");
675 ResponseEntity<String> response = restTemplate.exchange(
676 builder.toUriString(),
677 HttpMethod.GET, entity, String.class);
679 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
683 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
684 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
685 headers.set("Accept", MediaType.APPLICATION_JSON);
687 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
688 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
690 ResponseEntity<String> response = restTemplate.exchange(
691 builder.toUriString(),
692 HttpMethod.GET, entity, String.class);
694 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
695 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
699 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
700 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
701 headers.set("Accept", MediaType.APPLICATION_JSON);
703 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
704 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
705 .queryParam("serviceModelVersion", "1.0");
707 ResponseEntity<String> response = restTemplate.exchange(
708 builder.toUriString(),
709 HttpMethod.GET, entity, String.class);
711 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
712 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
716 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
717 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
718 headers.set("Accept", MediaType.APPLICATION_JSON);
720 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
721 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
722 .queryParam("serviceModelVersion", "1.0");
724 ResponseEntity<String> response = restTemplate.exchange(
725 builder.toUriString(),
726 HttpMethod.GET, entity, String.class);
728 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
729 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
733 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
734 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
735 headers.set("Accept", MediaType.APPLICATION_JSON);
737 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
738 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
740 ResponseEntity<String> response = restTemplate.exchange(
741 builder.toUriString(),
742 HttpMethod.GET, entity, String.class);
744 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
745 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
750 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
751 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
752 headers.set("Accept", MediaType.APPLICATION_JSON);
754 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
755 .queryParam("arModelCustomizationUuid", "NOTEXIST");
757 ResponseEntity<String> response = restTemplate.exchange(
758 builder.toUriString(),
759 HttpMethod.GET, entity, String.class);
761 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
765 /* VF Modules Endpoint */
768 public void testGetVFModulesNonExistResource() throws JSONException {
769 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
770 headers.set("Accept", MediaType.APPLICATION_JSON);
772 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
773 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
775 ResponseEntity<String> response = restTemplate.exchange(
776 builder.toUriString(),
777 HttpMethod.GET, entity, String.class);
779 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
784 public void testGetVFModulesByVfModuleModelName() throws JSONException {
785 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
786 headers.set("Accept", MediaType.APPLICATION_JSON);
787 String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n}";
788 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
789 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
791 ResponseEntity<String> response = restTemplate.exchange(
792 builder.toUriString(),
793 HttpMethod.GET, entity, String.class);
795 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
796 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
801 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
802 TestAppender.events.clear();
803 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
804 headers.set("Accept", MediaType.APPLICATION_JSON);
806 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
807 .queryParam("ADASD", "NEUTRON_BASIC");
809 ResponseEntity<String> response = restTemplate.exchange(
810 builder.toUriString(),
811 HttpMethod.GET, entity, String.class);
813 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
814 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
817 for(ILoggingEvent logEvent : TestAppender.events)
818 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
819 logEvent.getMarker().getName().equals("ENTRY")
821 Map<String,String> mdc = logEvent.getMDCPropertyMap();
822 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
823 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
824 assertNotNull(mdc.get(INVOCATION_ID));
825 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
826 assertEquals("v2/vfModules",mdc.get(SERVICE_NAME));
827 assertEquals("INPROGRESS",mdc.get(STATUSCODE));
828 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
829 logEvent.getMarker().getName().equals("EXIT")){
830 Map<String,String> mdc = logEvent.getMDCPropertyMap();
831 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
832 assertNotNull(mdc.get(ENDTIME));
833 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
834 assertNotNull(mdc.get(INVOCATION_ID));
835 assertEquals("500",mdc.get(RESPONSECODE));
836 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
837 assertEquals("v2/vfModules",mdc.get(SERVICE_NAME));
838 assertEquals("ERROR",mdc.get(STATUSCODE));
839 assertNotNull(mdc.get(RESPONSEDESC));
843 private String createURLWithPort(String uri) {
844 return "http://localhost:" + port + uri;