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 com.github.tomakehurst.wiremock.junit.WireMockRule
24 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
25 import org.junit.Assert
26 import org.junit.Before
27 import org.junit.Ignore
30 import org.junit.runner.RunWith
31 import org.mockito.ArgumentCaptor
32 import org.mockito.Captor
33 import org.mockito.Mockito
34 import org.mockito.runners.MockitoJUnitRunner
36 import static org.mockito.Mockito.times
37 import static org.mockito.Mockito.when
38 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutServiceInstance
42 * @since January 10, 2018
44 @RunWith(MockitoJUnitRunner.class)
46 class CustomE2EPutServiceTest extends MsoGroovyTest {
48 public WireMockRule wireMockRule = new WireMockRule(28090)
51 static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
54 public void testPutServiceInstance(){
55 ExecutionEntity mockExecution = setupMockWithPrefix('CustomE2EPutService','GENPS_')
56 when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
57 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
58 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
59 when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer')
60 when(mockExecution.getVariable("GENPS_type")).thenReturn('service-instance')
61 when(mockExecution.getVariable("GENPS_payload")).thenReturn('')
62 when(mockExecution.getVariable("GENPS_globalSubscriberId")).thenReturn("1604-MVM-26")
63 when(mockExecution.getVariable("GENPS_serviceType")).thenReturn("SDN-ETHERNET-INTERNET")
64 when(mockExecution.getVariable("GENPS_serviceInstanceId")).thenReturn( "1234")
65 MockPutServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", "GenericFlows/getServiceInstance.xml");
67 CustomE2EPutService customE2EPutService = new CustomE2EPutService()
68 customE2EPutService.putServiceInstance(mockExecution);
69 Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture())
70 Assert.assertEquals(200, captor.getAllValues().get(7))