2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.INVOCATION_ID;
26 import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.LOG_TIMESTAMP;
27 import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.PARTNER_NAME;
28 import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_CODE;
29 import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION;
30 import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE;
31 import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.SERVICE_NAME;
32 import java.io.IOException;
34 import javax.ws.rs.core.MediaType;
35 import javax.ws.rs.core.Response;
36 import org.json.JSONException;
37 import org.junit.Test;
38 import org.onap.logging.ref.slf4j.ONAPLogConstants;
39 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
40 import org.onap.so.db.catalog.beans.ServiceRecipe;
41 import org.skyscreamer.jsonassert.JSONAssert;
42 import org.skyscreamer.jsonassert.JSONCompareMode;
43 import org.springframework.boot.test.web.client.TestRestTemplate;
44 import org.springframework.http.HttpEntity;
45 import org.springframework.http.HttpHeaders;
46 import org.springframework.http.HttpMethod;
47 import org.springframework.http.ResponseEntity;
48 import org.springframework.web.util.UriComponentsBuilder;
49 import ch.qos.logback.classic.spi.ILoggingEvent;
52 public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
54 private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
56 private static final String SERVICE_RECIPE = "serviceRecipe";
58 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES =
59 "ecomp/mso/catalog/v2/serviceAllottedResources";
61 private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe";
63 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
65 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
67 private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
69 TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
71 HttpHeaders headers = new HttpHeaders();
73 private final String expectedServiceResourceResponse =
74 "{\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}";
76 private final String expectedServiceResourceResponsev2 =
77 "{\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}";
80 private final String expectedServiceVnfResponse =
81 "{\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}";
83 private final String expectedServiceVnfResponseV3 =
84 "{\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}";
86 private final String expectedServiceNetworkResourceResponse =
87 "{\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}";
89 private final String badQueryParamResponse =
90 "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
92 private final String expectedAllottedResponse =
93 "{\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}";
95 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
97 private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df";
99 private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
101 /* Health Check Resources Endpoint */
104 public void testHealthcheck() throws JSONException {
106 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
108 ResponseEntity<String> response =
109 restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
111 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
112 for (ILoggingEvent logEvent : TestAppender.events)
113 if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
114 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
115 Map<String, String> mdc = logEvent.getMDCPropertyMap();
116 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
117 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
118 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
119 assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
120 assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
121 assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
122 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor")
123 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
124 Map<String, String> mdc = logEvent.getMDCPropertyMap();
125 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
126 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
127 assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
128 assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
129 assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
130 assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
134 /* Service Resources Endpoint */
137 public void testGetServiceModelUUID() throws JSONException {
138 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
139 headers.set("Accept", MediaType.APPLICATION_JSON);
141 UriComponentsBuilder builder =
142 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
143 .queryParam("serviceModelUuid", serviceUUID);
145 ResponseEntity<String> response =
146 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
148 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
149 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(),
150 JSONCompareMode.LENIENT);
154 public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
155 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
156 headers.set("Accept", MediaType.APPLICATION_JSON);
157 UriComponentsBuilder builder =
158 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
159 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
160 .queryParam("serviceModelVersion", "1.0");
162 ResponseEntity<String> response =
163 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
165 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
166 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
170 public void testGetServiceInvariantUUID() throws JSONException {
171 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
172 headers.set("Accept", MediaType.APPLICATION_JSON);
173 UriComponentsBuilder builder =
174 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
175 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
177 ResponseEntity<String> response =
178 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
180 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
181 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
185 public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
186 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
187 headers.set("Accept", MediaType.APPLICATION_JSON);
188 UriComponentsBuilder builder =
189 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
190 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
191 .queryParam("serviceModelVersion", "");;
193 ResponseEntity<String> response =
194 restTemplate.exchange(builder.toUriString(), 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 =
206 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
207 .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
209 ResponseEntity<String> response =
210 restTemplate.exchange(builder.toUriString(), 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 =
221 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
222 .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
224 ResponseEntity<String> response =
225 restTemplate.exchange(builder.toUriString(), 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 =
238 "{\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}";
239 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
240 createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"));
242 ResponseEntity<String> response =
243 restTemplate.exchange(builder.toUriString(), 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
257 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"));
259 ResponseEntity<String> response =
260 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
262 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
267 public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
268 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
269 headers.set("Accept", MediaType.APPLICATION_JSON);
271 UriComponentsBuilder builder =
272 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
273 .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
275 ResponseEntity<String> response =
276 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
278 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
279 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
283 public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
284 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
285 headers.set("Accept", MediaType.APPLICATION_JSON);
287 UriComponentsBuilder builder =
288 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
289 .queryParam("serviceModelUuid", serviceUUID);
291 ResponseEntity<String> response =
292 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
294 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
295 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
299 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
300 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
301 headers.set("Accept", MediaType.APPLICATION_JSON);
303 UriComponentsBuilder builder =
304 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 =
309 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
311 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
312 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
316 public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
317 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
318 headers.set("Accept", MediaType.APPLICATION_JSON);
320 UriComponentsBuilder builder =
321 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
322 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
323 .queryParam("serviceModelVersion", "");
325 ResponseEntity<String> response =
326 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
328 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
329 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
334 public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
335 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
336 headers.set("Accept", MediaType.APPLICATION_JSON);
338 UriComponentsBuilder builder =
339 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
340 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
342 ResponseEntity<String> response =
343 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
345 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
346 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
350 public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
351 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
352 headers.set("Accept", MediaType.APPLICATION_JSON);
354 UriComponentsBuilder builder =
355 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
356 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
358 ResponseEntity<String> response =
359 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
361 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
362 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
366 public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
367 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
368 headers.set("Accept", MediaType.APPLICATION_JSON);
370 UriComponentsBuilder builder = UriComponentsBuilder
371 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
372 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
374 ResponseEntity<String> response =
375 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
377 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
378 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
382 public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
383 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
384 headers.set("Accept", MediaType.APPLICATION_JSON);
386 UriComponentsBuilder builder =
387 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
388 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service")
389 .queryParam("serviceModelVersion", "1.0");
391 ResponseEntity<String> response =
392 restTemplate.exchange(builder.toUriString(), 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 =
404 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
405 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
407 ResponseEntity<String> response =
408 restTemplate.exchange(builder.toUriString(), 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 =
421 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
422 .queryParam("BadParamName", "BADNAME");
424 ResponseEntity<String> response =
425 restTemplate.exchange(builder.toUriString(), 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 =
441 "{\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}";
442 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
443 createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"));
445 ResponseEntity<String> response =
446 restTemplate.exchange(builder.toUriString(), 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
460 .fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"));
462 ResponseEntity<String> response =
463 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
465 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
469 /* Service Network Resources Endpoints */
472 public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
473 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
474 headers.set("Accept", MediaType.APPLICATION_JSON);
476 UriComponentsBuilder builder =
477 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
478 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
480 ResponseEntity<String> response =
481 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
483 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
484 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
488 public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
489 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
490 headers.set("Accept", MediaType.APPLICATION_JSON);
492 UriComponentsBuilder builder =
493 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
494 .queryParam("serviceModelUuid", serviceUUID);
496 ResponseEntity<String> response =
497 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
499 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
500 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
504 public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
505 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
506 headers.set("Accept", MediaType.APPLICATION_JSON);
508 UriComponentsBuilder builder =
509 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
510 .queryParam("serviceModelUuid", "doesNotExist");
512 ResponseEntity<String> response =
513 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
515 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
520 public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
521 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
522 headers.set("Accept", MediaType.APPLICATION_JSON);
524 UriComponentsBuilder builder =
525 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
526 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
528 ResponseEntity<String> response =
529 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
531 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
536 public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
537 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
538 headers.set("Accept", MediaType.APPLICATION_JSON);
540 UriComponentsBuilder builder =
541 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
542 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
544 ResponseEntity<String> response =
545 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
547 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
548 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
552 public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
553 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
554 headers.set("Accept", MediaType.APPLICATION_JSON);
556 UriComponentsBuilder builder = UriComponentsBuilder
557 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
558 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "2.0");
560 ResponseEntity<String> response =
561 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
563 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
564 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
568 public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
569 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
570 headers.set("Accept", MediaType.APPLICATION_JSON);
572 UriComponentsBuilder builder = UriComponentsBuilder
573 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
574 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "");
575 ResponseEntity<String> response =
576 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
578 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
579 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
584 public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
585 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
586 headers.set("Accept", MediaType.APPLICATION_JSON);
588 UriComponentsBuilder builder =
589 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
590 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
592 ResponseEntity<String> response =
593 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
595 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
596 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
600 public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
601 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
602 headers.set("Accept", MediaType.APPLICATION_JSON);
604 UriComponentsBuilder builder =
605 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
606 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
608 ResponseEntity<String> response =
609 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
611 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
612 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
615 /* Allotted endpoints */
618 public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
619 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
620 headers.set("Accept", MediaType.APPLICATION_JSON);
621 String expectedResponse =
622 "{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}";
624 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
625 createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
628 ResponseEntity<String> response =
629 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
631 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
632 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
637 public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
638 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
639 headers.set("Accept", MediaType.APPLICATION_JSON);
641 UriComponentsBuilder builder =
642 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
643 .queryParam("serviceModelUuid", serviceUUID);
645 ResponseEntity<String> response =
646 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
648 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
649 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
653 public void testResourceReceipe() throws JSONException {
654 String expectedResourceRecipe =
655 "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}";
657 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
658 headers.set("Accept", MediaType.APPLICATION_JSON);
660 UriComponentsBuilder builder =
661 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
662 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance");
664 ResponseEntity<String> response =
665 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
667 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
668 JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false);
672 public void testResourceReceipeNotMatched() throws JSONException {
674 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
675 headers.set("Accept", MediaType.APPLICATION_JSON);
677 UriComponentsBuilder builder =
678 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE))
679 .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action");
681 ResponseEntity<String> response =
682 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
684 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
688 public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
689 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
690 headers.set("Accept", MediaType.APPLICATION_JSON);
692 UriComponentsBuilder builder =
693 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
694 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
696 ResponseEntity<String> response =
697 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
699 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
700 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
704 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
705 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
706 headers.set("Accept", MediaType.APPLICATION_JSON);
708 UriComponentsBuilder builder = UriComponentsBuilder
709 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
710 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
712 ResponseEntity<String> response =
713 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
715 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
716 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
720 public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
721 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
722 headers.set("Accept", MediaType.APPLICATION_JSON);
724 UriComponentsBuilder builder = UriComponentsBuilder
725 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
726 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID).queryParam("serviceModelVersion", "1.0");
728 ResponseEntity<String> response =
729 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
731 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
732 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
736 public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
737 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
738 headers.set("Accept", MediaType.APPLICATION_JSON);
740 UriComponentsBuilder builder =
741 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
742 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
744 ResponseEntity<String> response =
745 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
747 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
748 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
753 public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
754 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
755 headers.set("Accept", MediaType.APPLICATION_JSON);
757 UriComponentsBuilder builder =
758 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
759 .queryParam("arModelCustomizationUuid", "NOTEXIST");
761 ResponseEntity<String> response =
762 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
764 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
768 /* VF Modules Endpoint */
771 public void testGetVFModulesNonExistResource() throws JSONException {
772 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
773 headers.set("Accept", MediaType.APPLICATION_JSON);
775 UriComponentsBuilder builder =
776 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
777 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
779 ResponseEntity<String> response =
780 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
782 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
787 public void testGetVFModulesByVfModuleModelName() throws JSONException {
788 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
789 headers.set("Accept", MediaType.APPLICATION_JSON);
790 String expectedResponse =
791 "{\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}";
792 UriComponentsBuilder builder =
793 UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
794 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
796 ResponseEntity<String> response =
797 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
799 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
800 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
805 public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
806 TestAppender.events.clear();
807 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
808 headers.set("Accept", MediaType.APPLICATION_JSON);
810 UriComponentsBuilder builder = UriComponentsBuilder
811 .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)).queryParam("ADASD", "NEUTRON_BASIC");
813 ResponseEntity<String> response =
814 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
816 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
817 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
820 for (ILoggingEvent logEvent : TestAppender.events)
821 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter")
822 && logEvent.getMarker().getName().equals("ENTRY")) {
823 Map<String, String> mdc = logEvent.getMDCPropertyMap();
824 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
825 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
826 assertNotNull(mdc.get(INVOCATION_ID));
827 assertEquals("UNKNOWN", mdc.get(PARTNER_NAME));
828 assertEquals("v2/vfModules", mdc.get(SERVICE_NAME));
829 assertEquals("INPROGRESS", mdc.get(RESPONSE_STATUS_CODE));
830 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter")
831 && logEvent.getMarker().getName().equals("EXIT")) {
832 Map<String, String> mdc = logEvent.getMDCPropertyMap();
833 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
834 assertNotNull(mdc.get(LOG_TIMESTAMP));
835 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
836 assertNotNull(mdc.get(INVOCATION_ID));
837 assertEquals("500", mdc.get(RESPONSE_CODE));
838 assertEquals("UNKNOWN", mdc.get(PARTNER_NAME));
839 assertEquals("v2/vfModules", mdc.get(SERVICE_NAME));
840 assertEquals("ERROR", mdc.get(RESPONSE_STATUS_CODE));
841 assertNotNull(mdc.get(RESPONSE_DESCRIPTION));
846 public void testCreateServiceRecipe() throws JSONException {
847 ServiceRecipe recipe = new ServiceRecipe();
848 recipe.setAction("action");
849 recipe.setDescription("description");
850 recipe.setOrchestrationUri("http://test");
851 recipe.setRecipeTimeout(120);
852 recipe.setServiceModelUUID(serviceUUID);
853 HttpEntity<ServiceRecipe> entity = new HttpEntity<ServiceRecipe>(recipe, headers);
854 headers.set("Accept", MediaType.APPLICATION_JSON);
856 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(SERVICE_RECIPE));
858 ResponseEntity<String> response =
859 restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
861 assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
864 private String createURLWithPort(String uri) {
865 return "http://localhost:" + port + uri;