use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class LdapIntegrationTest method testUserQueryById.
public void testUserQueryById() {
List<User> users = identityService.createUserQuery().userId("kermit").list();
assertEquals(1, users.size());
User user = users.get(0);
assertEquals("kermit", user.getId());
assertEquals("Kermit", user.getFirstName());
assertEquals("The Frog", user.getLastName());
user = identityService.createUserQuery().userId("fozzie").singleResult();
assertEquals("fozzie", user.getId());
assertEquals("Fozzie", user.getFirstName());
assertEquals("Bear", user.getLastName());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class LdapIntegrationTest method testUserQueryByFullNameLike.
public void testUserQueryByFullNameLike() {
List<User> users = identityService.createUserQuery().userFullNameLike("ermi").list();
assertEquals(1, users.size());
assertEquals(1, identityService.createUserQuery().userFullNameLike("ermi").count());
User user = users.get(0);
assertEquals("kermit", user.getId());
assertEquals("Kermit", user.getFirstName());
assertEquals("The Frog", user.getLastName());
users = identityService.createUserQuery().userFullNameLike("rog").list();
assertEquals(1, users.size());
assertEquals(1, identityService.createUserQuery().userFullNameLike("rog").count());
user = users.get(0);
assertEquals("kermit", user.getId());
assertEquals("Kermit", user.getFirstName());
assertEquals("The Frog", user.getLastName());
users = identityService.createUserQuery().userFullNameLike("e").list();
assertEquals(5, users.size());
assertEquals(5, identityService.createUserQuery().userFullNameLike("e").count());
users = identityService.createUserQuery().userFullNameLike("The").list();
assertEquals(3, users.size());
assertEquals(3, identityService.createUserQuery().userFullNameLike("The").count());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class SerializableVariablesDiabledTest method setupServer.
@Before
public void setupServer() {
if (serverUrlPrefix == null) {
TestServer testServer = TestServerUtil.createAndStartServer(ObjectVariableSerializationDisabledApplicationConfiguration.class);
serverUrlPrefix = testServer.getServerUrlPrefix();
this.repositoryService = testServer.getApplicationContext().getBean(RepositoryService.class);
this.runtimeService = testServer.getApplicationContext().getBean(RuntimeService.class);
this.identityService = testServer.getApplicationContext().getBean(IdentityService.class);
this.taskService = testServer.getApplicationContext().getBean(TaskService.class);
User user = identityService.newUser("kermit");
user.setFirstName("Kermit");
user.setLastName("the Frog");
user.setPassword("kermit");
identityService.saveUser(user);
Group group = identityService.newGroup("admin");
group.setName("Administrators");
identityService.saveGroup(group);
identityService.createMembership(user.getId(), group.getId());
this.testUserId = user.getId();
this.testGroupId = group.getId();
}
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserEventsTest method testUserEntityEvents.
/**
* Test create, update and delete events of users.
*/
public void testUserEntityEvents() throws Exception {
User user = null;
try {
user = identityService.newUser("fred");
user.setFirstName("Frederik");
user.setLastName("Heremans");
identityService.saveUser(user);
assertEquals(2, listener.getEventsReceived().size());
ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
assertTrue(event.getEntity() instanceof User);
User userFromEvent = (User) event.getEntity();
assertEquals("fred", userFromEvent.getId());
assertNull(event.getProcessDefinitionId());
assertNull(event.getExecutionId());
assertNull(event.getProcessInstanceId());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
listener.clearEventsReceived();
// Update user
user.setFirstName("Anna");
identityService.saveUser(user);
assertEquals(1, listener.getEventsReceived().size());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
assertTrue(event.getEntity() instanceof User);
userFromEvent = (User) event.getEntity();
assertEquals("fred", userFromEvent.getId());
assertEquals("Anna", userFromEvent.getFirstName());
assertNull(event.getProcessDefinitionId());
assertNull(event.getExecutionId());
assertNull(event.getProcessInstanceId());
listener.clearEventsReceived();
// Delete user
identityService.deleteUser(user.getId());
assertEquals(1, listener.getEventsReceived().size());
event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
assertTrue(event.getEntity() instanceof User);
userFromEvent = (User) event.getEntity();
assertEquals("fred", userFromEvent.getId());
assertNull(event.getProcessDefinitionId());
assertNull(event.getExecutionId());
assertNull(event.getProcessInstanceId());
listener.clearEventsReceived();
} finally {
if (user != null && user.getId() != null) {
identityService.deleteUser(user.getId());
}
}
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class TaskServiceTest method testClaimUnexistingTaskId.
public void testClaimUnexistingTaskId() {
User user = identityService.newUser("user");
identityService.saveUser(user);
try {
taskService.claim("unexistingtaskid", user.getId());
fail("ActivitiException expected");
} catch (ActivitiObjectNotFoundException ae) {
assertTextPresent("Cannot find task with id unexistingtaskid", ae.getMessage());
assertEquals(Task.class, ae.getObjectClass());
}
identityService.deleteUser(user.getId());
}
Aggregations