@@ -0,0 +1,2066 @@
+package org.jvalue.commons.auth.rest;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.jvalue.commons.auth.Role;%0Aimport org.jvalue.commons.auth.UnauthorizedException;%0Aimport org.jvalue.commons.auth.User;%0Aimport org.jvalue.commons.auth.UserDescription;%0Aimport org.jvalue.commons.auth.UserManager;%0A%0Aimport mockit.Expectations;%0Aimport mockit.Mocked;%0Aimport mockit.Verifications;%0Aimport mockit.integration.junit4.JMockit;%0A%0A%0A@RunWith(JMockit.class)%0Apublic final class UserApiTest %7B%0A%0A%09@Mocked private UserManager userManager;%0A%09private UserApi userApi;%0A%0A%0A%09@Before%0A%09public void setupApi() %7B%0A%09%09userApi = new UserApi(userManager);%0A%09%7D%0A%0A%0A%09public void testAddUserFailure() %7B%0A%09%09userApi.getAllUsers(null);%0A%09%09new Expectations() %7B%7B%0A%09%09%09userManager.getAll();%0A%09%09%7D%7D;%0A%09%7D%0A%0A%0A%09@Test(expected = UnauthorizedException.class)%0A%09public void testAddUserSuccess() %7B%0A%09%09testAddUser(null);%0A%09%7D%0A%0A%0A%09public void testAddAdminUser() %7B%0A%09%09testAddUser(new User(%22%22, %22%22, %22%22, Role.ADMIN));%0A%09%09new Verifications() %7B%7B%0A%09%09%09userManager.add((UserDescription) any);%0A%09%09%7D%7D;%0A%09%7D%0A%0A%0A%09private void testAddUser(User user) %7B%0A%09%09UserDescription description = new UserDescription(%22%22, %22%22, Role.ADMIN, %22%22);%0A%09%09userApi.addUser(user, description);%0A%09%7D%0A%0A%0A%09@Test(expected = UnauthorizedException.class)%0A%09public void testGetUserFailure() %7B%0A%09%09userApi.getUser(new User(%22id1%22, %22%22, %22%22, Role.PUBLIC), %22id2%22);%0A%09%7D%0A%0A%0A%09@Test%0A%09public void testGetUserSuccess() %7B%0A%09%09userApi.getUser(new User(%22id1%22, %22%22, %22%22, Role.ADMIN), %22id2%22);%0A%09%09new Verifications() %7B%7B%0A%09%09%09userManager.findById(%22id2%22);%0A%09%09%7D%7D;%0A%09%7D%0A%0A%0A%09@Test(expected = UnauthorizedException.class)%0A%09public void testRemoveUserFailure() %7B%0A%09%09userApi.removeUser(new User(%22id1%22, %22%22, %22%22, Role.PUBLIC), %22id2%22);%0A%09%7D%0A%0A%0A%09@Test%0A%09public void testRemoveUserSuccess() %7B%0A%09%09final User removeUser = new User(%22id2%22, %22%22, %22%22, Role.PUBLIC);%0A%09%09new Expectations() %7B%7B%0A%09%09%09userManager.findById(removeUser.getId()); result = removeUser;%0A%09%09%7D%7D;%0A%0A%09%09userApi.removeUser(new User(%22id1%22, %22%22, %22%22, Role.ADMIN), removeUser.getId());%0A%09%09new Verifications() %7B%7B%0A%09%09%09userManager.remove(removeUser);%0A%09%09%7D%7D;%0A%09%7D%0A%0A%7D

add UserApiTest