This commit is contained in:
@@ -22,111 +22,98 @@ import org.yacos.core.users.User;
|
|||||||
|
|
||||||
|
|
||||||
public class ConferenceManagerTest {
|
public class ConferenceManagerTest {
|
||||||
static IConferenceManager manager;
|
static IConferenceManager cm;
|
||||||
static IUserManager userManager;
|
static IUserManager um;
|
||||||
int id;
|
int id;
|
||||||
Conference conf;
|
Conference conf;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpManager() throws NamingException {
|
public static void setUpManager() throws NamingException, PKAlreadyUsedException {
|
||||||
Context context = new InitialContext();
|
Context context = new InitialContext();
|
||||||
manager = (IConferenceManager) context.lookup("ConferenceManagerBean/remote");
|
cm = (IConferenceManager) context.lookup("ConferenceManagerBean/remote");
|
||||||
userManager = (IUserManager) context.lookup("UserManagerBean/remote");
|
um = (IUserManager) context.lookup("UserManagerBean/remote");
|
||||||
|
|
||||||
|
|
||||||
|
if(!um.exists("max")){
|
||||||
|
um.addUser("max","pw","maxime","dagn","ipint", "e@e.fr");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUpConferences() throws PKAlreadyUsedException {
|
public void setUpConferences() {
|
||||||
conf = manager.addConference("titre","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
conf = cm.addConference("titre","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||||
id = conf.getId();
|
id = conf.getId();
|
||||||
if(userManager.exists("toto")){
|
|
||||||
userManager.removeUser(userManager.getUser("toto"));
|
|
||||||
}
|
|
||||||
User user = userManager.addUser("toto","mp","bruno","dupont","ipint","e@e.fr");
|
|
||||||
manager.addRole(Role.RoleType.AUTHOR, user, conf);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void unSetUpConferences(){
|
public void unSetUpConferences(){
|
||||||
conf = manager.getConference(id);
|
conf = cm.getConference(id);
|
||||||
if (conf != null){
|
if (conf != null){
|
||||||
manager.remove(conf);
|
cm.remove(conf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConferenceTest(){
|
public void getConferenceTest(){
|
||||||
conf = manager.getConference(id);
|
conf = cm.getConference(id);
|
||||||
assertNotNull(conf);
|
assertNotNull(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateConferenceTest(){
|
public void updateConferenceTest(){
|
||||||
conf = manager.getConference(id);
|
conf = cm.getConference(id);
|
||||||
conf.setTitle("autre titre");
|
conf.setTitle("autre titre");
|
||||||
manager.update(conf);
|
cm.update(conf);
|
||||||
conf = manager.getConference(id);
|
conf = cm.getConference(id);
|
||||||
assertEquals("autre titre", conf.getTitle());
|
assertEquals("autre titre", conf.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeConferenceTest(){
|
public void removeConferenceTest(){
|
||||||
conf = manager.getConference(id);
|
conf = cm.getConference(id);
|
||||||
manager.remove(conf);
|
cm.remove(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConferencesTest(){
|
public void getConferencesTest(){
|
||||||
conf = manager.addConference("titre2","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
conf = cm.addConference("titre2","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||||
List<Conference> list = manager.getConferences();
|
List<Conference> list = cm.getConferences();
|
||||||
|
assertFalse("liste vide",list.isEmpty());
|
||||||
|
|
||||||
for (Conference conf : list) {
|
|
||||||
assertNotNull(conf);
|
|
||||||
}
|
|
||||||
conf = list.get(list.size()-1);
|
|
||||||
assertEquals("titre2",conf.getTitle() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getConferencesForUserTest(){
|
|
||||||
User user = userManager.getUser("toto");
|
|
||||||
List<Conference> list = manager.getConferences(user);
|
|
||||||
conf = list.get(0);
|
|
||||||
assertNotNull(conf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addRoleForUserTest(){
|
public void addRoleForUserTest(){
|
||||||
User user = userManager.getUser("toto");
|
User user = um.getUser("max");
|
||||||
manager.addRole(Role.RoleType.AUTHOR, user , conf);
|
cm.addRole(Role.RoleType.AUTHOR, user , conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getRoleTest(){
|
|
||||||
User user = userManager.getUser("toto");
|
|
||||||
manager.getRoles(user, conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRolesTest(){
|
public void getRolesTest(){
|
||||||
User user = userManager.getUser("toto");
|
User user = um.getUser("max");
|
||||||
List<Role> list = manager.getRoles(user, conf);
|
List<Role> list = cm.getRoles(user,conf);
|
||||||
assertEquals(1,list.size());
|
assertFalse("liste vide",list.isEmpty());
|
||||||
Role role = list.get(0);
|
Role role = list.get(0);
|
||||||
|
System.out.println(role.getType());
|
||||||
assertNotNull(role);
|
assertNotNull(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getConferencesForUserTest(){
|
||||||
|
User user = um.getUser("max");
|
||||||
|
List<Conference> list = cm.getConferences(user);
|
||||||
|
conf = list.get(0);
|
||||||
|
assertNotNull(conf);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRolesForUserConfTest(){
|
public void getRolesForUserConfTest(){
|
||||||
User user = userManager.getUser("toto");
|
User user = um.getUser("max");
|
||||||
List<Role> list = manager.getRoles(user, conf);
|
List<Role> list = cm.getRoles(user, conf);
|
||||||
assertEquals(1,list.size());
|
assertFalse("liste vide",list.isEmpty());
|
||||||
Role role = list.get(0);
|
Role role = list.get(0);
|
||||||
assertNotNull(role);
|
assertNotNull(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user