2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import static org.junit.Assert.*;
26 import java.io.IOException;
28 import javax.ws.rs.core.MediaType;
29 import javax.ws.rs.core.Response;
32 import org.json.JSONException;
33 import org.junit.Before;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37 import org.onap.logging.ref.slf4j.ONAPLogConstants;
38 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
40 import org.onap.so.logger.MsoLogger;
41 import org.skyscreamer.jsonassert.JSONAssert;
42 import org.skyscreamer.jsonassert.JSONCompareMode;
43 import org.springframework.boot.web.server.LocalServerPort;
44 import org.springframework.boot.test.context.SpringBootTest;
45 import org.springframework.boot.test.web.client.TestRestTemplate;
46 import org.springframework.http.HttpEntity;
47 import org.springframework.http.HttpHeaders;
48 import org.springframework.http.HttpMethod;
49 import org.springframework.http.ResponseEntity;
50 import org.springframework.test.annotation.DirtiesContext;
51 import org.springframework.test.annotation.DirtiesContext.ClassMode;
52 import org.springframework.test.context.ActiveProfiles;
53 import org.springframework.test.context.junit4.SpringRunner;
54 import org.springframework.web.util.UriComponentsBuilder;
56 import ch.qos.logback.classic.spi.ILoggingEvent;
59 @RunWith(SpringRunner.class)
60 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
61 @ActiveProfiles("test")
62 public class CatalogDBRestTest {
64 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
66 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources";
68 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
70 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
72 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
77 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
79 HttpHeaders headers = new HttpHeaders();
81 private final String expectedServiceResourceResponse = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}";
83 private final String expectedServiceResourceResponsev2 = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}";
86 private final String expectedServiceVnfResponse = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}";
88 private final String expectedServiceVnfResponseV3 = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}";
90 private final String expectedServiceNetworkResourceResponse = "{\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n]\r\n}";
92 private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
94 private final String expectedAllottedResponse = "{\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}";
96 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
98 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
100 /* Health Check Resources Endpoint */
103 public void testHealthcheck() throws JSONException {
105 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
107 ResponseEntity<String> response = restTemplate.exchange(
108 createURLWithPort("/manage/health"),
109 HttpMethod.GET, entity, String.class);
111 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
112 for(ILoggingEvent logEvent : TestAppender.events)
113 if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
114 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
116 Map<String,String> mdc = logEvent.getMDCPropertyMap();
117 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
118 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
119 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
120 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
121 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
122 assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
123 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
124 logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
125 Map<String,String> mdc = logEvent.getMDCPropertyMap();
126 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
127 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
128 assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
129 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
130 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
131 assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
135 /* Service Resources Endpoint */
138 public void testGetServiceModelUUID() throws JSONException {
139 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
140 headers.set("Accept", MediaType.APPLICATION_JSON);
142 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
143 .queryParam("serviceModelUuid", serviceUUID);
145 ResponseEntity<String> response = restTemplate.exchange(
146 builder.toUriString(),
147 HttpMethod.GET, entity, String.class);
149 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
150 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
154 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
155 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
156 headers.set("Accept", MediaType.APPLICATION_JSON);
157 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
158 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
160 ResponseEntity<String> response = restTemplate.exchange(
161 builder.toUriString(),
162 HttpMethod.GET, entity, String.class);
164 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
165 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
169 public void testGetServiceInvariantUUID() throws JSONException {
170 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
171 headers.set("Accept", MediaType.APPLICATION_JSON);
172 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
173 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
175 ResponseEntity<String> response = restTemplate.exchange(
176 builder.toUriString(),
177 HttpMethod.GET, entity, String.class);
179 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
180 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
184 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
185 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
186 headers.set("Accept", MediaType.APPLICATION_JSON);
187 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
188 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
190 ResponseEntity<String> response = restTemplate.exchange(
191 builder.toUriString(),
192 HttpMethod.GET, entity, String.class);
194 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
195 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
199 public void testGetServiceModelUUID404() throws JSONException {
200 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
201 headers.set("Accept", MediaType.APPLICATION_JSON);
202 String expectedResponse = "\"serviceResources\": null";
203 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
204 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
206 ResponseEntity<String> response = restTemplate.exchange(
207 builder.toUriString(),
208 HttpMethod.GET, entity, String.class);
210 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
211 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
215 public void testGetServiceBadQueryParams() throws JSONException {
216 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
217 headers.set("Accept", MediaType.APPLICATION_JSON);
218 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
219 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
221 ResponseEntity<String> response = restTemplate.exchange(
222 builder.toUriString(),
223 HttpMethod.GET, entity, String.class);
225 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
226 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
229 /* VNF Resources Endpoint */
232 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
233 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
234 headers.set("Accept", MediaType.APPLICATION_JSON);
235 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}";
236 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
239 ResponseEntity<String> response = restTemplate.exchange(
240 builder.toUriString(),
241 HttpMethod.GET, entity, String.class);
243 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
244 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
250 public void testGetVNFResources404() throws JSONException {
251 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
252 headers.set("Accept", MediaType.APPLICATION_JSON);
254 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
257 ResponseEntity<String> response = restTemplate.exchange(
258 builder.toUriString(),
259 HttpMethod.GET, entity, String.class);
261 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
266 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
267 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
268 headers.set("Accept", MediaType.APPLICATION_JSON);
270 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
271 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
273 ResponseEntity<String> response = restTemplate.exchange(
274 builder.toUriString(),
275 HttpMethod.GET, entity, String.class);
277 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
278 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
282 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
283 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
284 headers.set("Accept", MediaType.APPLICATION_JSON);
286 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
287 .queryParam("serviceModelUuid", serviceUUID);
289 ResponseEntity<String> response = restTemplate.exchange(
290 builder.toUriString(),
291 HttpMethod.GET, entity, String.class);
293 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
294 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
298 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
299 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
300 headers.set("Accept", MediaType.APPLICATION_JSON);
302 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
303 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
304 .queryParam("serviceModelVersion", "1.0");
306 ResponseEntity<String> response = restTemplate.exchange(
307 builder.toUriString(),
308 HttpMethod.GET, entity, String.class);
310 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
311 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
315 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
316 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
317 headers.set("Accept", MediaType.APPLICATION_JSON);
319 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
320 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
321 .queryParam("serviceModelVersion", "");
323 ResponseEntity<String> response = restTemplate.exchange(
324 builder.toUriString(),
325 HttpMethod.GET, entity, String.class);
327 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
328 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
333 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
334 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
335 headers.set("Accept", MediaType.APPLICATION_JSON);
337 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
338 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
340 ResponseEntity<String> response = restTemplate.exchange(
341 builder.toUriString(),
342 HttpMethod.GET, entity, String.class);
344 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
345 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
349 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
350 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
351 headers.set("Accept", MediaType.APPLICATION_JSON);
353 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
354 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
356 ResponseEntity<String> response = restTemplate.exchange(
357 builder.toUriString(),
358 HttpMethod.GET, entity, String.class);
360 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
361 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
365 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
366 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
367 headers.set("Accept", MediaType.APPLICATION_JSON);
369 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
370 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
372 ResponseEntity<String> response = restTemplate.exchange(
373 builder.toUriString(),
374 HttpMethod.GET, entity, String.class);
376 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
377 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
381 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
382 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
383 headers.set("Accept", MediaType.APPLICATION_JSON);
385 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
386 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
388 ResponseEntity<String> response = restTemplate.exchange(
389 builder.toUriString(),
390 HttpMethod.GET, entity, String.class);
392 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
393 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
397 public void testSerfviceVNFResources404() throws JSONException {
398 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
399 headers.set("Accept", MediaType.APPLICATION_JSON);
401 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
402 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
404 ResponseEntity<String> response = restTemplate.exchange(
405 builder.toUriString(),
406 HttpMethod.GET, entity, String.class);
408 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
414 public void testSerfviceVNFBadParams() throws JSONException {
415 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
416 headers.set("Accept", MediaType.APPLICATION_JSON);
418 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
419 .queryParam("BadParamName", "BADNAME");
421 ResponseEntity<String> response = restTemplate.exchange(
422 builder.toUriString(),
423 HttpMethod.GET, entity, String.class);
424 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
425 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
432 /* Network Resources Endpoint */
435 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
436 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
437 headers.set("Accept", MediaType.APPLICATION_JSON);
438 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}";
439 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
442 ResponseEntity<String> response = restTemplate.exchange(
443 builder.toUriString(),
444 HttpMethod.GET, entity, String.class);
446 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
447 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
453 public void testGetNetworkResources404() throws JSONException {
454 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
455 headers.set("Accept", MediaType.APPLICATION_JSON);
457 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"))
460 ResponseEntity<String> response = restTemplate.exchange(
461 builder.toUriString(),
462 HttpMethod.GET, entity, String.class);
464 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
468 /* Service Network Resources Endpoints */
471 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
472 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
473 headers.set("Accept", MediaType.APPLICATION_JSON);
475 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
476 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
478 ResponseEntity<String> response = restTemplate.exchange(
479 builder.toUriString(),
480 HttpMethod.GET, entity, String.class);
482 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
483 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
487 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
488 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
489 headers.set("Accept", MediaType.APPLICATION_JSON);
491 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
492 .queryParam("serviceModelUuid", serviceUUID);
494 ResponseEntity<String> response = restTemplate.exchange(
495 builder.toUriString(),
496 HttpMethod.GET, entity, String.class);
498 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
499 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
503 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
504 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
505 headers.set("Accept", MediaType.APPLICATION_JSON);
507 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
508 .queryParam("serviceModelUuid", "doesNotExist");
510 ResponseEntity<String> response = restTemplate.exchange(
511 builder.toUriString(),
512 HttpMethod.GET, entity, String.class);
514 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
519 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
520 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
521 headers.set("Accept", MediaType.APPLICATION_JSON);
523 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
524 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
526 ResponseEntity<String> response = restTemplate.exchange(
527 builder.toUriString(),
528 HttpMethod.GET, entity, String.class);
530 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
535 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
536 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
537 headers.set("Accept", MediaType.APPLICATION_JSON);
539 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
540 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
542 ResponseEntity<String> response = restTemplate.exchange(
543 builder.toUriString(),
544 HttpMethod.GET, entity, String.class);
546 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
547 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
551 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
552 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
553 headers.set("Accept", MediaType.APPLICATION_JSON);
555 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
556 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
557 .queryParam("serviceModelVersion", "2.0");
559 ResponseEntity<String> response = restTemplate.exchange(
560 builder.toUriString(),
561 HttpMethod.GET, entity, String.class);
563 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
564 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
568 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
569 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
570 headers.set("Accept", MediaType.APPLICATION_JSON);
572 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
573 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
574 .queryParam("serviceModelVersion", "");
575 ResponseEntity<String> response = restTemplate.exchange(
576 builder.toUriString(),
577 HttpMethod.GET, entity, String.class);
579 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
580 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
585 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
586 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
587 headers.set("Accept", MediaType.APPLICATION_JSON);
589 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
590 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
592 ResponseEntity<String> response = restTemplate.exchange(
593 builder.toUriString(),
594 HttpMethod.GET, entity, String.class);
596 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
597 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
601 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
602 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
603 headers.set("Accept", MediaType.APPLICATION_JSON);
605 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
606 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
608 ResponseEntity<String> response = restTemplate.exchange(
609 builder.toUriString(),
610 HttpMethod.GET, entity, String.class);
612 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
613 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
616 /* Allotted endpoints */
619 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
620 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
621 headers.set("Accept", MediaType.APPLICATION_JSON);
622 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}";
624 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
627 ResponseEntity<String> response = restTemplate.exchange(
628 builder.toUriString(),
629 HttpMethod.GET, entity, String.class);
631 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
632 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
637 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
638 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
639 headers.set("Accept", MediaType.APPLICATION_JSON);
641 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
642 .queryParam("serviceModelUuid",serviceUUID);
644 ResponseEntity<String> response = restTemplate.exchange(
645 builder.toUriString(),
646 HttpMethod.GET, entity, String.class);
648 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
649 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
653 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
654 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
655 headers.set("Accept", MediaType.APPLICATION_JSON);
657 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
658 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
660 ResponseEntity<String> response = restTemplate.exchange(
661 builder.toUriString(),
662 HttpMethod.GET, entity, String.class);
664 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
665 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
669 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
670 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
671 headers.set("Accept", MediaType.APPLICATION_JSON);
673 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
674 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
675 .queryParam("serviceModelVersion", "1.0");
677 ResponseEntity<String> response = restTemplate.exchange(
678 builder.toUriString(),
679 HttpMethod.GET, entity, String.class);
681 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
682 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
686 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
687 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
688 headers.set("Accept", MediaType.APPLICATION_JSON);
690 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
691 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
692 .queryParam("serviceModelVersion", "1.0");
694 ResponseEntity<String> response = restTemplate.exchange(
695 builder.toUriString(),
696 HttpMethod.GET, entity, String.class);
698 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
699 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
703 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
704 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
705 headers.set("Accept", MediaType.APPLICATION_JSON);
707 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
708 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
710 ResponseEntity<String> response = restTemplate.exchange(
711 builder.toUriString(),
712 HttpMethod.GET, entity, String.class);
714 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
715 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
720 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
721 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
722 headers.set("Accept", MediaType.APPLICATION_JSON);
724 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
725 .queryParam("arModelCustomizationUuid", "NOTEXIST");
727 ResponseEntity<String> response = restTemplate.exchange(
728 builder.toUriString(),
729 HttpMethod.GET, entity, String.class);
731 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
735 /* VF Modules Endpoint */
738 public void testGetVFModulesNonExistResource() throws JSONException {
739 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
740 headers.set("Accept", MediaType.APPLICATION_JSON);
742 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
743 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
745 ResponseEntity<String> response = restTemplate.exchange(
746 builder.toUriString(),
747 HttpMethod.GET, entity, String.class);
749 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
754 public void testGetVFModulesByVfModuleModelName() throws JSONException {
755 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
756 headers.set("Accept", MediaType.APPLICATION_JSON);
757 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}";
758 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
759 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
761 ResponseEntity<String> response = restTemplate.exchange(
762 builder.toUriString(),
763 HttpMethod.GET, entity, String.class);
765 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
766 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
771 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
772 TestAppender.events.clear();
773 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
774 headers.set("Accept", MediaType.APPLICATION_JSON);
776 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
777 .queryParam("ADASD", "NEUTRON_BASIC");
779 ResponseEntity<String> response = restTemplate.exchange(
780 builder.toUriString(),
781 HttpMethod.GET, entity, String.class);
783 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
784 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
787 for(ILoggingEvent logEvent : TestAppender.events)
788 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
789 logEvent.getMarker().getName().equals("ENTRY")
791 Map<String,String> mdc = logEvent.getMDCPropertyMap();
792 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
793 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
794 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
795 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
796 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
797 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
798 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
799 logEvent.getMarker().getName().equals("EXIT")){
800 Map<String,String> mdc = logEvent.getMDCPropertyMap();
801 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
802 assertNotNull(mdc.get(MsoLogger.ENDTIME));
803 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
804 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
805 assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));
806 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
807 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
808 assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
809 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
813 private String createURLWithPort(String uri) {
814 return "http://localhost:" + port + uri;