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 java.util.regex.Matcher;
29 import java.util.regex.Pattern;
30 import javax.ws.rs.core.MediaType;
31 import javax.ws.rs.core.Response;
34 import org.json.JSONException;
35 import org.junit.Before;
36 import org.junit.BeforeClass;
37 import org.junit.Test;
38 import org.junit.runner.RunWith;
39 import org.onap.logging.ref.slf4j.ONAPLogConstants;
40 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
42 import org.onap.so.logger.MsoLogger;
43 import org.skyscreamer.jsonassert.JSONAssert;
44 import org.skyscreamer.jsonassert.JSONCompareMode;
45 import org.springframework.boot.context.embedded.LocalServerPort;
46 import org.springframework.boot.test.context.SpringBootTest;
47 import org.springframework.boot.test.web.client.TestRestTemplate;
48 import org.springframework.http.HttpEntity;
49 import org.springframework.http.HttpHeaders;
50 import org.springframework.http.HttpMethod;
51 import org.springframework.http.ResponseEntity;
52 import org.springframework.test.annotation.DirtiesContext;
53 import org.springframework.test.annotation.DirtiesContext.ClassMode;
54 import org.springframework.test.context.ActiveProfiles;
55 import org.springframework.test.context.junit4.SpringRunner;
56 import org.springframework.web.util.UriComponentsBuilder;
58 import ch.qos.logback.classic.spi.ILoggingEvent;
61 @RunWith(SpringRunner.class)
62 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
63 @ActiveProfiles("test")
64 public class CatalogDBRestTest {
66 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
68 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources";
70 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
72 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
74 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
79 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
81 HttpHeaders headers = new HttpHeaders();
83 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}";
85 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}";
88 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}";
90 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}";
92 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}";
94 private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
96 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}";
98 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
100 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
102 /* Health Check Resources Endpoint */
105 public void testHealthcheck() throws JSONException {
107 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
109 ResponseEntity<String> response = restTemplate.exchange(
110 createURLWithPort("/manage/health"),
111 HttpMethod.GET, entity, String.class);
113 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
114 for(ILoggingEvent logEvent : TestAppender.events)
115 if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
116 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
118 Map<String,String> mdc = logEvent.getMDCPropertyMap();
119 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
120 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
121 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
122 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
123 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
124 assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
125 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
126 logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
127 Map<String,String> mdc = logEvent.getMDCPropertyMap();
128 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
129 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
130 assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
131 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
132 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
133 assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
137 /* Service Resources Endpoint */
140 public void testGetServiceModelUUID() throws JSONException {
141 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
142 headers.set("Accept", MediaType.APPLICATION_JSON);
144 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
145 .queryParam("serviceModelUuid", serviceUUID);
147 ResponseEntity<String> response = restTemplate.exchange(
148 builder.toUriString(),
149 HttpMethod.GET, entity, String.class);
151 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
152 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
156 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
157 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
158 headers.set("Accept", MediaType.APPLICATION_JSON);
159 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
160 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
162 ResponseEntity<String> response = restTemplate.exchange(
163 builder.toUriString(),
164 HttpMethod.GET, entity, String.class);
166 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
167 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
171 public void testGetServiceInvariantUUID() throws JSONException {
172 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
173 headers.set("Accept", MediaType.APPLICATION_JSON);
174 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
175 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
177 ResponseEntity<String> response = restTemplate.exchange(
178 builder.toUriString(),
179 HttpMethod.GET, entity, String.class);
181 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
182 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
186 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
187 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
188 headers.set("Accept", MediaType.APPLICATION_JSON);
189 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
190 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
192 ResponseEntity<String> response = restTemplate.exchange(
193 builder.toUriString(),
194 HttpMethod.GET, entity, String.class);
196 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
197 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
201 public void testGetServiceModelUUID404() throws JSONException {
202 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
203 headers.set("Accept", MediaType.APPLICATION_JSON);
204 String expectedResponse = "\"serviceResources\": null";
205 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
206 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
208 ResponseEntity<String> response = restTemplate.exchange(
209 builder.toUriString(),
210 HttpMethod.GET, entity, String.class);
212 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
213 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
217 public void testGetServiceBadQueryParams() throws JSONException {
218 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
219 headers.set("Accept", MediaType.APPLICATION_JSON);
220 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
221 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
223 ResponseEntity<String> response = restTemplate.exchange(
224 builder.toUriString(),
225 HttpMethod.GET, entity, String.class);
227 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
228 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
231 /* VNF Resources Endpoint */
234 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
235 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
236 headers.set("Accept", MediaType.APPLICATION_JSON);
237 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}";
238 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
241 ResponseEntity<String> response = restTemplate.exchange(
242 builder.toUriString(),
243 HttpMethod.GET, entity, String.class);
245 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
246 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
252 public void testGetVNFResources404() throws JSONException {
253 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
254 headers.set("Accept", MediaType.APPLICATION_JSON);
256 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
259 ResponseEntity<String> response = restTemplate.exchange(
260 builder.toUriString(),
261 HttpMethod.GET, entity, String.class);
263 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
268 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
269 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
270 headers.set("Accept", MediaType.APPLICATION_JSON);
272 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
273 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
275 ResponseEntity<String> response = restTemplate.exchange(
276 builder.toUriString(),
277 HttpMethod.GET, entity, String.class);
279 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
280 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
284 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
285 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
286 headers.set("Accept", MediaType.APPLICATION_JSON);
288 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
289 .queryParam("serviceModelUuid", serviceUUID);
291 ResponseEntity<String> response = restTemplate.exchange(
292 builder.toUriString(),
293 HttpMethod.GET, entity, String.class);
295 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
296 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
300 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
301 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
302 headers.set("Accept", MediaType.APPLICATION_JSON);
304 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
305 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
306 .queryParam("serviceModelVersion", "1.0");
308 ResponseEntity<String> response = restTemplate.exchange(
309 builder.toUriString(),
310 HttpMethod.GET, entity, String.class);
312 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
313 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
317 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
318 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
319 headers.set("Accept", MediaType.APPLICATION_JSON);
321 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
322 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
323 .queryParam("serviceModelVersion", "");
325 ResponseEntity<String> response = restTemplate.exchange(
326 builder.toUriString(),
327 HttpMethod.GET, entity, String.class);
329 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
330 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
335 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
336 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
337 headers.set("Accept", MediaType.APPLICATION_JSON);
339 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
340 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
342 ResponseEntity<String> response = restTemplate.exchange(
343 builder.toUriString(),
344 HttpMethod.GET, entity, String.class);
346 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
347 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
351 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
352 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
353 headers.set("Accept", MediaType.APPLICATION_JSON);
355 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
356 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
358 ResponseEntity<String> response = restTemplate.exchange(
359 builder.toUriString(),
360 HttpMethod.GET, entity, String.class);
362 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
363 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
367 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
368 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
369 headers.set("Accept", MediaType.APPLICATION_JSON);
371 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
372 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
374 ResponseEntity<String> response = restTemplate.exchange(
375 builder.toUriString(),
376 HttpMethod.GET, entity, String.class);
378 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
379 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
383 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
384 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
385 headers.set("Accept", MediaType.APPLICATION_JSON);
387 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
388 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
390 ResponseEntity<String> response = restTemplate.exchange(
391 builder.toUriString(),
392 HttpMethod.GET, entity, String.class);
394 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
395 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
399 public void testSerfviceVNFResources404() throws JSONException {
400 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
401 headers.set("Accept", MediaType.APPLICATION_JSON);
403 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
404 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
406 ResponseEntity<String> response = restTemplate.exchange(
407 builder.toUriString(),
408 HttpMethod.GET, entity, String.class);
410 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
416 public void testSerfviceVNFBadParams() throws JSONException {
417 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
418 headers.set("Accept", MediaType.APPLICATION_JSON);
420 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
421 .queryParam("BadParamName", "BADNAME");
423 ResponseEntity<String> response = restTemplate.exchange(
424 builder.toUriString(),
425 HttpMethod.GET, entity, String.class);
426 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
427 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
434 /* Network Resources Endpoint */
437 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
438 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
439 headers.set("Accept", MediaType.APPLICATION_JSON);
440 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}";
441 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
444 ResponseEntity<String> response = restTemplate.exchange(
445 builder.toUriString(),
446 HttpMethod.GET, entity, String.class);
448 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
449 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
455 public void testGetNetworkResources404() throws JSONException {
456 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
457 headers.set("Accept", MediaType.APPLICATION_JSON);
459 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"))
462 ResponseEntity<String> response = restTemplate.exchange(
463 builder.toUriString(),
464 HttpMethod.GET, entity, String.class);
466 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
470 /* Service Network Resources Endpoints */
473 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
474 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
475 headers.set("Accept", MediaType.APPLICATION_JSON);
477 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
478 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
480 ResponseEntity<String> response = restTemplate.exchange(
481 builder.toUriString(),
482 HttpMethod.GET, entity, String.class);
484 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
485 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
489 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
490 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
491 headers.set("Accept", MediaType.APPLICATION_JSON);
493 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
494 .queryParam("serviceModelUuid", serviceUUID);
496 ResponseEntity<String> response = restTemplate.exchange(
497 builder.toUriString(),
498 HttpMethod.GET, entity, String.class);
500 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
501 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
505 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
506 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
507 headers.set("Accept", MediaType.APPLICATION_JSON);
509 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
510 .queryParam("serviceModelUuid", "doesNotExist");
512 ResponseEntity<String> response = restTemplate.exchange(
513 builder.toUriString(),
514 HttpMethod.GET, entity, String.class);
516 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
521 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
522 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
523 headers.set("Accept", MediaType.APPLICATION_JSON);
525 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
526 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
528 ResponseEntity<String> response = restTemplate.exchange(
529 builder.toUriString(),
530 HttpMethod.GET, entity, String.class);
532 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
537 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
538 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
539 headers.set("Accept", MediaType.APPLICATION_JSON);
541 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
542 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
544 ResponseEntity<String> response = restTemplate.exchange(
545 builder.toUriString(),
546 HttpMethod.GET, entity, String.class);
548 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
549 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
553 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
554 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
555 headers.set("Accept", MediaType.APPLICATION_JSON);
557 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
558 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
559 .queryParam("serviceModelVersion", "2.0");
561 ResponseEntity<String> response = restTemplate.exchange(
562 builder.toUriString(),
563 HttpMethod.GET, entity, String.class);
565 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
566 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
570 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
571 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
572 headers.set("Accept", MediaType.APPLICATION_JSON);
574 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
575 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
576 .queryParam("serviceModelVersion", "");
577 ResponseEntity<String> response = restTemplate.exchange(
578 builder.toUriString(),
579 HttpMethod.GET, entity, String.class);
581 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
582 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
587 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
588 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
589 headers.set("Accept", MediaType.APPLICATION_JSON);
591 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
592 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
594 ResponseEntity<String> response = restTemplate.exchange(
595 builder.toUriString(),
596 HttpMethod.GET, entity, String.class);
598 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
599 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
603 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
604 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
605 headers.set("Accept", MediaType.APPLICATION_JSON);
607 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
608 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
610 ResponseEntity<String> response = restTemplate.exchange(
611 builder.toUriString(),
612 HttpMethod.GET, entity, String.class);
614 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
615 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
618 /* Allotted endpoints */
621 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
622 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
623 headers.set("Accept", MediaType.APPLICATION_JSON);
624 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}";
626 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
629 ResponseEntity<String> response = restTemplate.exchange(
630 builder.toUriString(),
631 HttpMethod.GET, entity, String.class);
633 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
634 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
639 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
640 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
641 headers.set("Accept", MediaType.APPLICATION_JSON);
643 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
644 .queryParam("serviceModelUuid",serviceUUID);
646 ResponseEntity<String> response = restTemplate.exchange(
647 builder.toUriString(),
648 HttpMethod.GET, entity, String.class);
650 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
651 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
655 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
656 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
657 headers.set("Accept", MediaType.APPLICATION_JSON);
659 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
660 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
662 ResponseEntity<String> response = restTemplate.exchange(
663 builder.toUriString(),
664 HttpMethod.GET, entity, String.class);
666 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
667 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
671 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
672 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
673 headers.set("Accept", MediaType.APPLICATION_JSON);
675 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
676 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
677 .queryParam("serviceModelVersion", "1.0");
679 ResponseEntity<String> response = restTemplate.exchange(
680 builder.toUriString(),
681 HttpMethod.GET, entity, String.class);
683 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
684 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
688 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
689 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
690 headers.set("Accept", MediaType.APPLICATION_JSON);
692 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
693 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
694 .queryParam("serviceModelVersion", "1.0");
696 ResponseEntity<String> response = restTemplate.exchange(
697 builder.toUriString(),
698 HttpMethod.GET, entity, String.class);
700 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
701 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
705 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
706 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
707 headers.set("Accept", MediaType.APPLICATION_JSON);
709 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
710 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
712 ResponseEntity<String> response = restTemplate.exchange(
713 builder.toUriString(),
714 HttpMethod.GET, entity, String.class);
716 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
717 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
722 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
723 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
724 headers.set("Accept", MediaType.APPLICATION_JSON);
726 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
727 .queryParam("arModelCustomizationUuid", "NOTEXIST");
729 ResponseEntity<String> response = restTemplate.exchange(
730 builder.toUriString(),
731 HttpMethod.GET, entity, String.class);
733 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
737 /* VF Modules Endpoint */
740 public void testGetVFModulesNonExistResource() throws JSONException {
741 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
742 headers.set("Accept", MediaType.APPLICATION_JSON);
744 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
745 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
747 ResponseEntity<String> response = restTemplate.exchange(
748 builder.toUriString(),
749 HttpMethod.GET, entity, String.class);
751 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
756 public void testGetVFModulesByVfModuleModelName() throws JSONException {
757 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
758 headers.set("Accept", MediaType.APPLICATION_JSON);
759 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}";
760 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
761 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
763 ResponseEntity<String> response = restTemplate.exchange(
764 builder.toUriString(),
765 HttpMethod.GET, entity, String.class);
767 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
768 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
773 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
774 TestAppender.events.clear();
775 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
776 headers.set("Accept", MediaType.APPLICATION_JSON);
778 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
779 .queryParam("ADASD", "NEUTRON_BASIC");
781 ResponseEntity<String> response = restTemplate.exchange(
782 builder.toUriString(),
783 HttpMethod.GET, entity, String.class);
785 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
786 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
789 for(ILoggingEvent logEvent : TestAppender.events)
790 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
791 logEvent.getMarker().getName().equals("ENTRY")
793 Map<String,String> mdc = logEvent.getMDCPropertyMap();
794 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
795 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
796 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
797 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
798 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
799 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
800 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
801 logEvent.getMarker().getName().equals("EXIT")){
802 Map<String,String> mdc = logEvent.getMDCPropertyMap();
803 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
804 assertNotNull(mdc.get(MsoLogger.ENDTIME));
805 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
806 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
807 assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));
808 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
809 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
810 assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
811 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
815 private String createURLWithPort(String uri) {
816 return "http://localhost:" + port + uri;