2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2022 Samsung Electronics Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.so.adapters.catalogdb.catalogrest;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26 import java.io.IOException;
27 import java.nio.file.Files;
28 import java.nio.file.Paths;
29 import java.util.List;
30 import javax.ws.rs.core.MediaType;
31 import javax.ws.rs.core.Response;
32 import org.json.JSONException;
33 import org.json.simple.parser.ParseException;
34 import org.junit.Test;
35 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
36 import org.onap.so.db.catalog.beans.ProcessingFlags;
37 import org.onap.so.db.catalog.beans.ServiceRecipe;
38 import org.skyscreamer.jsonassert.JSONAssert;
39 import org.skyscreamer.jsonassert.JSONCompareMode;
40 import org.springframework.boot.test.web.client.TestRestTemplate;
41 import org.springframework.http.HttpEntity;
42 import org.springframework.http.HttpHeaders;
43 import org.springframework.http.HttpMethod;
44 import org.springframework.http.ResponseEntity;
45 import org.springframework.web.util.UriComponentsBuilder;
46 import com.fasterxml.jackson.core.type.TypeReference;
47 import com.fasterxml.jackson.databind.ObjectMapper;
50 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
52 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
54 private static final String SERVICE_RECIPE = "serviceRecipe";
56 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
57 "ecomp/mso/catalog/v2/serviceAllottedResources";
59 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
61 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
63 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
65 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
67 private static final String ECOMP_MSO_CATALOG_PROCESSING_FLAGS = "ecomp/mso/catalog/v2/processingFlags";
69 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
71 HttpHeaders headers = new HttpHeaders();
73 private final String expectedServiceResourceResponsev2 =
74 "{\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}";
76 private final String expectedServiceVnfResponse =
77 "{\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}";
79 private final String expectedServiceVnfResponseV3 =
80 "{\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 =
83 "{\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}";
85 private final String badQueryParamResponse =
86 "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
88 private final String expectedAllottedResponse =
89 "{\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}";
91 private final String expectedFilteredServiceResourceResponse =
92 "{\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}";
94 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
96 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
98 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
100 /* Health Check Resources Endpoint */
103 public void testHealthcheck() throws JSONException {
105 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
107 ResponseEntity<String> response =
108 restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
110 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
113 /* Service Resources Endpoint */
116 public void testGetServiceModelUUID() throws JSONException, IOException, ParseException {
117 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
118 headers.set("Accept", MediaType.APPLICATION_JSON);
120 UriComponentsBuilder builder =
121 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
122 .queryParam("serviceModelUuid", serviceUUID);
124 ResponseEntity<String> response =
125 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
127 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
128 JSONAssert.assertEquals(getJson("ExpectedServiceResourceEscaped.json"), response.getBody().toString(),
129 JSONCompareMode.LENIENT);
133 public void testGetFilteredVnfResourceInputServiceModelUUID() throws JSONException {
134 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
135 headers.set("Accept", MediaType.APPLICATION_JSON);
137 UriComponentsBuilder builder =
138 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
139 .queryParam("serviceModelUuid", serviceUUID).queryParam("filter", "resourceInput");
141 ResponseEntity<String> response =
142 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
144 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
145 JSONAssert.assertEquals(expectedFilteredServiceResourceResponse, response.getBody().toString(),
146 JSONCompareMode.LENIENT);
150 public void testGetServiceInvariantUUIDAndVersion() throws JSONException, IOException {
151 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
152 headers.set("Accept", MediaType.APPLICATION_JSON);
153 UriComponentsBuilder builder =
154 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
155 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
156 .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput");
158 ResponseEntity<String> response =
159 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
161 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
162 JSONAssert.assertEquals(expectedFilteredServiceResourceResponse, response.getBody().toString(),
163 JSONCompareMode.LENIENT);
167 public void testGetServiceInvariantUUID() throws JSONException {
168 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
169 headers.set("Accept", MediaType.APPLICATION_JSON);
170 UriComponentsBuilder builder =
171 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
172 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
174 ResponseEntity<String> response =
175 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
177 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
178 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
182 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
183 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
184 headers.set("Accept", MediaType.APPLICATION_JSON);
185 UriComponentsBuilder builder =
186 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
187 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
188 .queryParam("serviceModelVersion", "");;
190 ResponseEntity<String> response =
191 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
193 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
194 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
198 public void testGetServiceModelUUID404() throws JSONException {
199 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
200 headers.set("Accept", MediaType.APPLICATION_JSON);
201 String expectedResponse = "\"serviceResources\": null";
202 UriComponentsBuilder builder =
203 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
204 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
206 ResponseEntity<String> response =
207 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
209 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
210 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
214 public void testGetServiceBadQueryParams() throws JSONException {
215 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
216 headers.set("Accept", MediaType.APPLICATION_JSON);
217 UriComponentsBuilder builder =
218 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
219 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
221 ResponseEntity<String> response =
222 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
224 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
225 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
228 /* VNF Resources Endpoint */
231 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
232 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
233 headers.set("Accept", MediaType.APPLICATION_JSON);
234 String expectedResponse =
235 "{\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}";
236 UriComponentsBuilder builder = UriComponentsBuilder
238 createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
239 .queryParam("filter", "resourceInput");
241 ResponseEntity<String> response =
242 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
244 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
245 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
251 public void testGetVNFResources404() throws JSONException {
252 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
253 headers.set("Accept", MediaType.APPLICATION_JSON);
255 UriComponentsBuilder builder = UriComponentsBuilder
256 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"));
258 ResponseEntity<String> response =
259 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
261 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
266 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
267 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
268 headers.set("Accept", MediaType.APPLICATION_JSON);
270 UriComponentsBuilder builder =
271 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
272 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671")
273 .queryParam("filter", "resourceInput");
275 ResponseEntity<String> response =
276 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
278 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
279 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
283 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
284 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
285 headers.set("Accept", MediaType.APPLICATION_JSON);
287 UriComponentsBuilder builder =
288 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
289 .queryParam("serviceModelUuid", serviceUUID).queryParam("filter", "resourceInput");
291 ResponseEntity<String> response =
292 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
294 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
295 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
299 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
300 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
301 headers.set("Accept", MediaType.APPLICATION_JSON);
303 UriComponentsBuilder builder =
304 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
305 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
306 .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput");
308 ResponseEntity<String> response =
309 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
311 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
312 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
316 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
317 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
318 headers.set("Accept", MediaType.APPLICATION_JSON);
320 UriComponentsBuilder builder =
321 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
322 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
323 .queryParam("serviceModelVersion", "");
325 ResponseEntity<String> response =
326 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
328 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
329 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
334 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
335 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
336 headers.set("Accept", MediaType.APPLICATION_JSON);
338 UriComponentsBuilder builder =
339 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
340 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
342 ResponseEntity<String> response =
343 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
345 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
346 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
350 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
351 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
352 headers.set("Accept", MediaType.APPLICATION_JSON);
354 UriComponentsBuilder builder =
355 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
356 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
358 ResponseEntity<String> response =
359 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
361 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
362 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
366 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
367 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
368 headers.set("Accept", MediaType.APPLICATION_JSON);
370 UriComponentsBuilder builder = UriComponentsBuilder
371 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
372 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
374 ResponseEntity<String> response =
375 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
377 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
378 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
382 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
383 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
384 headers.set("Accept", MediaType.APPLICATION_JSON);
386 UriComponentsBuilder builder =
387 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
388 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service")
389 .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput");
391 ResponseEntity<String> response =
392 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
394 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
395 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
399 public void testSerfviceVNFResources404() throws JSONException {
400 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
401 headers.set("Accept", MediaType.APPLICATION_JSON);
403 UriComponentsBuilder builder =
404 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
405 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
407 ResponseEntity<String> response =
408 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
410 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
416 public void testSerfviceVNFBadParams() throws JSONException {
417 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
418 headers.set("Accept", MediaType.APPLICATION_JSON);
420 UriComponentsBuilder builder =
421 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
422 .queryParam("BadParamName", "BADNAME");
424 ResponseEntity<String> response =
425 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
426 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
427 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
434 /* Network Resources Endpoint */
437 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
438 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
439 headers.set("Accept", MediaType.APPLICATION_JSON);
440 String expectedResponse =
441 "{\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}";
442 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
443 createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"));
445 ResponseEntity<String> response =
446 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
448 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
449 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
455 public void testGetNetworkResources404() throws JSONException {
456 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
457 headers.set("Accept", MediaType.APPLICATION_JSON);
459 UriComponentsBuilder builder = UriComponentsBuilder
460 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"));
462 ResponseEntity<String> response =
463 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
465 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
469 /* Service Network Resources Endpoints */
472 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
473 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
474 headers.set("Accept", MediaType.APPLICATION_JSON);
476 UriComponentsBuilder builder =
477 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
478 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
480 ResponseEntity<String> response =
481 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
483 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
484 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
488 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
489 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
490 headers.set("Accept", MediaType.APPLICATION_JSON);
492 UriComponentsBuilder builder =
493 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
494 .queryParam("serviceModelUuid", serviceUUID);
496 ResponseEntity<String> response =
497 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
499 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
500 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
504 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
505 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
506 headers.set("Accept", MediaType.APPLICATION_JSON);
508 UriComponentsBuilder builder =
509 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
510 .queryParam("serviceModelUuid", "doesNotExist");
512 ResponseEntity<String> response =
513 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
515 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
520 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
521 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
522 headers.set("Accept", MediaType.APPLICATION_JSON);
524 UriComponentsBuilder builder =
525 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
526 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
528 ResponseEntity<String> response =
529 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
531 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
536 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
537 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
538 headers.set("Accept", MediaType.APPLICATION_JSON);
540 UriComponentsBuilder builder =
541 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
542 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
544 ResponseEntity<String> response =
545 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
547 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
548 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
552 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
553 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
554 headers.set("Accept", MediaType.APPLICATION_JSON);
556 UriComponentsBuilder builder = UriComponentsBuilder
557 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
558 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "2.0");
560 ResponseEntity<String> response =
561 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
563 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
564 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
568 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
569 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
570 headers.set("Accept", MediaType.APPLICATION_JSON);
572 UriComponentsBuilder builder = UriComponentsBuilder
573 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
574 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "");
575 ResponseEntity<String> response =
576 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
578 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
579 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
584 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
585 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
586 headers.set("Accept", MediaType.APPLICATION_JSON);
588 UriComponentsBuilder builder =
589 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
590 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
592 ResponseEntity<String> response =
593 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
595 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
596 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
600 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
601 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
602 headers.set("Accept", MediaType.APPLICATION_JSON);
604 UriComponentsBuilder builder =
605 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
606 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
608 ResponseEntity<String> response =
609 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
611 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
612 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
615 /* Allotted endpoints */
618 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
619 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
620 headers.set("Accept", MediaType.APPLICATION_JSON);
621 String expectedResponse =
622 "{\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}";
624 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
625 createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
628 ResponseEntity<String> response =
629 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
631 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
632 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
637 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
638 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
639 headers.set("Accept", MediaType.APPLICATION_JSON);
641 UriComponentsBuilder builder =
642 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
643 .queryParam("serviceModelUuid", serviceUUID);
645 ResponseEntity<String> response =
646 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
648 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
649 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
653 public void testResourceReceipe() throws JSONException {
654 String expectedResourceRecipe =
655 "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
657 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
658 headers.set("Accept", MediaType.APPLICATION_JSON);
660 UriComponentsBuilder builder =
661 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
662 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance");
664 ResponseEntity<String> response =
665 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
667 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
668 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
672 public void testResourceReceipeNotMatched() throws JSONException {
674 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
675 headers.set("Accept", MediaType.APPLICATION_JSON);
677 UriComponentsBuilder builder =
678 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
679 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action");
681 ResponseEntity<String> response =
682 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
684 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
688 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
689 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
690 headers.set("Accept", MediaType.APPLICATION_JSON);
692 UriComponentsBuilder builder =
693 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
694 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
696 ResponseEntity<String> response =
697 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
699 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
700 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
704 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
705 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
706 headers.set("Accept", MediaType.APPLICATION_JSON);
708 UriComponentsBuilder builder = UriComponentsBuilder
709 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
710 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
712 ResponseEntity<String> response =
713 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
715 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
716 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
720 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
721 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
722 headers.set("Accept", MediaType.APPLICATION_JSON);
724 UriComponentsBuilder builder = UriComponentsBuilder
725 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
726 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
728 ResponseEntity<String> response =
729 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
731 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
732 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
736 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
737 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
738 headers.set("Accept", MediaType.APPLICATION_JSON);
740 UriComponentsBuilder builder =
741 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
742 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
744 ResponseEntity<String> response =
745 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
747 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
748 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
753 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
754 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
755 headers.set("Accept", MediaType.APPLICATION_JSON);
757 UriComponentsBuilder builder =
758 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
759 .queryParam("arModelCustomizationUuid", "NOTEXIST");
761 ResponseEntity<String> response =
762 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
764 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
768 /* VF Modules Endpoint */
771 public void testGetVFModulesNonExistResource() throws JSONException {
772 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
773 headers.set("Accept", MediaType.APPLICATION_JSON);
775 UriComponentsBuilder builder =
776 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
777 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
779 ResponseEntity<String> response =
780 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
782 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
787 public void testGetVFModulesByVfModuleModelName() throws JSONException {
788 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
789 headers.set("Accept", MediaType.APPLICATION_JSON);
790 String expectedResponse =
791 "{\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}";
792 UriComponentsBuilder builder =
793 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
794 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
796 ResponseEntity<String> response =
797 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
799 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
800 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
805 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
806 TestAppender.events.clear();
807 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
808 headers.set("Accept", MediaType.APPLICATION_JSON);
810 UriComponentsBuilder builder = UriComponentsBuilder
811 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)).queryParam("ADASD", "NEUTRON_BASIC");
813 ResponseEntity<String> response =
814 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
816 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
817 JSONAssert.assertEquals(badQueryParamResponse, response.getBody(), false);
821 public void testCreateServiceRecipe() throws JSONException {
822 ServiceRecipe recipe = new ServiceRecipe();
823 recipe.setAction("action");
824 recipe.setDescription("description");
825 recipe.setOrchestrationUri("http://test");
826 recipe.setRecipeTimeout(120);
827 recipe.setServiceModelUUID(serviceUUID);
828 HttpEntity<ServiceRecipe> entity = new HttpEntity<ServiceRecipe>(recipe, headers);
829 headers.set("Accept", MediaType.APPLICATION_JSON);
831 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(SERVICE_RECIPE));
833 ResponseEntity<String> response =
834 restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
836 assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
840 public void testGetProcessingFlagsByFlag() throws Exception {
841 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
842 headers.set("Accept", MediaType.APPLICATION_JSON);
844 UriComponentsBuilder builder = UriComponentsBuilder
845 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
847 ResponseEntity<String> response =
848 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
850 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
851 ObjectMapper mapper = new ObjectMapper();
852 ProcessingFlags processingFlagsResponse = mapper.readValue(response.getBody(), ProcessingFlags.class);
854 assertEquals("TESTFLAG", processingFlagsResponse.getFlag());
855 assertEquals("NO", processingFlagsResponse.getValue());
856 assertEquals("TESTENDPOINT", processingFlagsResponse.getEndpoint());
857 assertEquals("TEST FLAG", processingFlagsResponse.getDescription());
861 public void testGetAllProcessingFlags() throws Exception {
862 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
863 headers.set("Accept", MediaType.APPLICATION_JSON);
865 UriComponentsBuilder builder =
866 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS));
868 ResponseEntity<String> response =
869 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
871 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
872 ObjectMapper mapper = new ObjectMapper();
874 List<ProcessingFlags> processingFlagsResponse =
875 mapper.readValue(response.getBody(), new TypeReference<List<ProcessingFlags>>() {});
877 boolean testFlagFound = false;
878 for (int i = 0; i < processingFlagsResponse.size(); i++) {
879 if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) {
880 assertEquals("TESTENDPOINT", processingFlagsResponse.get(i).getEndpoint());
881 assertEquals("TEST FLAG", processingFlagsResponse.get(i).getDescription());
882 testFlagFound = true;
885 assertTrue(testFlagFound);
889 public void testSetProcessingFlagsFlagValue() throws JSONException {
890 ProcessingFlags updatedProcessingFlag = new ProcessingFlags();
891 updatedProcessingFlag.setFlag("TESTFLAG");
892 updatedProcessingFlag.setValue("YES");
893 HttpEntity<ProcessingFlags> entity = new HttpEntity<ProcessingFlags>(updatedProcessingFlag, headers);
894 headers.set("Accept", MediaType.APPLICATION_JSON);
896 UriComponentsBuilder builder = UriComponentsBuilder
897 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
899 ResponseEntity<String> response =
900 restTemplate.exchange(builder.toUriString(), HttpMethod.PUT, entity, String.class);
902 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
905 private String createURLWithPort(String uri) {
906 return "http://localhost:" + port + uri;
909 private String getJson(String filename) throws IOException {
910 return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename)));