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