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")
61 public class CatalogDBRestTest {
63 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
65 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources";
67 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
69 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
71 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
76 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
78 HttpHeaders headers = new HttpHeaders();
80 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}";
82 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}";
85 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}";
87 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}";
89 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}";
91 private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
93 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}";
95 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
97 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
99 /* Health Check Resources Endpoint */
102 public void testHealthcheck() throws JSONException {
104 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
106 ResponseEntity<String> response = restTemplate.exchange(
107 createURLWithPort("/manage/health"),
108 HttpMethod.GET, entity, String.class);
110 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
113 /* Service Resources Endpoint */
116 public void testGetServiceModelUUID() throws JSONException {
117 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
118 headers.set("Accept", MediaType.APPLICATION_JSON);
120 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
121 .queryParam("serviceModelUuid", serviceUUID);
123 ResponseEntity<String> response = restTemplate.exchange(
124 builder.toUriString(),
125 HttpMethod.GET, entity, String.class);
127 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
128 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
132 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
133 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
134 headers.set("Accept", MediaType.APPLICATION_JSON);
135 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
136 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
138 ResponseEntity<String> response = restTemplate.exchange(
139 builder.toUriString(),
140 HttpMethod.GET, entity, String.class);
142 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
143 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
147 public void testGetServiceInvariantUUID() throws JSONException {
148 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
149 headers.set("Accept", MediaType.APPLICATION_JSON);
150 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
151 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
153 ResponseEntity<String> response = restTemplate.exchange(
154 builder.toUriString(),
155 HttpMethod.GET, entity, String.class);
157 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
158 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
162 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
163 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
164 headers.set("Accept", MediaType.APPLICATION_JSON);
165 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
166 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
168 ResponseEntity<String> response = restTemplate.exchange(
169 builder.toUriString(),
170 HttpMethod.GET, entity, String.class);
172 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
173 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
177 public void testGetServiceModelUUID404() throws JSONException {
178 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
179 headers.set("Accept", MediaType.APPLICATION_JSON);
180 String expectedResponse = "\"serviceResources\": null";
181 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
182 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
184 ResponseEntity<String> response = restTemplate.exchange(
185 builder.toUriString(),
186 HttpMethod.GET, entity, String.class);
188 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
189 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
193 public void testGetServiceBadQueryParams() throws JSONException {
194 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
195 headers.set("Accept", MediaType.APPLICATION_JSON);
196 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
197 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
199 ResponseEntity<String> response = restTemplate.exchange(
200 builder.toUriString(),
201 HttpMethod.GET, entity, String.class);
203 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
204 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
207 /* VNF Resources Endpoint */
210 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
211 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
212 headers.set("Accept", MediaType.APPLICATION_JSON);
213 String expectedResponse = "{\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}";
214 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
217 ResponseEntity<String> response = restTemplate.exchange(
218 builder.toUriString(),
219 HttpMethod.GET, entity, String.class);
221 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
222 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
228 public void testGetVNFResources404() throws JSONException {
229 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
230 headers.set("Accept", MediaType.APPLICATION_JSON);
232 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
235 ResponseEntity<String> response = restTemplate.exchange(
236 builder.toUriString(),
237 HttpMethod.GET, entity, String.class);
239 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
244 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
245 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
246 headers.set("Accept", MediaType.APPLICATION_JSON);
248 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
249 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
251 ResponseEntity<String> response = restTemplate.exchange(
252 builder.toUriString(),
253 HttpMethod.GET, entity, String.class);
255 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
256 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
260 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
261 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
262 headers.set("Accept", MediaType.APPLICATION_JSON);
264 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
265 .queryParam("serviceModelUuid", serviceUUID);
267 ResponseEntity<String> response = restTemplate.exchange(
268 builder.toUriString(),
269 HttpMethod.GET, entity, String.class);
271 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
272 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
276 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
277 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
278 headers.set("Accept", MediaType.APPLICATION_JSON);
280 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
281 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
282 .queryParam("serviceModelVersion", "1.0");
284 ResponseEntity<String> response = restTemplate.exchange(
285 builder.toUriString(),
286 HttpMethod.GET, entity, String.class);
288 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
289 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
293 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
294 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
295 headers.set("Accept", MediaType.APPLICATION_JSON);
297 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
298 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
299 .queryParam("serviceModelVersion", "");
301 ResponseEntity<String> response = restTemplate.exchange(
302 builder.toUriString(),
303 HttpMethod.GET, entity, String.class);
305 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
306 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
311 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
312 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
313 headers.set("Accept", MediaType.APPLICATION_JSON);
315 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
316 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
318 ResponseEntity<String> response = restTemplate.exchange(
319 builder.toUriString(),
320 HttpMethod.GET, entity, String.class);
322 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
323 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
327 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
328 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
329 headers.set("Accept", MediaType.APPLICATION_JSON);
331 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
332 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
334 ResponseEntity<String> response = restTemplate.exchange(
335 builder.toUriString(),
336 HttpMethod.GET, entity, String.class);
338 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
339 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
343 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
344 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
345 headers.set("Accept", MediaType.APPLICATION_JSON);
347 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
348 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
350 ResponseEntity<String> response = restTemplate.exchange(
351 builder.toUriString(),
352 HttpMethod.GET, entity, String.class);
354 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
355 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
359 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
360 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
361 headers.set("Accept", MediaType.APPLICATION_JSON);
363 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
364 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
366 ResponseEntity<String> response = restTemplate.exchange(
367 builder.toUriString(),
368 HttpMethod.GET, entity, String.class);
370 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
371 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
375 public void testSerfviceVNFResources404() throws JSONException {
376 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
377 headers.set("Accept", MediaType.APPLICATION_JSON);
379 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
380 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
382 ResponseEntity<String> response = restTemplate.exchange(
383 builder.toUriString(),
384 HttpMethod.GET, entity, String.class);
386 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
392 public void testSerfviceVNFBadParams() throws JSONException {
393 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
394 headers.set("Accept", MediaType.APPLICATION_JSON);
396 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
397 .queryParam("BadParamName", "BADNAME");
399 ResponseEntity<String> response = restTemplate.exchange(
400 builder.toUriString(),
401 HttpMethod.GET, entity, String.class);
402 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
403 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
410 /* Network Resources Endpoint */
413 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
414 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
415 headers.set("Accept", MediaType.APPLICATION_JSON);
416 String expectedResponse = "{\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}";
417 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
420 ResponseEntity<String> response = restTemplate.exchange(
421 builder.toUriString(),
422 HttpMethod.GET, entity, String.class);
424 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
425 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
431 public void testGetNetworkResources404() throws JSONException {
432 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
433 headers.set("Accept", MediaType.APPLICATION_JSON);
435 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"))
438 ResponseEntity<String> response = restTemplate.exchange(
439 builder.toUriString(),
440 HttpMethod.GET, entity, String.class);
442 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
446 /* Service Network Resources Endpoints */
449 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
450 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
451 headers.set("Accept", MediaType.APPLICATION_JSON);
453 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
454 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
456 ResponseEntity<String> response = restTemplate.exchange(
457 builder.toUriString(),
458 HttpMethod.GET, entity, String.class);
460 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
461 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
465 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
466 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
467 headers.set("Accept", MediaType.APPLICATION_JSON);
469 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
470 .queryParam("serviceModelUuid", serviceUUID);
472 ResponseEntity<String> response = restTemplate.exchange(
473 builder.toUriString(),
474 HttpMethod.GET, entity, String.class);
476 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
477 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
481 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
482 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
483 headers.set("Accept", MediaType.APPLICATION_JSON);
485 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
486 .queryParam("serviceModelUuid", "doesNotExist");
488 ResponseEntity<String> response = restTemplate.exchange(
489 builder.toUriString(),
490 HttpMethod.GET, entity, String.class);
492 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
497 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
498 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
499 headers.set("Accept", MediaType.APPLICATION_JSON);
501 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
502 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
504 ResponseEntity<String> response = restTemplate.exchange(
505 builder.toUriString(),
506 HttpMethod.GET, entity, String.class);
508 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
513 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
514 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
515 headers.set("Accept", MediaType.APPLICATION_JSON);
517 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
518 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
520 ResponseEntity<String> response = restTemplate.exchange(
521 builder.toUriString(),
522 HttpMethod.GET, entity, String.class);
524 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
525 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
529 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
530 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
531 headers.set("Accept", MediaType.APPLICATION_JSON);
533 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
534 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
535 .queryParam("serviceModelVersion", "2.0");
537 ResponseEntity<String> response = restTemplate.exchange(
538 builder.toUriString(),
539 HttpMethod.GET, entity, String.class);
541 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
542 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
546 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
547 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
548 headers.set("Accept", MediaType.APPLICATION_JSON);
550 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
551 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
552 .queryParam("serviceModelVersion", "");
553 ResponseEntity<String> response = restTemplate.exchange(
554 builder.toUriString(),
555 HttpMethod.GET, entity, String.class);
557 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
558 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
563 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
564 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
565 headers.set("Accept", MediaType.APPLICATION_JSON);
567 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
568 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
570 ResponseEntity<String> response = restTemplate.exchange(
571 builder.toUriString(),
572 HttpMethod.GET, entity, String.class);
574 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
575 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
579 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
580 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
581 headers.set("Accept", MediaType.APPLICATION_JSON);
583 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
584 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
586 ResponseEntity<String> response = restTemplate.exchange(
587 builder.toUriString(),
588 HttpMethod.GET, entity, String.class);
590 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
591 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
594 /* Allotted endpoints */
597 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
598 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
599 headers.set("Accept", MediaType.APPLICATION_JSON);
600 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}";
602 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
605 ResponseEntity<String> response = restTemplate.exchange(
606 builder.toUriString(),
607 HttpMethod.GET, entity, String.class);
609 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
610 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
615 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
616 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
617 headers.set("Accept", MediaType.APPLICATION_JSON);
619 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
620 .queryParam("serviceModelUuid",serviceUUID);
622 ResponseEntity<String> response = restTemplate.exchange(
623 builder.toUriString(),
624 HttpMethod.GET, entity, String.class);
626 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
627 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
631 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
632 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
633 headers.set("Accept", MediaType.APPLICATION_JSON);
635 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
636 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
638 ResponseEntity<String> response = restTemplate.exchange(
639 builder.toUriString(),
640 HttpMethod.GET, entity, String.class);
642 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
643 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
647 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
648 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
649 headers.set("Accept", MediaType.APPLICATION_JSON);
651 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
652 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
653 .queryParam("serviceModelVersion", "1.0");
655 ResponseEntity<String> response = restTemplate.exchange(
656 builder.toUriString(),
657 HttpMethod.GET, entity, String.class);
659 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
660 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
664 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
665 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
666 headers.set("Accept", MediaType.APPLICATION_JSON);
668 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
669 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
670 .queryParam("serviceModelVersion", "1.0");
672 ResponseEntity<String> response = restTemplate.exchange(
673 builder.toUriString(),
674 HttpMethod.GET, entity, String.class);
676 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
677 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
681 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
682 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
683 headers.set("Accept", MediaType.APPLICATION_JSON);
685 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
686 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
688 ResponseEntity<String> response = restTemplate.exchange(
689 builder.toUriString(),
690 HttpMethod.GET, entity, String.class);
692 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
693 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
698 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
699 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
700 headers.set("Accept", MediaType.APPLICATION_JSON);
702 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
703 .queryParam("arModelCustomizationUuid", "NOTEXIST");
705 ResponseEntity<String> response = restTemplate.exchange(
706 builder.toUriString(),
707 HttpMethod.GET, entity, String.class);
709 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
713 /* VF Modules Endpoint */
716 public void testGetVFModulesNonExistResource() throws JSONException {
717 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
718 headers.set("Accept", MediaType.APPLICATION_JSON);
720 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
721 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
723 ResponseEntity<String> response = restTemplate.exchange(
724 builder.toUriString(),
725 HttpMethod.GET, entity, String.class);
727 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
732 public void testGetVFModulesByVfModuleModelName() throws JSONException {
733 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
734 headers.set("Accept", MediaType.APPLICATION_JSON);
735 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}";
736 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
737 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
739 ResponseEntity<String> response = restTemplate.exchange(
740 builder.toUriString(),
741 HttpMethod.GET, entity, String.class);
743 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
744 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
749 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
750 TestAppender.events.clear();
751 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
752 headers.set("Accept", MediaType.APPLICATION_JSON);
754 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
755 .queryParam("ADASD", "NEUTRON_BASIC");
757 ResponseEntity<String> response = restTemplate.exchange(
758 builder.toUriString(),
759 HttpMethod.GET, entity, String.class);
761 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
762 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
765 for(ILoggingEvent logEvent : TestAppender.events)
766 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
767 logEvent.getMarker().getName().equals("ENTRY")
769 Map<String,String> mdc = logEvent.getMDCPropertyMap();
770 assertNotNull(mdc.get(MsoLogger.BEGINTIME));
771 assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
772 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
773 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
774 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
775 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
776 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
777 logEvent.getMarker().getName().equals("EXIT")){
778 Map<String,String> mdc = logEvent.getMDCPropertyMap();
779 assertNotNull(mdc.get(MsoLogger.BEGINTIME));
780 assertNotNull(mdc.get(MsoLogger.ENDTIME));
781 assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
782 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
783 assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));
784 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
785 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
786 assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
787 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
791 private String createURLWithPort(String uri) {
792 return "http://localhost:" + port + uri;