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.*;
24 import static org.onap.so.logger.MdcConstants.ENDTIME;
25 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
26 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
27 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
28 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
29 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
30 import static org.onap.so.logger.MdcConstants.STATUSCODE;
33 import java.io.IOException;
35 import java.util.regex.Matcher;
36 import java.util.regex.Pattern;
37 import javax.ws.rs.core.MediaType;
38 import javax.ws.rs.core.Response;
41 import org.json.JSONException;
42 import org.junit.Before;
43 import org.junit.BeforeClass;
44 import org.junit.Test;
45 import org.junit.runner.RunWith;
46 import org.onap.logging.ref.slf4j.ONAPLogConstants;
47 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
49 import org.skyscreamer.jsonassert.JSONAssert;
50 import org.skyscreamer.jsonassert.JSONCompareMode;
51 import org.springframework.boot.web.server.LocalServerPort;
52 import org.springframework.boot.test.context.SpringBootTest;
53 import org.springframework.boot.test.web.client.TestRestTemplate;
54 import org.springframework.http.HttpEntity;
55 import org.springframework.http.HttpHeaders;
56 import org.springframework.http.HttpMethod;
57 import org.springframework.http.ResponseEntity;
58 import org.springframework.test.annotation.DirtiesContext;
59 import org.springframework.test.annotation.DirtiesContext.ClassMode;
60 import org.springframework.test.context.ActiveProfiles;
61 import org.springframework.test.context.junit4.SpringRunner;
62 import org.springframework.web.util.UriComponentsBuilder;
64 import ch.qos.logback.classic.spi.ILoggingEvent;
67 @RunWith(SpringRunner.class)
68 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
69 @ActiveProfiles("test")
70 public class CatalogDBRestTest {
72 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
74 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources";
76 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
78 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
80 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
82 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
87 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
89 HttpHeaders headers = new HttpHeaders();
91 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}";
93 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}";
96 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}";
98 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}";
100 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}";
102 private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
104 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}";
106 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
108 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
110 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
112 /* Health Check Resources Endpoint */
115 public void testHealthcheck() throws JSONException {
117 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
119 ResponseEntity<String> response = restTemplate.exchange(
120 createURLWithPort("/manage/health"),
121 HttpMethod.GET, entity, String.class);
123 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
124 for(ILoggingEvent logEvent : TestAppender.events)
125 if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
126 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
128 Map<String,String> mdc = logEvent.getMDCPropertyMap();
129 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
130 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
131 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
132 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
133 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
134 assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
135 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
136 logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
137 Map<String,String> mdc = logEvent.getMDCPropertyMap();
138 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
139 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
140 assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
141 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
142 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
143 assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
147 /* Service Resources Endpoint */
150 public void testGetServiceModelUUID() throws JSONException {
151 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
152 headers.set("Accept", MediaType.APPLICATION_JSON);
154 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
155 .queryParam("serviceModelUuid", serviceUUID);
157 ResponseEntity<String> response = restTemplate.exchange(
158 builder.toUriString(),
159 HttpMethod.GET, entity, String.class);
161 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
162 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
166 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
167 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
168 headers.set("Accept", MediaType.APPLICATION_JSON);
169 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
170 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
172 ResponseEntity<String> response = restTemplate.exchange(
173 builder.toUriString(),
174 HttpMethod.GET, entity, String.class);
176 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
177 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
181 public void testGetServiceInvariantUUID() throws JSONException {
182 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
183 headers.set("Accept", MediaType.APPLICATION_JSON);
184 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
185 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
187 ResponseEntity<String> response = restTemplate.exchange(
188 builder.toUriString(),
189 HttpMethod.GET, entity, String.class);
191 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
192 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
196 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
197 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
198 headers.set("Accept", MediaType.APPLICATION_JSON);
199 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
200 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
202 ResponseEntity<String> response = restTemplate.exchange(
203 builder.toUriString(),
204 HttpMethod.GET, entity, String.class);
206 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
207 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
211 public void testGetServiceModelUUID404() throws JSONException {
212 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
213 headers.set("Accept", MediaType.APPLICATION_JSON);
214 String expectedResponse = "\"serviceResources\": null";
215 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
216 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
218 ResponseEntity<String> response = restTemplate.exchange(
219 builder.toUriString(),
220 HttpMethod.GET, entity, String.class);
222 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
223 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
227 public void testGetServiceBadQueryParams() throws JSONException {
228 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
229 headers.set("Accept", MediaType.APPLICATION_JSON);
230 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
231 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
233 ResponseEntity<String> response = restTemplate.exchange(
234 builder.toUriString(),
235 HttpMethod.GET, entity, String.class);
237 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
238 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
241 /* VNF Resources Endpoint */
244 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
245 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
246 headers.set("Accept", MediaType.APPLICATION_JSON);
247 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}";
248 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/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(expectedResponse, response.getBody().toString(), false);
262 public void testGetVNFResources404() throws JSONException {
263 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
264 headers.set("Accept", MediaType.APPLICATION_JSON);
266 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
269 ResponseEntity<String> response = restTemplate.exchange(
270 builder.toUriString(),
271 HttpMethod.GET, entity, String.class);
273 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
278 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
279 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
280 headers.set("Accept", MediaType.APPLICATION_JSON);
282 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
283 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
285 ResponseEntity<String> response = restTemplate.exchange(
286 builder.toUriString(),
287 HttpMethod.GET, entity, String.class);
289 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
290 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
294 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
295 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
296 headers.set("Accept", MediaType.APPLICATION_JSON);
298 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
299 .queryParam("serviceModelUuid", serviceUUID);
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(expectedServiceVnfResponse, response.getBody().toString(), false);
310 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
311 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
312 headers.set("Accept", MediaType.APPLICATION_JSON);
314 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
315 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
316 .queryParam("serviceModelVersion", "1.0");
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(expectedServiceVnfResponse, response.getBody().toString(), false);
327 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() 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("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
333 .queryParam("serviceModelVersion", "");
335 ResponseEntity<String> response = restTemplate.exchange(
336 builder.toUriString(),
337 HttpMethod.GET, entity, String.class);
339 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
340 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
345 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
346 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
347 headers.set("Accept", MediaType.APPLICATION_JSON);
349 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
350 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
352 ResponseEntity<String> response = restTemplate.exchange(
353 builder.toUriString(),
354 HttpMethod.GET, entity, String.class);
356 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
357 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
361 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
362 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
363 headers.set("Accept", MediaType.APPLICATION_JSON);
365 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
366 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
368 ResponseEntity<String> response = restTemplate.exchange(
369 builder.toUriString(),
370 HttpMethod.GET, entity, String.class);
372 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
373 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
377 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
378 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
379 headers.set("Accept", MediaType.APPLICATION_JSON);
381 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
382 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
384 ResponseEntity<String> response = restTemplate.exchange(
385 builder.toUriString(),
386 HttpMethod.GET, entity, String.class);
388 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
389 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
393 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
394 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
395 headers.set("Accept", MediaType.APPLICATION_JSON);
397 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
398 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
400 ResponseEntity<String> response = restTemplate.exchange(
401 builder.toUriString(),
402 HttpMethod.GET, entity, String.class);
404 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
405 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
409 public void testSerfviceVNFResources404() throws JSONException {
410 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
411 headers.set("Accept", MediaType.APPLICATION_JSON);
413 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
414 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
416 ResponseEntity<String> response = restTemplate.exchange(
417 builder.toUriString(),
418 HttpMethod.GET, entity, String.class);
420 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
426 public void testSerfviceVNFBadParams() throws JSONException {
427 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
428 headers.set("Accept", MediaType.APPLICATION_JSON);
430 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
431 .queryParam("BadParamName", "BADNAME");
433 ResponseEntity<String> response = restTemplate.exchange(
434 builder.toUriString(),
435 HttpMethod.GET, entity, String.class);
436 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
437 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
444 /* Network Resources Endpoint */
447 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
448 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
449 headers.set("Accept", MediaType.APPLICATION_JSON);
450 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}";
451 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
454 ResponseEntity<String> response = restTemplate.exchange(
455 builder.toUriString(),
456 HttpMethod.GET, entity, String.class);
458 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
459 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
465 public void testGetNetworkResources404() 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/networkResources/3bdbb104-4asdf"))
472 ResponseEntity<String> response = restTemplate.exchange(
473 builder.toUriString(),
474 HttpMethod.GET, entity, String.class);
476 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
480 /* Service Network Resources Endpoints */
483 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
484 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
485 headers.set("Accept", MediaType.APPLICATION_JSON);
487 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
488 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
490 ResponseEntity<String> response = restTemplate.exchange(
491 builder.toUriString(),
492 HttpMethod.GET, entity, String.class);
494 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
495 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
499 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
500 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
501 headers.set("Accept", MediaType.APPLICATION_JSON);
503 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
504 .queryParam("serviceModelUuid", serviceUUID);
506 ResponseEntity<String> response = restTemplate.exchange(
507 builder.toUriString(),
508 HttpMethod.GET, entity, String.class);
510 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
511 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
515 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
516 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
517 headers.set("Accept", MediaType.APPLICATION_JSON);
519 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
520 .queryParam("serviceModelUuid", "doesNotExist");
522 ResponseEntity<String> response = restTemplate.exchange(
523 builder.toUriString(),
524 HttpMethod.GET, entity, String.class);
526 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
531 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
532 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
533 headers.set("Accept", MediaType.APPLICATION_JSON);
535 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
536 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
538 ResponseEntity<String> response = restTemplate.exchange(
539 builder.toUriString(),
540 HttpMethod.GET, entity, String.class);
542 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
547 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
548 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
549 headers.set("Accept", MediaType.APPLICATION_JSON);
551 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
552 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
554 ResponseEntity<String> response = restTemplate.exchange(
555 builder.toUriString(),
556 HttpMethod.GET, entity, String.class);
558 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
559 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
563 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() 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("serviceModelInvariantUuid", serviceInvariantUUID)
569 .queryParam("serviceModelVersion", "2.0");
571 ResponseEntity<String> response = restTemplate.exchange(
572 builder.toUriString(),
573 HttpMethod.GET, entity, String.class);
575 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
576 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
580 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
581 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
582 headers.set("Accept", MediaType.APPLICATION_JSON);
584 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
585 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
586 .queryParam("serviceModelVersion", "");
587 ResponseEntity<String> response = restTemplate.exchange(
588 builder.toUriString(),
589 HttpMethod.GET, entity, String.class);
591 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
592 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
597 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
598 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
599 headers.set("Accept", MediaType.APPLICATION_JSON);
601 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
602 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
604 ResponseEntity<String> response = restTemplate.exchange(
605 builder.toUriString(),
606 HttpMethod.GET, entity, String.class);
608 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
609 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
613 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
614 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
615 headers.set("Accept", MediaType.APPLICATION_JSON);
617 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
618 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
620 ResponseEntity<String> response = restTemplate.exchange(
621 builder.toUriString(),
622 HttpMethod.GET, entity, String.class);
624 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
625 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
628 /* Allotted endpoints */
631 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
632 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
633 headers.set("Accept", MediaType.APPLICATION_JSON);
634 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}";
636 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
639 ResponseEntity<String> response = restTemplate.exchange(
640 builder.toUriString(),
641 HttpMethod.GET, entity, String.class);
643 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
644 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
649 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
650 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
651 headers.set("Accept", MediaType.APPLICATION_JSON);
653 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
654 .queryParam("serviceModelUuid",serviceUUID);
656 ResponseEntity<String> response = restTemplate.exchange(
657 builder.toUriString(),
658 HttpMethod.GET, entity, String.class);
660 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
661 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
665 public void testResourceReceipe() throws JSONException {
666 String expectedResourceRecipe = "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
668 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
669 headers.set("Accept", MediaType.APPLICATION_JSON);
671 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
672 .queryParam("resourceModelUuid", arResourceUUID)
673 .queryParam("action", "createInstance");
675 ResponseEntity<String> response = restTemplate.exchange(
676 builder.toUriString(),
677 HttpMethod.GET, entity, String.class);
679 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
680 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
684 public void testResourceReceipeNotMatched() throws JSONException {
686 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
687 headers.set("Accept", MediaType.APPLICATION_JSON);
689 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
690 .queryParam("resourceModelUuid", arResourceUUID)
691 .queryParam("action", "invalid_action");
693 ResponseEntity<String> response = restTemplate.exchange(
694 builder.toUriString(),
695 HttpMethod.GET, entity, String.class);
697 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
701 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
702 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
703 headers.set("Accept", MediaType.APPLICATION_JSON);
705 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
706 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
708 ResponseEntity<String> response = restTemplate.exchange(
709 builder.toUriString(),
710 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 testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
718 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
719 headers.set("Accept", MediaType.APPLICATION_JSON);
721 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
722 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
723 .queryParam("serviceModelVersion", "1.0");
725 ResponseEntity<String> response = restTemplate.exchange(
726 builder.toUriString(),
727 HttpMethod.GET, entity, String.class);
729 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
730 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
734 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
735 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
736 headers.set("Accept", MediaType.APPLICATION_JSON);
738 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
739 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
740 .queryParam("serviceModelVersion", "1.0");
742 ResponseEntity<String> response = restTemplate.exchange(
743 builder.toUriString(),
744 HttpMethod.GET, entity, String.class);
746 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
747 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
751 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
752 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
753 headers.set("Accept", MediaType.APPLICATION_JSON);
755 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
756 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
758 ResponseEntity<String> response = restTemplate.exchange(
759 builder.toUriString(),
760 HttpMethod.GET, entity, String.class);
762 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
763 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
768 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
769 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
770 headers.set("Accept", MediaType.APPLICATION_JSON);
772 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
773 .queryParam("arModelCustomizationUuid", "NOTEXIST");
775 ResponseEntity<String> response = restTemplate.exchange(
776 builder.toUriString(),
777 HttpMethod.GET, entity, String.class);
779 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
783 /* VF Modules Endpoint */
786 public void testGetVFModulesNonExistResource() throws JSONException {
787 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
788 headers.set("Accept", MediaType.APPLICATION_JSON);
790 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
791 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
793 ResponseEntity<String> response = restTemplate.exchange(
794 builder.toUriString(),
795 HttpMethod.GET, entity, String.class);
797 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
802 public void testGetVFModulesByVfModuleModelName() throws JSONException {
803 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
804 headers.set("Accept", MediaType.APPLICATION_JSON);
805 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}";
806 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
807 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
809 ResponseEntity<String> response = restTemplate.exchange(
810 builder.toUriString(),
811 HttpMethod.GET, entity, String.class);
813 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
814 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
819 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
820 TestAppender.events.clear();
821 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
822 headers.set("Accept", MediaType.APPLICATION_JSON);
824 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
825 .queryParam("ADASD", "NEUTRON_BASIC");
827 ResponseEntity<String> response = restTemplate.exchange(
828 builder.toUriString(),
829 HttpMethod.GET, entity, String.class);
831 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
832 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
835 for(ILoggingEvent logEvent : TestAppender.events)
836 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
837 logEvent.getMarker().getName().equals("ENTRY")
839 Map<String,String> mdc = logEvent.getMDCPropertyMap();
840 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
841 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
842 assertNotNull(mdc.get(INVOCATION_ID));
843 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
844 assertEquals("v2/vfModules",mdc.get(SERVICE_NAME));
845 assertEquals("INPROGRESS",mdc.get(STATUSCODE));
846 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
847 logEvent.getMarker().getName().equals("EXIT")){
848 Map<String,String> mdc = logEvent.getMDCPropertyMap();
849 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
850 assertNotNull(mdc.get(ENDTIME));
851 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
852 assertNotNull(mdc.get(INVOCATION_ID));
853 assertEquals("500",mdc.get(RESPONSECODE));
854 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
855 assertEquals("v2/vfModules",mdc.get(SERVICE_NAME));
856 assertEquals("ERROR",mdc.get(STATUSCODE));
857 assertNotNull(mdc.get(RESPONSEDESC));
861 private String createURLWithPort(String uri) {
862 return "http://localhost:" + port + uri;