change made to enable https mode
[integration/csit.git] / plans / so / integration-etsi-testing / so-simulators / sdnc-simulator / src / test / java / org / onap / so / sdncsimulator / controller / OperationsControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.sdncsimulator.controller;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26 import static org.onap.sdnc.northbound.client.model.GenericResourceApiRpcActionEnumeration.ASSIGN;
27 import static org.onap.sdnc.northbound.client.model.GenericResourceApiRpcActionEnumeration.DEACTIVATE;
28 import static org.onap.so.sdncsimulator.controller.TestUtils.getInvalidRequestInput;
29 import static org.onap.so.sdncsimulator.controller.TestUtils.getRequestInput;
30 import static org.onap.so.sdncsimulator.controller.TestUtils.getServiceRequestWithRequestActionDeleteServiceAndSvcActionDeactivateInput;
31 import static org.onap.so.sdncsimulator.controller.TestUtils.getServiceRequestWithRequestActionDeleteServiceInput;
32 import static org.onap.so.sdncsimulator.controller.TestUtils.getVnfRequestInput;
33 import static org.onap.so.sdncsimulator.controller.TestUtils.getVnfRequestWithRequestActionDeleteVnfInput;
34 import static org.onap.so.sdncsimulator.controller.TestUtils.getVnfRequestWithSvcActionActivateInput;
35 import java.util.Optional;
36 import org.junit.After;
37 import org.junit.Test;
38 import org.junit.runner.RunWith;
39 import org.onap.sdnc.northbound.client.model.GenericResourceApiInstanceReference;
40 import org.onap.sdnc.northbound.client.model.GenericResourceApiLastRpcActionEnumeration;
41 import org.onap.sdnc.northbound.client.model.GenericResourceApiOperStatusData;
42 import org.onap.sdnc.northbound.client.model.GenericResourceApiServicedataServicedataVnfsVnf;
43 import org.onap.sdnc.northbound.client.model.GenericResourceApiServicemodelinfrastructureService;
44 import org.onap.so.sdncsimulator.models.InputRequest;
45 import org.onap.so.sdncsimulator.models.Output;
46 import org.onap.so.sdncsimulator.models.OutputRequest;
47 import org.onap.so.sdncsimulator.providers.ServiceOperationsCacheServiceProvider;
48 import org.onap.so.sdncsimulator.utils.Constants;
49 import org.onap.so.simulator.model.UserCredentials;
50 import org.springframework.beans.factory.annotation.Autowired;
51 import org.springframework.boot.test.context.SpringBootTest;
52 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
53 import org.springframework.boot.test.web.client.TestRestTemplate;
54 import org.springframework.boot.web.server.LocalServerPort;
55 import org.springframework.context.annotation.Configuration;
56 import org.springframework.http.HttpEntity;
57 import org.springframework.http.HttpHeaders;
58 import org.springframework.http.HttpMethod;
59 import org.springframework.http.HttpStatus;
60 import org.springframework.http.ResponseEntity;
61 import org.springframework.test.context.ActiveProfiles;
62 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
63
64 /**
65  * @author Waqas Ikram (waqas.ikram@est.tech)
66  *
67  */
68 @RunWith(SpringJUnit4ClassRunner.class)
69 @ActiveProfiles("test")
70 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
71 @Configuration
72 public class OperationsControllerTest {
73
74     private static final String SVC_REQUEST_ID = "04fc9f50-87b8-430d-a232-ef24bd6c4150";
75
76     private static final String VNF_SVC_REQUEST_ID = "8fd2622b-01fc-424d-bfc8-f48bcd64e546";
77
78     private static final String SERVICE_INSTANCE_ID = "ccece8fe-13da-456a-baf6-41b3a4a2bc2b";
79
80     private static final String SERVICE_TOPOLOGY_OPERATION_URL = "/GENERIC-RESOURCE-API:service-topology-operation/";
81
82     private static final String VNF_TOPOLOGY_OPERATION_URL = "/GENERIC-RESOURCE-API:vnf-topology-operation/";
83
84     private static final String VNF_INSTANCE_ID = "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701";
85
86     @LocalServerPort
87     private int port;
88
89     @Autowired
90     private TestRestTemplate restTemplate;
91
92     @Autowired
93     private ServiceOperationsCacheServiceProvider cacheServiceProvider;
94
95     @Autowired
96     private UserCredentials userCredentials;
97
98
99     @Test
100     public void test_postServiceOperationInformation_successfullyAddedToCache() throws Exception {
101
102         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
103         final ResponseEntity<OutputRequest> responseEntity =
104                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
105
106         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
107         assertTrue(responseEntity.hasBody());
108
109         final OutputRequest actualOutputRequest = responseEntity.getBody();
110         assertNotNull(actualOutputRequest);
111
112         final Output actualObject = actualOutputRequest.getOutput();
113
114         assertNotNull(actualObject);
115         assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode());
116         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
117         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
118         assertNotNull(actualObject.getServiceResponseInformation());
119
120         final GenericResourceApiInstanceReference acutalReference = actualObject.getServiceResponseInformation();
121         assertEquals(Constants.RESTCONF_CONFIG_END_POINT + SERVICE_INSTANCE_ID, acutalReference.getObjectPath());
122         assertEquals(SERVICE_INSTANCE_ID, acutalReference.getInstanceId());
123         final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
124                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
125         assertTrue(optional.isPresent());
126
127         final GenericResourceApiServicemodelinfrastructureService service = optional.get();
128         assertNotNull(service.getServiceInstanceId());
129         assertEquals(SERVICE_INSTANCE_ID, service.getServiceInstanceId());
130         assertNotNull(service.getServiceData());
131         assertNotNull(service.getServiceStatus());
132
133     }
134
135     @Test
136     public void test_postServiceOperationInformation_NullInputRequest_badRequest() throws Exception {
137
138         final HttpEntity<?> httpEntity = new HttpEntity<>(new InputRequest<>(), getHttpHeaders());
139         final ResponseEntity<OutputRequest> responseEntity =
140                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
141
142         assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
143     }
144
145     @Test
146     public void test_postServiceOperationInformation_NullServiceInstanceId_badRequest() throws Exception {
147
148         final HttpEntity<?> httpEntity = new HttpEntity<>(getInvalidRequestInput(), getHttpHeaders());
149         final ResponseEntity<OutputRequest> responseEntity =
150                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
151
152         assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
153         assertTrue(responseEntity.hasBody());
154
155         final OutputRequest actualOutputRequest = responseEntity.getBody();
156         assertNotNull(actualOutputRequest);
157
158         final Output actualObject = actualOutputRequest.getOutput();
159         assertNotNull(actualObject);
160         assertEquals(HttpStatus.BAD_REQUEST.toString(), actualObject.getResponseCode());
161         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
162         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
163
164     }
165
166     @Test
167     public void test_postVnfOperationInformation_successfullyAddToExistingServiceInCache() throws Exception {
168         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
169         final ResponseEntity<OutputRequest> responseEntity =
170                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
171
172         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
173
174         final HttpEntity<?> httpVnfEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
175         final ResponseEntity<OutputRequest> responseVnfEntity =
176                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
177         assertEquals(HttpStatus.OK, responseVnfEntity.getStatusCode());
178         assertTrue(responseVnfEntity.hasBody());
179
180         final OutputRequest actualOutputRequest = responseVnfEntity.getBody();
181         assertNotNull(actualOutputRequest);
182         assertNotNull(actualOutputRequest.getOutput());
183
184         final Output actualObject = actualOutputRequest.getOutput();
185
186         assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode());
187         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
188         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
189         assertNotNull(actualObject.getServiceResponseInformation());
190
191         final GenericResourceApiInstanceReference acutalReference = actualObject.getServiceResponseInformation();
192         assertEquals(Constants.RESTCONF_CONFIG_END_POINT + SERVICE_INSTANCE_ID, acutalReference.getObjectPath());
193         assertEquals(SERVICE_INSTANCE_ID, acutalReference.getInstanceId());
194         final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
195                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
196         assertTrue(optional.isPresent());
197
198         final GenericResourceApiInstanceReference actualvnfInformation = actualObject.getVnfResponseInformation();
199         assertEquals(VNF_INSTANCE_ID, actualvnfInformation.getInstanceId());
200
201         final Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
202                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
203         assertTrue(serviceOptional.isPresent());
204
205         final GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
206         assertNotNull(service.getServiceInstanceId());
207         assertNotNull(service.getServiceData().getVnfs().getVnf());
208         assertNotNull(service.getServiceData());
209         assertNotNull(service.getServiceData().getVnfs());
210         assertNotNull(service.getServiceData().getVnfs().getVnf());
211         assertEquals(1, service.getServiceData().getVnfs().getVnf().size());
212         final GenericResourceApiServicedataServicedataVnfsVnf vnf = service.getServiceData().getVnfs().getVnf().get(0);
213         assertNotNull(vnf.getVnfId());
214         assertEquals(VNF_INSTANCE_ID, vnf.getVnfId());
215         assertNotNull(vnf.getVnfData());
216     }
217
218     @Test
219     public void test_postSameVnfOperationInformationTwice_ShouldReturnbadRequest() throws Exception {
220
221         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
222         final ResponseEntity<OutputRequest> responseEntity =
223                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
224
225         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
226
227         final HttpEntity<?> httpVnfEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
228         final ResponseEntity<OutputRequest> responseVnfEntity =
229                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
230         assertEquals(HttpStatus.OK, responseVnfEntity.getStatusCode());
231         assertTrue(responseVnfEntity.hasBody());
232
233         final OutputRequest actualOutputRequest = responseVnfEntity.getBody();
234         assertNotNull(actualOutputRequest);
235         assertNotNull(actualOutputRequest.getOutput());
236
237         final ResponseEntity<OutputRequest> badResponse =
238                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
239
240         final OutputRequest badOutputRequest = badResponse.getBody();
241         assertNotNull(badOutputRequest);
242
243         final Output actualObject = badOutputRequest.getOutput();
244         assertNotNull(actualObject);
245         assertEquals(HttpStatus.BAD_REQUEST.toString(), actualObject.getResponseCode());
246         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
247         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
248
249     }
250
251     @Test
252     public void test_postVnfOperationInformationWithSvcActionChanged_successfullyAddToExistingServiceInCache()
253             throws Exception {
254         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
255         final ResponseEntity<OutputRequest> responseEntity =
256                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
257
258         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
259
260         final HttpEntity<?> httpVnfWithSvcActionAssignEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
261         final ResponseEntity<OutputRequest> response = restTemplate.exchange(getVnfUrl(), HttpMethod.POST,
262                 httpVnfWithSvcActionAssignEntity, OutputRequest.class);
263         assertEquals(HttpStatus.OK, response.getStatusCode());
264         assertTrue(response.hasBody());
265
266         final HttpEntity<?> httpVnfEntity =
267                 new HttpEntity<>(getVnfRequestWithSvcActionActivateInput(), getHttpHeaders());
268         final ResponseEntity<OutputRequest> responseVnfEntity =
269                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
270         assertEquals(HttpStatus.OK, responseVnfEntity.getStatusCode());
271         assertTrue(responseVnfEntity.hasBody());
272
273         final OutputRequest actualOutputRequest = responseVnfEntity.getBody();
274         assertNotNull(actualOutputRequest);
275         assertNotNull(actualOutputRequest.getOutput());
276
277         final Output actualObject = actualOutputRequest.getOutput();
278
279         assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode());
280         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
281         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
282         assertNotNull(actualObject.getServiceResponseInformation());
283
284         final GenericResourceApiInstanceReference acutalReference = actualObject.getServiceResponseInformation();
285         assertEquals(Constants.RESTCONF_CONFIG_END_POINT + SERVICE_INSTANCE_ID, acutalReference.getObjectPath());
286         assertEquals(SERVICE_INSTANCE_ID, acutalReference.getInstanceId());
287         final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
288                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
289         assertTrue(optional.isPresent());
290
291         final GenericResourceApiInstanceReference actualvnfInformation = actualObject.getVnfResponseInformation();
292         assertEquals(VNF_INSTANCE_ID, actualvnfInformation.getInstanceId());
293
294         final Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
295                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
296         assertTrue(serviceOptional.isPresent());
297
298         final GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
299         assertNotNull(service.getServiceInstanceId());
300         assertNotNull(service.getServiceData().getVnfs().getVnf());
301         assertNotNull(service.getServiceData());
302         assertNotNull(service.getServiceData().getVnfs());
303         assertNotNull(service.getServiceData().getVnfs().getVnf());
304         assertEquals(1, service.getServiceData().getVnfs().getVnf().size());
305         final GenericResourceApiServicedataServicedataVnfsVnf vnf = service.getServiceData().getVnfs().getVnf().get(0);
306         assertNotNull(vnf.getVnfId());
307         assertEquals(VNF_INSTANCE_ID, vnf.getVnfId());
308         assertNotNull(vnf.getVnfData());
309         final GenericResourceApiOperStatusData vnfLevelOperStatus = vnf.getVnfData().getVnfLevelOperStatus();
310         assertNotNull(vnfLevelOperStatus);
311         assertEquals(GenericResourceApiLastRpcActionEnumeration.ACTIVATE, vnfLevelOperStatus.getLastRpcAction());
312
313     }
314
315     @Test
316     public void test_postVnfOperationInformation_successfullyRemoveVnfFromExistingServiceInCache() throws Exception {
317         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
318         final ResponseEntity<OutputRequest> responseEntity =
319                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
320
321         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
322
323         final HttpEntity<?> httpAddVnfEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
324         final ResponseEntity<OutputRequest> responseAddVnfEntity =
325                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpAddVnfEntity, OutputRequest.class);
326         assertEquals(HttpStatus.OK, responseAddVnfEntity.getStatusCode());
327
328         Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
329                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
330         assertTrue(serviceOptional.isPresent());
331
332         GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
333         assertNotNull(service.getServiceInstanceId());
334         assertNotNull(service.getServiceData().getVnfs().getVnf());
335         assertNotNull(service.getServiceData());
336         assertNotNull(service.getServiceData().getVnfs());
337         assertNotNull(service.getServiceData().getVnfs().getVnf());
338         assertFalse(service.getServiceData().getVnfs().getVnf().isEmpty());
339
340         final HttpEntity<?> httpRemoveVnfEntity =
341                 new HttpEntity<>(getVnfRequestWithRequestActionDeleteVnfInput(), getHttpHeaders());
342         final ResponseEntity<OutputRequest> responseRemoveVnfEntity =
343                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpRemoveVnfEntity, OutputRequest.class);
344         assertEquals(HttpStatus.OK, responseRemoveVnfEntity.getStatusCode());
345
346         final OutputRequest actualOutputRequest = responseRemoveVnfEntity.getBody();
347         assertNotNull(actualOutputRequest);
348         assertNotNull(actualOutputRequest.getOutput());
349
350         final Output actualObject = actualOutputRequest.getOutput();
351
352         assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode());
353         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
354         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
355
356         serviceOptional =
357                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
358         assertTrue(serviceOptional.isPresent());
359
360         service = serviceOptional.get();
361         assertNotNull(service.getServiceInstanceId());
362         assertNotNull(service.getServiceData().getVnfs().getVnf());
363         assertNotNull(service.getServiceData());
364         assertNotNull(service.getServiceData().getVnfs());
365         assertNotNull(service.getServiceData().getVnfs().getVnf());
366         assertTrue(service.getServiceData().getVnfs().getVnf().isEmpty());
367
368
369     }
370
371     @Test
372     public void test_postServiceOperationInformation_withActionDeleteServiceInstance_successfullyRemoveServiceFromExistingServiceInCache()
373             throws Exception {
374         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
375         final ResponseEntity<OutputRequest> responseEntity =
376                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
377
378         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
379         Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
380                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
381         assertTrue(serviceOptional.isPresent());
382
383         final GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
384         assertNotNull(service.getServiceInstanceId());
385
386         final HttpEntity<?> httpRemoveServiceEntity =
387                 new HttpEntity<>(getServiceRequestWithRequestActionDeleteServiceInput(), getHttpHeaders());
388         final ResponseEntity<OutputRequest> responseRemoveServiceEntity =
389                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpRemoveServiceEntity, OutputRequest.class);
390         assertEquals(HttpStatus.OK, responseRemoveServiceEntity.getStatusCode());
391
392         final OutputRequest actualOutputRequest = responseRemoveServiceEntity.getBody();
393         assertNotNull(actualOutputRequest);
394         assertNotNull(actualOutputRequest.getOutput());
395
396         final Output actualObject = actualOutputRequest.getOutput();
397
398         assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode());
399         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
400         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
401
402         serviceOptional =
403                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
404         assertFalse(serviceOptional.isPresent());
405
406     }
407
408     @Test
409     public void test_postServiceOperationInformation_withActionDeleteServiceInstanceAndSvcActionDeactivate_successfullyUpdateExistingServiceInCache()
410             throws Exception {
411
412         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
413         final ResponseEntity<OutputRequest> responseEntity =
414                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
415
416         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
417         Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
418                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
419         assertTrue(serviceOptional.isPresent());
420
421         GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
422         assertNotNull(service.getServiceInstanceId());
423         assertNotNull(service.getServiceStatus());
424         assertEquals(ASSIGN, service.getServiceStatus().getRpcAction());
425
426         final HttpEntity<?> entity = new HttpEntity<>(
427                 getServiceRequestWithRequestActionDeleteServiceAndSvcActionDeactivateInput(), getHttpHeaders());
428         final ResponseEntity<OutputRequest> deactivateResponseEntity =
429                 restTemplate.exchange(getUrl(), HttpMethod.POST, entity, OutputRequest.class);
430         assertEquals(HttpStatus.OK, deactivateResponseEntity.getStatusCode());
431
432         final OutputRequest actualOutputRequest = deactivateResponseEntity.getBody();
433         assertNotNull(actualOutputRequest);
434         assertNotNull(actualOutputRequest.getOutput());
435
436         final Output actualObject = actualOutputRequest.getOutput();
437
438         assertEquals(HttpStatus.OK.toString(), actualObject.getResponseCode());
439         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
440         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
441
442         serviceOptional =
443                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
444         assertTrue(serviceOptional.isPresent());
445         service = serviceOptional.get();
446         assertNotNull(service.getServiceStatus());
447         assertEquals(DEACTIVATE, service.getServiceStatus().getRpcAction());
448
449     }
450
451     private HttpHeaders getHttpHeaders() {
452         return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
453     }
454
455     private String getUrl() {
456         return "http://localhost:" + port + Constants.OPERATIONS_URL + SERVICE_TOPOLOGY_OPERATION_URL;
457     }
458
459     private String getVnfUrl() {
460         return "http://localhost:" + port + Constants.OPERATIONS_URL + VNF_TOPOLOGY_OPERATION_URL;
461     }
462
463     @After
464     public void after() {
465         cacheServiceProvider.clearAll();
466     }
467
468 }