2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.mso.bpmn.common.scripts
23 import static org.mockito.Mockito.*
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
34 abstract class MsoGroovyTest {
36 protected ExecutionEntity setupMock(String procName) {
37 ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
38 when(mockProcessDefinition.getKey()).thenReturn(procName)
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")
45 ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
46 when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
48 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
49 when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
54 protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) {
55 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
57 when(mockExecution.getVariable("prefix")).thenReturn(prefix)
59 ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class)
60 RepositoryService repositoryService = mock(RepositoryService.class)
61 ProcessDefinition processDefinition = mock(ProcessDefinition.class)
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")