[SO] SO release image for CSIT testing
[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 HTTP_STATUS_BAD_REQUEST = Integer.toString(HttpStatus.BAD_REQUEST.value());
75     private static final String HTTP_STATUS_OK = Integer.toString(HttpStatus.OK.value());
76
77     private static final String SVC_REQUEST_ID = "04fc9f50-87b8-430d-a232-ef24bd6c4150";
78
79     private static final String VNF_SVC_REQUEST_ID = "8fd2622b-01fc-424d-bfc8-f48bcd64e546";
80
81     private static final String SERVICE_INSTANCE_ID = "ccece8fe-13da-456a-baf6-41b3a4a2bc2b";
82
83     private static final String SERVICE_TOPOLOGY_OPERATION_URL = "/GENERIC-RESOURCE-API:service-topology-operation/";
84
85     private static final String VNF_TOPOLOGY_OPERATION_URL = "/GENERIC-RESOURCE-API:vnf-topology-operation/";
86
87     private static final String VNF_INSTANCE_ID = "dfd02fb5-d7fb-4aac-b3c4-cd6b60058701";
88
89     @LocalServerPort
90     private int port;
91
92     @Autowired
93     private TestRestTemplate restTemplate;
94
95     @Autowired
96     private ServiceOperationsCacheServiceProvider cacheServiceProvider;
97
98     @Autowired
99     private UserCredentials userCredentials;
100
101
102     @Test
103     public void test_postServiceOperationInformation_successfullyAddedToCache() throws Exception {
104
105         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
106         final ResponseEntity<OutputRequest> responseEntity =
107                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
108
109         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
110         assertTrue(responseEntity.hasBody());
111
112         final OutputRequest actualOutputRequest = responseEntity.getBody();
113         assertNotNull(actualOutputRequest);
114
115         final Output actualObject = actualOutputRequest.getOutput();
116
117         assertNotNull(actualObject);
118         assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode());
119         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
120         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
121         assertNotNull(actualObject.getServiceResponseInformation());
122
123         final GenericResourceApiInstanceReference acutalReference = actualObject.getServiceResponseInformation();
124         assertEquals(Constants.RESTCONF_CONFIG_END_POINT + SERVICE_INSTANCE_ID, acutalReference.getObjectPath());
125         assertEquals(SERVICE_INSTANCE_ID, acutalReference.getInstanceId());
126         final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
127                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
128         assertTrue(optional.isPresent());
129
130         final GenericResourceApiServicemodelinfrastructureService service = optional.get();
131         assertNotNull(service.getServiceInstanceId());
132         assertEquals(SERVICE_INSTANCE_ID, service.getServiceInstanceId());
133         assertNotNull(service.getServiceData());
134         assertNotNull(service.getServiceStatus());
135
136     }
137
138     @Test
139     public void test_postServiceOperationInformation_NullInputRequest_badRequest() throws Exception {
140
141         final HttpEntity<?> httpEntity = new HttpEntity<>(new InputRequest<>(), getHttpHeaders());
142         final ResponseEntity<OutputRequest> responseEntity =
143                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
144
145         assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
146     }
147
148     @Test
149     public void test_postServiceOperationInformation_NullServiceInstanceId_badRequest() throws Exception {
150
151         final HttpEntity<?> httpEntity = new HttpEntity<>(getInvalidRequestInput(), getHttpHeaders());
152         final ResponseEntity<OutputRequest> responseEntity =
153                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
154
155         assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
156         assertTrue(responseEntity.hasBody());
157
158         final OutputRequest actualOutputRequest = responseEntity.getBody();
159         assertNotNull(actualOutputRequest);
160
161         final Output actualObject = actualOutputRequest.getOutput();
162         assertNotNull(actualObject);
163         assertEquals(HTTP_STATUS_BAD_REQUEST, actualObject.getResponseCode());
164         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
165         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
166
167     }
168
169     @Test
170     public void test_postVnfOperationInformation_successfullyAddToExistingServiceInCache() throws Exception {
171         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
172         final ResponseEntity<OutputRequest> responseEntity =
173                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
174
175         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
176
177         final HttpEntity<?> httpVnfEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
178         final ResponseEntity<OutputRequest> responseVnfEntity =
179                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
180         assertEquals(HttpStatus.OK, responseVnfEntity.getStatusCode());
181         assertTrue(responseVnfEntity.hasBody());
182
183         final OutputRequest actualOutputRequest = responseVnfEntity.getBody();
184         assertNotNull(actualOutputRequest);
185         assertNotNull(actualOutputRequest.getOutput());
186
187         final Output actualObject = actualOutputRequest.getOutput();
188
189         assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode());
190         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
191         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
192         assertNotNull(actualObject.getServiceResponseInformation());
193
194         final GenericResourceApiInstanceReference acutalReference = actualObject.getServiceResponseInformation();
195         assertEquals(Constants.RESTCONF_CONFIG_END_POINT + SERVICE_INSTANCE_ID, acutalReference.getObjectPath());
196         assertEquals(SERVICE_INSTANCE_ID, acutalReference.getInstanceId());
197         final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
198                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
199         assertTrue(optional.isPresent());
200
201         final GenericResourceApiInstanceReference actualvnfInformation = actualObject.getVnfResponseInformation();
202         assertEquals(VNF_INSTANCE_ID, actualvnfInformation.getInstanceId());
203
204         final Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
205                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
206         assertTrue(serviceOptional.isPresent());
207
208         final GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
209         assertNotNull(service.getServiceInstanceId());
210         assertNotNull(service.getServiceData().getVnfs().getVnf());
211         assertNotNull(service.getServiceData());
212         assertNotNull(service.getServiceData().getVnfs());
213         assertNotNull(service.getServiceData().getVnfs().getVnf());
214         assertEquals(1, service.getServiceData().getVnfs().getVnf().size());
215         final GenericResourceApiServicedataServicedataVnfsVnf vnf = service.getServiceData().getVnfs().getVnf().get(0);
216         assertNotNull(vnf.getVnfId());
217         assertEquals(VNF_INSTANCE_ID, vnf.getVnfId());
218         assertNotNull(vnf.getVnfData());
219     }
220
221     @Test
222     public void test_postSameVnfOperationInformationTwice_ShouldReturnbadRequest() throws Exception {
223
224         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
225         final ResponseEntity<OutputRequest> responseEntity =
226                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
227
228         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
229
230         final HttpEntity<?> httpVnfEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
231         final ResponseEntity<OutputRequest> responseVnfEntity =
232                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
233         assertEquals(HttpStatus.OK, responseVnfEntity.getStatusCode());
234         assertTrue(responseVnfEntity.hasBody());
235
236         final OutputRequest actualOutputRequest = responseVnfEntity.getBody();
237         assertNotNull(actualOutputRequest);
238         assertNotNull(actualOutputRequest.getOutput());
239
240         final ResponseEntity<OutputRequest> badResponse =
241                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
242
243         final OutputRequest badOutputRequest = badResponse.getBody();
244         assertNotNull(badOutputRequest);
245
246         final Output actualObject = badOutputRequest.getOutput();
247         assertNotNull(actualObject);
248         assertEquals(HTTP_STATUS_BAD_REQUEST, actualObject.getResponseCode());
249         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
250         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
251
252     }
253
254     @Test
255     public void test_postVnfOperationInformationWithSvcActionChanged_successfullyAddToExistingServiceInCache()
256             throws Exception {
257         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
258         final ResponseEntity<OutputRequest> responseEntity =
259                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
260
261         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
262
263         final HttpEntity<?> httpVnfWithSvcActionAssignEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
264         final ResponseEntity<OutputRequest> response = restTemplate.exchange(getVnfUrl(), HttpMethod.POST,
265                 httpVnfWithSvcActionAssignEntity, OutputRequest.class);
266         assertEquals(HttpStatus.OK, response.getStatusCode());
267         assertTrue(response.hasBody());
268
269         final HttpEntity<?> httpVnfEntity =
270                 new HttpEntity<>(getVnfRequestWithSvcActionActivateInput(), getHttpHeaders());
271         final ResponseEntity<OutputRequest> responseVnfEntity =
272                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpVnfEntity, OutputRequest.class);
273         assertEquals(HttpStatus.OK, responseVnfEntity.getStatusCode());
274         assertTrue(responseVnfEntity.hasBody());
275
276         final OutputRequest actualOutputRequest = responseVnfEntity.getBody();
277         assertNotNull(actualOutputRequest);
278         assertNotNull(actualOutputRequest.getOutput());
279
280         final Output actualObject = actualOutputRequest.getOutput();
281
282         assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode());
283         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
284         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
285         assertNotNull(actualObject.getServiceResponseInformation());
286
287         final GenericResourceApiInstanceReference acutalReference = actualObject.getServiceResponseInformation();
288         assertEquals(Constants.RESTCONF_CONFIG_END_POINT + SERVICE_INSTANCE_ID, acutalReference.getObjectPath());
289         assertEquals(SERVICE_INSTANCE_ID, acutalReference.getInstanceId());
290         final Optional<GenericResourceApiServicemodelinfrastructureService> optional =
291                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
292         assertTrue(optional.isPresent());
293
294         final GenericResourceApiInstanceReference actualvnfInformation = actualObject.getVnfResponseInformation();
295         assertEquals(VNF_INSTANCE_ID, actualvnfInformation.getInstanceId());
296
297         final Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
298                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
299         assertTrue(serviceOptional.isPresent());
300
301         final GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
302         assertNotNull(service.getServiceInstanceId());
303         assertNotNull(service.getServiceData().getVnfs().getVnf());
304         assertNotNull(service.getServiceData());
305         assertNotNull(service.getServiceData().getVnfs());
306         assertNotNull(service.getServiceData().getVnfs().getVnf());
307         assertEquals(1, service.getServiceData().getVnfs().getVnf().size());
308         final GenericResourceApiServicedataServicedataVnfsVnf vnf = service.getServiceData().getVnfs().getVnf().get(0);
309         assertNotNull(vnf.getVnfId());
310         assertEquals(VNF_INSTANCE_ID, vnf.getVnfId());
311         assertNotNull(vnf.getVnfData());
312         final GenericResourceApiOperStatusData vnfLevelOperStatus = vnf.getVnfData().getVnfLevelOperStatus();
313         assertNotNull(vnfLevelOperStatus);
314         assertEquals(GenericResourceApiLastRpcActionEnumeration.ACTIVATE, vnfLevelOperStatus.getLastRpcAction());
315
316     }
317
318     @Test
319     public void test_postVnfOperationInformation_successfullyRemoveVnfFromExistingServiceInCache() throws Exception {
320         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
321         final ResponseEntity<OutputRequest> responseEntity =
322                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
323
324         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
325
326         final HttpEntity<?> httpAddVnfEntity = new HttpEntity<>(getVnfRequestInput(), getHttpHeaders());
327         final ResponseEntity<OutputRequest> responseAddVnfEntity =
328                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpAddVnfEntity, OutputRequest.class);
329         assertEquals(HttpStatus.OK, responseAddVnfEntity.getStatusCode());
330
331         Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
332                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
333         assertTrue(serviceOptional.isPresent());
334
335         GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
336         assertNotNull(service.getServiceInstanceId());
337         assertNotNull(service.getServiceData().getVnfs().getVnf());
338         assertNotNull(service.getServiceData());
339         assertNotNull(service.getServiceData().getVnfs());
340         assertNotNull(service.getServiceData().getVnfs().getVnf());
341         assertFalse(service.getServiceData().getVnfs().getVnf().isEmpty());
342
343         final HttpEntity<?> httpRemoveVnfEntity =
344                 new HttpEntity<>(getVnfRequestWithRequestActionDeleteVnfInput(), getHttpHeaders());
345         final ResponseEntity<OutputRequest> responseRemoveVnfEntity =
346                 restTemplate.exchange(getVnfUrl(), HttpMethod.POST, httpRemoveVnfEntity, OutputRequest.class);
347         assertEquals(HttpStatus.OK, responseRemoveVnfEntity.getStatusCode());
348
349         final OutputRequest actualOutputRequest = responseRemoveVnfEntity.getBody();
350         assertNotNull(actualOutputRequest);
351         assertNotNull(actualOutputRequest.getOutput());
352
353         final Output actualObject = actualOutputRequest.getOutput();
354
355         assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode());
356         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
357         assertEquals(VNF_SVC_REQUEST_ID, actualObject.getSvcRequestId());
358
359         serviceOptional =
360                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
361         assertTrue(serviceOptional.isPresent());
362
363         service = serviceOptional.get();
364         assertNotNull(service.getServiceInstanceId());
365         assertNotNull(service.getServiceData().getVnfs().getVnf());
366         assertNotNull(service.getServiceData());
367         assertNotNull(service.getServiceData().getVnfs());
368         assertNotNull(service.getServiceData().getVnfs().getVnf());
369         assertTrue(service.getServiceData().getVnfs().getVnf().isEmpty());
370
371
372     }
373
374     @Test
375     public void test_postServiceOperationInformation_withActionDeleteServiceInstance_successfullyRemoveServiceFromExistingServiceInCache()
376             throws Exception {
377         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
378         final ResponseEntity<OutputRequest> responseEntity =
379                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
380
381         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
382         Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
383                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
384         assertTrue(serviceOptional.isPresent());
385
386         final GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
387         assertNotNull(service.getServiceInstanceId());
388
389         final HttpEntity<?> httpRemoveServiceEntity =
390                 new HttpEntity<>(getServiceRequestWithRequestActionDeleteServiceInput(), getHttpHeaders());
391         final ResponseEntity<OutputRequest> responseRemoveServiceEntity =
392                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpRemoveServiceEntity, OutputRequest.class);
393         assertEquals(HttpStatus.OK, responseRemoveServiceEntity.getStatusCode());
394
395         final OutputRequest actualOutputRequest = responseRemoveServiceEntity.getBody();
396         assertNotNull(actualOutputRequest);
397         assertNotNull(actualOutputRequest.getOutput());
398
399         final Output actualObject = actualOutputRequest.getOutput();
400
401         assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode());
402         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
403         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
404
405         serviceOptional =
406                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
407         assertFalse(serviceOptional.isPresent());
408
409     }
410
411     @Test
412     public void test_postServiceOperationInformation_withActionDeleteServiceInstanceAndSvcActionDeactivate_successfullyUpdateExistingServiceInCache()
413             throws Exception {
414
415         final HttpEntity<?> httpEntity = new HttpEntity<>(getRequestInput(), getHttpHeaders());
416         final ResponseEntity<OutputRequest> responseEntity =
417                 restTemplate.exchange(getUrl(), HttpMethod.POST, httpEntity, OutputRequest.class);
418
419         assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
420         Optional<GenericResourceApiServicemodelinfrastructureService> serviceOptional =
421                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
422         assertTrue(serviceOptional.isPresent());
423
424         GenericResourceApiServicemodelinfrastructureService service = serviceOptional.get();
425         assertNotNull(service.getServiceInstanceId());
426         assertNotNull(service.getServiceStatus());
427         assertEquals(ASSIGN, service.getServiceStatus().getRpcAction());
428
429         final HttpEntity<?> entity = new HttpEntity<>(
430                 getServiceRequestWithRequestActionDeleteServiceAndSvcActionDeactivateInput(), getHttpHeaders());
431         final ResponseEntity<OutputRequest> deactivateResponseEntity =
432                 restTemplate.exchange(getUrl(), HttpMethod.POST, entity, OutputRequest.class);
433         assertEquals(HttpStatus.OK, deactivateResponseEntity.getStatusCode());
434
435         final OutputRequest actualOutputRequest = deactivateResponseEntity.getBody();
436         assertNotNull(actualOutputRequest);
437         assertNotNull(actualOutputRequest.getOutput());
438
439         final Output actualObject = actualOutputRequest.getOutput();
440
441         assertEquals(HTTP_STATUS_OK, actualObject.getResponseCode());
442         assertEquals(Constants.YES, actualObject.getAckFinalIndicator());
443         assertEquals(SVC_REQUEST_ID, actualObject.getSvcRequestId());
444
445         serviceOptional =
446                 cacheServiceProvider.getGenericResourceApiServicemodelinfrastructureService(SERVICE_INSTANCE_ID);
447         assertTrue(serviceOptional.isPresent());
448         service = serviceOptional.get();
449         assertNotNull(service.getServiceStatus());
450         assertEquals(DEACTIVATE, service.getServiceStatus().getRpcAction());
451
452     }
453
454     private HttpHeaders getHttpHeaders() {
455         return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
456     }
457
458     private String getUrl() {
459         return "http://localhost:" + port + Constants.OPERATIONS_URL + SERVICE_TOPOLOGY_OPERATION_URL;
460     }
461
462     private String getVnfUrl() {
463         return "http://localhost:" + port + Constants.OPERATIONS_URL + VNF_TOPOLOGY_OPERATION_URL;
464     }
465
466     @After
467     public void after() {
468         cacheServiceProvider.clearAll();
469     }
470
471 }