Skip to content

Commit

Permalink
fix(engine): add missing property to process definition statistics query
Browse files Browse the repository at this point in the history
Related to #3891

Co-authored-by: psavidis <[email protected]>
  • Loading branch information
mboskamp and psavidis authored Nov 16, 2023
1 parent fcb300a commit b269c63
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER"/>
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="versionTag" column="VERSION_TAG_" jdbcType="VARCHAR" />
<result property="isStartableInTasklist" column="STARTABLE_" jdbcType="BOOLEAN" />
<collection property="incidentStatistics" javaType="ArrayList" ofType="org.camunda.bpm.engine.impl.persistence.entity.IncidentStatisticsEntity">
<result property="incidentType" column="INCIDENT_TYPE_" jdbcType="VARCHAR" />
<result property="incidentCount" column="INCIDENT_COUNT_" jdbcType="INTEGER"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.management.IncidentStatistics;
import org.camunda.bpm.engine.management.ProcessDefinitionStatistics;
Expand All @@ -44,7 +43,7 @@ public class ProcessDefinitionStatisticsQueryTest extends PluggableProcessEngine
public void testProcessDefinitionStatisticsQueryWithFailedJobs() {
runtimeService.startProcessInstanceByKey("ExampleProcess");

Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("fail", true);
runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);

Expand All @@ -68,7 +67,7 @@ public void testProcessDefinitionStatisticsQueryWithFailedJobs() {
public void testProcessDefinitionStatisticsQueryWithIncidents() {
runtimeService.startProcessInstanceByKey("ExampleProcess");

Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("fail", true);
runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);

Expand Down Expand Up @@ -98,7 +97,7 @@ public void testProcessDefinitionStatisticsQueryWithIncidents() {
public void testProcessDefinitionStatisticsQueryWithIncidentType() {
runtimeService.startProcessInstanceByKey("ExampleProcess");

Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("fail", true);
runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);

Expand Down Expand Up @@ -128,7 +127,7 @@ public void testProcessDefinitionStatisticsQueryWithIncidentType() {
public void testProcessDefinitionStatisticsQueryWithInvalidIncidentType() {
runtimeService.startProcessInstanceByKey("ExampleProcess");

Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("fail", true);
runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);

Expand All @@ -153,7 +152,7 @@ public void testProcessDefinitionStatisticsQueryWithInvalidIncidentType() {
public void testProcessDefinitionStatisticsQueryWithIncidentsAndFailedJobs() {
runtimeService.startProcessInstanceByKey("ExampleProcess");

Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("fail", true);
runtimeService.startProcessInstanceByKey("ExampleProcess", parameters);

Expand Down Expand Up @@ -337,7 +336,7 @@ public void testProcessDefinitionStatisticsQueryForMultipleVersionsWithFailedJob
.processDefinitionKey("ExampleProcess")
.list();

Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("fail", true);

for (ProcessDefinition definition : definitions) {
Expand Down Expand Up @@ -681,19 +680,20 @@ public void testProcessDefinitionStatisticsProperties() {

ProcessDefinitionStatistics processDefinitionStatistics = managementService.createProcessDefinitionStatisticsQuery().singleResult();

assertEquals("testProcess", processDefinitionStatistics.getKey());
assertEquals("process name", processDefinitionStatistics.getName());
assertEquals("Examples", processDefinitionStatistics.getCategory());
assertEquals(null, processDefinitionStatistics.getDescription()); // it is not parsed for the statistics query
assertEquals("tenant1", processDefinitionStatistics.getTenantId());
assertEquals("v0.1.0", processDefinitionStatistics.getVersionTag());
assertEquals(deploymentId, processDefinitionStatistics.getDeploymentId());
assertEquals(resourceName, processDefinitionStatistics.getResourceName());
assertEquals(null, processDefinitionStatistics.getDiagramResourceName());
assertEquals(1, processDefinitionStatistics.getVersion());
assertEquals(0, processDefinitionStatistics.getInstances());
assertEquals(0, processDefinitionStatistics.getFailedJobs());
assertTrue(processDefinitionStatistics.getIncidentStatistics().isEmpty());
assertThat(processDefinitionStatistics.getKey()).isEqualTo("testProcess");
assertThat(processDefinitionStatistics.getName()).isEqualTo("process name");
assertThat(processDefinitionStatistics.getCategory()).isEqualTo("Examples");
assertThat(processDefinitionStatistics.getDescription()).isNull(); // it is not parsed for the statistics query
assertThat(processDefinitionStatistics.getTenantId()).isEqualTo("tenant1");
assertThat(processDefinitionStatistics.getVersionTag()).isEqualTo("v0.1.0");
assertThat(processDefinitionStatistics.getDeploymentId()).isEqualTo(deploymentId);
assertThat(processDefinitionStatistics.getResourceName()).isEqualTo(resourceName);
assertThat(processDefinitionStatistics.getDiagramResourceName()).isNull();
assertThat(processDefinitionStatistics.getVersion()).isEqualTo(1);
assertThat(processDefinitionStatistics.getInstances()).isEqualTo(0);
assertThat(processDefinitionStatistics.getFailedJobs()).isEqualTo(0);
assertThat(processDefinitionStatistics.getIncidentStatistics()).isEmpty();
assertThat(processDefinitionStatistics.isStartableInTasklist()).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.time.DateUtils;
import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.impl.util.ClockUtil;
Expand Down Expand Up @@ -90,20 +89,31 @@ public void testProcessDefinitionProperties() {
assertThat(processDefinition.getDescription()).isEqualTo("Desc one");
assertThat(processDefinition.getId()).startsWith("one:1");
assertThat(processDefinition.getCategory()).isEqualTo("Examples");
assertThat(processDefinition.isStartableInTasklist()).isEqualTo(true);

processDefinition = processDefinitions.get(1);
assertThat(processDefinition.getKey()).isEqualTo("one");
assertThat(processDefinition.getName()).isEqualTo("One");
assertThat(processDefinition.getDescription()).isEqualTo("Desc one");
assertThat(processDefinition.getId()).startsWith("one:2");
assertThat(processDefinition.getCategory()).isEqualTo("Examples");
assertThat(processDefinition.isStartableInTasklist()).isEqualTo(true);

processDefinition = processDefinitions.get(2);
assertThat(processDefinition.getKey()).isEqualTo("two");
assertThat(processDefinition.getName()).isEqualTo("Two");
assertThat(processDefinition.getDescription()).isNull();
assertThat(processDefinition.getId().startsWith("two:1"));
assertThat(processDefinition.getCategory()).isEqualTo("Examples2");
assertThat(processDefinition.isStartableInTasklist()).isEqualTo(true);

processDefinition = processDefinitions.get(3);
assertThat(processDefinition.getKey()).isEqualTo("xyz_");
assertThat(processDefinition.getName()).isEqualTo("Xyz_");
assertThat(processDefinition.getDescription()).isNull();
assertThat(processDefinition.getId().startsWith("xyz_:1"));
assertThat(processDefinition.getCategory()).isEqualTo("xyz_");
assertThat(processDefinition.isStartableInTasklist()).isEqualTo(false);
}

@Test
Expand Down Expand Up @@ -855,7 +865,19 @@ public void testQueryOrderByVersionTag() {

@Test
public void testQueryByStartableInTasklist() {
assertThat(repositoryService.createProcessDefinitionQuery().startableInTasklist().count()).isEqualTo(4);
// given
// three definitions with startableInTasklist=true
// one definition with startableInTasklist=false

// when
List<ProcessDefinition> startable = repositoryService.createProcessDefinitionQuery().startableInTasklist().list();
List<ProcessDefinition> notStartable = repositoryService.createProcessDefinitionQuery().notStartableInTasklist().list();

// then
assertThat(startable).hasSize(3);
assertThat(startable).extracting("key").containsExactlyInAnyOrder("one", "one", "two");
assertThat(notStartable).hasSize(1);
assertThat(notStartable.get(0).getKey()).isEqualTo("xyz_");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
targetNamespace="xyz_">

<process id="xyz_" name="Xyz_" isExecutable="true">
<process id="xyz_" name="Xyz_" isExecutable="true" camunda:isStartableInTasklist="false">

<startEvent id="start" />
<sequenceFlow id="flow1" sourceRef="start" targetRef="end" />
Expand Down

0 comments on commit b269c63

Please sign in to comment.