use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class StartAuthorizationTest method testAddAndRemoveIdentityLinks.
@Deployment
public void testAddAndRemoveIdentityLinks() throws Exception {
setUpUsersAndGroups();
try {
ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarterNoDefinition").singleResult();
assertNotNull(latestProcessDef);
List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(0, links.size());
repositoryService.addCandidateStarterGroup(latestProcessDef.getId(), "group1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(1, links.size());
assertEquals("group1", links.get(0).getGroupId());
repositoryService.addCandidateStarterUser(latestProcessDef.getId(), "user1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(2, links.size());
assertEquals(true, containsUserOrGroup(null, "group1", links));
assertEquals(true, containsUserOrGroup("user1", null, links));
repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "nonexisting");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(2, links.size());
repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "group1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(1, links.size());
assertEquals("user1", links.get(0).getUserId());
repositoryService.deleteCandidateStarterUser(latestProcessDef.getId(), "user1");
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(0, links.size());
} finally {
tearDownUsersAndGroups();
}
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessValidationExecutedAfterDeployTest method testGetStartFormData.
public void testGetStartFormData() {
disableValidation();
repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/regression/ProcessValidationExecutedAfterDeployTest.bpmn20.xml").deploy();
enableValidation();
clearDeploymentCache();
ProcessDefinition definition = getLatestProcessDefinitionVersionByKey("testProcess1");
if (definition == null) {
fail("Error occurred in fetching process model.");
}
try {
formService.getStartFormData(definition.getId());
assertTrue(true);
} catch (ActivitiException e) {
fail("Error occurred in fetching start form data:");
}
for (org.activiti.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId());
}
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class StartAuthorizationTest method testPotentialStarter.
@Deployment
public void testPotentialStarter() throws Exception {
// first check an unauthorized user. An exception is expected
setUpUsersAndGroups();
try {
// Authentication should not be done. So an unidentified user should also be able to start the process
identityService.setAuthenticatedUserId("unauthorizedUser");
try {
runtimeService.startProcessInstanceByKey("potentialStarter");
} catch (Exception e) {
fail("No StartAuthorizationException expected, " + e.getClass().getName() + " caught.");
}
// check with an authorized user obviously it should be no problem starting the process
identityService.setAuthenticatedUserId("user1");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("potentialStarter");
assertProcessEnded(processInstance.getId());
assertTrue(processInstance.isEnded());
//check extensionElements with : <formalExpression>group2, group(group3), user(user3)</formalExpression>
ProcessDefinition potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("user1").latestVersion().singleResult();
assertNotNull(potentialStarter);
potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("user3").latestVersion().singleResult();
assertNotNull(potentialStarter);
potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("userInGroup2").latestVersion().singleResult();
assertNotNull(potentialStarter);
potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("userInGroup3").latestVersion().singleResult();
assertNotNull(potentialStarter);
} finally {
tearDownUsersAndGroups();
}
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinkResource method deleteIdentityLink.
@RequestMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.DELETE)
public void deleteIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family, @PathVariable("identityId") String identityId, HttpServletResponse response) {
ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
validateIdentityLinkArguments(family, identityId);
// Check if identitylink to delete exists
IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
if (link.getUserId() != null) {
repositoryService.deleteCandidateStarterUser(processDefinition.getId(), link.getUserId());
} else {
repositoryService.deleteCandidateStarterGroup(processDefinition.getId(), link.getGroupId());
}
response.setStatus(HttpStatus.NO_CONTENT.value());
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinkResource method getIdentityLink.
@RequestMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.GET, produces = "application/json")
public RestIdentityLink getIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family, @PathVariable("identityId") String identityId, HttpServletRequest request) {
ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
validateIdentityLinkArguments(family, identityId);
// Check if identitylink to get exists
IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
return restResponseFactory.createRestIdentityLink(link);
}
Aggregations