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_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
72 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
74 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
76 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
81 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
83 HttpHeaders headers = new HttpHeaders();
85 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}";
87 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}";
90 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}";
92 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}";
94 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}";
96 private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
98 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}";
100 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
102 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
104 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
106 /* Health Check Resources Endpoint */
109 public void testHealthcheck() throws JSONException {
111 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
113 ResponseEntity<String> response = restTemplate.exchange(
114 createURLWithPort("/manage/health"),
115 HttpMethod.GET, entity, String.class);
117 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
118 for(ILoggingEvent logEvent : TestAppender.events)
119 if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
120 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
122 Map<String,String> mdc = logEvent.getMDCPropertyMap();
123 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
124 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
125 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
126 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
127 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
128 assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
129 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") &&
130 logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
131 Map<String,String> mdc = logEvent.getMDCPropertyMap();
132 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
133 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
134 assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
135 assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
136 assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
137 assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
141 /* Service Resources Endpoint */
144 public void testGetServiceModelUUID() throws JSONException {
145 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
146 headers.set("Accept", MediaType.APPLICATION_JSON);
148 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
149 .queryParam("serviceModelUuid", serviceUUID);
151 ResponseEntity<String> response = restTemplate.exchange(
152 builder.toUriString(),
153 HttpMethod.GET, entity, String.class);
155 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
156 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
160 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
161 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
162 headers.set("Accept", MediaType.APPLICATION_JSON);
163 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
164 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
166 ResponseEntity<String> response = restTemplate.exchange(
167 builder.toUriString(),
168 HttpMethod.GET, entity, String.class);
170 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
171 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
175 public void testGetServiceInvariantUUID() throws JSONException {
176 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
177 headers.set("Accept", MediaType.APPLICATION_JSON);
178 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
179 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
181 ResponseEntity<String> response = restTemplate.exchange(
182 builder.toUriString(),
183 HttpMethod.GET, entity, String.class);
185 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
186 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
190 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
191 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
192 headers.set("Accept", MediaType.APPLICATION_JSON);
193 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
194 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
196 ResponseEntity<String> response = restTemplate.exchange(
197 builder.toUriString(),
198 HttpMethod.GET, entity, String.class);
200 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
201 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
205 public void testGetServiceModelUUID404() throws JSONException {
206 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
207 headers.set("Accept", MediaType.APPLICATION_JSON);
208 String expectedResponse = "\"serviceResources\": null";
209 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
210 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
212 ResponseEntity<String> response = restTemplate.exchange(
213 builder.toUriString(),
214 HttpMethod.GET, entity, String.class);
216 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
217 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
221 public void testGetServiceBadQueryParams() throws JSONException {
222 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
223 headers.set("Accept", MediaType.APPLICATION_JSON);
224 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
225 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
227 ResponseEntity<String> response = restTemplate.exchange(
228 builder.toUriString(),
229 HttpMethod.GET, entity, String.class);
231 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
232 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
235 /* VNF Resources Endpoint */
238 public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
239 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
240 headers.set("Accept", MediaType.APPLICATION_JSON);
241 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}";
242 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
245 ResponseEntity<String> response = restTemplate.exchange(
246 builder.toUriString(),
247 HttpMethod.GET, entity, String.class);
249 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
250 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
256 public void testGetVNFResources404() throws JSONException {
257 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
258 headers.set("Accept", MediaType.APPLICATION_JSON);
260 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
263 ResponseEntity<String> response = restTemplate.exchange(
264 builder.toUriString(),
265 HttpMethod.GET, entity, String.class);
267 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
272 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
273 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
274 headers.set("Accept", MediaType.APPLICATION_JSON);
276 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
277 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
279 ResponseEntity<String> response = restTemplate.exchange(
280 builder.toUriString(),
281 HttpMethod.GET, entity, String.class);
283 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
284 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
288 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
289 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
290 headers.set("Accept", MediaType.APPLICATION_JSON);
292 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
293 .queryParam("serviceModelUuid", serviceUUID);
295 ResponseEntity<String> response = restTemplate.exchange(
296 builder.toUriString(),
297 HttpMethod.GET, entity, String.class);
299 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
300 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
304 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
305 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
306 headers.set("Accept", MediaType.APPLICATION_JSON);
308 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
309 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
310 .queryParam("serviceModelVersion", "1.0");
312 ResponseEntity<String> response = restTemplate.exchange(
313 builder.toUriString(),
314 HttpMethod.GET, entity, String.class);
316 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
317 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
321 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
322 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
323 headers.set("Accept", MediaType.APPLICATION_JSON);
325 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
326 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
327 .queryParam("serviceModelVersion", "");
329 ResponseEntity<String> response = restTemplate.exchange(
330 builder.toUriString(),
331 HttpMethod.GET, entity, String.class);
333 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
334 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
339 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
340 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
341 headers.set("Accept", MediaType.APPLICATION_JSON);
343 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
344 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
346 ResponseEntity<String> response = restTemplate.exchange(
347 builder.toUriString(),
348 HttpMethod.GET, entity, String.class);
350 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
351 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
355 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
356 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
357 headers.set("Accept", MediaType.APPLICATION_JSON);
359 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
360 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
362 ResponseEntity<String> response = restTemplate.exchange(
363 builder.toUriString(),
364 HttpMethod.GET, entity, String.class);
366 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
367 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
371 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
372 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
373 headers.set("Accept", MediaType.APPLICATION_JSON);
375 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
376 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
378 ResponseEntity<String> response = restTemplate.exchange(
379 builder.toUriString(),
380 HttpMethod.GET, entity, String.class);
382 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
383 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
387 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
388 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
389 headers.set("Accept", MediaType.APPLICATION_JSON);
391 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
392 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
394 ResponseEntity<String> response = restTemplate.exchange(
395 builder.toUriString(),
396 HttpMethod.GET, entity, String.class);
398 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
399 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
403 public void testSerfviceVNFResources404() throws JSONException {
404 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
405 headers.set("Accept", MediaType.APPLICATION_JSON);
407 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
408 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
410 ResponseEntity<String> response = restTemplate.exchange(
411 builder.toUriString(),
412 HttpMethod.GET, entity, String.class);
414 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
420 public void testSerfviceVNFBadParams() throws JSONException {
421 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
422 headers.set("Accept", MediaType.APPLICATION_JSON);
424 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
425 .queryParam("BadParamName", "BADNAME");
427 ResponseEntity<String> response = restTemplate.exchange(
428 builder.toUriString(),
429 HttpMethod.GET, entity, String.class);
430 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
431 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
438 /* Network Resources Endpoint */
441 public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
442 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
443 headers.set("Accept", MediaType.APPLICATION_JSON);
444 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}";
445 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
448 ResponseEntity<String> response = restTemplate.exchange(
449 builder.toUriString(),
450 HttpMethod.GET, entity, String.class);
452 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
453 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
459 public void testGetNetworkResources404() throws JSONException {
460 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
461 headers.set("Accept", MediaType.APPLICATION_JSON);
463 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"))
466 ResponseEntity<String> response = restTemplate.exchange(
467 builder.toUriString(),
468 HttpMethod.GET, entity, String.class);
470 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
474 /* Service Network Resources Endpoints */
477 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
478 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
479 headers.set("Accept", MediaType.APPLICATION_JSON);
481 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
482 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
484 ResponseEntity<String> response = restTemplate.exchange(
485 builder.toUriString(),
486 HttpMethod.GET, entity, String.class);
488 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
489 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
493 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
494 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
495 headers.set("Accept", MediaType.APPLICATION_JSON);
497 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
498 .queryParam("serviceModelUuid", serviceUUID);
500 ResponseEntity<String> response = restTemplate.exchange(
501 builder.toUriString(),
502 HttpMethod.GET, entity, String.class);
504 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
505 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
509 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
510 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
511 headers.set("Accept", MediaType.APPLICATION_JSON);
513 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
514 .queryParam("serviceModelUuid", "doesNotExist");
516 ResponseEntity<String> response = restTemplate.exchange(
517 builder.toUriString(),
518 HttpMethod.GET, entity, String.class);
520 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
525 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
526 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
527 headers.set("Accept", MediaType.APPLICATION_JSON);
529 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
530 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
532 ResponseEntity<String> response = restTemplate.exchange(
533 builder.toUriString(),
534 HttpMethod.GET, entity, String.class);
536 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
541 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
542 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
543 headers.set("Accept", MediaType.APPLICATION_JSON);
545 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
546 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
548 ResponseEntity<String> response = restTemplate.exchange(
549 builder.toUriString(),
550 HttpMethod.GET, entity, String.class);
552 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
553 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
557 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
558 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
559 headers.set("Accept", MediaType.APPLICATION_JSON);
561 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
562 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
563 .queryParam("serviceModelVersion", "2.0");
565 ResponseEntity<String> response = restTemplate.exchange(
566 builder.toUriString(),
567 HttpMethod.GET, entity, String.class);
569 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
570 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
574 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
575 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
576 headers.set("Accept", MediaType.APPLICATION_JSON);
578 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
579 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
580 .queryParam("serviceModelVersion", "");
581 ResponseEntity<String> response = restTemplate.exchange(
582 builder.toUriString(),
583 HttpMethod.GET, entity, String.class);
585 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
586 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
591 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
592 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
593 headers.set("Accept", MediaType.APPLICATION_JSON);
595 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
596 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
598 ResponseEntity<String> response = restTemplate.exchange(
599 builder.toUriString(),
600 HttpMethod.GET, entity, String.class);
602 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
603 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
607 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
608 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
609 headers.set("Accept", MediaType.APPLICATION_JSON);
611 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
612 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
614 ResponseEntity<String> response = restTemplate.exchange(
615 builder.toUriString(),
616 HttpMethod.GET, entity, String.class);
618 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
619 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
622 /* Allotted endpoints */
625 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
626 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
627 headers.set("Accept", MediaType.APPLICATION_JSON);
628 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}";
630 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
633 ResponseEntity<String> response = restTemplate.exchange(
634 builder.toUriString(),
635 HttpMethod.GET, entity, String.class);
637 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
638 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
643 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
644 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
645 headers.set("Accept", MediaType.APPLICATION_JSON);
647 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
648 .queryParam("serviceModelUuid",serviceUUID);
650 ResponseEntity<String> response = restTemplate.exchange(
651 builder.toUriString(),
652 HttpMethod.GET, entity, String.class);
654 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
655 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
659 public void testResourceReceipe() throws JSONException {
660 String expectedResourceRecipe = "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
662 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
663 headers.set("Accept", MediaType.APPLICATION_JSON);
665 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
666 .queryParam("resourceModelUuid", arResourceUUID)
667 .queryParam("action", "createInstance");
669 ResponseEntity<String> response = restTemplate.exchange(
670 builder.toUriString(),
671 HttpMethod.GET, entity, String.class);
673 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
674 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
678 public void testResourceReceipeNotMatched() throws JSONException {
680 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
681 headers.set("Accept", MediaType.APPLICATION_JSON);
683 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
684 .queryParam("resourceModelUuid", arResourceUUID)
685 .queryParam("action", "invalid_action");
687 ResponseEntity<String> response = restTemplate.exchange(
688 builder.toUriString(),
689 HttpMethod.GET, entity, String.class);
691 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
695 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
696 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
697 headers.set("Accept", MediaType.APPLICATION_JSON);
699 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
700 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
702 ResponseEntity<String> response = restTemplate.exchange(
703 builder.toUriString(),
704 HttpMethod.GET, entity, String.class);
706 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
707 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
711 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
712 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
713 headers.set("Accept", MediaType.APPLICATION_JSON);
715 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
716 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
717 .queryParam("serviceModelVersion", "1.0");
719 ResponseEntity<String> response = restTemplate.exchange(
720 builder.toUriString(),
721 HttpMethod.GET, entity, String.class);
723 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
724 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
728 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
729 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
730 headers.set("Accept", MediaType.APPLICATION_JSON);
732 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
733 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
734 .queryParam("serviceModelVersion", "1.0");
736 ResponseEntity<String> response = restTemplate.exchange(
737 builder.toUriString(),
738 HttpMethod.GET, entity, String.class);
740 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
741 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
745 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
746 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
747 headers.set("Accept", MediaType.APPLICATION_JSON);
749 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
750 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
752 ResponseEntity<String> response = restTemplate.exchange(
753 builder.toUriString(),
754 HttpMethod.GET, entity, String.class);
756 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
757 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
762 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
763 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
764 headers.set("Accept", MediaType.APPLICATION_JSON);
766 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
767 .queryParam("arModelCustomizationUuid", "NOTEXIST");
769 ResponseEntity<String> response = restTemplate.exchange(
770 builder.toUriString(),
771 HttpMethod.GET, entity, String.class);
773 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
777 /* VF Modules Endpoint */
780 public void testGetVFModulesNonExistResource() throws JSONException {
781 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
782 headers.set("Accept", MediaType.APPLICATION_JSON);
784 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
785 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
787 ResponseEntity<String> response = restTemplate.exchange(
788 builder.toUriString(),
789 HttpMethod.GET, entity, String.class);
791 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
796 public void testGetVFModulesByVfModuleModelName() throws JSONException {
797 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
798 headers.set("Accept", MediaType.APPLICATION_JSON);
799 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}";
800 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
801 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
803 ResponseEntity<String> response = restTemplate.exchange(
804 builder.toUriString(),
805 HttpMethod.GET, entity, String.class);
807 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
808 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
813 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
814 TestAppender.events.clear();
815 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
816 headers.set("Accept", MediaType.APPLICATION_JSON);
818 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
819 .queryParam("ADASD", "NEUTRON_BASIC");
821 ResponseEntity<String> response = restTemplate.exchange(
822 builder.toUriString(),
823 HttpMethod.GET, entity, String.class);
825 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
826 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
829 for(ILoggingEvent logEvent : TestAppender.events)
830 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
831 logEvent.getMarker().getName().equals("ENTRY")
833 Map<String,String> mdc = logEvent.getMDCPropertyMap();
834 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
835 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
836 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
837 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
838 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
839 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
840 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
841 logEvent.getMarker().getName().equals("EXIT")){
842 Map<String,String> mdc = logEvent.getMDCPropertyMap();
843 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
844 assertNotNull(mdc.get(MsoLogger.ENDTIME));
845 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
846 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
847 assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));
848 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
849 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
850 assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
851 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
855 private String createURLWithPort(String uri) {
856 return "http://localhost:" + port + uri;