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.*;
26 import java.io.IOException;
28 import javax.ws.rs.core.MediaType;
29 import javax.ws.rs.core.Response;
32 import org.json.JSONException;
33 import org.junit.Before;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
39 import org.onap.so.logger.MsoLogger;
40 import org.skyscreamer.jsonassert.JSONAssert;
41 import org.skyscreamer.jsonassert.JSONCompareMode;
42 import org.springframework.boot.context.embedded.LocalServerPort;
43 import org.springframework.boot.test.context.SpringBootTest;
44 import org.springframework.boot.test.web.client.TestRestTemplate;
45 import org.springframework.http.HttpEntity;
46 import org.springframework.http.HttpHeaders;
47 import org.springframework.http.HttpMethod;
48 import org.springframework.http.ResponseEntity;
49 import org.springframework.test.annotation.DirtiesContext;
50 import org.springframework.test.annotation.DirtiesContext.ClassMode;
51 import org.springframework.test.context.ActiveProfiles;
52 import org.springframework.test.context.junit4.SpringRunner;
53 import org.springframework.web.util.UriComponentsBuilder;
55 import ch.qos.logback.classic.spi.ILoggingEvent;
58 @RunWith(SpringRunner.class)
59 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
60 @ActiveProfiles("test")
62 public class CatalogDBRestTest {
64 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
66 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources";
68 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
70 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
72 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
77 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
79 HttpHeaders headers = new HttpHeaders();
81 private final String expectedServiceResourceResponse = "{\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}";
83 private final String expectedServiceResourceResponsev2 = "{\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}";
86 private final String expectedServiceVnfResponse = "{\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}";
88 private final String expectedServiceVnfResponseV3 = "{\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}";
90 private final String expectedServiceNetworkResourceResponse = "{\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}";
92 private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
94 private final String expectedAllottedResponse = "{\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}";
96 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
98 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
100 /* Health Check Resources Endpoint */
103 public void testHealthcheck() throws JSONException {
105 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
107 ResponseEntity<String> response = restTemplate.exchange(
108 createURLWithPort("/manage/health"),
109 HttpMethod.GET, entity, String.class);
111 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
114 /* Service Resources Endpoint */
117 public void testGetServiceModelUUID() throws JSONException {
118 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
119 headers.set("Accept", MediaType.APPLICATION_JSON);
121 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
122 .queryParam("serviceModelUuid", serviceUUID);
124 ResponseEntity<String> response = restTemplate.exchange(
125 builder.toUriString(),
126 HttpMethod.GET, entity, String.class);
128 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
129 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
133 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
134 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
135 headers.set("Accept", MediaType.APPLICATION_JSON);
136 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
137 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
139 ResponseEntity<String> response = restTemplate.exchange(
140 builder.toUriString(),
141 HttpMethod.GET, entity, String.class);
143 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
144 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
148 public void testGetServiceInvariantUUID() throws JSONException {
149 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
150 headers.set("Accept", MediaType.APPLICATION_JSON);
151 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
152 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
154 ResponseEntity<String> response = restTemplate.exchange(
155 builder.toUriString(),
156 HttpMethod.GET, entity, String.class);
158 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
159 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
163 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
164 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
165 headers.set("Accept", MediaType.APPLICATION_JSON);
166 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
167 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
169 ResponseEntity<String> response = restTemplate.exchange(
170 builder.toUriString(),
171 HttpMethod.GET, entity, String.class);
173 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
174 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
178 public void testGetServiceModelUUID404() throws JSONException {
179 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
180 headers.set("Accept", MediaType.APPLICATION_JSON);
181 String expectedResponse = "\"serviceResources\": null";
182 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
183 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
185 ResponseEntity<String> response = restTemplate.exchange(
186 builder.toUriString(),
187 HttpMethod.GET, entity, String.class);
189 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
190 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
194 public void testGetServiceBadQueryParams() throws JSONException {
195 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
196 headers.set("Accept", MediaType.APPLICATION_JSON);
197 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
198 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
200 ResponseEntity<String> response = restTemplate.exchange(
201 builder.toUriString(),
202 HttpMethod.GET, entity, String.class);
204 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
205 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
208 /* VNF Resources Endpoint */
211 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
212 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
213 headers.set("Accept", MediaType.APPLICATION_JSON);
214 String expectedResponse = "{\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(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
218 ResponseEntity<String> response = restTemplate.exchange(
219 builder.toUriString(),
220 HttpMethod.GET, entity, String.class);
222 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
223 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
229 public void testGetVNFResources404() throws JSONException {
230 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
231 headers.set("Accept", MediaType.APPLICATION_JSON);
233 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
236 ResponseEntity<String> response = restTemplate.exchange(
237 builder.toUriString(),
238 HttpMethod.GET, entity, String.class);
240 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
245 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
246 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
247 headers.set("Accept", MediaType.APPLICATION_JSON);
249 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
250 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
252 ResponseEntity<String> response = restTemplate.exchange(
253 builder.toUriString(),
254 HttpMethod.GET, entity, String.class);
256 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
257 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
261 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
262 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
263 headers.set("Accept", MediaType.APPLICATION_JSON);
265 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
266 .queryParam("serviceModelUuid", serviceUUID);
268 ResponseEntity<String> response = restTemplate.exchange(
269 builder.toUriString(),
270 HttpMethod.GET, entity, String.class);
272 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
273 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
277 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
278 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
279 headers.set("Accept", MediaType.APPLICATION_JSON);
281 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
282 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
283 .queryParam("serviceModelVersion", "1.0");
285 ResponseEntity<String> response = restTemplate.exchange(
286 builder.toUriString(),
287 HttpMethod.GET, entity, String.class);
289 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
290 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
294 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
295 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
296 headers.set("Accept", MediaType.APPLICATION_JSON);
298 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
299 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
300 .queryParam("serviceModelVersion", "");
302 ResponseEntity<String> response = restTemplate.exchange(
303 builder.toUriString(),
304 HttpMethod.GET, entity, String.class);
306 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
307 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
312 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
313 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
314 headers.set("Accept", MediaType.APPLICATION_JSON);
316 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
317 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
319 ResponseEntity<String> response = restTemplate.exchange(
320 builder.toUriString(),
321 HttpMethod.GET, entity, String.class);
323 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
324 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
328 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
329 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
330 headers.set("Accept", MediaType.APPLICATION_JSON);
332 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
333 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
335 ResponseEntity<String> response = restTemplate.exchange(
336 builder.toUriString(),
337 HttpMethod.GET, entity, String.class);
339 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
340 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
344 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
345 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
346 headers.set("Accept", MediaType.APPLICATION_JSON);
348 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
349 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
351 ResponseEntity<String> response = restTemplate.exchange(
352 builder.toUriString(),
353 HttpMethod.GET, entity, String.class);
355 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
356 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
360 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
361 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
362 headers.set("Accept", MediaType.APPLICATION_JSON);
364 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
365 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
367 ResponseEntity<String> response = restTemplate.exchange(
368 builder.toUriString(),
369 HttpMethod.GET, entity, String.class);
371 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
372 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
376 public void testSerfviceVNFResources404() throws JSONException {
377 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
378 headers.set("Accept", MediaType.APPLICATION_JSON);
380 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
381 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
383 ResponseEntity<String> response = restTemplate.exchange(
384 builder.toUriString(),
385 HttpMethod.GET, entity, String.class);
387 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
393 public void testSerfviceVNFBadParams() throws JSONException {
394 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
395 headers.set("Accept", MediaType.APPLICATION_JSON);
397 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
398 .queryParam("BadParamName", "BADNAME");
400 ResponseEntity<String> response = restTemplate.exchange(
401 builder.toUriString(),
402 HttpMethod.GET, entity, String.class);
403 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
404 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
411 /* Network Resources Endpoint */
414 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
415 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
416 headers.set("Accept", MediaType.APPLICATION_JSON);
417 String expectedResponse = "{\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(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
421 ResponseEntity<String> response = restTemplate.exchange(
422 builder.toUriString(),
423 HttpMethod.GET, entity, String.class);
425 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
426 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
432 public void testGetNetworkResources404() throws JSONException {
433 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
434 headers.set("Accept", MediaType.APPLICATION_JSON);
436 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"))
439 ResponseEntity<String> response = restTemplate.exchange(
440 builder.toUriString(),
441 HttpMethod.GET, entity, String.class);
443 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
447 /* Service Network Resources Endpoints */
450 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
451 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
452 headers.set("Accept", MediaType.APPLICATION_JSON);
454 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
455 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
457 ResponseEntity<String> response = restTemplate.exchange(
458 builder.toUriString(),
459 HttpMethod.GET, entity, String.class);
461 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
462 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
466 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
467 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
468 headers.set("Accept", MediaType.APPLICATION_JSON);
470 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
471 .queryParam("serviceModelUuid", serviceUUID);
473 ResponseEntity<String> response = restTemplate.exchange(
474 builder.toUriString(),
475 HttpMethod.GET, entity, String.class);
477 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
478 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
482 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
483 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
484 headers.set("Accept", MediaType.APPLICATION_JSON);
486 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
487 .queryParam("serviceModelUuid", "doesNotExist");
489 ResponseEntity<String> response = restTemplate.exchange(
490 builder.toUriString(),
491 HttpMethod.GET, entity, String.class);
493 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
498 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
499 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
500 headers.set("Accept", MediaType.APPLICATION_JSON);
502 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
503 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
505 ResponseEntity<String> response = restTemplate.exchange(
506 builder.toUriString(),
507 HttpMethod.GET, entity, String.class);
509 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
514 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
515 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
516 headers.set("Accept", MediaType.APPLICATION_JSON);
518 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
519 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
521 ResponseEntity<String> response = restTemplate.exchange(
522 builder.toUriString(),
523 HttpMethod.GET, entity, String.class);
525 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
526 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
530 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
531 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
532 headers.set("Accept", MediaType.APPLICATION_JSON);
534 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
535 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
536 .queryParam("serviceModelVersion", "2.0");
538 ResponseEntity<String> response = restTemplate.exchange(
539 builder.toUriString(),
540 HttpMethod.GET, entity, String.class);
542 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
543 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
547 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
548 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
549 headers.set("Accept", MediaType.APPLICATION_JSON);
551 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
552 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
553 .queryParam("serviceModelVersion", "");
554 ResponseEntity<String> response = restTemplate.exchange(
555 builder.toUriString(),
556 HttpMethod.GET, entity, String.class);
558 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
559 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
564 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
565 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
566 headers.set("Accept", MediaType.APPLICATION_JSON);
568 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
569 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
571 ResponseEntity<String> response = restTemplate.exchange(
572 builder.toUriString(),
573 HttpMethod.GET, entity, String.class);
575 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
576 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
580 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
581 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
582 headers.set("Accept", MediaType.APPLICATION_JSON);
584 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
585 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
587 ResponseEntity<String> response = restTemplate.exchange(
588 builder.toUriString(),
589 HttpMethod.GET, entity, String.class);
591 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
592 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
595 /* Allotted endpoints */
598 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
599 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
600 headers.set("Accept", MediaType.APPLICATION_JSON);
601 String expectedResponse = "{\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}";
603 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
606 ResponseEntity<String> response = restTemplate.exchange(
607 builder.toUriString(),
608 HttpMethod.GET, entity, String.class);
610 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
611 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
616 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
617 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
618 headers.set("Accept", MediaType.APPLICATION_JSON);
620 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
621 .queryParam("serviceModelUuid",serviceUUID);
623 ResponseEntity<String> response = restTemplate.exchange(
624 builder.toUriString(),
625 HttpMethod.GET, entity, String.class);
627 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
628 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
632 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
633 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
634 headers.set("Accept", MediaType.APPLICATION_JSON);
636 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
637 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
639 ResponseEntity<String> response = restTemplate.exchange(
640 builder.toUriString(),
641 HttpMethod.GET, entity, String.class);
643 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
644 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
648 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
649 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
650 headers.set("Accept", MediaType.APPLICATION_JSON);
652 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
653 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
654 .queryParam("serviceModelVersion", "1.0");
656 ResponseEntity<String> response = restTemplate.exchange(
657 builder.toUriString(),
658 HttpMethod.GET, entity, String.class);
660 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
661 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
665 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
666 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
667 headers.set("Accept", MediaType.APPLICATION_JSON);
669 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
670 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
671 .queryParam("serviceModelVersion", "1.0");
673 ResponseEntity<String> response = restTemplate.exchange(
674 builder.toUriString(),
675 HttpMethod.GET, entity, String.class);
677 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
678 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
682 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
683 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
684 headers.set("Accept", MediaType.APPLICATION_JSON);
686 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
687 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
689 ResponseEntity<String> response = restTemplate.exchange(
690 builder.toUriString(),
691 HttpMethod.GET, entity, String.class);
693 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
694 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
699 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
700 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
701 headers.set("Accept", MediaType.APPLICATION_JSON);
703 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
704 .queryParam("arModelCustomizationUuid", "NOTEXIST");
706 ResponseEntity<String> response = restTemplate.exchange(
707 builder.toUriString(),
708 HttpMethod.GET, entity, String.class);
710 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
714 /* VF Modules Endpoint */
717 public void testGetVFModulesNonExistResource() throws JSONException {
718 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
719 headers.set("Accept", MediaType.APPLICATION_JSON);
721 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
722 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
724 ResponseEntity<String> response = restTemplate.exchange(
725 builder.toUriString(),
726 HttpMethod.GET, entity, String.class);
728 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
733 public void testGetVFModulesByVfModuleModelName() throws JSONException {
734 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
735 headers.set("Accept", MediaType.APPLICATION_JSON);
736 String expectedResponse = "{\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}";
737 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
738 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
740 ResponseEntity<String> response = restTemplate.exchange(
741 builder.toUriString(),
742 HttpMethod.GET, entity, String.class);
744 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
745 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
750 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
751 TestAppender.events.clear();
752 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
753 headers.set("Accept", MediaType.APPLICATION_JSON);
755 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
756 .queryParam("ADASD", "NEUTRON_BASIC");
758 ResponseEntity<String> response = restTemplate.exchange(
759 builder.toUriString(),
760 HttpMethod.GET, entity, String.class);
762 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
763 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
766 ILoggingEvent logEvent = TestAppender.events.get(0);
767 Map<String,String> mdc = logEvent.getMDCPropertyMap();
768 assertNotNull(mdc.get(MsoLogger.BEGINTIME));
769 assertNotNull(mdc.get(MsoLogger.ENDTIME));
770 assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
771 assertNotNull(mdc.get(MsoLogger.TIMER));
772 assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));
773 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
774 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
775 assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
776 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
779 private String createURLWithPort(String uri) {
780 return "http://localhost:" + port + uri;