From 00f0a8c1f0fbee5e58ed208ee49b57e627fccef7 Mon Sep 17 00:00:00 2001 From: seshukm Date: Sat, 28 Oct 2017 15:18:23 +0530 Subject: add sendSyncResponse to groovy test IssueId: SO-281 Change-Id: I71c168162ce98be9592c50c35814c521fc325312 Signed-off-by: seshukm --- ...CreateGenericAlaCarteServiceInstanceTest.groovy | 48 +++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'bpmn/MSOInfrastructureBPMN') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy index 293eac091e..0b7617f00f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy @@ -207,4 +207,50 @@ class CreateGenericAlaCarteServiceInstanceTest { //ignore } } - } \ No newline at end of file + + @Test + //@Ignore + public void sendSyncResponse() { + + println "************ sendSyncResponse ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + try{ + // preProcessRequest(Execution execution) + CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() + CreateNetworkInstance.sendSyncResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable("CreateNetworkInstanceResponseCode", "202") + }catch(Exception e){ + //ignore + } + } + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("CreateNetworkInstance") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateNetworkInstance") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("CreateNetworkInstance") + when(mockExecution.getProcessInstanceId()).thenReturn("CreateNetworkInstance") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } +} -- cgit 1.2.3-korg