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.onap.so.bpmn.common.scripts
23 import static org.mockito.Mockito.*
25 import org.camunda.bpm.engine.ProcessEngineServices
26 import org.camunda.bpm.engine.RepositoryService
27 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
28 import org.camunda.bpm.engine.repository.ProcessDefinition
30 abstract class MsoGroovyTest {
32 protected ExecutionEntity setupMock(String procName) {
33 ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
34 when(mockProcessDefinition.getKey()).thenReturn(procName)
36 RepositoryService mockRepositoryService = mock(RepositoryService.class)
37 when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
38 when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(procName)
39 when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
41 ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
42 when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
44 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
45 when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
50 protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) {
51 ExecutionEntity mockExecution = mock(ExecutionEntity.class)
53 when(mockExecution.getVariable("prefix")).thenReturn(prefix)
55 ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class)
56 RepositoryService repositoryService = mock(RepositoryService.class)
57 ProcessDefinition processDefinition = mock(ProcessDefinition.class)
59 when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices)
60 when(processEngineServices.getRepositoryService()).thenReturn(repositoryService)
61 when(repositoryService.getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(processDefinition)
62 when(processDefinition.getKey()).thenReturn(procName)
63 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")