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.ProcessingFlags;
31 import org.onap.so.db.catalog.beans.ServiceRecipe;
32 import org.skyscreamer.jsonassert.JSONAssert;
33 import org.skyscreamer.jsonassert.JSONCompareMode;
34 import org.springframework.boot.test.web.client.TestRestTemplate;
35 import org.springframework.http.HttpEntity;
36 import org.springframework.http.HttpHeaders;
37 import org.springframework.http.HttpMethod;
38 import org.springframework.http.ResponseEntity;
39 import org.springframework.web.util.UriComponentsBuilder;
40 import com.fasterxml.jackson.databind.ObjectMapper;
43 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
45 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
47 private static final String SERVICE_RECIPE = "serviceRecipe";
49 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
50 "ecomp/mso/catalog/v2/serviceAllottedResources";
52 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
54 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
56 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
58 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
60 private static final String ECOMP_MSO_CATALOG_PROCESSING_FLAGS = "ecomp/mso/catalog/v2/processingFlags";
62 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
64 HttpHeaders headers = new HttpHeaders();
66 private final String expectedServiceResourceResponse =
67 "{\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}";
69 private final String expectedServiceResourceResponsev2 =
70 "{\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}";
73 private final String expectedServiceVnfResponse =
74 "{\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}";
76 private final String expectedServiceVnfResponseV3 =
77 "{\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}";
79 private final String expectedServiceNetworkResourceResponse =
80 "{\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}";
82 private final String badQueryParamResponse =
83 "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
85 private final String expectedAllottedResponse =
86 "{\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}";
88 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
90 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
92 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
94 /* Health Check Resources Endpoint */
97 public void testHealthcheck() throws JSONException {
99 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
101 ResponseEntity<String> response =
102 restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
104 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
107 /* Service Resources Endpoint */
110 public void testGetServiceModelUUID() throws JSONException {
111 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
112 headers.set("Accept", MediaType.APPLICATION_JSON);
114 UriComponentsBuilder builder =
115 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
116 .queryParam("serviceModelUuid", serviceUUID);
118 ResponseEntity<String> response =
119 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
121 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
122 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(),
123 JSONCompareMode.LENIENT);
127 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
128 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
129 headers.set("Accept", MediaType.APPLICATION_JSON);
130 UriComponentsBuilder builder =
131 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
132 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
133 .queryParam("serviceModelVersion", "1.0");
135 ResponseEntity<String> response =
136 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
138 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
139 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
143 public void testGetServiceInvariantUUID() throws JSONException {
144 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
145 headers.set("Accept", MediaType.APPLICATION_JSON);
146 UriComponentsBuilder builder =
147 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
148 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
150 ResponseEntity<String> response =
151 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
153 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
154 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
158 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
159 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
160 headers.set("Accept", MediaType.APPLICATION_JSON);
161 UriComponentsBuilder builder =
162 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
163 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
164 .queryParam("serviceModelVersion", "");;
166 ResponseEntity<String> response =
167 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
169 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
170 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
174 public void testGetServiceModelUUID404() throws JSONException {
175 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
176 headers.set("Accept", MediaType.APPLICATION_JSON);
177 String expectedResponse = "\"serviceResources\": null";
178 UriComponentsBuilder builder =
179 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
180 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
182 ResponseEntity<String> response =
183 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
185 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
186 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
190 public void testGetServiceBadQueryParams() throws JSONException {
191 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
192 headers.set("Accept", MediaType.APPLICATION_JSON);
193 UriComponentsBuilder builder =
194 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
195 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
197 ResponseEntity<String> response =
198 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
200 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
201 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
204 /* VNF Resources Endpoint */
207 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
208 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
209 headers.set("Accept", MediaType.APPLICATION_JSON);
210 String expectedResponse =
211 "{\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}";
212 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
213 createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"));
215 ResponseEntity<String> response =
216 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
218 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
219 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
225 public void testGetVNFResources404() throws JSONException {
226 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
227 headers.set("Accept", MediaType.APPLICATION_JSON);
229 UriComponentsBuilder builder = UriComponentsBuilder
230 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"));
232 ResponseEntity<String> response =
233 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
235 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
240 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
241 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
242 headers.set("Accept", MediaType.APPLICATION_JSON);
244 UriComponentsBuilder builder =
245 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
246 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
248 ResponseEntity<String> response =
249 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
251 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
252 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
256 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
257 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
258 headers.set("Accept", MediaType.APPLICATION_JSON);
260 UriComponentsBuilder builder =
261 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
262 .queryParam("serviceModelUuid", serviceUUID);
264 ResponseEntity<String> response =
265 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
267 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
268 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
272 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
273 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
274 headers.set("Accept", MediaType.APPLICATION_JSON);
276 UriComponentsBuilder builder =
277 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
278 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
279 .queryParam("serviceModelVersion", "1.0");
281 ResponseEntity<String> response =
282 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
284 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
285 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
289 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
290 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
291 headers.set("Accept", MediaType.APPLICATION_JSON);
293 UriComponentsBuilder builder =
294 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
295 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
296 .queryParam("serviceModelVersion", "");
298 ResponseEntity<String> response =
299 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
301 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
302 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
307 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
308 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
309 headers.set("Accept", MediaType.APPLICATION_JSON);
311 UriComponentsBuilder builder =
312 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
313 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
315 ResponseEntity<String> response =
316 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
318 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
319 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
323 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
324 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
325 headers.set("Accept", MediaType.APPLICATION_JSON);
327 UriComponentsBuilder builder =
328 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
329 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
331 ResponseEntity<String> response =
332 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
334 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
335 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
339 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
340 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
341 headers.set("Accept", MediaType.APPLICATION_JSON);
343 UriComponentsBuilder builder = UriComponentsBuilder
344 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
345 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
347 ResponseEntity<String> response =
348 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
350 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
351 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
355 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
356 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
357 headers.set("Accept", MediaType.APPLICATION_JSON);
359 UriComponentsBuilder builder =
360 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
361 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service")
362 .queryParam("serviceModelVersion", "1.0");
364 ResponseEntity<String> response =
365 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
367 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
368 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
372 public void testSerfviceVNFResources404() throws JSONException {
373 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
374 headers.set("Accept", MediaType.APPLICATION_JSON);
376 UriComponentsBuilder builder =
377 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
378 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
380 ResponseEntity<String> response =
381 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
383 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
389 public void testSerfviceVNFBadParams() throws JSONException {
390 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
391 headers.set("Accept", MediaType.APPLICATION_JSON);
393 UriComponentsBuilder builder =
394 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
395 .queryParam("BadParamName", "BADNAME");
397 ResponseEntity<String> response =
398 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
399 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
400 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
407 /* Network Resources Endpoint */
410 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
411 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
412 headers.set("Accept", MediaType.APPLICATION_JSON);
413 String expectedResponse =
414 "{\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}";
415 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
416 createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"));
418 ResponseEntity<String> response =
419 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
421 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
422 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
428 public void testGetNetworkResources404() throws JSONException {
429 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
430 headers.set("Accept", MediaType.APPLICATION_JSON);
432 UriComponentsBuilder builder = UriComponentsBuilder
433 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"));
435 ResponseEntity<String> response =
436 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
438 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
442 /* Service Network Resources Endpoints */
445 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
446 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
447 headers.set("Accept", MediaType.APPLICATION_JSON);
449 UriComponentsBuilder builder =
450 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
451 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
453 ResponseEntity<String> response =
454 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
456 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
457 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
461 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
462 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
463 headers.set("Accept", MediaType.APPLICATION_JSON);
465 UriComponentsBuilder builder =
466 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
467 .queryParam("serviceModelUuid", serviceUUID);
469 ResponseEntity<String> response =
470 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
472 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
473 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
477 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
478 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
479 headers.set("Accept", MediaType.APPLICATION_JSON);
481 UriComponentsBuilder builder =
482 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
483 .queryParam("serviceModelUuid", "doesNotExist");
485 ResponseEntity<String> response =
486 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
488 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
493 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
494 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
495 headers.set("Accept", MediaType.APPLICATION_JSON);
497 UriComponentsBuilder builder =
498 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
499 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
501 ResponseEntity<String> response =
502 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
504 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
509 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
510 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
511 headers.set("Accept", MediaType.APPLICATION_JSON);
513 UriComponentsBuilder builder =
514 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
515 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
517 ResponseEntity<String> response =
518 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
520 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
521 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
525 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
526 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
527 headers.set("Accept", MediaType.APPLICATION_JSON);
529 UriComponentsBuilder builder = UriComponentsBuilder
530 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
531 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "2.0");
533 ResponseEntity<String> response =
534 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
536 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
537 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
541 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
542 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
543 headers.set("Accept", MediaType.APPLICATION_JSON);
545 UriComponentsBuilder builder = UriComponentsBuilder
546 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
547 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "");
548 ResponseEntity<String> response =
549 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
551 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
552 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
557 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
558 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
559 headers.set("Accept", MediaType.APPLICATION_JSON);
561 UriComponentsBuilder builder =
562 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
563 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
565 ResponseEntity<String> response =
566 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
568 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
569 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
573 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
574 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
575 headers.set("Accept", MediaType.APPLICATION_JSON);
577 UriComponentsBuilder builder =
578 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
579 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
581 ResponseEntity<String> response =
582 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
584 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
585 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
588 /* Allotted endpoints */
591 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
592 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
593 headers.set("Accept", MediaType.APPLICATION_JSON);
594 String expectedResponse =
595 "{\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}";
597 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
598 createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
601 ResponseEntity<String> response =
602 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
604 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
605 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
610 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
611 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
612 headers.set("Accept", MediaType.APPLICATION_JSON);
614 UriComponentsBuilder builder =
615 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
616 .queryParam("serviceModelUuid", serviceUUID);
618 ResponseEntity<String> response =
619 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
621 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
622 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
626 public void testResourceReceipe() throws JSONException {
627 String expectedResourceRecipe =
628 "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
630 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
631 headers.set("Accept", MediaType.APPLICATION_JSON);
633 UriComponentsBuilder builder =
634 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
635 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance");
637 ResponseEntity<String> response =
638 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
640 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
641 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
645 public void testResourceReceipeNotMatched() throws JSONException {
647 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
648 headers.set("Accept", MediaType.APPLICATION_JSON);
650 UriComponentsBuilder builder =
651 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
652 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action");
654 ResponseEntity<String> response =
655 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
657 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
661 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
662 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
663 headers.set("Accept", MediaType.APPLICATION_JSON);
665 UriComponentsBuilder builder =
666 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
667 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
669 ResponseEntity<String> response =
670 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
672 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
673 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
677 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
678 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
679 headers.set("Accept", MediaType.APPLICATION_JSON);
681 UriComponentsBuilder builder = UriComponentsBuilder
682 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
683 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
685 ResponseEntity<String> response =
686 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
688 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
689 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
693 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
694 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
695 headers.set("Accept", MediaType.APPLICATION_JSON);
697 UriComponentsBuilder builder = UriComponentsBuilder
698 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
699 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
701 ResponseEntity<String> response =
702 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
704 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
705 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
709 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
710 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
711 headers.set("Accept", MediaType.APPLICATION_JSON);
713 UriComponentsBuilder builder =
714 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
715 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
717 ResponseEntity<String> response =
718 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
720 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
721 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
726 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
727 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
728 headers.set("Accept", MediaType.APPLICATION_JSON);
730 UriComponentsBuilder builder =
731 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
732 .queryParam("arModelCustomizationUuid", "NOTEXIST");
734 ResponseEntity<String> response =
735 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
737 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
741 /* VF Modules Endpoint */
744 public void testGetVFModulesNonExistResource() throws JSONException {
745 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
746 headers.set("Accept", MediaType.APPLICATION_JSON);
748 UriComponentsBuilder builder =
749 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
750 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
752 ResponseEntity<String> response =
753 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
755 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
760 public void testGetVFModulesByVfModuleModelName() throws JSONException {
761 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
762 headers.set("Accept", MediaType.APPLICATION_JSON);
763 String expectedResponse =
764 "{\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}";
765 UriComponentsBuilder builder =
766 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
767 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
769 ResponseEntity<String> response =
770 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
772 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
773 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
778 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
779 TestAppender.events.clear();
780 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
781 headers.set("Accept", MediaType.APPLICATION_JSON);
783 UriComponentsBuilder builder = UriComponentsBuilder
784 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)).queryParam("ADASD", "NEUTRON_BASIC");
786 ResponseEntity<String> response =
787 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
789 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
790 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
794 public void testCreateServiceRecipe() throws JSONException {
795 ServiceRecipe recipe = new ServiceRecipe();
796 recipe.setAction("action");
797 recipe.setDescription("description");
798 recipe.setOrchestrationUri("http://test");
799 recipe.setRecipeTimeout(120);
800 recipe.setServiceModelUUID(serviceUUID);
801 HttpEntity<ServiceRecipe> entity = new HttpEntity<ServiceRecipe>(recipe, headers);
802 headers.set("Accept", MediaType.APPLICATION_JSON);
804 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(SERVICE_RECIPE));
806 ResponseEntity<String> response =
807 restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
809 assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
813 public void testGetProcessingFlagsByFlag() throws Exception {
814 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
815 headers.set("Accept", MediaType.APPLICATION_JSON);
817 UriComponentsBuilder builder = UriComponentsBuilder
818 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
820 ResponseEntity<String> response =
821 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
823 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
824 ObjectMapper mapper = new ObjectMapper();
825 ProcessingFlags processingFlagsResponse = mapper.readValue(response.getBody(), ProcessingFlags.class);
827 assertEquals(processingFlagsResponse.getFlag(), "TESTFLAG");
828 assertEquals(processingFlagsResponse.getValue(), "NO");
829 assertEquals(processingFlagsResponse.getEndpoint(), "TESTENDPOINT");
830 assertEquals(processingFlagsResponse.getDescription(), "TEST FLAG");
834 public void testSetProcessingFlagsFlagValue() throws JSONException {
835 ProcessingFlags updatedProcessingFlag = new ProcessingFlags();
836 updatedProcessingFlag.setFlag("TESTFLAG");
837 updatedProcessingFlag.setValue("YES");
838 HttpEntity<ProcessingFlags> entity = new HttpEntity<ProcessingFlags>(updatedProcessingFlag, headers);
839 headers.set("Accept", MediaType.APPLICATION_JSON);
841 UriComponentsBuilder builder = UriComponentsBuilder
842 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
844 ResponseEntity<String> response =
845 restTemplate.exchange(builder.toUriString(), HttpMethod.PUT, entity, String.class);
847 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
850 private String createURLWithPort(String uri) {
851 return "http://localhost:" + port + uri;