import org.activiti.engine.IdentityService;
import org.activiti.engine.identity.User;
import org.activiti.engine.test.ActivitiRule;
import org.junit.Rule;
import org.junit.Test;
public class IdentityServiceTest {
@Rule
public ActivitiRule activitiRule = new ActivitiRule();
@Test
public void testUser() throws Exception{
IdentityService identityService = activitiRule.getIdentityService();
User user = identityService.newUser("tom");
user.setFirstName("tom");
user.setLastName("li");
user.setEmail("tom@qwe.com");
identityService.saveUser(user);
//链式编程的应用,在调用并执行完一个方法后该方法返回当前方法的对象实例,减少临时变量的产生,更加优雅。
User userInDb = identityService.createUserQuery().userId("tom").singleResult();
System.out.println("userIndb+++++++++++:"+userInDb);
identityService.deleteUser("tom");
userInDb = identityService.createUserQuery().userId("tom").singleResult();
System.out.println("+++++++++++++"+userInDb);
}
}
创建activitiRule时会自动创建一个引擎对象ProcessEngine,这样就可以通过activitiRule实例获取7个Service及其他对象