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.assertTrue;
25 import java.io.IOException;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import java.util.List;
29 import javax.ws.rs.core.MediaType;
30 import javax.ws.rs.core.Response;
31 import org.json.JSONException;
32 import org.json.simple.parser.ParseException;
33 import org.junit.Test;
34 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
35 import org.onap.so.db.catalog.beans.ProcessingFlags;
36 import org.onap.so.db.catalog.beans.ServiceRecipe;
37 import org.skyscreamer.jsonassert.JSONAssert;
38 import org.skyscreamer.jsonassert.JSONCompareMode;
39 import org.springframework.boot.test.web.client.TestRestTemplate;
40 import org.springframework.http.HttpEntity;
41 import org.springframework.http.HttpHeaders;
42 import org.springframework.http.HttpMethod;
43 import org.springframework.http.ResponseEntity;
44 import org.springframework.web.util.UriComponentsBuilder;
45 import com.fasterxml.jackson.core.type.TypeReference;
46 import com.fasterxml.jackson.databind.ObjectMapper;
49 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
51 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
53 private static final String SERVICE_RECIPE = "serviceRecipe";
55 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
56 "ecomp/mso/catalog/v2/serviceAllottedResources";
58 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
60 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
62 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
64 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
66 private static final String ECOMP_MSO_CATALOG_PROCESSING_FLAGS = "ecomp/mso/catalog/v2/processingFlags";
68 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
70 HttpHeaders headers = new HttpHeaders();
72 private final String expectedServiceResourceResponsev2 =
73 "{\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}";
75 private final String expectedServiceVnfResponse =
76 "{\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}";
78 private final String expectedServiceVnfResponseV3 =
79 "{\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}";
81 private final String expectedServiceNetworkResourceResponse =
82 "{\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 =
85 "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
87 private final String expectedAllottedResponse =
88 "{\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}";
90 private final String expectedFilteredServiceResourceResponse =
91 "{\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}";
93 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
95 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
97 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
99 /* Health Check Resources Endpoint */
102 public void testHealthcheck() throws JSONException {
104 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
106 ResponseEntity<String> response =
107 restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
109 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
112 /* Service Resources Endpoint */
115 public void testGetServiceModelUUID() throws JSONException, IOException, ParseException {
116 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
117 headers.set("Accept", MediaType.APPLICATION_JSON);
119 UriComponentsBuilder builder =
120 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
121 .queryParam("serviceModelUuid", serviceUUID);
123 ResponseEntity<String> response =
124 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
126 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
127 JSONAssert.assertEquals(getJson("ExpectedServiceResourceEscaped.json"), response.getBody().toString(),
128 JSONCompareMode.LENIENT);
132 public void testGetFilteredVnfResourceInputServiceModelUUID() throws JSONException {
133 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
134 headers.set("Accept", MediaType.APPLICATION_JSON);
136 UriComponentsBuilder builder =
137 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
138 .queryParam("serviceModelUuid", serviceUUID).queryParam("filter", "resourceInput");
140 ResponseEntity<String> response =
141 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
143 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
144 JSONAssert.assertEquals(expectedFilteredServiceResourceResponse, response.getBody().toString(),
145 JSONCompareMode.LENIENT);
149 public void testGetServiceInvariantUUIDAndVersion() throws JSONException, IOException {
150 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
151 headers.set("Accept", MediaType.APPLICATION_JSON);
152 UriComponentsBuilder builder =
153 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
154 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
155 .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput");
157 ResponseEntity<String> response =
158 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
160 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
161 JSONAssert.assertEquals(expectedFilteredServiceResourceResponse, response.getBody().toString(),
162 JSONCompareMode.LENIENT);
166 public void testGetServiceInvariantUUID() throws JSONException {
167 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
168 headers.set("Accept", MediaType.APPLICATION_JSON);
169 UriComponentsBuilder builder =
170 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
171 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
173 ResponseEntity<String> response =
174 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
176 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
177 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
181 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
182 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
183 headers.set("Accept", MediaType.APPLICATION_JSON);
184 UriComponentsBuilder builder =
185 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
186 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
187 .queryParam("serviceModelVersion", "");;
189 ResponseEntity<String> response =
190 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
192 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
193 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
197 public void testGetServiceModelUUID404() throws JSONException {
198 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
199 headers.set("Accept", MediaType.APPLICATION_JSON);
200 String expectedResponse = "\"serviceResources\": null";
201 UriComponentsBuilder builder =
202 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
203 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
205 ResponseEntity<String> response =
206 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
208 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
209 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
213 public void testGetServiceBadQueryParams() throws JSONException {
214 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
215 headers.set("Accept", MediaType.APPLICATION_JSON);
216 UriComponentsBuilder builder =
217 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
218 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
220 ResponseEntity<String> response =
221 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
223 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
224 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
227 /* VNF Resources Endpoint */
230 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
231 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
232 headers.set("Accept", MediaType.APPLICATION_JSON);
233 String expectedResponse =
234 "{\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}";
235 UriComponentsBuilder builder = UriComponentsBuilder
237 createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
238 .queryParam("filter", "resourceInput");
240 ResponseEntity<String> response =
241 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
243 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
244 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
250 public void testGetVNFResources404() throws JSONException {
251 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
252 headers.set("Accept", MediaType.APPLICATION_JSON);
254 UriComponentsBuilder builder = UriComponentsBuilder
255 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"));
257 ResponseEntity<String> response =
258 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
260 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
265 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
266 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
267 headers.set("Accept", MediaType.APPLICATION_JSON);
269 UriComponentsBuilder builder =
270 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
271 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671")
272 .queryParam("filter", "resourceInput");
274 ResponseEntity<String> response =
275 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
277 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
278 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
282 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
283 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
284 headers.set("Accept", MediaType.APPLICATION_JSON);
286 UriComponentsBuilder builder =
287 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
288 .queryParam("serviceModelUuid", serviceUUID).queryParam("filter", "resourceInput");
290 ResponseEntity<String> response =
291 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
293 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
294 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
298 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
299 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
300 headers.set("Accept", MediaType.APPLICATION_JSON);
302 UriComponentsBuilder builder =
303 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
304 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
305 .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput");
307 ResponseEntity<String> response =
308 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
310 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
311 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
315 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
316 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
317 headers.set("Accept", MediaType.APPLICATION_JSON);
319 UriComponentsBuilder builder =
320 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
321 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
322 .queryParam("serviceModelVersion", "");
324 ResponseEntity<String> response =
325 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
327 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
328 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
333 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
334 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
335 headers.set("Accept", MediaType.APPLICATION_JSON);
337 UriComponentsBuilder builder =
338 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
339 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
341 ResponseEntity<String> response =
342 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
344 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
345 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
349 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
350 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
351 headers.set("Accept", MediaType.APPLICATION_JSON);
353 UriComponentsBuilder builder =
354 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
355 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
357 ResponseEntity<String> response =
358 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
360 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
361 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
365 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
366 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
367 headers.set("Accept", MediaType.APPLICATION_JSON);
369 UriComponentsBuilder builder = UriComponentsBuilder
370 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
371 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
373 ResponseEntity<String> response =
374 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
376 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
377 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
381 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
382 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
383 headers.set("Accept", MediaType.APPLICATION_JSON);
385 UriComponentsBuilder builder =
386 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
387 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service")
388 .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput");
390 ResponseEntity<String> response =
391 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
393 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
394 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
398 public void testSerfviceVNFResources404() throws JSONException {
399 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
400 headers.set("Accept", MediaType.APPLICATION_JSON);
402 UriComponentsBuilder builder =
403 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
404 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
406 ResponseEntity<String> response =
407 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
409 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
415 public void testSerfviceVNFBadParams() throws JSONException {
416 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
417 headers.set("Accept", MediaType.APPLICATION_JSON);
419 UriComponentsBuilder builder =
420 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
421 .queryParam("BadParamName", "BADNAME");
423 ResponseEntity<String> response =
424 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
425 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
426 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
433 /* Network Resources Endpoint */
436 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
437 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
438 headers.set("Accept", MediaType.APPLICATION_JSON);
439 String expectedResponse =
440 "{\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}";
441 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
442 createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"));
444 ResponseEntity<String> response =
445 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
447 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
448 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
454 public void testGetNetworkResources404() throws JSONException {
455 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
456 headers.set("Accept", MediaType.APPLICATION_JSON);
458 UriComponentsBuilder builder = UriComponentsBuilder
459 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"));
461 ResponseEntity<String> response =
462 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
464 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
468 /* Service Network Resources Endpoints */
471 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
472 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
473 headers.set("Accept", MediaType.APPLICATION_JSON);
475 UriComponentsBuilder builder =
476 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
477 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
479 ResponseEntity<String> response =
480 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
482 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
483 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
487 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
488 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
489 headers.set("Accept", MediaType.APPLICATION_JSON);
491 UriComponentsBuilder builder =
492 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
493 .queryParam("serviceModelUuid", serviceUUID);
495 ResponseEntity<String> response =
496 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
498 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
499 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
503 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
504 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
505 headers.set("Accept", MediaType.APPLICATION_JSON);
507 UriComponentsBuilder builder =
508 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
509 .queryParam("serviceModelUuid", "doesNotExist");
511 ResponseEntity<String> response =
512 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
514 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
519 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
520 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
521 headers.set("Accept", MediaType.APPLICATION_JSON);
523 UriComponentsBuilder builder =
524 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
525 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
527 ResponseEntity<String> response =
528 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
530 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
535 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
536 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
537 headers.set("Accept", MediaType.APPLICATION_JSON);
539 UriComponentsBuilder builder =
540 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
541 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
543 ResponseEntity<String> response =
544 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
546 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
547 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
551 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
552 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
553 headers.set("Accept", MediaType.APPLICATION_JSON);
555 UriComponentsBuilder builder = UriComponentsBuilder
556 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
557 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "2.0");
559 ResponseEntity<String> response =
560 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
562 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
563 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
567 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
568 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
569 headers.set("Accept", MediaType.APPLICATION_JSON);
571 UriComponentsBuilder builder = UriComponentsBuilder
572 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
573 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "");
574 ResponseEntity<String> response =
575 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
577 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
578 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
583 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
584 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
585 headers.set("Accept", MediaType.APPLICATION_JSON);
587 UriComponentsBuilder builder =
588 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
589 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
591 ResponseEntity<String> response =
592 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
594 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
595 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
599 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
600 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
601 headers.set("Accept", MediaType.APPLICATION_JSON);
603 UriComponentsBuilder builder =
604 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
605 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
607 ResponseEntity<String> response =
608 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
610 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
611 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
614 /* Allotted endpoints */
617 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
618 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
619 headers.set("Accept", MediaType.APPLICATION_JSON);
620 String expectedResponse =
621 "{\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}";
623 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
624 createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
627 ResponseEntity<String> response =
628 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
630 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
631 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
636 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
637 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
638 headers.set("Accept", MediaType.APPLICATION_JSON);
640 UriComponentsBuilder builder =
641 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
642 .queryParam("serviceModelUuid", serviceUUID);
644 ResponseEntity<String> response =
645 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
647 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
648 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
652 public void testResourceReceipe() throws JSONException {
653 String expectedResourceRecipe =
654 "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
656 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
657 headers.set("Accept", MediaType.APPLICATION_JSON);
659 UriComponentsBuilder builder =
660 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
661 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance");
663 ResponseEntity<String> response =
664 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
666 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
667 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
671 public void testResourceReceipeNotMatched() throws JSONException {
673 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
674 headers.set("Accept", MediaType.APPLICATION_JSON);
676 UriComponentsBuilder builder =
677 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
678 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action");
680 ResponseEntity<String> response =
681 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
683 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
687 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
688 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
689 headers.set("Accept", MediaType.APPLICATION_JSON);
691 UriComponentsBuilder builder =
692 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
693 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
695 ResponseEntity<String> response =
696 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
698 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
699 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
703 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
704 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
705 headers.set("Accept", MediaType.APPLICATION_JSON);
707 UriComponentsBuilder builder = UriComponentsBuilder
708 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
709 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
711 ResponseEntity<String> response =
712 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
714 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
715 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
719 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
720 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
721 headers.set("Accept", MediaType.APPLICATION_JSON);
723 UriComponentsBuilder builder = UriComponentsBuilder
724 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
725 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
727 ResponseEntity<String> response =
728 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
730 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
731 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
735 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
736 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
737 headers.set("Accept", MediaType.APPLICATION_JSON);
739 UriComponentsBuilder builder =
740 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
741 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
743 ResponseEntity<String> response =
744 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
746 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
747 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
752 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
753 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
754 headers.set("Accept", MediaType.APPLICATION_JSON);
756 UriComponentsBuilder builder =
757 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
758 .queryParam("arModelCustomizationUuid", "NOTEXIST");
760 ResponseEntity<String> response =
761 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
763 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
767 /* VF Modules Endpoint */
770 public void testGetVFModulesNonExistResource() throws JSONException {
771 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
772 headers.set("Accept", MediaType.APPLICATION_JSON);
774 UriComponentsBuilder builder =
775 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
776 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
778 ResponseEntity<String> response =
779 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
781 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
786 public void testGetVFModulesByVfModuleModelName() throws JSONException {
787 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
788 headers.set("Accept", MediaType.APPLICATION_JSON);
789 String expectedResponse =
790 "{\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}";
791 UriComponentsBuilder builder =
792 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
793 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
795 ResponseEntity<String> response =
796 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
798 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
799 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
804 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
805 TestAppender.events.clear();
806 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
807 headers.set("Accept", MediaType.APPLICATION_JSON);
809 UriComponentsBuilder builder = UriComponentsBuilder
810 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)).queryParam("ADASD", "NEUTRON_BASIC");
812 ResponseEntity<String> response =
813 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
815 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
816 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
820 public void testCreateServiceRecipe() throws JSONException {
821 ServiceRecipe recipe = new ServiceRecipe();
822 recipe.setAction("action");
823 recipe.setDescription("description");
824 recipe.setOrchestrationUri("http://test");
825 recipe.setRecipeTimeout(120);
826 recipe.setServiceModelUUID(serviceUUID);
827 HttpEntity<ServiceRecipe> entity = new HttpEntity<ServiceRecipe>(recipe, headers);
828 headers.set("Accept", MediaType.APPLICATION_JSON);
830 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(SERVICE_RECIPE));
832 ResponseEntity<String> response =
833 restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
835 assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
839 public void testGetProcessingFlagsByFlag() throws Exception {
840 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
841 headers.set("Accept", MediaType.APPLICATION_JSON);
843 UriComponentsBuilder builder = UriComponentsBuilder
844 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
846 ResponseEntity<String> response =
847 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
849 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
850 ObjectMapper mapper = new ObjectMapper();
851 ProcessingFlags processingFlagsResponse = mapper.readValue(response.getBody(), ProcessingFlags.class);
853 assertEquals(processingFlagsResponse.getFlag(), "TESTFLAG");
854 assertEquals(processingFlagsResponse.getValue(), "NO");
855 assertEquals(processingFlagsResponse.getEndpoint(), "TESTENDPOINT");
856 assertEquals(processingFlagsResponse.getDescription(), "TEST FLAG");
860 public void testGetAllProcessingFlags() throws Exception {
861 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
862 headers.set("Accept", MediaType.APPLICATION_JSON);
864 UriComponentsBuilder builder =
865 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS));
867 ResponseEntity<String> response =
868 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
870 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
871 ObjectMapper mapper = new ObjectMapper();
873 List<ProcessingFlags> processingFlagsResponse =
874 mapper.readValue(response.getBody(), new TypeReference<List<ProcessingFlags>>() {});
876 boolean testFlagFound = false;
877 for (int i = 0; i < processingFlagsResponse.size(); i++) {
878 if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) {
879 assertEquals(processingFlagsResponse.get(i).getEndpoint(), "TESTENDPOINT");
880 assertEquals(processingFlagsResponse.get(i).getDescription(), "TEST FLAG");
881 testFlagFound = true;
884 assertTrue(testFlagFound);
888 public void testSetProcessingFlagsFlagValue() throws JSONException {
889 ProcessingFlags updatedProcessingFlag = new ProcessingFlags();
890 updatedProcessingFlag.setFlag("TESTFLAG");
891 updatedProcessingFlag.setValue("YES");
892 HttpEntity<ProcessingFlags> entity = new HttpEntity<ProcessingFlags>(updatedProcessingFlag, headers);
893 headers.set("Accept", MediaType.APPLICATION_JSON);
895 UriComponentsBuilder builder = UriComponentsBuilder
896 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
898 ResponseEntity<String> response =
899 restTemplate.exchange(builder.toUriString(), HttpMethod.PUT, entity, String.class);
901 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
904 private String createURLWithPort(String uri) {
905 return "http://localhost:" + port + uri;
908 private String getJson(String filename) throws IOException {
909 return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename)));