Skip to content

Commit

Permalink
RHBPMS-4241 - Fix NPE when deploymentId is null (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianonicolai authored and mswiderski committed Sep 7, 2016
1 parent 3d686d2 commit 04ced87
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Expand Up @@ -121,7 +121,7 @@ private void removeAllProcessDefinitions( Collection<ProcessAssetDesc> assets) {

private String getLatestDeploymentId(String deploymentId) {
String matched = deploymentId;
if (deploymentId.toLowerCase().endsWith("latest")) {
if (deploymentId != null && deploymentId.toLowerCase().endsWith("latest")) {
matched = DeploymentIdResolver.matchAndReturnLatest(deploymentId, deploymentIds);
}
return matched;
Expand Down
Expand Up @@ -26,6 +26,7 @@
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -139,7 +140,7 @@ public void cleanup() {
}

@Test
public void testGetProcessByDeploymentId() {
public void testGetProcessesByDeploymentId() {
Collection<ProcessDefinition> definitions = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(definitions);

Expand All @@ -164,6 +165,13 @@ public void testGetProcessByDeploymentId() {
deploymentUnit.setVersion(origVer);
}

@Test
public void testGetProcessesByDeploymentIdNull() {
Collection<ProcessDefinition> definitions = runtimeDataService.getProcessesByDeploymentId(null, new QueryContext());
assertNotNull(definitions);
assertTrue(definitions.isEmpty());
}

@Test
public void testGetProcessByDeploymentIdAndProcessId() {
ProcessDefinition definition = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
Expand All @@ -180,6 +188,12 @@ public void testGetProcessByDeploymentIdAndProcessId() {
deploymentUnit.setVersion(origVer);
}

@Test
public void testGetProcessByDeploymentIdAndProcessIdNull() {
ProcessDefinition definition = runtimeDataService.getProcessesByDeploymentIdProcessId(null, null);
assertNull(definition);
}

@Test
public void testGetProcessByFilter() {
Collection<ProcessDefinition> definitions = runtimeDataService.getProcessesByFilter("org.jbpm", new QueryContext());
Expand Down Expand Up @@ -246,6 +260,13 @@ public void testGetProcessIds() {
deploymentUnit.setVersion(origVer);
}

@Test
public void testGetProcessIdsNull() {
Collection<String> definitions = runtimeDataService.getProcessIds(null, new QueryContext());
assertNotNull(definitions);
assertTrue(definitions.isEmpty());
}

@Test
public void testGetProcessesSortByProcessName() {
Collection<ProcessDefinition> definitions = runtimeDataService.getProcesses(new QueryContext("ProcessName", true));
Expand Down Expand Up @@ -399,6 +420,13 @@ public void testGetProcessInstancesByDeploymentIdAndState() {
deploymentUnit.setVersion(origVer);
}

@Test
public void testGetProcessInstancesByDeploymentIdNull() {
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstancesByDeploymentId(null, Collections.<Integer>emptyList(), new QueryContext());
assertNotNull(instances);
assertTrue(instances.isEmpty());
}

@Test
public void testGetProcessInstancesByProcessId() {
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
Expand Down

0 comments on commit 04ced87

Please sign in to comment.