2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.onap.so.logger.MdcConstants.ENDTIME;
26 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
27 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
28 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
29 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
30 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
31 import static org.onap.so.logger.MdcConstants.STATUSCODE;
32 import java.io.IOException;
34 import javax.ws.rs.core.MediaType;
35 import javax.ws.rs.core.Response;
36 import org.json.JSONException;
37 import org.junit.Test;
38 import org.onap.logging.ref.slf4j.ONAPLogConstants;
39 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
40 import org.skyscreamer.jsonassert.JSONAssert;
41 import org.skyscreamer.jsonassert.JSONCompareMode;
42 import org.springframework.boot.test.web.client.TestRestTemplate;
43 import org.springframework.http.HttpEntity;
44 import org.springframework.http.HttpHeaders;
45 import org.springframework.http.HttpMethod;
46 import org.springframework.http.ResponseEntity;
47 import org.springframework.web.util.UriComponentsBuilder;
48 import ch.qos.logback.classic.spi.ILoggingEvent;
51 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
53 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
55 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
56 "ecomp/mso/catalog/v2/serviceAllottedResources";
58 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
60 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
62 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
64 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
66 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
68 HttpHeaders headers = new HttpHeaders();
70 private final String expectedServiceResourceResponse =
71 "{\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}";
73 private final String expectedServiceResourceResponsev2 =
74 "{\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}";
77 private final String expectedServiceVnfResponse =
78 "{\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}";
80 private final String expectedServiceVnfResponseV3 =
81 "{\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}";
83 private final String expectedServiceNetworkResourceResponse =
84 "{\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}";
86 private final String badQueryParamResponse =
87 "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
89 private final String expectedAllottedResponse =
90 "{\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}";
92 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
94 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
96 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
98 /* Health Check Resources Endpoint */
101 public void testHealthcheck() throws JSONException {
103 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
105 ResponseEntity<String> response =
106 restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
108 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
109 for (ILoggingEvent logEvent : TestAppender.events)
110 if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
111 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
112 Map<String, String> mdc = logEvent.getMDCPropertyMap();
113 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
114 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
115 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
116 assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
117 assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
118 assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
119 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
120 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
121 Map<String, String> mdc = logEvent.getMDCPropertyMap();
122 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
123 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
124 assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
125 assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
126 assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
127 assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
131 /* Service Resources Endpoint */
134 public void testGetServiceModelUUID() throws JSONException {
135 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
136 headers.set("Accept", MediaType.APPLICATION_JSON);
138 UriComponentsBuilder builder =
139 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
140 .queryParam("serviceModelUuid", serviceUUID);
142 ResponseEntity<String> response =
143 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
145 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
146 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(),
147 JSONCompareMode.LENIENT);
151 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
152 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
153 headers.set("Accept", MediaType.APPLICATION_JSON);
154 UriComponentsBuilder builder =
155 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
156 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
157 .queryParam("serviceModelVersion", "1.0");
159 ResponseEntity<String> response =
160 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
162 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
163 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
167 public void testGetServiceInvariantUUID() throws JSONException {
168 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
169 headers.set("Accept", MediaType.APPLICATION_JSON);
170 UriComponentsBuilder builder =
171 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
172 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
174 ResponseEntity<String> response =
175 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
177 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
178 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
182 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
183 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
184 headers.set("Accept", MediaType.APPLICATION_JSON);
185 UriComponentsBuilder builder =
186 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
187 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
188 .queryParam("serviceModelVersion", "");;
190 ResponseEntity<String> response =
191 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
193 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
194 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
198 public void testGetServiceModelUUID404() throws JSONException {
199 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
200 headers.set("Accept", MediaType.APPLICATION_JSON);
201 String expectedResponse = "\"serviceResources\": null";
202 UriComponentsBuilder builder =
203 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
204 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
206 ResponseEntity<String> response =
207 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
209 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
210 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
214 public void testGetServiceBadQueryParams() throws JSONException {
215 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
216 headers.set("Accept", MediaType.APPLICATION_JSON);
217 UriComponentsBuilder builder =
218 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
219 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
221 ResponseEntity<String> response =
222 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
224 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
225 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
228 /* VNF Resources Endpoint */
231 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
232 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
233 headers.set("Accept", MediaType.APPLICATION_JSON);
234 String expectedResponse =
235 "{\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}";
236 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
237 createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"));
239 ResponseEntity<String> response =
240 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
242 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
243 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
249 public void testGetVNFResources404() throws JSONException {
250 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
251 headers.set("Accept", MediaType.APPLICATION_JSON);
253 UriComponentsBuilder builder = UriComponentsBuilder
254 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"));
256 ResponseEntity<String> response =
257 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
259 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
264 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
265 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
266 headers.set("Accept", MediaType.APPLICATION_JSON);
268 UriComponentsBuilder builder =
269 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
270 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
272 ResponseEntity<String> response =
273 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
275 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
276 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
280 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
281 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
282 headers.set("Accept", MediaType.APPLICATION_JSON);
284 UriComponentsBuilder builder =
285 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
286 .queryParam("serviceModelUuid", serviceUUID);
288 ResponseEntity<String> response =
289 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
291 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
292 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
296 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
297 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
298 headers.set("Accept", MediaType.APPLICATION_JSON);
300 UriComponentsBuilder builder =
301 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
302 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
303 .queryParam("serviceModelVersion", "1.0");
305 ResponseEntity<String> response =
306 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
308 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
309 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
313 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
314 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
315 headers.set("Accept", MediaType.APPLICATION_JSON);
317 UriComponentsBuilder builder =
318 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
319 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
320 .queryParam("serviceModelVersion", "");
322 ResponseEntity<String> response =
323 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
325 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
326 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
331 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
332 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
333 headers.set("Accept", MediaType.APPLICATION_JSON);
335 UriComponentsBuilder builder =
336 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
337 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
339 ResponseEntity<String> response =
340 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
342 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
343 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
347 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
348 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
349 headers.set("Accept", MediaType.APPLICATION_JSON);
351 UriComponentsBuilder builder =
352 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
353 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
355 ResponseEntity<String> response =
356 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
358 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
359 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
363 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
364 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
365 headers.set("Accept", MediaType.APPLICATION_JSON);
367 UriComponentsBuilder builder = UriComponentsBuilder
368 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
369 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
371 ResponseEntity<String> response =
372 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
374 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
375 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
379 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
380 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
381 headers.set("Accept", MediaType.APPLICATION_JSON);
383 UriComponentsBuilder builder =
384 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
385 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service")
386 .queryParam("serviceModelVersion", "1.0");
388 ResponseEntity<String> response =
389 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
391 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
392 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
396 public void testSerfviceVNFResources404() throws JSONException {
397 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
398 headers.set("Accept", MediaType.APPLICATION_JSON);
400 UriComponentsBuilder builder =
401 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
402 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
404 ResponseEntity<String> response =
405 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
407 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
413 public void testSerfviceVNFBadParams() throws JSONException {
414 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
415 headers.set("Accept", MediaType.APPLICATION_JSON);
417 UriComponentsBuilder builder =
418 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
419 .queryParam("BadParamName", "BADNAME");
421 ResponseEntity<String> response =
422 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
423 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
424 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
431 /* Network Resources Endpoint */
434 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
435 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
436 headers.set("Accept", MediaType.APPLICATION_JSON);
437 String expectedResponse =
438 "{\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}";
439 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
440 createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"));
442 ResponseEntity<String> response =
443 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
445 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
446 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
452 public void testGetNetworkResources404() throws JSONException {
453 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
454 headers.set("Accept", MediaType.APPLICATION_JSON);
456 UriComponentsBuilder builder = UriComponentsBuilder
457 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"));
459 ResponseEntity<String> response =
460 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
462 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
466 /* Service Network Resources Endpoints */
469 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
470 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
471 headers.set("Accept", MediaType.APPLICATION_JSON);
473 UriComponentsBuilder builder =
474 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
475 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
477 ResponseEntity<String> response =
478 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
480 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
481 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
485 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
486 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
487 headers.set("Accept", MediaType.APPLICATION_JSON);
489 UriComponentsBuilder builder =
490 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
491 .queryParam("serviceModelUuid", serviceUUID);
493 ResponseEntity<String> response =
494 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
496 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
497 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
501 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
502 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
503 headers.set("Accept", MediaType.APPLICATION_JSON);
505 UriComponentsBuilder builder =
506 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
507 .queryParam("serviceModelUuid", "doesNotExist");
509 ResponseEntity<String> response =
510 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
512 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
517 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
518 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
519 headers.set("Accept", MediaType.APPLICATION_JSON);
521 UriComponentsBuilder builder =
522 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
523 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
525 ResponseEntity<String> response =
526 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
528 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
533 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
534 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
535 headers.set("Accept", MediaType.APPLICATION_JSON);
537 UriComponentsBuilder builder =
538 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
539 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
541 ResponseEntity<String> response =
542 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
544 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
545 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
549 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
550 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
551 headers.set("Accept", MediaType.APPLICATION_JSON);
553 UriComponentsBuilder builder = UriComponentsBuilder
554 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
555 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "2.0");
557 ResponseEntity<String> response =
558 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
560 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
561 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
565 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
566 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
567 headers.set("Accept", MediaType.APPLICATION_JSON);
569 UriComponentsBuilder builder = UriComponentsBuilder
570 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
571 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "");
572 ResponseEntity<String> response =
573 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
575 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
576 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
581 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
582 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
583 headers.set("Accept", MediaType.APPLICATION_JSON);
585 UriComponentsBuilder builder =
586 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
587 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
589 ResponseEntity<String> response =
590 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
592 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
593 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
597 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
598 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
599 headers.set("Accept", MediaType.APPLICATION_JSON);
601 UriComponentsBuilder builder =
602 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
603 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
605 ResponseEntity<String> response =
606 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
608 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
609 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
612 /* Allotted endpoints */
615 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
616 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
617 headers.set("Accept", MediaType.APPLICATION_JSON);
618 String expectedResponse =
619 "{\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}";
621 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
622 createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
625 ResponseEntity<String> response =
626 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
628 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
629 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
634 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
635 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
636 headers.set("Accept", MediaType.APPLICATION_JSON);
638 UriComponentsBuilder builder =
639 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
640 .queryParam("serviceModelUuid", serviceUUID);
642 ResponseEntity<String> response =
643 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
645 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
646 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
650 public void testResourceReceipe() throws JSONException {
651 String expectedResourceRecipe =
652 "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
654 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
655 headers.set("Accept", MediaType.APPLICATION_JSON);
657 UriComponentsBuilder builder =
658 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
659 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance");
661 ResponseEntity<String> response =
662 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
664 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
665 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
669 public void testResourceReceipeNotMatched() throws JSONException {
671 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
672 headers.set("Accept", MediaType.APPLICATION_JSON);
674 UriComponentsBuilder builder =
675 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
676 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action");
678 ResponseEntity<String> response =
679 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
681 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
685 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
686 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
687 headers.set("Accept", MediaType.APPLICATION_JSON);
689 UriComponentsBuilder builder =
690 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
691 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
693 ResponseEntity<String> response =
694 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
696 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
697 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
701 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
702 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
703 headers.set("Accept", MediaType.APPLICATION_JSON);
705 UriComponentsBuilder builder = UriComponentsBuilder
706 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
707 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
709 ResponseEntity<String> response =
710 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
712 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
713 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
717 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
718 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
719 headers.set("Accept", MediaType.APPLICATION_JSON);
721 UriComponentsBuilder builder = UriComponentsBuilder
722 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
723 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
725 ResponseEntity<String> response =
726 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
728 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
729 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
733 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
734 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
735 headers.set("Accept", MediaType.APPLICATION_JSON);
737 UriComponentsBuilder builder =
738 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
739 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
741 ResponseEntity<String> response =
742 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
744 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
745 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
750 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
751 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
752 headers.set("Accept", MediaType.APPLICATION_JSON);
754 UriComponentsBuilder builder =
755 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
756 .queryParam("arModelCustomizationUuid", "NOTEXIST");
758 ResponseEntity<String> response =
759 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
761 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
765 /* VF Modules Endpoint */
768 public void testGetVFModulesNonExistResource() throws JSONException {
769 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
770 headers.set("Accept", MediaType.APPLICATION_JSON);
772 UriComponentsBuilder builder =
773 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
774 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
776 ResponseEntity<String> response =
777 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
779 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
784 public void testGetVFModulesByVfModuleModelName() throws JSONException {
785 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
786 headers.set("Accept", MediaType.APPLICATION_JSON);
787 String expectedResponse =
788 "{\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}";
789 UriComponentsBuilder builder =
790 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
791 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
793 ResponseEntity<String> response =
794 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
796 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
797 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
802 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
803 TestAppender.events.clear();
804 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
805 headers.set("Accept", MediaType.APPLICATION_JSON);
807 UriComponentsBuilder builder = UriComponentsBuilder
808 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)).queryParam("ADASD", "NEUTRON_BASIC");
810 ResponseEntity<String> response =
811 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
813 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
814 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
817 for (ILoggingEvent logEvent : TestAppender.events)
818 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
819 && logEvent.getMarker().getName().equals("ENTRY")) {
820 Map<String, String> mdc = logEvent.getMDCPropertyMap();
821 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
822 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
823 assertNotNull(mdc.get(INVOCATION_ID));
824 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
825 assertEquals("v2/vfModules", mdc.get(SERVICE_NAME));
826 assertEquals("INPROGRESS", mdc.get(STATUSCODE));
827 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
828 && logEvent.getMarker().getName().equals("EXIT")) {
829 Map<String, String> mdc = logEvent.getMDCPropertyMap();
830 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
831 assertNotNull(mdc.get(ENDTIME));
832 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
833 assertNotNull(mdc.get(INVOCATION_ID));
834 assertEquals("500", mdc.get(RESPONSECODE));
835 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
836 assertEquals("v2/vfModules", mdc.get(SERVICE_NAME));
837 assertEquals("ERROR", mdc.get(STATUSCODE));
838 assertNotNull(mdc.get(RESPONSEDESC));
842 private String createURLWithPort(String uri) {
843 return "http://localhost:" + port + uri;