First part of onap rename
[appc.git] / appc-dispatcher / appc-request-handler / appc-request-handler-core / src / test / java / org / openecomp / appc / requesthandler / RequestValidatorTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.requesthandler;
26
27 import com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.mockito.Mockito;
33 import org.onap.appc.domainmodel.lcm.ActionIdentifiers;
34 import org.onap.appc.domainmodel.lcm.CommonHeader;
35 import org.onap.appc.domainmodel.lcm.Flags;
36 import org.onap.appc.domainmodel.lcm.RequestContext;
37 import org.onap.appc.domainmodel.lcm.ResponseContext;
38 import org.onap.appc.domainmodel.lcm.RuntimeContext;
39 import org.onap.appc.domainmodel.lcm.Status;
40 import org.onap.appc.domainmodel.lcm.VNFContext;
41 import org.onap.appc.domainmodel.lcm.VNFOperation;
42 import org.onap.appc.lifecyclemanager.LifecycleManager;
43 import org.onap.appc.lifecyclemanager.objects.NoTransitionDefinedException;
44 import org.onap.appc.requesthandler.exceptions.InvalidInputException;
45 import org.onap.appc.requesthandler.exceptions.LCMOperationsDisabledException;
46 import org.onap.appc.requesthandler.impl.RequestHandlerImpl;
47 import org.onap.appc.requesthandler.impl.RequestValidatorImpl;
48 import org.onap.appc.requesthandler.objects.RequestHandlerInput;
49 import org.onap.appc.transactionrecorder.TransactionRecorder;
50 import org.onap.appc.workflow.WorkFlowManager;
51 import org.onap.appc.workflow.objects.WorkflowExistsOutput;
52 import org.onap.appc.workingstatemanager.WorkingStateManager;
53 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
54 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
55 import org.onap.ccsdk.sli.adaptors.aai.AAIService;
56 import org.osgi.framework.Bundle;
57 import org.osgi.framework.BundleContext;
58 import org.osgi.framework.FrameworkUtil;
59 import org.osgi.framework.ServiceReference;
60 import org.powermock.api.mockito.PowerMockito;
61 import org.powermock.core.classloader.annotations.PrepareForTest;
62 import org.powermock.modules.junit4.PowerMockRunner;
63
64 import java.time.Instant;
65 import java.util.UUID;
66
67 import static junit.framework.TestCase.assertNotNull;
68 import static org.junit.Assert.assertNull;
69 import static org.mockito.Matchers.*;
70
71 @SuppressWarnings("unchecked")
72 @RunWith(PowerMockRunner.class)
73 @PrepareForTest( {WorkingStateManager.class,FrameworkUtil.class, TransactionRecorder.class, RequestHandlerImpl.class,
74         RequestValidatorImpl.class, TransactionRecorder.class})
75 public class RequestValidatorTest {
76     private final EELFLogger logger = EELFManager.getInstance().getLogger(TestRequestHandler.class);
77
78     private RequestValidatorImpl requestValidator;
79
80     private AAIService aaiAdapter ;
81     private LifecycleManager lifecyclemanager;
82     private WorkFlowManager workflowManager;
83     private WorkingStateManager workingStateManager ;
84     private LCMStateManager lcmStateManager;
85
86     private final BundleContext bundleContext= Mockito.mock(BundleContext.class);
87     private final Bundle bundleService=Mockito.mock(Bundle.class);
88     private final ServiceReference sref=Mockito.mock(ServiceReference.class);
89
90     @Before
91     public void init() throws Exception {
92         // ***
93         AAIService aaiService = Mockito.mock(AAIService.class);
94         PowerMockito.mockStatic(FrameworkUtil.class);
95         PowerMockito.when(FrameworkUtil.getBundle(AAIService.class)).thenReturn(bundleService);
96         PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
97         PowerMockito.when(bundleContext.getServiceReference(AAIService.class.getName())).thenReturn(sref);
98         PowerMockito.when(bundleContext.<AAIService>getService(sref)).thenReturn(aaiService);
99         PowerMockito.when(aaiService.query(anyString(),anyBoolean(),anyString(),anyString(),anyString(),anyString(),
100                 anyObject())).thenAnswer(invocation -> {
101                     Object[] args = invocation.getArguments();
102                     SvcLogicContext ctx =(SvcLogicContext)args[6];
103                     String prefix = (String)args[4];
104                     String key = (String)args[3];
105                     if(key.contains("'28'")){
106                         return  SvcLogicResource.QueryStatus.FAILURE ;
107                     }else if ( key.contains("'8'")) {
108                         return  SvcLogicResource.QueryStatus.NOT_FOUND ;
109                     }else {
110                         ctx.setAttribute(prefix + ".vnf-type", "FIREWALL");
111                         ctx.setAttribute(prefix + ".orchestration-status", "Instantiated");
112                     }
113                     return  SvcLogicResource.QueryStatus.SUCCESS ;
114                 });
115         PowerMockito.when(aaiService.update(anyString(),anyString(), anyObject(),anyString(), anyObject()))
116                 .thenReturn(SvcLogicResource.QueryStatus.SUCCESS);
117         //  ***
118
119         aaiAdapter = Mockito.mock(AAIService.class);
120         lifecyclemanager= Mockito.mock(LifecycleManager.class);
121         workflowManager= Mockito.mock(WorkFlowManager.class);
122         workingStateManager = Mockito.mock(WorkingStateManager.class);
123         lcmStateManager = Mockito.mock(LCMStateManager.class);
124
125         requestValidator = new RequestValidatorImpl();
126         requestValidator.setWorkflowManager(workflowManager);
127         requestValidator.setLifecyclemanager(lifecyclemanager);
128         requestValidator.setWorkingStateManager(workingStateManager);
129         requestValidator.setLcmStateManager(lcmStateManager);
130
131         Mockito.when(lcmStateManager.isLCMOperationEnabled()).thenReturn(true);
132     }
133
134     public AAIService getAaiadapter() {
135         return this.aaiAdapter;
136     }
137
138     private RequestHandlerInput getRequestHandlerInput(String vnfID, VNFOperation action, int ttl,
139                                                        boolean force, String originatorId, String requestId,
140                                                        String subRequestId, Instant timeStamp){
141         String API_VERSION= "2.0.0";
142         RequestHandlerInput input = new RequestHandlerInput();
143         RuntimeContext runtimeContext = createRuntimeContextWithSubObjects();
144         RequestContext requestContext = runtimeContext.getRequestContext();
145         input.setRequestContext(requestContext);
146         requestContext.getActionIdentifiers().setVnfId(vnfID);
147         requestContext.setAction(action);
148         if (action != null) {
149             input.setRpcName(convertActionNameToUrl(action.name()));
150         } else{
151             input.setRpcName(null);
152         }
153         requestContext.getCommonHeader().setRequestId(requestId);
154         requestContext.getCommonHeader().setSubRequestId(subRequestId);
155         requestContext.getCommonHeader().setOriginatorId(originatorId);
156         requestContext.getCommonHeader().setFlags(new Flags(null, force, ttl));
157         requestContext.getCommonHeader().getTimeStamp();
158         requestContext.getCommonHeader().setApiVer(API_VERSION);
159         requestContext.getCommonHeader().setTimestamp(timeStamp);
160         return input;
161     }
162
163     @Test
164     public void testNullVnfID() throws Exception {
165         logger.debug("=====================testNullVnfID=============================");
166         Mockito.when(workflowManager.workflowExists(anyObject()))
167                 .thenReturn(new WorkflowExistsOutput(true,true));
168         RequestHandlerInput input = this.getRequestHandlerInput(null, VNFOperation.Configure, 30,
169                 false, UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
170                 Instant.now());
171         Exception ex =null;
172         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
173         try {
174             requestValidator.validateRequest(runtimeContext);
175         }catch(InvalidInputException e ) {
176             ex = e;
177         }
178         assertNotNull(ex);
179         logger.debug("=====================testNullVnfID=============================");
180     }
181
182     @Test
183     public void testPositiveFlowWithConfigure() throws Exception {
184         logger.debug("=====================testPositiveFlowWithConfigure=============================");
185         Mockito.when(workflowManager.workflowExists(anyObject()))
186                 .thenReturn(new WorkflowExistsOutput(true,true));
187         Mockito.when(workingStateManager.isVNFStable("1")).thenReturn(true);
188         RequestHandlerInput input = this.getRequestHandlerInput("1", VNFOperation.Configure, 30,
189                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
190                 Instant.now());
191         Exception ex =null;
192         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
193         try {
194             requestValidator.validateRequest(runtimeContext);
195         }catch(Exception e ) {
196             ex = e;
197         }
198         assertNull(ex);
199         logger.debug("testPositiveFlowWithConfigure");
200         logger.debug("=====================testPositiveFlowWithConfigure=============================");
201     }
202
203     @Test
204     public void testVnfNotFound() throws Exception {
205         logger.debug("=====================testVnfNotFound=============================");
206         Mockito.when(workflowManager.workflowExists(anyObject()))
207                 .thenReturn(new WorkflowExistsOutput(true,true));
208         RequestHandlerInput input = this.getRequestHandlerInput("8", VNFOperation.Configure, 30,
209                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
210                 Instant.now());
211         Exception ex =null;
212         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
213         try {
214             requestValidator.validateRequest(runtimeContext);
215         }catch(Exception e ) {
216             ex = e;
217         }
218         assertNotNull(ex);
219         logger.debug("=====================testVnfNotFound=============================");
220     }
221
222     @Test
223     public void testNullCommand() throws Exception {
224         logger.debug("=====================testNullCommand=============================");
225         Mockito.when(workflowManager.workflowExists(anyObject()))
226                 .thenReturn(new WorkflowExistsOutput(true,true));
227         RequestHandlerInput input = this.getRequestHandlerInput("7", null,30,
228                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
229                 Instant.now());
230        Exception ex =null;
231        RuntimeContext runtimeContext = putInputToRuntimeContext(input);
232        try {
233            requestValidator.validateRequest(runtimeContext);
234        }catch(InvalidInputException e ) {
235            ex = e;
236        }
237        assertNotNull(ex);
238         logger.debug("=====================testNullCommand=============================");
239     }
240
241     @Test
242     public void testNullVnfIDAndCommand() throws Exception {
243         logger.debug("=====================testNullVnfIDAndCommand=============================");
244         Mockito.when(workflowManager.workflowExists(anyObject()))
245                 .thenReturn(new WorkflowExistsOutput(true,true));
246         RequestHandlerInput input = this.getRequestHandlerInput(null, null,30,
247                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
248                 Instant.now());
249         Exception ex =null;
250         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
251         try {
252             requestValidator.validateRequest(runtimeContext);
253         }catch(InvalidInputException e ) {
254             ex = e;
255         }
256         assertNotNull(ex);
257         logger.debug("=====================testNullVnfIDAndCommand=============================");
258     }
259
260     @Test
261     public void testWorkflowNotFound() throws Exception {
262         logger.debug("=====================testWorkflowNotFound=============================");
263         Mockito.when(workflowManager.workflowExists(anyObject()))
264                 .thenReturn(new WorkflowExistsOutput(false,false));
265         RequestHandlerInput input = this.getRequestHandlerInput("10", VNFOperation.Configure, 30,
266                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
267                 Instant.now());
268         Exception ex =null;
269         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
270         try {
271             requestValidator.validateRequest(runtimeContext);
272         }catch(Exception e ) {
273             ex = e;
274         }
275         assertNotNull(ex);
276         logger.debug("=====================testWorkflowNotFound=============================");
277     }
278
279     @Test
280     public void testUnstableVnfWithConfigure() throws Exception {
281         logger.debug("=====================testUnstableVnfWithConfigure=============================");
282         Mockito.when(workflowManager.workflowExists(anyObject()))
283                 .thenReturn(new WorkflowExistsOutput(true,true));
284         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(),anyString()))
285                 .thenThrow( new NoTransitionDefinedException("","",""));
286
287         RequestHandlerInput input = this.getRequestHandlerInput("11", VNFOperation.Configure, 30,
288                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
289                 Instant.now());
290         Exception ex =null;
291         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
292         try {
293             requestValidator.validateRequest(runtimeContext);
294         }catch(Exception e ) {
295             ex = e;
296         }
297         assertNotNull(ex);
298         logger.debug("=====================testUnstableVnfWithConfigure=============================");
299     }
300
301     @Test
302     public void testUnstableVnfWithTest() throws Exception {
303         logger.debug("=====================testUnstableVnfWithTest=============================");
304         Mockito.when(workflowManager.workflowExists(anyObject()))
305                 .thenReturn(new WorkflowExistsOutput(true,true));
306         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(),anyString()))
307                 .thenThrow( new NoTransitionDefinedException("","",""));
308         RequestHandlerInput input = this.getRequestHandlerInput("12", VNFOperation.Test,30,
309                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
310                 Instant.now());
311         Exception ex =null;
312         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
313         try {
314             requestValidator.validateRequest(runtimeContext);
315         }catch(Exception e ) {
316             ex = e;
317         }
318         assertNotNull(ex);
319         logger.debug("=====================testUnstableVnfWithTest=============================");
320     }
321
322     @Test
323     public void testUnstableVnfWithStart() throws Exception {
324         logger.debug("=====================testUnstableVnfWithStart=============================");
325         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(),anyString()))
326                 .thenThrow( new NoTransitionDefinedException("","",""));
327
328         RequestHandlerInput input = this.getRequestHandlerInput("13", VNFOperation.Start,30,
329                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
330                 Instant.now());
331         Exception ex =null;
332         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
333         try {
334             requestValidator.validateRequest(runtimeContext);
335         }catch(Exception e ) {
336             ex = e;
337         }
338         assertNotNull(ex);
339         logger.debug("=====================testUnstableVnfWithStart=============================");
340     }
341
342     @Test
343     public void testUnstableVnfWithTerminate() throws Exception {
344         logger.debug("=====================testUnstableVnfWithTerminate=============================");
345         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(),anyString()))
346                 .thenThrow( new NoTransitionDefinedException("","",""));
347         RequestHandlerInput input = this.getRequestHandlerInput("14", VNFOperation.Terminate,30,
348                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
349                 Instant.now());
350         Exception ex =null;
351         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
352         try {
353             requestValidator.validateRequest(runtimeContext);
354         }catch(Exception e ) {
355             ex = e;
356         }
357         assertNotNull(ex);
358         logger.debug("=====================testUnstableVnfWithTerminate=============================");
359     }
360
361     @Test
362     public void testUnstableVnfWithRestart() throws Exception {
363         logger.debug("=====================testUnstableVnfWithRestart=============================");
364         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(),anyString()))
365                 .thenThrow( new NoTransitionDefinedException("","",""));
366
367         RequestHandlerInput input = this.getRequestHandlerInput("26", VNFOperation.Restart,30,
368                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
369                 Instant.now());
370         Exception ex =null;
371         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
372         try {
373             requestValidator.validateRequest(runtimeContext);
374         }catch(Exception e ) {
375             ex = e;
376         }
377         assertNotNull(ex);
378         logger.debug("=====================testUnstableVnfWithRestart=============================");
379     }
380
381     @Test
382     public void testUnstableVnfWithRebuild() throws Exception {
383         logger.debug("=====================testUnstableVnfWithRebuild=============================");
384         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(),anyString()))
385                 .thenThrow( new NoTransitionDefinedException("","",""));
386
387         RequestHandlerInput input = this.getRequestHandlerInput("27", VNFOperation.Rebuild,30,
388                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
389                 Instant.now());
390         Exception ex =null;
391         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
392         try {
393             requestValidator.validateRequest(runtimeContext);
394         }catch(Exception e ) {
395             ex = e;
396         }
397         assertNotNull(ex);
398         logger.debug("=====================testUnstableVnfWithRebuild=============================");
399     }
400
401     @Test
402     public void testAAIDown() throws Exception {
403         logger.debug("=====================testAAIDown=============================");
404         RequestHandlerInput input = this.getRequestHandlerInput("28", VNFOperation.Configure, 30,
405                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),
406                 Instant.now());
407         Exception ex =null;
408         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
409         try {
410             requestValidator.validateRequest(runtimeContext);
411         }catch(Exception e ) {
412             ex = e;
413         }
414         assertNotNull(ex);
415         logger.debug("=====================testAAIDown=============================");
416     }
417
418     @Test
419     public void testNegativeFlowWithTimeStamp() throws Exception {
420         logger.debug("=====================testNegativeFlowWithTimeStamp=============================");
421         Instant now =  Instant.now();
422         Instant past =  now.minusMillis(1000000);
423         RequestHandlerInput input = this.getRequestHandlerInput("35", VNFOperation.Configure, 30,
424                 false,UUID.randomUUID().toString(),UUID.randomUUID().toString(),UUID.randomUUID().toString(),past);
425         Exception ex =null;
426         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
427        
428         try {
429             requestValidator.validateRequest(runtimeContext);
430         }catch(Exception e ) {
431             ex = e;
432         }
433         assertNotNull(ex);
434         logger.debug("testNegativeFlowWithTimeStamp");
435         logger.debug("=====================testNegativeFlowWithTimeStamp=============================");
436     }
437
438     @Test
439     public void rejectDuplicateRequest() throws Exception {
440         String originatorID = UUID.randomUUID().toString();
441         String requestID = UUID.randomUUID().toString();
442         String subRequestID = UUID.randomUUID().toString();
443
444         Mockito.when(workflowManager.workflowExists(anyObject()))
445                 .thenReturn(new WorkflowExistsOutput(true,true));
446         Mockito.when(workingStateManager.isVNFStable("301")).thenReturn(true);
447         Mockito.when(workingStateManager.isVNFStable("309")).thenReturn(true);
448         RequestHandlerInput input = this.getRequestHandlerInput("301", VNFOperation.Configure,0,false,
449                 originatorID, requestID, subRequestID, Instant.now());
450
451         RequestHandlerInput input1 = this.getRequestHandlerInput("309", VNFOperation.Configure,0,false,
452                 originatorID, requestID, subRequestID, Instant.now());
453         Exception ex =null;
454         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
455         RuntimeContext runtimeContext1 = putInputToRuntimeContext(input1);
456
457         try {
458             requestValidator.validateRequest(runtimeContext);
459         }catch(Exception e ) {
460             ex = e;
461         }
462         assertNull(ex);
463
464         try {
465             requestValidator.validateRequest(runtimeContext1);
466         }catch(Exception e ) {
467             ex = e;
468         }
469         assertNotNull(ex);
470     }
471
472     @Test
473     public void testLockOperation() throws Exception {
474         Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
475         testOperation("no-matter", VNFOperation.Lock);
476     }
477
478     @Test
479     public void testUnlockOperation() throws Exception {
480         Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
481         testOperation("no-matter", VNFOperation.Unlock);
482     }
483
484     @Test
485     public void testCheckLockOperation() throws Exception {
486         Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
487         testOperation("no-matter", VNFOperation.CheckLock);
488     }
489
490     @Test(expected = NoTransitionDefinedException.class)
491     public void testLockOperationNegative() throws Exception {
492         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.Lock.toString())))
493                 .thenThrow(new NoTransitionDefinedException("", "", ""));
494         Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
495         testOperation("no-matter", VNFOperation.Lock);
496     }
497
498     @Test(expected = NoTransitionDefinedException.class)
499     public void testUnlockOperationNegative() throws Exception {
500         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.Unlock.toString())))
501                 .thenThrow(new NoTransitionDefinedException("", "", ""));
502         Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
503         testOperation("no-matter", VNFOperation.Unlock);
504     }
505
506     @Test(expected = NoTransitionDefinedException.class)
507     public void testCheckLockOperationNegative() throws Exception {
508         Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.CheckLock.toString())))
509                 .thenThrow(new NoTransitionDefinedException("", "", ""));
510         Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
511         testOperation("no-matter", VNFOperation.CheckLock);
512     }
513
514     @Test(expected = LCMOperationsDisabledException.class)
515     public void testLCMOperationsDisabled() throws Exception {
516         Mockito.when(lcmStateManager.isLCMOperationEnabled()).thenReturn(false);
517         testOperation("no-matter", VNFOperation.Configure);
518     }
519     private void testOperation(String resource, VNFOperation operation) throws Exception {
520         String originatorID = UUID.randomUUID().toString();
521         String requestID = UUID.randomUUID().toString();
522         String subRequestID = UUID.randomUUID().toString();
523
524         RequestHandlerInput input = this.getRequestHandlerInput(resource, operation, 0, false, originatorID,
525                 requestID, subRequestID,  Instant.now());
526         RuntimeContext runtimeContext = putInputToRuntimeContext(input);
527         requestValidator.validateRequest(runtimeContext);
528     }
529
530     private RuntimeContext createRuntimeContextWithSubObjects() {
531         RuntimeContext runtimeContext = new RuntimeContext();
532         RequestContext requestContext = new RequestContext();
533         runtimeContext.setRequestContext(requestContext);
534         ResponseContext responseContext = createResponseContextWithSuObjects();
535         runtimeContext.setResponseContext(responseContext);
536         CommonHeader commonHeader = new CommonHeader();
537         requestContext.setCommonHeader(commonHeader);
538         commonHeader.setFlags(new Flags(null, false, 0));
539         ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
540         requestContext.setActionIdentifiers(actionIdentifiers);
541         VNFContext vnfContext = new VNFContext();
542         runtimeContext.setVnfContext(vnfContext);
543         return runtimeContext;
544
545     }
546
547     private ResponseContext createResponseContextWithSuObjects(){
548         ResponseContext responseContext = new ResponseContext();
549         CommonHeader commonHeader = new CommonHeader();
550         responseContext.setCommonHeader(commonHeader);
551         responseContext.setStatus(new Status(0, null));
552         commonHeader.setFlags(new Flags(null, false, 0));
553         return responseContext;
554     }
555
556     private String convertActionNameToUrl(String action) {
557         String regex = "([a-z])([A-Z]+)";
558         String replacement = "$1-$2";
559         return action.replaceAll(regex, replacement)
560                 .toLowerCase();
561     }
562
563     private RuntimeContext putInputToRuntimeContext(RequestHandlerInput input) {
564         RuntimeContext runtimeContext = createRuntimeContextWithSubObjects();
565         runtimeContext.setRequestContext(input.getRequestContext());
566         runtimeContext.setRpcName(input.getRpcName());
567         runtimeContext.getVnfContext().setId(input.getRequestContext().getActionIdentifiers().getVnfId());
568         return runtimeContext;
569     }
570 }