2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.vcpe.scripts
25 import org.camunda.bpm.engine.ProcessEngineServices
26 import org.camunda.bpm.engine.RepositoryService
27 import org.camunda.bpm.engine.delegate.BpmnError
28 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
29 import org.camunda.bpm.engine.repository.ProcessDefinition
30 import org.junit.runner.RunWith
31 import org.mockito.Mock
32 import org.mockito.junit.MockitoJUnitRunner
33 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
34 import org.onap.so.bpmn.common.scripts.AllottedResourceUtils
35 import org.onap.so.bpmn.core.UrnPropertiesReader
36 import org.onap.so.client.aai.AAIResourcesClient
38 import static org.mockito.ArgumentMatchers.any
39 import static org.mockito.Mockito.*
41 @RunWith(MockitoJUnitRunner.class)
42 class GroovyTestBase {
44 static final int PORT = 28090
45 static final String LOCAL_URI = "http://localhost:" + PORT
47 static final String CUST = "SDN-ETHERNET-INTERNET"
48 static final String SVC = "123456789"
49 static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET"
50 static final String ARID = "arId-1"
51 static final String VERS = "myvers"
53 static final String DBGFLAG = "isDebugLogEnabled"
55 static String aaiUriPfx
59 AllottedResourceUtils allottedResourceUtils_MOCK
62 AAIResourcesClient client_MOCK
64 public static void setUpBeforeClass() {
65 aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
68 public GroovyTestBase(String processName) {
69 this.processName = processName
72 public boolean doBpmnError(def func) {
78 } catch (BpmnError e) {
83 public ExecutionEntity setupMock() {
85 ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
86 when(mockProcessDefinition.getKey()).thenReturn(processName)
87 RepositoryService mockRepositoryService = mock(RepositoryService.class)
88 when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
89 when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName)
90 ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
91 when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
93 ExecutionEntity mex = mock(ExecutionEntity.class)
95 when(mex.getProcessDefinitionId()).thenReturn(processName)
96 when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
97 when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
99 when(mex.getVariable("isAsyncProcess")).thenReturn("true")
100 when(mex.getVariable(processName + "WorkflowResponseSent")).thenReturn("false")
105 public Map<String, Object> setupMap(ExecutionEntity mex) {
106 MapSetter mapset = new MapSetter();
107 doAnswer(mapset).when(mex).setVariable(any(), any())
108 return mapset.getMap();
111 void initAllottedResourceMock() {
112 allottedResourceUtils_MOCK = spy(new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class)))