f3315b57eb5730f7d0f006c6a2f375dba2ebf98a
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.adapters.catalogdb.catalogrest;
22
23 import static org.junit.Assert.*;
24
25
26 import java.io.IOException;
27 import java.util.Map;
28 import javax.ws.rs.core.MediaType;
29 import javax.ws.rs.core.Response;
30
31
32 import org.json.JSONException;
33 import org.junit.Before;
34 import org.junit.BeforeClass;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37 import org.onap.so.adapters.catalogdb.CatalogDBApplication;
38
39 import org.onap.so.logger.MsoLogger;
40 import org.skyscreamer.jsonassert.JSONAssert;
41 import org.skyscreamer.jsonassert.JSONCompareMode;
42 import org.springframework.boot.context.embedded.LocalServerPort;
43 import org.springframework.boot.test.context.SpringBootTest;
44 import org.springframework.boot.test.web.client.TestRestTemplate;
45 import org.springframework.http.HttpEntity;
46 import org.springframework.http.HttpHeaders;
47 import org.springframework.http.HttpMethod;
48 import org.springframework.http.ResponseEntity;
49 import org.springframework.test.annotation.DirtiesContext;
50 import org.springframework.test.annotation.DirtiesContext.ClassMode;
51 import org.springframework.test.context.ActiveProfiles;
52 import org.springframework.test.context.junit4.SpringRunner;
53 import org.springframework.web.util.UriComponentsBuilder;
54
55 import ch.qos.logback.classic.spi.ILoggingEvent;
56
57
58 @RunWith(SpringRunner.class)
59 @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
60 @ActiveProfiles("test")
61
62 public class CatalogDBRestTest {
63
64         private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
65
66         private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources";
67
68         private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks";
69
70         private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs";
71
72         private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
73
74         @LocalServerPort
75         private int port;
76
77         TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
78
79         HttpHeaders headers = new HttpHeaders();
80         
81         private final String expectedServiceResourceResponse = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}";
82
83         private final String expectedServiceResourceResponsev2 = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}";
84
85         
86         private final String expectedServiceVnfResponse = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}";
87
88         private final String expectedServiceVnfResponseV3 = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}";
89         
90         private final String expectedServiceNetworkResourceResponse = "{\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n]\r\n}";
91         
92         private final String badQueryParamResponse  = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\"";
93         
94         private final String expectedAllottedResponse = "{\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}";
95         
96         private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
97         
98         private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671";
99         
100         /* Health Check Resources Endpoint */
101         
102         @Test
103         public void testHealthcheck() throws JSONException {
104
105                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
106
107                 ResponseEntity<String> response = restTemplate.exchange(
108                                 createURLWithPort("/manage/health"),
109                                 HttpMethod.GET, entity, String.class);
110                 
111                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
112         }
113         
114         /* Service Resources Endpoint */
115         
116         @Test
117         public void testGetServiceModelUUID() throws JSONException {
118                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
119                 headers.set("Accept", MediaType.APPLICATION_JSON);
120                 
121                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
122                         .queryParam("serviceModelUuid", serviceUUID);
123                        
124                 ResponseEntity<String> response = restTemplate.exchange(
125                                 builder.toUriString(),
126                                 HttpMethod.GET, entity, String.class);
127                 
128                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
129                 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT);
130         }
131         
132         @Test
133         public void testGetServiceInvariantUUIDAndVersion() throws JSONException {
134                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
135                 headers.set("Accept", MediaType.APPLICATION_JSON);
136                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
137                         .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0");
138                        
139                 ResponseEntity<String> response = restTemplate.exchange(
140                                 builder.toUriString(),
141                                 HttpMethod.GET, entity, String.class);
142                 
143                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
144                 JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false);
145         }
146         
147         @Test
148         public void testGetServiceInvariantUUID() throws JSONException {
149                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
150                 headers.set("Accept", MediaType.APPLICATION_JSON);
151         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
152                         .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
153                        
154                 ResponseEntity<String> response = restTemplate.exchange(
155                                 builder.toUriString(),
156                                 HttpMethod.GET, entity, String.class);
157                 
158                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
159                 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
160         }
161         
162         @Test
163         public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException {
164                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
165                 headers.set("Accept", MediaType.APPLICATION_JSON);
166                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
167                         .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");;
168                        
169                 ResponseEntity<String> response = restTemplate.exchange(
170                                 builder.toUriString(),
171                                 HttpMethod.GET, entity, String.class);
172                 
173                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
174                 JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false);
175         }
176         
177         @Test
178         public void testGetServiceModelUUID404() throws JSONException {
179                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
180                 headers.set("Accept", MediaType.APPLICATION_JSON);
181                 String expectedResponse = "\"serviceResources\": null";
182                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
183                         .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93");
184                        
185                 ResponseEntity<String> response = restTemplate.exchange(
186                                 builder.toUriString(),
187                                 HttpMethod.GET, entity, String.class);
188                 
189                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
190                 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
191         }
192         
193         @Test
194         public void testGetServiceBadQueryParams() throws JSONException {
195                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
196                 headers.set("Accept", MediaType.APPLICATION_JSON);
197                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES))
198                         .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93");
199                        
200                 ResponseEntity<String> response = restTemplate.exchange(
201                                 builder.toUriString(),
202                                 HttpMethod.GET, entity, String.class);
203                 
204                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
205                 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
206         }
207         
208         /* VNF Resources Endpoint */
209         
210         @Test
211         public void testGetVNFResourcesByCustomizationUUID() throws JSONException {
212                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
213                 headers.set("Accept", MediaType.APPLICATION_JSON);
214                 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}";
215                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671"))
216                        ;
217                        
218                 ResponseEntity<String> response = restTemplate.exchange(
219                                 builder.toUriString(),
220                                 HttpMethod.GET, entity, String.class);
221                 
222                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
223                 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
224         }
225         
226         
227         
228         @Test
229         public void testGetVNFResources404() throws JSONException {
230                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
231                 headers.set("Accept", MediaType.APPLICATION_JSON);
232                 
233                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671"))
234                        ;
235                        
236                 ResponseEntity<String> response = restTemplate.exchange(
237                                 builder.toUriString(),
238                                 HttpMethod.GET, entity, String.class);
239                 
240                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
241                 
242         }
243         
244         @Test
245         public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException {
246                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
247                 headers.set("Accept", MediaType.APPLICATION_JSON);
248                 
249                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
250                        .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671");
251                        
252                 ResponseEntity<String> response = restTemplate.exchange(
253                                 builder.toUriString(),
254                                 HttpMethod.GET, entity, String.class);
255                 
256                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
257                 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
258         }
259         
260         @Test
261         public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException {
262                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
263                 headers.set("Accept", MediaType.APPLICATION_JSON);
264                 
265                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
266                                 .queryParam("serviceModelUuid", serviceUUID);
267                        
268                 ResponseEntity<String> response = restTemplate.exchange(
269                                 builder.toUriString(),
270                                 HttpMethod.GET, entity, String.class);
271                 
272                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
273                 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
274         }
275         
276         @Test
277         public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
278                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
279                 headers.set("Accept", MediaType.APPLICATION_JSON);
280                 
281                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
282                                 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
283                                 .queryParam("serviceModelVersion", "1.0");
284                        
285                 ResponseEntity<String> response = restTemplate.exchange(
286                                 builder.toUriString(),
287                                 HttpMethod.GET, entity, String.class);
288                 
289                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
290                 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
291         }
292         
293         @Test
294         public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException {
295                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
296                 headers.set("Accept", MediaType.APPLICATION_JSON);
297                 
298                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
299                                 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671")
300                                 .queryParam("serviceModelVersion", "");
301                        
302                 ResponseEntity<String> response = restTemplate.exchange(
303                                 builder.toUriString(),
304                                 HttpMethod.GET, entity, String.class);
305                 
306                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
307                 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
308         }
309         
310         
311         @Test
312         public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException {
313                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
314                 headers.set("Accept", MediaType.APPLICATION_JSON);
315                 
316                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
317                                 .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671");
318                        
319                 ResponseEntity<String> response = restTemplate.exchange(
320                                 builder.toUriString(),
321                                 HttpMethod.GET, entity, String.class);
322                 
323                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
324                 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
325         }
326         
327         @Test
328         public void testGetServiceVNFResourcesByServiceModelName() throws JSONException {
329                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
330                 headers.set("Accept", MediaType.APPLICATION_JSON);
331                 
332                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
333                                 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service");
334                        
335                 ResponseEntity<String> response = restTemplate.exchange(
336                                 builder.toUriString(),
337                                 HttpMethod.GET, entity, String.class);
338                 
339                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
340                 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
341         }
342         
343         @Test
344         public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException {
345                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
346                 headers.set("Accept", MediaType.APPLICATION_JSON);
347                 
348                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
349                                 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "");
350                        
351                 ResponseEntity<String> response = restTemplate.exchange(
352                                 builder.toUriString(),
353                                 HttpMethod.GET, entity, String.class);
354                 
355                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
356                 JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false);
357         }
358         
359         @Test
360         public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException {
361                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
362                 headers.set("Accept", MediaType.APPLICATION_JSON);
363                 
364                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
365                                 .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0");
366                        
367                 ResponseEntity<String> response = restTemplate.exchange(
368                                 builder.toUriString(),
369                                 HttpMethod.GET, entity, String.class);
370                 
371                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
372                 JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false);
373         }
374         
375         @Test
376         public void testSerfviceVNFResources404() throws JSONException {
377                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
378                 headers.set("Accept", MediaType.APPLICATION_JSON);
379                 
380                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
381                                 .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0");
382                        
383                 ResponseEntity<String> response = restTemplate.exchange(
384                                 builder.toUriString(),
385                                 HttpMethod.GET, entity, String.class);
386                 
387                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
388                 
389         }
390         
391         
392         @Test
393         public void testSerfviceVNFBadParams() throws JSONException {
394                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
395                 headers.set("Accept", MediaType.APPLICATION_JSON);
396                 
397                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS))
398                                 .queryParam("BadParamName", "BADNAME");
399                        
400                 ResponseEntity<String> response = restTemplate.exchange(
401                                 builder.toUriString(),
402                                 HttpMethod.GET, entity, String.class);
403                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
404                 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
405                 
406                 
407         }
408         
409         
410         
411     /* Network Resources Endpoint */
412         
413         @Test
414         public void testGetNetworkResourcesByCustomizationUUID() throws JSONException {
415                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
416                 headers.set("Accept", MediaType.APPLICATION_JSON);
417                 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}";
418                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
419                        ;
420                        
421                 ResponseEntity<String> response = restTemplate.exchange(
422                                 builder.toUriString(),
423                                 HttpMethod.GET, entity, String.class);
424                 
425                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
426                 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
427         }
428         
429         
430         
431         @Test
432         public void testGetNetworkResources404() throws JSONException {
433                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
434                 headers.set("Accept", MediaType.APPLICATION_JSON);
435                 
436                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf"))
437                        ;
438                        
439                 ResponseEntity<String> response = restTemplate.exchange(
440                                 builder.toUriString(),
441                                 HttpMethod.GET, entity, String.class);
442                 
443                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
444                 
445         }
446         
447         /* Service Network Resources Endpoints */
448         
449         @Test
450         public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException {
451                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
452                 headers.set("Accept", MediaType.APPLICATION_JSON);
453                 
454                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
455                                 .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0");
456                        
457                 ResponseEntity<String> response = restTemplate.exchange(
458                                 builder.toUriString(),
459                                 HttpMethod.GET, entity, String.class);
460                 
461                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
462                 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
463         } 
464         
465         @Test
466         public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException {
467                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
468                 headers.set("Accept", MediaType.APPLICATION_JSON);
469                 
470                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
471                                 .queryParam("serviceModelUuid", serviceUUID);
472                        
473                 ResponseEntity<String> response = restTemplate.exchange(
474                                 builder.toUriString(),
475                                 HttpMethod.GET, entity, String.class);
476                 
477                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
478                 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
479         }
480         
481         @Test
482         public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException {
483                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
484                 headers.set("Accept", MediaType.APPLICATION_JSON);
485                 
486                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
487                                 .queryParam("serviceModelUuid", "doesNotExist");
488                        
489                 ResponseEntity<String> response = restTemplate.exchange(
490                                 builder.toUriString(),
491                                 HttpMethod.GET, entity, String.class);
492                 
493                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
494                 
495         }
496         
497         @Test
498         public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException {
499                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
500                 headers.set("Accept", MediaType.APPLICATION_JSON);
501                 
502                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
503                                 .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d");
504                        
505                 ResponseEntity<String> response = restTemplate.exchange(
506                                 builder.toUriString(),
507                                 HttpMethod.GET, entity, String.class);
508                 
509                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
510                 
511         }
512         
513         @Test
514         public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException {
515                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
516                 headers.set("Accept", MediaType.APPLICATION_JSON);
517                 
518                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
519                                 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
520                        
521                 ResponseEntity<String> response = restTemplate.exchange(
522                                 builder.toUriString(),
523                                 HttpMethod.GET, entity, String.class);
524                 
525                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
526                 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
527         }
528         
529         @Test
530         public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException {
531                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
532                 headers.set("Accept", MediaType.APPLICATION_JSON);
533                 
534                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
535                                 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
536                         .queryParam("serviceModelVersion", "2.0");
537                        
538                 ResponseEntity<String> response = restTemplate.exchange(
539                                 builder.toUriString(),
540                                 HttpMethod.GET, entity, String.class);
541                 
542                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
543                 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
544         }
545         
546         @Test
547         public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException {
548                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
549                 headers.set("Accept", MediaType.APPLICATION_JSON);
550                 
551                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
552                                 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
553                         .queryParam("serviceModelVersion", "");
554                 ResponseEntity<String> response = restTemplate.exchange(
555                                 builder.toUriString(),
556                                 HttpMethod.GET, entity, String.class);
557                 
558                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
559                 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
560         }
561         
562         
563         @Test
564         public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException {
565                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
566                 headers.set("Accept", MediaType.APPLICATION_JSON);
567         
568                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
569                                 .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac");
570                        
571                 ResponseEntity<String> response = restTemplate.exchange(
572                                 builder.toUriString(),
573                                 HttpMethod.GET, entity, String.class);
574                 
575                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
576                 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
577         } 
578         
579         @Test
580         public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException {
581                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
582                 headers.set("Accept", MediaType.APPLICATION_JSON);
583                 
584                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS))
585                                 .queryParam("networkModelName", "CONTRAIL30_GNDIRECT");
586                        
587                 ResponseEntity<String> response = restTemplate.exchange(
588                                 builder.toUriString(),
589                                 HttpMethod.GET, entity, String.class);
590                 
591                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
592                 JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false);
593         }
594         
595         /*  Allotted endpoints */
596         
597         @Test
598         public void testGetAllottedResourcesByCustomizationUUID() throws JSONException {
599                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
600                 headers.set("Accept", MediaType.APPLICATION_JSON);
601                 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}";
602                 
603                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6"));
604                                 
605                        
606                 ResponseEntity<String> response = restTemplate.exchange(
607                                 builder.toUriString(),
608                                 HttpMethod.GET, entity, String.class);
609                 
610                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
611                 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
612         }
613         
614         
615         @Test
616         public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException {
617                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
618                 headers.set("Accept", MediaType.APPLICATION_JSON);
619
620                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
621                                 .queryParam("serviceModelUuid",serviceUUID);
622                        
623                 ResponseEntity<String> response = restTemplate.exchange(
624                                 builder.toUriString(),
625                                 HttpMethod.GET, entity, String.class);
626                 
627                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
628                 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
629         }
630         
631         @Test
632         public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException {
633                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
634                 headers.set("Accept", MediaType.APPLICATION_JSON);
635
636                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
637                                 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID);
638                        
639                 ResponseEntity<String> response = restTemplate.exchange(
640                                 builder.toUriString(),
641                                 HttpMethod.GET, entity, String.class);
642                 
643                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
644                 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
645         }
646         
647         @Test
648         public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException {
649                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
650                 headers.set("Accept", MediaType.APPLICATION_JSON);
651
652                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
653                                 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
654                                 .queryParam("serviceModelVersion", "1.0");
655                        
656                 ResponseEntity<String> response = restTemplate.exchange(
657                                 builder.toUriString(),
658                                 HttpMethod.GET, entity, String.class);
659                 
660                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
661                 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
662         }
663         
664         @Test
665         public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException {
666                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
667                 headers.set("Accept", MediaType.APPLICATION_JSON);
668
669                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
670                                 .queryParam("serviceModelInvariantUuid", serviceInvariantUUID)
671                                 .queryParam("serviceModelVersion", "1.0");
672                        
673                 ResponseEntity<String> response = restTemplate.exchange(
674                                 builder.toUriString(),
675                                 HttpMethod.GET, entity, String.class);
676                 
677                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
678                 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
679         }
680         
681         @Test
682         public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException {
683                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
684                 headers.set("Accept", MediaType.APPLICATION_JSON);
685         
686                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
687                                 .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6");
688                        
689                 ResponseEntity<String> response = restTemplate.exchange(
690                                 builder.toUriString(),
691                                 HttpMethod.GET, entity, String.class);
692                 
693                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
694                 JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false);
695         }
696         
697         
698         @Test
699         public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException {
700                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
701                 headers.set("Accept", MediaType.APPLICATION_JSON);
702                 
703                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES))
704                                 .queryParam("arModelCustomizationUuid", "NOTEXIST");
705                        
706                 ResponseEntity<String> response = restTemplate.exchange(
707                                 builder.toUriString(),
708                                 HttpMethod.GET, entity, String.class);
709                 
710                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
711                 
712         }
713         
714         /* VF Modules Endpoint */
715         
716         @Test
717         public void testGetVFModulesNonExistResource() throws JSONException {
718                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
719                 headers.set("Accept", MediaType.APPLICATION_JSON);
720                 
721                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
722                                 .queryParam("vfModuleModelName", "NEUTRON_BASIC");
723                        
724                 ResponseEntity<String> response = restTemplate.exchange(
725                                 builder.toUriString(),
726                                 HttpMethod.GET, entity, String.class);
727                 
728                 assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value());
729                 
730         }
731          
732         @Test
733         public void testGetVFModulesByVfModuleModelName() throws JSONException {
734                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
735                 headers.set("Accept", MediaType.APPLICATION_JSON);
736                 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}";
737                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
738                                 .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0");
739                        
740                 ResponseEntity<String> response = restTemplate.exchange(
741                                 builder.toUriString(),
742                                 HttpMethod.GET, entity, String.class);
743                 
744                 assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
745                 JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false);
746                 
747         }
748         
749         @Test
750         public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
751                 TestAppender.events.clear();
752                 HttpEntity<String> entity = new HttpEntity<String>(null, headers);
753                 headers.set("Accept", MediaType.APPLICATION_JSON);
754
755                 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
756                                 .queryParam("ADASD", "NEUTRON_BASIC");
757
758                 ResponseEntity<String> response = restTemplate.exchange(
759                                 builder.toUriString(),
760                                 HttpMethod.GET, entity, String.class);
761
762                 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
763                 JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);                   
764
765         
766                 ILoggingEvent logEvent = TestAppender.events.get(0);
767                 Map<String,String> mdc = logEvent.getMDCPropertyMap();
768                 assertNotNull(mdc.get(MsoLogger.BEGINTIME));
769                 assertNotNull(mdc.get(MsoLogger.ENDTIME));
770                 assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
771                 assertNotNull(mdc.get(MsoLogger.TIMER));
772                 assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));            
773                 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
774                 assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
775                 assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
776                 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
777         }
778         
779         private String createURLWithPort(String uri) {
780                 return "http://localhost:" + port + uri;
781         }
782 }