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.infrastructure.scripts
23 import static com.shazam.shazamcrest.MatcherAssert.assertThat
24 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs
25 import static org.mockito.Mockito.times
26 import static org.mockito.Mockito.when
28 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
29 import org.junit.Before
31 import org.mockito.ArgumentCaptor
32 import org.mockito.Captor
33 import org.mockito.Mockito
34 import org.onap.aai.domain.yang.ServiceInstance
35 import org.onap.so.bpmn.common.scripts.MsoGroovyTest
39 * @since January 10, 2018
41 class DoCreateE2EServiceInstanceTest extends MsoGroovyTest{
46 super.init("DoCreateE2EServiceInstance")
49 static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
51 public void testPreProcessRequest(){
53 ServiceInstance expectedServiceInstanceData = getExpectedServiceInstance()
54 DoCreateE2EServiceInstance serviceInstance = new DoCreateE2EServiceInstance()
55 serviceInstance.preProcessRequest(mockExecution)
56 Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture())
57 assertThat(captor.getValue(), sameBeanAs(expectedServiceInstanceData))
60 private ServiceInstance getExpectedServiceInstance() {
61 ServiceInstance expectedServiceInstanceData = new ServiceInstance()
62 expectedServiceInstanceData.setServiceInstanceId("1234")
63 expectedServiceInstanceData.setServiceInstanceName("volte-service")
64 expectedServiceInstanceData.setServiceType("E2E Service")
65 expectedServiceInstanceData.setServiceRole("E2E Service")
66 expectedServiceInstanceData.setOrchestrationStatus("Created")
67 return expectedServiceInstanceData
70 private void mockData() {
71 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
72 when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345")
73 when(mockExecution.getVariable("serviceType")).thenReturn("TRANSPORT")
74 when(mockExecution.getVariable("serviceInstanceId")).thenReturn("1234")
75 when(mockExecution.getVariable("serviceInstanceName")).thenReturn("volte-service")
76 when(mockExecution.getVariable("uuiRequest")).thenReturn("""{"service":{"serviceDefId":"c1d4305f-cdbd-4bbe-9069-a2f4978fd89e" , "templateId" : "d4df5c27-98a1-4812-a8aa-c17f055b7a3f"}}""")
77 when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/")
78 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
79 when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8")
80 when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer')
81 when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn('/testUrl')