From aac7d52bf557944eb703b35930579af8ff9e5764 Mon Sep 17 00:00:00 2001 From: auslin-aot <99173163+auslin-aot@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:03:19 +0530 Subject: [PATCH] [Bugfix]: Update taskVariables param in form bpm filtered listener --- .../data/FormProcessMappingData.java | 4 +-- ...rmBPMFilteredDataPipelineListenerTest.java | 33 ++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/forms-flow-bpm/forms-flow-bpm-camunda/src/main/java/org/camunda/bpm/extension/hooks/listeners/data/FormProcessMappingData.java b/forms-flow-bpm/forms-flow-bpm-camunda/src/main/java/org/camunda/bpm/extension/hooks/listeners/data/FormProcessMappingData.java index 0c57bee435..2a978c3cbd 100644 --- a/forms-flow-bpm/forms-flow-bpm-camunda/src/main/java/org/camunda/bpm/extension/hooks/listeners/data/FormProcessMappingData.java +++ b/forms-flow-bpm/forms-flow-bpm-camunda/src/main/java/org/camunda/bpm/extension/hooks/listeners/data/FormProcessMappingData.java @@ -17,11 +17,11 @@ public class FormProcessMappingData implements IResponse, Serializable { private static final long serialVersionUID = 1L; - private String taskVariable; + private String taskVariables; private String processName; private String processKey; public FilterInfo[] getTaskVariableList(ObjectMapper objectMapper) throws JsonProcessingException { - return objectMapper.readValue(this.taskVariable, FilterInfo[].class); + return objectMapper.readValue(this.taskVariables, FilterInfo[].class); } } diff --git a/forms-flow-bpm/forms-flow-bpm-camunda/src/test/java/org/camunda/bpm/extension/hooks/listeners/FormBPMFilteredDataPipelineListenerTest.java b/forms-flow-bpm/forms-flow-bpm-camunda/src/test/java/org/camunda/bpm/extension/hooks/listeners/FormBPMFilteredDataPipelineListenerTest.java index 8d0c864826..aefb88133e 100644 --- a/forms-flow-bpm/forms-flow-bpm-camunda/src/test/java/org/camunda/bpm/extension/hooks/listeners/FormBPMFilteredDataPipelineListenerTest.java +++ b/forms-flow-bpm/forms-flow-bpm-camunda/src/test/java/org/camunda/bpm/extension/hooks/listeners/FormBPMFilteredDataPipelineListenerTest.java @@ -1,34 +1,37 @@ package org.camunda.bpm.extension.hooks.listeners; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.DelegateTask; import org.camunda.bpm.extension.commons.connector.HTTPServiceInvoker; -import org.camunda.bpm.extension.hooks.listeners.data.FilterInfo; +import static org.camunda.bpm.extension.commons.utils.VariableConstants.APPLICATION_ID; +import static org.camunda.bpm.extension.commons.utils.VariableConstants.FORM_URL; import org.camunda.bpm.extension.hooks.listeners.data.FormProcessMappingData; import org.camunda.bpm.extension.hooks.services.FormSubmissionService; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import org.mockito.InjectMocks; import org.mockito.Mock; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.util.ReflectionTestUtils; -import java.lang.reflect.Field; -import java.util.*; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.*; - -import static org.camunda.bpm.extension.commons.utils.VariableConstants.FORM_URL; -import static org.camunda.bpm.extension.commons.utils.VariableConstants.APPLICATION_ID; +import com.fasterxml.jackson.databind.ObjectMapper; /** * FormBPM FilteredData Pipeline Listener Test. @@ -81,7 +84,7 @@ public void syncFormVariables_with_delegatetask_and_validapi_withdata_test() thr FormProcessMappingData formProcessMappingData = new FormProcessMappingData(); formProcessMappingData.setProcessKey("onestepapproval"); formProcessMappingData.setProcessKey("onestepapproval"); - formProcessMappingData.setTaskVariable("[{\"key\" : \"businessOwner\", \"defaultLabel\" : \"Business Owner\", \"label\" : \"Business Owner\"}]"); + formProcessMappingData.setTaskVariables("[{\"key\" : \"businessOwner\", \"defaultLabel\" : \"Business Owner\", \"label\" : \"Business Owner\"}]"); when(httpServiceInvoker.execute(anyString(), any(HttpMethod.class), any(), any())) .thenReturn(ResponseEntity.ok(formProcessMappingData)); @@ -115,7 +118,7 @@ public void syncFormVariables_with_delegateExecution_and_validapi_withdata_test( FormProcessMappingData formProcessMappingData = new FormProcessMappingData(); formProcessMappingData.setProcessKey("onestepapproval"); formProcessMappingData.setProcessKey("onestepapproval"); - formProcessMappingData.setTaskVariable("[{\"key\" : \"businessOwner\", \"defaultLabel\" : \"Business Owner\", \"label\" : \"Business Owner\"}]"); + formProcessMappingData.setTaskVariables("[{\"key\" : \"businessOwner\", \"defaultLabel\" : \"Business Owner\", \"label\" : \"Business Owner\"}]"); when(httpServiceInvoker.execute(anyString(), any(HttpMethod.class), any(), any())) .thenReturn(ResponseEntity.ok(formProcessMappingData)); @@ -153,7 +156,7 @@ public void syncFormVariables_with_validapi_and_emptydata_test() throws Exceptio FormProcessMappingData formProcessMappingData = new FormProcessMappingData(); formProcessMappingData.setProcessKey("onestepapproval"); formProcessMappingData.setProcessKey("onestepapproval"); - formProcessMappingData.setTaskVariable("[{\"key\" : \"businessOwner\", \"value\" : \"john\", \"label\" : \"Business Owner\"}]"); + formProcessMappingData.setTaskVariables("[{\"key\" : \"businessOwner\", \"value\" : \"john\", \"label\" : \"Business Owner\"}]"); when(httpServiceInvoker.execute(anyString(), any(HttpMethod.class), any(), any())) .thenReturn(ResponseEntity.ok(formProcessMappingData)); formBPMFilteredDataPipelineListener.notify(delegateTask);