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