2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertTrue;
25 import java.io.IOException;
26 import java.util.List;
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
29 import org.json.JSONException;
30 import org.junit.Test;
31 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
32 import org.onap.so.db.catalog.beans.ProcessingFlags;
33 import org.onap.so.db.catalog.beans.ServiceRecipe;
34 import org.skyscreamer.jsonassert.JSONAssert;
35 import org.skyscreamer.jsonassert.JSONCompareMode;
36 import org.springframework.boot.test.web.client.TestRestTemplate;
37 import org.springframework.http.HttpEntity;
38 import org.springframework.http.HttpHeaders;
39 import org.springframework.http.HttpMethod;
40 import org.springframework.http.ResponseEntity;
41 import org.springframework.web.util.UriComponentsBuilder;
42 import com.fasterxml.jackson.core.type.TypeReference;
43 import com.fasterxml.jackson.databind.ObjectMapper;
46 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
48 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
50 private static final String SERVICE_RECIPE = "serviceRecipe";
52 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
53 "ecomp/mso/catalog/v2/serviceAllottedResources";
55 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
57 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
59 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
61 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
63 private static final String ECOMP_MSO_CATALOG_PROCESSING_FLAGS = "ecomp/mso/catalog/v2/processingFlags";
65 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
67 HttpHeaders headers = new HttpHeaders();
69 private final String expectedServiceResourceResponse =
70 "{\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}";
72 private final String expectedServiceResourceResponsev2 =
73 "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}";
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 serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
93 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
95 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
97 /* Health Check Resources Endpoint */
100 public void testHealthcheck() throws JSONException {
102 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
104 ResponseEntity<String> response =
105 restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
107 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
110 /* Service Resources Endpoint */
113 public void testGetServiceModelUUID() throws JSONException {
114 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
115 headers.set("Accept", MediaType.APPLICATION_JSON);
117 UriComponentsBuilder builder =
118 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
119 .queryParam("serviceModelUuid", serviceUUID);
121 ResponseEntity<String> response =
122 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
124 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
125 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(),
126 JSONCompareMode.LENIENT);
130 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
131 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
132 headers.set("Accept", MediaType.APPLICATION_JSON);
133 UriComponentsBuilder builder =
134 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
135 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
136 .queryParam("serviceModelVersion", "1.0");
138 ResponseEntity<String> response =
139 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
141 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
142 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
146 public void testGetServiceInvariantUUID() throws JSONException {
147 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
148 headers.set("Accept", MediaType.APPLICATION_JSON);
149 UriComponentsBuilder builder =
150 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
151 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
153 ResponseEntity<String> response =
154 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
156 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
157 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
161 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
162 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
163 headers.set("Accept", MediaType.APPLICATION_JSON);
164 UriComponentsBuilder builder =
165 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
166 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
167 .queryParam("serviceModelVersion", "");;
169 ResponseEntity<String> response =
170 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
172 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
173 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
177 public void testGetServiceModelUUID404() throws JSONException {
178 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
179 headers.set("Accept", MediaType.APPLICATION_JSON);
180 String expectedResponse = "\"serviceResources\": null";
181 UriComponentsBuilder builder =
182 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
183 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
185 ResponseEntity<String> response =
186 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
188 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
189 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
193 public void testGetServiceBadQueryParams() throws JSONException {
194 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
195 headers.set("Accept", MediaType.APPLICATION_JSON);
196 UriComponentsBuilder builder =
197 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
198 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
200 ResponseEntity<String> response =
201 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
203 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
204 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
207 /* VNF Resources Endpoint */
210 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
211 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
212 headers.set("Accept", MediaType.APPLICATION_JSON);
213 String expectedResponse =
214 "{\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}";
215 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
216 createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"));
218 ResponseEntity<String> response =
219 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
221 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
222 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
228 public void testGetVNFResources404() throws JSONException {
229 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
230 headers.set("Accept", MediaType.APPLICATION_JSON);
232 UriComponentsBuilder builder = UriComponentsBuilder
233 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"));
235 ResponseEntity<String> response =
236 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
238 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
243 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
244 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
245 headers.set("Accept", MediaType.APPLICATION_JSON);
247 UriComponentsBuilder builder =
248 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
249 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
251 ResponseEntity<String> response =
252 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
254 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
255 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
259 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
260 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
261 headers.set("Accept", MediaType.APPLICATION_JSON);
263 UriComponentsBuilder builder =
264 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
265 .queryParam("serviceModelUuid", serviceUUID);
267 ResponseEntity<String> response =
268 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
270 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
271 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
275 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
276 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
277 headers.set("Accept", MediaType.APPLICATION_JSON);
279 UriComponentsBuilder builder =
280 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
281 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
282 .queryParam("serviceModelVersion", "1.0");
284 ResponseEntity<String> response =
285 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
287 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
288 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
292 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
293 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
294 headers.set("Accept", MediaType.APPLICATION_JSON);
296 UriComponentsBuilder builder =
297 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
298 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
299 .queryParam("serviceModelVersion", "");
301 ResponseEntity<String> response =
302 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
304 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
305 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
310 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
311 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
312 headers.set("Accept", MediaType.APPLICATION_JSON);
314 UriComponentsBuilder builder =
315 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
316 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
318 ResponseEntity<String> response =
319 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
321 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
322 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
326 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
327 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
328 headers.set("Accept", MediaType.APPLICATION_JSON);
330 UriComponentsBuilder builder =
331 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
332 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
334 ResponseEntity<String> response =
335 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
337 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
338 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
342 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
343 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
344 headers.set("Accept", MediaType.APPLICATION_JSON);
346 UriComponentsBuilder builder = UriComponentsBuilder
347 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
348 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
350 ResponseEntity<String> response =
351 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
353 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
354 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
358 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
359 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
360 headers.set("Accept", MediaType.APPLICATION_JSON);
362 UriComponentsBuilder builder =
363 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
364 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service")
365 .queryParam("serviceModelVersion", "1.0");
367 ResponseEntity<String> response =
368 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
370 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
371 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
375 public void testSerfviceVNFResources404() throws JSONException {
376 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
377 headers.set("Accept", MediaType.APPLICATION_JSON);
379 UriComponentsBuilder builder =
380 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
381 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
383 ResponseEntity<String> response =
384 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
386 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
392 public void testSerfviceVNFBadParams() throws JSONException {
393 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
394 headers.set("Accept", MediaType.APPLICATION_JSON);
396 UriComponentsBuilder builder =
397 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
398 .queryParam("BadParamName", "BADNAME");
400 ResponseEntity<String> response =
401 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
402 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
403 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
410 /* Network Resources Endpoint */
413 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
414 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
415 headers.set("Accept", MediaType.APPLICATION_JSON);
416 String expectedResponse =
417 "{\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}";
418 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
419 createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"));
421 ResponseEntity<String> response =
422 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
424 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
425 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
431 public void testGetNetworkResources404() throws JSONException {
432 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
433 headers.set("Accept", MediaType.APPLICATION_JSON);
435 UriComponentsBuilder builder = UriComponentsBuilder
436 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"));
438 ResponseEntity<String> response =
439 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
441 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
445 /* Service Network Resources Endpoints */
448 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
449 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
450 headers.set("Accept", MediaType.APPLICATION_JSON);
452 UriComponentsBuilder builder =
453 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
454 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
456 ResponseEntity<String> response =
457 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
459 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
460 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
464 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
465 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
466 headers.set("Accept", MediaType.APPLICATION_JSON);
468 UriComponentsBuilder builder =
469 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
470 .queryParam("serviceModelUuid", serviceUUID);
472 ResponseEntity<String> response =
473 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
475 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
476 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
480 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
481 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
482 headers.set("Accept", MediaType.APPLICATION_JSON);
484 UriComponentsBuilder builder =
485 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
486 .queryParam("serviceModelUuid", "doesNotExist");
488 ResponseEntity<String> response =
489 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
491 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
496 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
497 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
498 headers.set("Accept", MediaType.APPLICATION_JSON);
500 UriComponentsBuilder builder =
501 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
502 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
504 ResponseEntity<String> response =
505 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
507 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
512 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
513 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
514 headers.set("Accept", MediaType.APPLICATION_JSON);
516 UriComponentsBuilder builder =
517 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
518 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
520 ResponseEntity<String> response =
521 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
523 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
524 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
528 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
529 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
530 headers.set("Accept", MediaType.APPLICATION_JSON);
532 UriComponentsBuilder builder = UriComponentsBuilder
533 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
534 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "2.0");
536 ResponseEntity<String> response =
537 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
539 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
540 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
544 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
545 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
546 headers.set("Accept", MediaType.APPLICATION_JSON);
548 UriComponentsBuilder builder = UriComponentsBuilder
549 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
550 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "");
551 ResponseEntity<String> response =
552 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
554 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
555 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
560 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
561 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
562 headers.set("Accept", MediaType.APPLICATION_JSON);
564 UriComponentsBuilder builder =
565 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
566 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
568 ResponseEntity<String> response =
569 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
571 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
572 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
576 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
577 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
578 headers.set("Accept", MediaType.APPLICATION_JSON);
580 UriComponentsBuilder builder =
581 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
582 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
584 ResponseEntity<String> response =
585 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
587 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
588 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
591 /* Allotted endpoints */
594 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
595 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
596 headers.set("Accept", MediaType.APPLICATION_JSON);
597 String expectedResponse =
598 "{\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}";
600 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
601 createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
604 ResponseEntity<String> response =
605 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
607 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
608 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
613 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
614 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
615 headers.set("Accept", MediaType.APPLICATION_JSON);
617 UriComponentsBuilder builder =
618 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
619 .queryParam("serviceModelUuid", serviceUUID);
621 ResponseEntity<String> response =
622 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
624 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
625 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
629 public void testResourceReceipe() throws JSONException {
630 String expectedResourceRecipe =
631 "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
633 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
634 headers.set("Accept", MediaType.APPLICATION_JSON);
636 UriComponentsBuilder builder =
637 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
638 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance");
640 ResponseEntity<String> response =
641 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
643 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
644 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
648 public void testResourceReceipeNotMatched() throws JSONException {
650 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
651 headers.set("Accept", MediaType.APPLICATION_JSON);
653 UriComponentsBuilder builder =
654 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
655 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action");
657 ResponseEntity<String> response =
658 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
660 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
664 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
665 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
666 headers.set("Accept", MediaType.APPLICATION_JSON);
668 UriComponentsBuilder builder =
669 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
670 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
672 ResponseEntity<String> response =
673 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
675 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
676 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
680 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
681 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
682 headers.set("Accept", MediaType.APPLICATION_JSON);
684 UriComponentsBuilder builder = UriComponentsBuilder
685 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
686 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
688 ResponseEntity<String> response =
689 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
691 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
692 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
696 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
697 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
698 headers.set("Accept", MediaType.APPLICATION_JSON);
700 UriComponentsBuilder builder = UriComponentsBuilder
701 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
702 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
704 ResponseEntity<String> response =
705 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
707 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
708 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
712 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
713 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
714 headers.set("Accept", MediaType.APPLICATION_JSON);
716 UriComponentsBuilder builder =
717 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
718 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
720 ResponseEntity<String> response =
721 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
723 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
724 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
729 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
730 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
731 headers.set("Accept", MediaType.APPLICATION_JSON);
733 UriComponentsBuilder builder =
734 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
735 .queryParam("arModelCustomizationUuid", "NOTEXIST");
737 ResponseEntity<String> response =
738 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
740 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
744 /* VF Modules Endpoint */
747 public void testGetVFModulesNonExistResource() throws JSONException {
748 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
749 headers.set("Accept", MediaType.APPLICATION_JSON);
751 UriComponentsBuilder builder =
752 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
753 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
755 ResponseEntity<String> response =
756 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
758 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
763 public void testGetVFModulesByVfModuleModelName() throws JSONException {
764 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
765 headers.set("Accept", MediaType.APPLICATION_JSON);
766 String expectedResponse =
767 "{\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}";
768 UriComponentsBuilder builder =
769 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
770 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
772 ResponseEntity<String> response =
773 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
775 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
776 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
781 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
782 TestAppender.events.clear();
783 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
784 headers.set("Accept", MediaType.APPLICATION_JSON);
786 UriComponentsBuilder builder = UriComponentsBuilder
787 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)).queryParam("ADASD", "NEUTRON_BASIC");
789 ResponseEntity<String> response =
790 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
792 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
793 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
797 public void testCreateServiceRecipe() throws JSONException {
798 ServiceRecipe recipe = new ServiceRecipe();
799 recipe.setAction("action");
800 recipe.setDescription("description");
801 recipe.setOrchestrationUri("http://test");
802 recipe.setRecipeTimeout(120);
803 recipe.setServiceModelUUID(serviceUUID);
804 HttpEntity<ServiceRecipe> entity = new HttpEntity<ServiceRecipe>(recipe, headers);
805 headers.set("Accept", MediaType.APPLICATION_JSON);
807 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(SERVICE_RECIPE));
809 ResponseEntity<String> response =
810 restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
812 assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
816 public void testGetProcessingFlagsByFlag() throws Exception {
817 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
818 headers.set("Accept", MediaType.APPLICATION_JSON);
820 UriComponentsBuilder builder = UriComponentsBuilder
821 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
823 ResponseEntity<String> response =
824 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
826 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
827 ObjectMapper mapper = new ObjectMapper();
828 ProcessingFlags processingFlagsResponse = mapper.readValue(response.getBody(), ProcessingFlags.class);
830 assertEquals(processingFlagsResponse.getFlag(), "TESTFLAG");
831 assertEquals(processingFlagsResponse.getValue(), "NO");
832 assertEquals(processingFlagsResponse.getEndpoint(), "TESTENDPOINT");
833 assertEquals(processingFlagsResponse.getDescription(), "TEST FLAG");
837 public void testGetAllProcessingFlags() throws Exception {
838 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
839 headers.set("Accept", MediaType.APPLICATION_JSON);
841 UriComponentsBuilder builder =
842 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS));
844 ResponseEntity<String> response =
845 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
847 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
848 ObjectMapper mapper = new ObjectMapper();
850 List<ProcessingFlags> processingFlagsResponse =
851 mapper.readValue(response.getBody(), new TypeReference<List<ProcessingFlags>>() {});
853 boolean testFlagFound = false;
854 for (int i = 0; i < processingFlagsResponse.size(); i++) {
855 if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) {
856 assertEquals(processingFlagsResponse.get(i).getEndpoint(), "TESTENDPOINT");
857 assertEquals(processingFlagsResponse.get(i).getDescription(), "TEST FLAG");
858 testFlagFound = true;
861 assertTrue(testFlagFound);
865 public void testSetProcessingFlagsFlagValue() throws JSONException {
866 ProcessingFlags updatedProcessingFlag = new ProcessingFlags();
867 updatedProcessingFlag.setFlag("TESTFLAG");
868 updatedProcessingFlag.setValue("YES");
869 HttpEntity<ProcessingFlags> entity = new HttpEntity<ProcessingFlags>(updatedProcessingFlag, headers);
870 headers.set("Accept", MediaType.APPLICATION_JSON);
872 UriComponentsBuilder builder = UriComponentsBuilder
873 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
875 ResponseEntity<String> response =
876 restTemplate.exchange(builder.toUriString(), HttpMethod.PUT, entity, String.class);
878 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
881 private String createURLWithPort(String uri) {
882 return "http://localhost:" + port + uri;