Groovy scripts header correction
[so.git] / bpmn / MSOCommonBPMN / src / test / groovy / org / openecomp / mso / bpmn / common / scripts / MsoGroovyTest.groovy
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.openecomp.mso.bpmn.common.scripts
22
23 import static org.mockito.Mockito.*
24
25 import org.mockito.MockitoAnnotations
26 import org.mockito.runners.MockitoJUnitRunner
27 import org.mockito.internal.debugging.MockitoDebuggerImpl
28 import org.camunda.bpm.engine.ProcessEngineServices
29 import org.camunda.bpm.engine.RepositoryService
30 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
31 import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
32 import org.camunda.bpm.engine.repository.ProcessDefinition
33
34 abstract class MsoGroovyTest {
35         
36         protected ExecutionEntity setupMock(String procName) {
37                 ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
38                 when(mockProcessDefinition.getKey()).thenReturn(procName)
39                 
40                 RepositoryService mockRepositoryService = mock(RepositoryService.class)
41                 when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
42                 when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(procName)
43                 when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
44                 
45                 ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
46                 when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
47                 
48                 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
49                 when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
50                 
51                 return mockExecution
52         }
53         
54         protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) {
55                 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
56
57                 when(mockExecution.getVariable("prefix")).thenReturn(prefix)
58
59                 ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class)
60                 RepositoryService repositoryService = mock(RepositoryService.class)
61                 ProcessDefinition processDefinition = mock(ProcessDefinition.class)
62
63                 when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices)
64                 when(processEngineServices.getRepositoryService()).thenReturn(repositoryService)
65                 when(repositoryService.getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(processDefinition)
66                 when(processDefinition.getKey()).thenReturn(procName)
67                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
68                 return mockExecution
69         }
70         
71         
72 }