Skip to content

Commit

Permalink
fix(rest): fix forms not being fetched for cmmn tasks
Browse files Browse the repository at this point in the history
Related to CAM-13433
  • Loading branch information
yT0n1 authored May 19, 2021
1 parent 1848980 commit 5506df1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,9 @@ protected Task getTaskById(String id) {
}

protected String getTaskFormMediaType(String taskId) {
// retrieving the task and the form key can require additional permissions (e.g. READ on ProcessDefinition)
// that we should not force on the user additionally just to retrieve the correct content type
String formKey = runWithoutAuthorization(() -> {
Task task = engine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
ensureNotNull("No task found for taskId '" + taskId + "'", "task", task);
return engine.getFormService().getTaskFormKey(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
});
Task task = engine.getTaskService().createTaskQuery().initializeFormKeys().taskId(taskId).singleResult();
ensureNotNull("No task found for taskId '" + taskId + "'", "task", task);
String formKey = task.getFormKey();
return ContentTypeUtil.getFormContentType(formKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3259,7 +3259,7 @@ public void testGetDeployedTaskForm() {
public void testGetDeployedTaskFormJson() {
InputStream deployedFormMock = new ByteArrayInputStream("Test".getBytes());
when(formServiceMock.getDeployedTaskForm(anyString())).thenReturn(deployedFormMock);
when(formServiceMock.getTaskFormKey(anyString(), anyString())).thenReturn("test.form");
when(mockTask.getFormKey()).thenReturn("test.form");

given()
.pathParam("id", MockProvider.EXAMPLE_TASK_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5020,6 +5020,20 @@ public void testInitializeFormKeys() {
}
}

@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithFormKey.cmmn"})
@Test
public void testInitializeFormKeysForCaseInstance() {
String caseDefinitionId = getCaseDefinitionId();

CaseInstance caseInstance = caseService
.withCaseDefinition(caseDefinitionId)
.create();

Task task = taskService.createTaskQuery().initializeFormKeys().caseInstanceId(caseInstance.getId()).singleResult();
assertEquals("aFormKey", task.getFormKey());

}

@Deployment(resources = "org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml")
@Test
public void testQueryOrderByProcessVariableInteger() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<definitions id="_7f0c94c0-2a22-445d-b4b7-4fd181e08248"
xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camunda="http://camunda.org/schema/1.0/cmmn"
targetNamespace="Examples">
<case id="oneTaskCase" name="One Task Case">

<casePlanModel id="CasePlanModel_1">
<planItem id="PI_HumanTask_1" definitionRef="HumanTask_1">
<documentation>This is a description...</documentation>
</planItem>

<humanTask id="HumanTask_1" name="A HumanTask" camunda:formKey="aFormKey"/>
</casePlanModel>
</case>

</definitions>

0 comments on commit 5506df1

Please sign in to comment.