Skip to content

Commit

Permalink
JBPM-4658 - RuntimeDataService getProcessById incorrectly returns sin…
Browse files Browse the repository at this point in the history
…gle ProcessDefinition while it should return list
  • Loading branch information
mswiderski committed May 20, 2015
1 parent 848348f commit 33a7e88
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 21 deletions.
Expand Up @@ -286,15 +286,25 @@ public Collection<ProcessDefinition> getProcessesByFilter(String filter, QueryCo
applySorting(outputCollection, queryContext);
return applyPaginition(outputCollection, queryContext);
}


@Deprecated
public ProcessDefinition getProcessById(String processId){

Collection<ProcessAssetDesc> outputCollection = new HashSet<ProcessAssetDesc>();
CollectionUtils.select(availableProcesses, new ByProcessIdPredicate(processId, identityProvider.getRoles()), outputCollection);
if (!outputCollection.isEmpty()) {
return outputCollection.iterator().next();
Collection<ProcessDefinition> definitions = getProcessesById(processId);
if (!definitions.isEmpty()) {
return definitions.iterator().next();
}
return null;

return null;
}


public Collection<ProcessDefinition> getProcessesById(String processId){

Collection<ProcessDefinition> outputCollection = new HashSet<ProcessDefinition>();
CollectionUtils.select(availableProcesses, new ByProcessIdPredicate(processId, identityProvider.getRoles()), outputCollection);

return outputCollection;
}

public Collection<ProcessDefinition> getProcesses(QueryContext queryContext) {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public void testDeploymentOfProcesses() {
assertNotNull(processes);
assertEquals(5, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
Expand Down
Expand Up @@ -125,7 +125,7 @@ public void testDeploymentOfProcessesFromCustomerPackageDeafultKBase() {
assertNotNull(processes);
assertEquals(2, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

}
Expand Down Expand Up @@ -160,7 +160,7 @@ public void testDeploymentOfProcessesFromCustomerPackage() {
assertNotNull(processes);
assertEquals(2, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

}
Expand Down Expand Up @@ -191,7 +191,7 @@ public void testDeploymentOfProcessesFromOrderPackage() {
assertNotNull(processes);
assertEquals(1, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("Import");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "Import");
assertNotNull(process);

}
Expand Down Expand Up @@ -226,7 +226,7 @@ public void testDeploymentOfProcessesWildcardPackage() {
assertNotNull(processes);
assertEquals(2, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

}
Expand Down
Expand Up @@ -135,7 +135,7 @@ public void testDeploymentOfProcesses() {
assertNotNull(processes);
assertEquals(3, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
Expand Down Expand Up @@ -183,7 +183,7 @@ public void testDeploymentOfProcessesOnDefaultKbaseAndKsession() {
assertNotNull(processes);
assertEquals(3, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
Expand Down
Expand Up @@ -125,7 +125,7 @@ public void testDeploymentOfProcesses() {
assertNotNull(processes);
assertEquals(5, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
Expand Down
Expand Up @@ -178,10 +178,11 @@ public void testGetProcessByFilter() {

@Test
public void testGetProcessByProcessId() {
ProcessDefinition definition = runtimeDataService.getProcessById("org.jbpm.writedocument");
Collection<ProcessDefinition> definition = runtimeDataService.getProcessesById("org.jbpm.writedocument");

assertNotNull(definition);
assertEquals("org.jbpm.writedocument", definition.getId());
assertEquals(1, definition.size());
assertEquals("org.jbpm.writedocument", definition.iterator().next().getId());
}

@Test
Expand Down
Expand Up @@ -256,12 +256,27 @@ public int getValue() {
Collection<String> getProcessIds(String deploymentId, QueryContext queryContext);

/**
* Deprecated since 6.3 as it does return only first ProcessDefinition even if there are more
* that reside in different deployments. Use <code>getProcessesById(String processId)</code> instead
* <br/>
* Returns process definition for given process id
* @param processId The id of the process
* @return A {@link ProcessAssetDesc} instance, representing the {@link Process}
* with the specified (process) id.
*
* @see RuntimeDataService#getProcessesById(String)
* @deprecated will be removed in version 7
*/
@Deprecated
ProcessDefinition getProcessById(String processId);

/**
* Returns process definitions for given process id regardless of the deployment
* @param processId The id of the process
* @return A {@link ProcessAssetDesc} instance, representing the {@link Process}
* with the specified (process) id.
*/
Collection<ProcessDefinition> getProcessesById(String processId);

/**
* Returns process definition for given deployment and process identifiers
Expand Down
Expand Up @@ -182,7 +182,7 @@ public void testDeploymentOfProcesses() {
assertNotNull(processes);
assertEquals(5, processes.size());

ProcessDefinition process = runtimeDataService.getProcessById("customtask");
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);

RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
Expand Down
Expand Up @@ -209,10 +209,11 @@ public void testGetProcessByFilter() {

@Test
public void testGetProcessByProcessId() {
ProcessDefinition definition = runtimeDataService.getProcessById("org.jbpm.writedocument");

assertNotNull(definition);
assertEquals("org.jbpm.writedocument", definition.getId());
Collection<ProcessDefinition> definition = runtimeDataService.getProcessesById("org.jbpm.writedocument");

assertNotNull(definition);
assertEquals(1, definition.size());
assertEquals("org.jbpm.writedocument", definition.iterator().next().getId());
}

@Test
Expand Down

0 comments on commit 33a7e88

Please sign in to comment.