diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2017-11-06 12:09:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-11-06 12:09:39 +0000 |
commit | b238e088461b9e3b39362410e5770e57f5a7fe42 (patch) | |
tree | f3503a04a5dc849a670eae8e8e5514acdf06b11e /bpmn | |
parent | a0652c47e1dc06e4e91857072c2701ced9bcacc3 (diff) | |
parent | 2490c467a095b253551c7fde83803aa65f2e548b (diff) |
Merge "UT for Delete e2e main process"
Diffstat (limited to 'bpmn')
-rw-r--r-- | bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy new file mode 100644 index 0000000000..8ccb18a625 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy @@ -0,0 +1,160 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import com.github.tomakehurst.wiremock.junit.WireMockRule +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.infrastructure.scripts.DeleteCustomE2EServiceInstance +import org.openecomp.mso.bpmn.mock.FileUtil +import org.openecomp.mso.bpmn.vcpe.scripts.GroovyTestBase + +import static org.junit.Assert.assertTrue +import static org.junit.Assert.assertTrue +import static org.junit.Assert.assertTrue +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when + +class DeleteCustomE2EServiceInstanceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT) + + String Prefix = "CVRCS_" + String RbType = "DCRENI_" + + @BeforeClass + public static void setUpBeforeClass() { + request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DeleteCustomE2EServiceInstanceTest(){ + super("DeleteCustomE2EServiceInstance") + } + @Test + public void preProcessRequestTest () { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + mex.setVariable("isDebugLogEnabled","true") + instance.preProcessRequest(mex); + + verify(mex).getVariable(GroovyTestBase.DBGFLAG) + + verify(mex).setVariable("globalSubscriberId", "38829939920000") + verify(mex).setVariable("operationId", "59960003992") + verify(mex).setVariable("URN_mso_adapters_openecomp_db_endpoint", "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") + } + + @Test + public void sendSyncResponseTest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.sendSyncResponse(mex) + verify(mex).setVariable("DeleteCustomE2EServiceInstanceWorkflowResponseSent", "true") + } + + @Test + public void prepareCompletionRequestTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.prepareCompletionRequest(mex) + String msoComplitionRequest = FileUtil.readResourceFile("__files/GenericFlows/MsoCompletionRequest.xml") + //verify(mex).setVariable("completionRequest", msoComplitionRequest) + } + + @Test + public void sendSyncErrorTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.sendSyncError(mex) + + } + + @Test + public void prepareFalloutRequest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.prepareFalloutRequest(mex) + String requestInfo = + """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> + <request-id>null</request-id> + <action>DELETE</action> + <source>null</source> + </request-info>""" + //verify(mex).setVariable("falloutRequest", requestInfo) + } + + @Test + public void processJavaExceptionTest(){ + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() + instance.processJavaException() + } + + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceType")).thenReturn("VoLTE") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("requestAction")).thenReturn("ra") + when(mex.getVariable("operationId")).thenReturn("59960003992") + } +} |