Tests de conferenceCreationToken
Prise en compte du chairman dans les classes Corrections diverses (seul EvaluationManagerTest est en rouge)
This commit is contained in:
@@ -13,6 +13,7 @@ import org.yacos.core.conferences.Conference;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.evaluation.IEvaluationManager;
|
||||
import org.yacos.core.exceptions.ConferenceDoesntExistException;
|
||||
import org.yacos.core.exceptions.NoConferenceCreationTokenLeftException;
|
||||
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
||||
import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
|
||||
import org.yacos.core.users.IUserManager;
|
||||
@@ -26,7 +27,7 @@ import org.yacos.core.users.Role.RoleType;
|
||||
public class Filler {
|
||||
|
||||
|
||||
public static void main(String[] args) throws NamingException, PKAlreadyUsedException, ConferenceDoesntExistException {
|
||||
public static void main(String[] args) throws NamingException, PKAlreadyUsedException, ConferenceDoesntExistException, NoConferenceCreationTokenLeftException {
|
||||
|
||||
System.out.println("--> DEBUT REMPLISSAGE DATABASE");
|
||||
|
||||
@@ -41,11 +42,8 @@ public class Filler {
|
||||
cm = (IConferenceManager) context.lookup("ConferenceManagerBean/remote");
|
||||
em = (IEvaluationManager) context.lookup("EvaluationManagerBean/remote");
|
||||
|
||||
// add two conference
|
||||
Conference conf = cm.addConference("Conf 1","Je suis une conf","J'aime le cafe",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
cm.addConference("Conf 2","Je suis un schtroumpf","J'aime la salsepareille",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
|
||||
|
||||
Conference conf = null;
|
||||
Conference conf2 = null;
|
||||
try {
|
||||
// Create different users
|
||||
User admin = um.addUser("admin",User.hashPassword("admin"),"Admin","admin","LIFL", "admin@yacos.org");
|
||||
@@ -53,7 +51,12 @@ public class Filler {
|
||||
User pcmember = um.addUser("pcmember",User.hashPassword("pcmember"),"PC","member","LIFL", "pcmember@yacos.org");
|
||||
User referee = um.addUser("referee",User.hashPassword("referee"),"Referee","referee","LIFL", "referee@yacos.org");
|
||||
User author = um.addUser("author",User.hashPassword("author"),"Author","author","LIFL", "author@yacos.org");
|
||||
|
||||
|
||||
// add two conference
|
||||
cm.addConferenceCreationToken("chairman");
|
||||
cm.addConferenceCreationToken("admin");
|
||||
conf = cm.addConference("Conf 1","chairman","Je suis une conf","J'aime le cafe",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
conf2 = cm.addConference("Conf 2","admin","Je suis un schtroumpf","J'aime la salsepareille",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
|
||||
// Add role for users
|
||||
|
||||
@@ -107,10 +110,10 @@ public class Filler {
|
||||
|
||||
// ajout de critere
|
||||
|
||||
em.addCriterion("Les schtroumpfs sont-ils bons ?", 1, 5, 1);
|
||||
em.addCriterion("Les gaulois sont-ils fous ?", 1, 4, 1);
|
||||
em.addCriterion("Un nain est-il vraiment petit ?", 1, 5, 2);
|
||||
em.addCriterion("Un chien peut-il se transformer en chat ?", 1, 4, 2);
|
||||
em.addCriterion("Les schtroumpfs sont-ils bons ?", 1, 5, conf.getId());
|
||||
em.addCriterion("Les gaulois sont-ils fous ?", 1, 4, conf.getId());
|
||||
em.addCriterion("Un nain est-il vraiment petit ?", 1, 5, conf2.getId());
|
||||
em.addCriterion("Un chien peut-il se transformer en chat ?", 1, 4, conf2.getId());
|
||||
|
||||
System.out.println("--> FIN OK");
|
||||
|
||||
|
||||
@@ -5,15 +5,12 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -24,6 +21,7 @@ import org.yacos.core.article.Preference;
|
||||
import org.yacos.core.conferences.Conference;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.exceptions.ConferenceDoesntExistException;
|
||||
import org.yacos.core.exceptions.NoConferenceCreationTokenLeftException;
|
||||
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
||||
import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
|
||||
import org.yacos.core.users.IUserManager;
|
||||
@@ -47,15 +45,17 @@ public class ArticleManagerTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setupArticleTest() throws PKAlreadyUsedException, UserEMailAlreadyExistsException{
|
||||
public void setupArticleTest() throws PKAlreadyUsedException, UserEMailAlreadyExistsException, NoConferenceCreationTokenLeftException{
|
||||
//ajout d'un user
|
||||
if (um.exists("max")){
|
||||
author = um.getUser("max");
|
||||
}else{
|
||||
author = um.addUser("max",User.hashPassword("pw"),"maxime","dagn","ipint", "e@e.fr");
|
||||
}
|
||||
um.addUser("articleManagerTestChairman",User.hashPassword("pw"),"maxime","dagn","ipint", "articleManagerTestChairman@yacos.com");
|
||||
//ajout d'une conf
|
||||
conf = cm.addConference("titi","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
cm.addConferenceCreationToken("articleManagerTestChairman");
|
||||
conf = cm.addConference("titi","articleManagerTestChairman","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
assertEquals("titi", cm.getConference(conf.getId()).getTitle());;
|
||||
|
||||
//ajout d'un article
|
||||
@@ -73,11 +73,12 @@ public class ArticleManagerTest {
|
||||
|
||||
@After
|
||||
public void cleanup() throws ConferenceDoesntExistException{
|
||||
/* List<Article> list = am.getArticles(conf.getId());
|
||||
List<Article> list = am.getArticles(conf.getId());
|
||||
for (Article article : list) {
|
||||
am.removeArticle(article.getId());
|
||||
}
|
||||
cm.remove(conf.getId());*/
|
||||
cm.remove(conf.getId());
|
||||
um.removeUser("articleManagerTestChairman");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -4,19 +4,18 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.yacos.core.conferences.Conference;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.exceptions.NoConferenceCreationTokenLeftException;
|
||||
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
||||
import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
|
||||
import org.yacos.core.users.IUserManager;
|
||||
@@ -44,13 +43,15 @@ public class ConferenceManagerTest {
|
||||
} else {
|
||||
um.getUser("max");
|
||||
}
|
||||
conf = cm.addConference("titre","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
cm.addConferenceCreationToken("max");
|
||||
conf = cm.addConference("titre","max","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
id = conf.getId();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addConferenceTest(){
|
||||
conf = cm.addConference("titi","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
public void addConferenceTest() throws NoConferenceCreationTokenLeftException{
|
||||
cm.addConferenceCreationToken("max");
|
||||
conf = cm.addConference("titi","max","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
assertEquals("titi", cm.getConference(conf.getId()).getTitle());
|
||||
cm.remove(conf.getId());
|
||||
}
|
||||
@@ -71,15 +72,17 @@ public class ConferenceManagerTest {
|
||||
assertEquals("autre titre", conf.getTitle());
|
||||
}
|
||||
|
||||
public void removeConferenceTest(){
|
||||
public void removeConferenceTest() throws NoConferenceCreationTokenLeftException{
|
||||
conf = cm.getConference(id);
|
||||
cm.remove(conf.getId());
|
||||
cm.addConference("titre","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
cm.addConferenceCreationToken("max");
|
||||
cm.addConference("titre","max","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConferencesTest(){
|
||||
conf = cm.addConference("titre2","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
public void getConferencesTest() throws NoConferenceCreationTokenLeftException{
|
||||
cm.addConferenceCreationToken("max");
|
||||
conf = cm.addConference("titre2","max","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
List<Conference> list = cm.getConferences();
|
||||
assertFalse("liste vide",list.isEmpty());
|
||||
cm.remove(conf.getId());
|
||||
@@ -100,9 +103,10 @@ public class ConferenceManagerTest {
|
||||
@Test
|
||||
public void getConferencesForUserTest() throws PKAlreadyUsedException, UserEMailAlreadyExistsException{
|
||||
User user = um.getUser("max");
|
||||
cm.addRole(Role.RoleType.AUTHOR, "max" , id);
|
||||
List<Conference> list = cm.getConferences(user);
|
||||
assertFalse(list.isEmpty());
|
||||
User user2 = um.addUser("max2",User.hashPassword("pw"),"maxime","dagn","ipint", "e@e.fr");
|
||||
User user2 = um.addUser("max2",User.hashPassword("pw"),"maxime","dagn","ipint", "eMax2@ee.fr");
|
||||
list = cm.getConferences(user2);
|
||||
assertTrue(list.isEmpty());
|
||||
um.removeUser(user2.getLogin());
|
||||
@@ -110,6 +114,7 @@ public class ConferenceManagerTest {
|
||||
|
||||
@Test
|
||||
public void getRolesForUserAndConfTest(){
|
||||
cm.addRole(Role.RoleType.AUTHOR, "max" , id);
|
||||
List<Role> list = cm.getRoles("max", conf.getId());
|
||||
assertFalse("liste vide",list.isEmpty());
|
||||
Role role = list.get(0);
|
||||
@@ -123,19 +128,14 @@ public class ConferenceManagerTest {
|
||||
assertFalse(cm.exists(id));
|
||||
}
|
||||
|
||||
/*@After
|
||||
@After
|
||||
public void cleanup(){
|
||||
User user = um.getUser("max");
|
||||
|
||||
if(um.exists("max")){
|
||||
for(Role role : user.getRoles() ){
|
||||
um.removeRole("max", role.getType(), role.getConference().getId());
|
||||
}
|
||||
um.removeUser("max");
|
||||
}
|
||||
|
||||
if(cm.exists(id)){
|
||||
cm.remove(id);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.Context;
|
||||
@@ -19,6 +20,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.yacos.core.article.Article;
|
||||
import org.yacos.core.article.IArticleManager;
|
||||
import org.yacos.core.conferences.Conference;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.evaluation.Criterion;
|
||||
import org.yacos.core.evaluation.IEvaluationManager;
|
||||
@@ -47,19 +49,22 @@ public class EvaluationManagerTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initDB(){
|
||||
/*Conference conf = cm.addConference("titre","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
public void initDB() throws Exception{
|
||||
um.addUser("evaluationManagerTest", "pw", "first", "last", "yacos", "evaluationManagerTest@yacos.com");
|
||||
cm.addConferenceCreationToken("evaluationManagerTest");
|
||||
Conference conf = cm.addConference("titre","evaluationManagerTest","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
confId = conf.getId();
|
||||
*/
|
||||
confId = 1;
|
||||
|
||||
article = am.addArticle("title article max","topic","url_article",
|
||||
"max", new ArrayList<String>(), Article.State.SUBMITED, confId);
|
||||
"evaluationManagerTest", new ArrayList<String>(), Article.State.SUBMITED, confId);
|
||||
//article = am.getArticle(1);
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanDB(){
|
||||
am.removeArticle(article.getId());
|
||||
um.removeUser("evaluationManagerTest");
|
||||
cm.remove(confId);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,9 +41,12 @@ public class InvitationTokenTest {
|
||||
public void setUp() throws Exception {
|
||||
Context context = new InitialContext();
|
||||
userManager = (IUserManager) context.lookup("UserManagerBean/remote");
|
||||
userManager.addUser("invitationTestChairman", "", "First", "Last", "Yacos", "invitationTestChairman@yacos.com");
|
||||
confManager = (IConferenceManager) context.lookup("ConferenceManagerBean/remote");
|
||||
confManager.addConferenceCreationToken("invitationTestChairman");
|
||||
Conference conf = confManager.addConference(
|
||||
"InvitationToken Test conference",
|
||||
"invitationTestChairman",
|
||||
"A conference to test InvitationToken",
|
||||
"None",
|
||||
new Date(),
|
||||
@@ -76,8 +79,10 @@ public class InvitationTokenTest {
|
||||
|
||||
@Test
|
||||
public void testInvitationTokenUsedWhenUserCreated() throws Exception {
|
||||
confManager.addConferenceCreationToken("invitationTestChairman");
|
||||
Conference conf2 = confManager.addConference(
|
||||
"InvitationToken Test conference 2",
|
||||
"invitationTestChairman",
|
||||
"A second conference to test InvitationToken",
|
||||
"None",
|
||||
new Date(),
|
||||
@@ -105,6 +110,8 @@ public class InvitationTokenTest {
|
||||
assertTrue("Checking the roles for test user",
|
||||
userManager.hasRoleForConference(testUser.getLogin(), RoleType.PCMEMBER, conf2.getId()));
|
||||
|
||||
assertEquals(0,userManager.getInvitationTokensForEmail("InvitationToken@test.com").size());
|
||||
|
||||
// Cleaning up
|
||||
userManager.removeUser("testInvitationToken");
|
||||
confManager.remove(conf2.getId());
|
||||
@@ -125,6 +132,8 @@ public class InvitationTokenTest {
|
||||
confManager.remove(testConferenceId);
|
||||
assertNull("TearDown : checking that the test conference has been removed",
|
||||
confManager.getConference(testConferenceId));
|
||||
|
||||
userManager.removeUser("invitationTestChairman");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -21,6 +21,7 @@ import org.yacos.core.article.Article;
|
||||
import org.yacos.core.article.IArticleManager;
|
||||
import org.yacos.core.conferences.Conference;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.exceptions.NoConferenceCreationTokenLeftException;
|
||||
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
||||
import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
|
||||
import org.yacos.core.users.IUserManager;
|
||||
@@ -37,16 +38,18 @@ public class UserManagerTest {
|
||||
private static int conf_id;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpManager() throws NamingException, PKAlreadyUsedException {
|
||||
public static void setUpManager() throws NamingException, PKAlreadyUsedException, UserEMailAlreadyExistsException, NoConferenceCreationTokenLeftException {
|
||||
Context context = new InitialContext();
|
||||
|
||||
um = (IUserManager) context.lookup("UserManagerBean/remote");
|
||||
am = (IArticleManager) context.lookup("ArticleManagerBean/remote");
|
||||
cm = (IConferenceManager) context.lookup("ConferenceManagerBean/remote");
|
||||
um.addUser("userManagerTestChairman", "", "First", "Last", "Yacos", "articleManagerTestChairman@yacos.com");
|
||||
if (cm.exists(1)){
|
||||
conf_id = 1;
|
||||
}else{
|
||||
Conference conf = cm.addConference("titi","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
cm.addConferenceCreationToken("userManagerTestChairman");
|
||||
Conference conf = cm.addConference("titi","articleManagerTestChairman","desc conf","info en plus",new Date(),new Date(),new Date(),new Date(),new Date());
|
||||
conf_id = conf.getId();
|
||||
}
|
||||
}
|
||||
@@ -151,6 +154,28 @@ public class UserManagerTest {
|
||||
assertTrue("liste non vide",list.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void conferenceCreationTokensTest() throws Exception {
|
||||
assertFalse(cm.canCreateConference("truc"));
|
||||
cm.addConferenceCreationToken("truc");
|
||||
assertTrue(cm.canCreateConference("truc"));
|
||||
assertEquals(1, cm.conferenceCreationTokens("truc"));
|
||||
cm.addConferenceCreationToken("truc");
|
||||
assertTrue(cm.canCreateConference("truc"));
|
||||
assertEquals(2, cm.conferenceCreationTokens("truc"));
|
||||
cm.useConferenceCreationToken("truc");
|
||||
assertTrue(cm.canCreateConference("truc"));
|
||||
assertEquals(1, cm.conferenceCreationTokens("truc"));
|
||||
cm.useConferenceCreationToken("truc");
|
||||
assertFalse(cm.canCreateConference("truc"));
|
||||
assertEquals(0, cm.conferenceCreationTokens("truc"));
|
||||
try {
|
||||
cm.useConferenceCreationToken("truc");
|
||||
fail("Using a token when token count is 0 should have raised an exception");
|
||||
} catch (NoConferenceCreationTokenLeftException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void ControleUser() throws PKAlreadyUsedException{
|
||||
@@ -160,6 +185,7 @@ public class UserManagerTest {
|
||||
if(um.exists("admin")){
|
||||
um.removeUser("admin");
|
||||
}
|
||||
um.removeUser("userManagerTestChairman");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,10 @@ public class UserTest {
|
||||
|
||||
|
||||
Date dateArticles = new Date();
|
||||
confManager.addConferenceCreationToken("testUser1");
|
||||
conference = confManager.addConference("A Conference",
|
||||
"Test symposium 2008",
|
||||
"testUser1",
|
||||
"Some infos",
|
||||
dateArticles,
|
||||
dateArticles,
|
||||
|
||||
Reference in New Issue
Block a user