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 java.io.IOException;
25 import javax.ws.rs.core.MediaType;
26 import javax.ws.rs.core.Response;
27 import org.json.JSONException;
28 import org.junit.Test;
29 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
30 import org.onap.so.db.catalog.beans.ServiceRecipe;
31 import org.skyscreamer.jsonassert.JSONAssert;
32 import org.skyscreamer.jsonassert.JSONCompareMode;
33 import org.springframework.boot.test.web.client.TestRestTemplate;
34 import org.springframework.http.HttpEntity;
35 import org.springframework.http.HttpHeaders;
36 import org.springframework.http.HttpMethod;
37 import org.springframework.http.ResponseEntity;
38 import org.springframework.web.util.UriComponentsBuilder;
41 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
43 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
45 private static final String SERVICE_RECIPE = "serviceRecipe";
47 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
48 "ecomp/mso/catalog/v2/serviceAllottedResources";
50 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
52 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
54 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
56 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
58 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
60 HttpHeaders headers = new HttpHeaders();
62 private final String expectedServiceResourceResponse =
63 "{\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}";
65 private final String expectedServiceResourceResponsev2 =
66 "{\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}";
69 private final String expectedServiceVnfResponse =
70 "{\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}";
72 private final String expectedServiceVnfResponseV3 =
73 "{\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}";
75 private final String expectedServiceNetworkResourceResponse =
76 "{\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}";
78 private final String badQueryParamResponse =
79 "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
81 private final String expectedAllottedResponse =
82 "{\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}";
84 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
86 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
88 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
90 /* Health Check Resources Endpoint */
93 public void testHealthcheck() throws JSONException {
95 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
97 ResponseEntity<String> response =
98 restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
100 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
103 /* Service Resources Endpoint */
106 public void testGetServiceModelUUID() throws JSONException {
107 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
108 headers.set("Accept", MediaType.APPLICATION_JSON);
110 UriComponentsBuilder builder =
111 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
112 .queryParam("serviceModelUuid", serviceUUID);
114 ResponseEntity<String> response =
115 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
117 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
118 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(),
119 JSONCompareMode.LENIENT);
123 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
124 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
125 headers.set("Accept", MediaType.APPLICATION_JSON);
126 UriComponentsBuilder builder =
127 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
128 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
129 .queryParam("serviceModelVersion", "1.0");
131 ResponseEntity<String> response =
132 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
134 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
135 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
139 public void testGetServiceInvariantUUID() throws JSONException {
140 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
141 headers.set("Accept", MediaType.APPLICATION_JSON);
142 UriComponentsBuilder builder =
143 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
144 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
146 ResponseEntity<String> response =
147 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
149 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
150 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
154 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
155 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
156 headers.set("Accept", MediaType.APPLICATION_JSON);
157 UriComponentsBuilder builder =
158 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
159 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
160 .queryParam("serviceModelVersion", "");;
162 ResponseEntity<String> response =
163 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
165 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
166 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
170 public void testGetServiceModelUUID404() throws JSONException {
171 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
172 headers.set("Accept", MediaType.APPLICATION_JSON);
173 String expectedResponse = "\"serviceResources\": null";
174 UriComponentsBuilder builder =
175 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
176 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
178 ResponseEntity<String> response =
179 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
181 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
182 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
186 public void testGetServiceBadQueryParams() throws JSONException {
187 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
188 headers.set("Accept", MediaType.APPLICATION_JSON);
189 UriComponentsBuilder builder =
190 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
191 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
193 ResponseEntity<String> response =
194 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
196 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
197 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
200 /* VNF Resources Endpoint */
203 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
204 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
205 headers.set("Accept", MediaType.APPLICATION_JSON);
206 String expectedResponse =
207 "{\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}";
208 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
209 createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"));
211 ResponseEntity<String> response =
212 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
214 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
215 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
221 public void testGetVNFResources404() throws JSONException {
222 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
223 headers.set("Accept", MediaType.APPLICATION_JSON);
225 UriComponentsBuilder builder = UriComponentsBuilder
226 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"));
228 ResponseEntity<String> response =
229 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
231 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
236 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
237 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
238 headers.set("Accept", MediaType.APPLICATION_JSON);
240 UriComponentsBuilder builder =
241 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
242 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
244 ResponseEntity<String> response =
245 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
247 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
248 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
252 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
253 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
254 headers.set("Accept", MediaType.APPLICATION_JSON);
256 UriComponentsBuilder builder =
257 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
258 .queryParam("serviceModelUuid", serviceUUID);
260 ResponseEntity<String> response =
261 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
263 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
264 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
268 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
269 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
270 headers.set("Accept", MediaType.APPLICATION_JSON);
272 UriComponentsBuilder builder =
273 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
274 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
275 .queryParam("serviceModelVersion", "1.0");
277 ResponseEntity<String> response =
278 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
280 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
281 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
285 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
286 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
287 headers.set("Accept", MediaType.APPLICATION_JSON);
289 UriComponentsBuilder builder =
290 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
291 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
292 .queryParam("serviceModelVersion", "");
294 ResponseEntity<String> response =
295 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
297 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
298 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
303 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
304 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
305 headers.set("Accept", MediaType.APPLICATION_JSON);
307 UriComponentsBuilder builder =
308 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
309 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
311 ResponseEntity<String> response =
312 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
314 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
315 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
319 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
320 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
321 headers.set("Accept", MediaType.APPLICATION_JSON);
323 UriComponentsBuilder builder =
324 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
325 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
327 ResponseEntity<String> response =
328 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
330 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
331 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
335 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
336 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
337 headers.set("Accept", MediaType.APPLICATION_JSON);
339 UriComponentsBuilder builder = UriComponentsBuilder
340 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
341 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
343 ResponseEntity<String> response =
344 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
346 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
347 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
351 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
352 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
353 headers.set("Accept", MediaType.APPLICATION_JSON);
355 UriComponentsBuilder builder =
356 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
357 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service")
358 .queryParam("serviceModelVersion", "1.0");
360 ResponseEntity<String> response =
361 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
363 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
364 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
368 public void testSerfviceVNFResources404() throws JSONException {
369 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
370 headers.set("Accept", MediaType.APPLICATION_JSON);
372 UriComponentsBuilder builder =
373 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
374 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
376 ResponseEntity<String> response =
377 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
379 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
385 public void testSerfviceVNFBadParams() throws JSONException {
386 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
387 headers.set("Accept", MediaType.APPLICATION_JSON);
389 UriComponentsBuilder builder =
390 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
391 .queryParam("BadParamName", "BADNAME");
393 ResponseEntity<String> response =
394 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
395 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
396 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
403 /* Network Resources Endpoint */
406 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
407 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
408 headers.set("Accept", MediaType.APPLICATION_JSON);
409 String expectedResponse =
410 "{\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}";
411 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
412 createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"));
414 ResponseEntity<String> response =
415 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
417 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
418 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
424 public void testGetNetworkResources404() throws JSONException {
425 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
426 headers.set("Accept", MediaType.APPLICATION_JSON);
428 UriComponentsBuilder builder = UriComponentsBuilder
429 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"));
431 ResponseEntity<String> response =
432 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
434 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
438 /* Service Network Resources Endpoints */
441 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
442 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
443 headers.set("Accept", MediaType.APPLICATION_JSON);
445 UriComponentsBuilder builder =
446 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
447 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
449 ResponseEntity<String> response =
450 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
452 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
453 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
457 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
458 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
459 headers.set("Accept", MediaType.APPLICATION_JSON);
461 UriComponentsBuilder builder =
462 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
463 .queryParam("serviceModelUuid", serviceUUID);
465 ResponseEntity<String> response =
466 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
468 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
469 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
473 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
474 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
475 headers.set("Accept", MediaType.APPLICATION_JSON);
477 UriComponentsBuilder builder =
478 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
479 .queryParam("serviceModelUuid", "doesNotExist");
481 ResponseEntity<String> response =
482 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
484 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
489 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
490 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
491 headers.set("Accept", MediaType.APPLICATION_JSON);
493 UriComponentsBuilder builder =
494 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
495 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
497 ResponseEntity<String> response =
498 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
500 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
505 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
506 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
507 headers.set("Accept", MediaType.APPLICATION_JSON);
509 UriComponentsBuilder builder =
510 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
511 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
513 ResponseEntity<String> response =
514 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
516 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
517 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
521 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
522 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
523 headers.set("Accept", MediaType.APPLICATION_JSON);
525 UriComponentsBuilder builder = UriComponentsBuilder
526 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
527 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "2.0");
529 ResponseEntity<String> response =
530 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
532 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
533 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
537 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
538 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
539 headers.set("Accept", MediaType.APPLICATION_JSON);
541 UriComponentsBuilder builder = UriComponentsBuilder
542 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
543 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "");
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);
553 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
554 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
555 headers.set("Accept", MediaType.APPLICATION_JSON);
557 UriComponentsBuilder builder =
558 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
559 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
561 ResponseEntity<String> response =
562 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
564 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
565 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
569 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
570 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
571 headers.set("Accept", MediaType.APPLICATION_JSON);
573 UriComponentsBuilder builder =
574 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
575 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
577 ResponseEntity<String> response =
578 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
580 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
581 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
584 /* Allotted endpoints */
587 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
588 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
589 headers.set("Accept", MediaType.APPLICATION_JSON);
590 String expectedResponse =
591 "{\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}";
593 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
594 createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
597 ResponseEntity<String> response =
598 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
600 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
601 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
606 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
607 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
608 headers.set("Accept", MediaType.APPLICATION_JSON);
610 UriComponentsBuilder builder =
611 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
612 .queryParam("serviceModelUuid", serviceUUID);
614 ResponseEntity<String> response =
615 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
617 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
618 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
622 public void testResourceReceipe() throws JSONException {
623 String expectedResourceRecipe =
624 "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
626 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
627 headers.set("Accept", MediaType.APPLICATION_JSON);
629 UriComponentsBuilder builder =
630 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
631 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance");
633 ResponseEntity<String> response =
634 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
636 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
637 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
641 public void testResourceReceipeNotMatched() throws JSONException {
643 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
644 headers.set("Accept", MediaType.APPLICATION_JSON);
646 UriComponentsBuilder builder =
647 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
648 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action");
650 ResponseEntity<String> response =
651 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
653 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
657 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
658 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
659 headers.set("Accept", MediaType.APPLICATION_JSON);
661 UriComponentsBuilder builder =
662 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
663 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
665 ResponseEntity<String> response =
666 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
668 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
669 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
673 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
674 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
675 headers.set("Accept", MediaType.APPLICATION_JSON);
677 UriComponentsBuilder builder = UriComponentsBuilder
678 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
679 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
681 ResponseEntity<String> response =
682 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
684 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
685 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
689 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
690 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
691 headers.set("Accept", MediaType.APPLICATION_JSON);
693 UriComponentsBuilder builder = UriComponentsBuilder
694 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
695 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
697 ResponseEntity<String> response =
698 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
700 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
701 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
705 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
706 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
707 headers.set("Accept", MediaType.APPLICATION_JSON);
709 UriComponentsBuilder builder =
710 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
711 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
713 ResponseEntity<String> response =
714 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
716 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
717 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
722 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
723 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
724 headers.set("Accept", MediaType.APPLICATION_JSON);
726 UriComponentsBuilder builder =
727 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
728 .queryParam("arModelCustomizationUuid", "NOTEXIST");
730 ResponseEntity<String> response =
731 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
733 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
737 /* VF Modules Endpoint */
740 public void testGetVFModulesNonExistResource() throws JSONException {
741 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
742 headers.set("Accept", MediaType.APPLICATION_JSON);
744 UriComponentsBuilder builder =
745 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
746 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
748 ResponseEntity<String> response =
749 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
751 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
756 public void testGetVFModulesByVfModuleModelName() throws JSONException {
757 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
758 headers.set("Accept", MediaType.APPLICATION_JSON);
759 String expectedResponse =
760 "{\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}";
761 UriComponentsBuilder builder =
762 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
763 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
765 ResponseEntity<String> response =
766 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
768 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
769 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
774 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
775 TestAppender.events.clear();
776 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
777 headers.set("Accept", MediaType.APPLICATION_JSON);
779 UriComponentsBuilder builder = UriComponentsBuilder
780 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)).queryParam("ADASD", "NEUTRON_BASIC");
782 ResponseEntity<String> response =
783 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
785 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
786 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
790 public void testCreateServiceRecipe() throws JSONException {
791 ServiceRecipe recipe = new ServiceRecipe();
792 recipe.setAction("action");
793 recipe.setDescription("description");
794 recipe.setOrchestrationUri("http://test");
795 recipe.setRecipeTimeout(120);
796 recipe.setServiceModelUUID(serviceUUID);
797 HttpEntity<ServiceRecipe> entity = new HttpEntity<ServiceRecipe>(recipe, headers);
798 headers.set("Accept", MediaType.APPLICATION_JSON);
800 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(SERVICE_RECIPE));
802 ResponseEntity<String> response =
803 restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
805 assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
808 private String createURLWithPort(String uri) {
809 return "http://localhost:" + port + uri;