Skip to content

Commit

Permalink
[Bugfix]: Update taskVariables param in form bpm filtered listener
Browse files Browse the repository at this point in the history
  • Loading branch information
auslin-aot committed Dec 2, 2024
1 parent 5787099 commit aac7d52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit aac7d52

Please sign in to comment.