use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testSaveGroupWithGenericResourceId.
@Test
public void testSaveGroupWithGenericResourceId() {
Group group = identityService.newGroup("*");
thrown.expect(ProcessEngineException.class);
thrown.expectMessage("has an invalid id: id cannot be *. * is a reserved identifier.");
identityService.saveGroup(group);
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testGroupOptimisticLockingException.
@Test
public void testGroupOptimisticLockingException() {
Group group = identityService.newGroup("group");
identityService.saveGroup(group);
Group group1 = identityService.createGroupQuery().singleResult();
Group group2 = identityService.createGroupQuery().singleResult();
group1.setName("name one");
identityService.saveGroup(group1);
thrown.expect(OptimisticLockingException.class);
group2.setName("name two");
identityService.saveGroup(group2);
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testMembership.
@Test
public void testMembership() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
Group development = identityService.newGroup("development");
identityService.saveGroup(development);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
User joesmoe = identityService.newUser("joesmoe");
identityService.saveUser(joesmoe);
User jackblack = identityService.newUser("jackblack");
identityService.saveUser(jackblack);
identityService.createMembership("johndoe", "sales");
identityService.createMembership("joesmoe", "sales");
identityService.createMembership("joesmoe", "development");
identityService.createMembership("jackblack", "development");
List<Group> groups = identityService.createGroupQuery().groupMember("johndoe").list();
assertEquals(createStringSet("sales"), getGroupIds(groups));
groups = identityService.createGroupQuery().groupMember("joesmoe").list();
assertEquals(createStringSet("sales", "development"), getGroupIds(groups));
groups = identityService.createGroupQuery().groupMember("jackblack").list();
assertEquals(createStringSet("development"), getGroupIds(groups));
List<User> users = identityService.createUserQuery().memberOfGroup("sales").list();
assertEquals(createStringSet("johndoe", "joesmoe"), getUserIds(users));
users = identityService.createUserQuery().memberOfGroup("development").list();
assertEquals(createStringSet("joesmoe", "jackblack"), getUserIds(users));
identityService.deleteGroup("sales");
identityService.deleteGroup("development");
identityService.deleteUser("jackblack");
identityService.deleteUser("joesmoe");
identityService.deleteUser("johndoe");
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class AuthorizationScenario method createGroup.
// group //////////////////////////////////////////////////////////////
protected Group createGroup(IdentityService identityService, String groupId) {
Group group = identityService.newGroup(groupId);
identityService.saveGroup(group);
return group;
}
use of org.camunda.bpm.engine.identity.Group in project camunda-bpm-platform by camunda.
the class AuthorizationScenario method startProcessInstance.
@DescribesScenario("startProcessInstance")
public static ScenarioSetup startProcessInstance() {
return new ScenarioSetup() {
public void execute(ProcessEngine engine, String scenarioName) {
IdentityService identityService = engine.getIdentityService();
// create an user
String userId = "test";
User user = identityService.newUser(userId);
identityService.saveUser(user);
// create group
String groupId = "accounting";
Group group = identityService.newGroup(groupId);
identityService.saveGroup(group);
// create membership
identityService.createMembership("test", "accounting");
// start a process instance
engine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", scenarioName);
}
};
}
Aggregations