Mise a jour des tests pour EvaluationManager : tout au vert
This commit is contained in:
@@ -38,6 +38,8 @@ public class EvaluationManagerTest {
|
||||
private static IUserManager um;
|
||||
private int confId;
|
||||
private Article article;
|
||||
private int articleId;
|
||||
private int critId;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpManager() throws NamingException, PKAlreadyUsedException {
|
||||
@@ -50,40 +52,54 @@ public class EvaluationManagerTest {
|
||||
|
||||
@Before
|
||||
public void initDB() throws Exception{
|
||||
um.addUser("evaluationManagerTest", "pw", "first", "last", "yacos", "evaluationManagerTest@yacos.com");
|
||||
if(! um.exists("evaluationManagerTest")){
|
||||
um.addUser("evaluationManagerTest", "pw", "first", "last", "yacos", "evaluationManagerTest@yacos.com");
|
||||
}
|
||||
if(! um.exists("evaluationManagerTest2")){
|
||||
um.addUser("evaluationManagerTest2", "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();
|
||||
Criterion crit = em.addCriterion("name", 0, 4, confId);
|
||||
critId = crit.getId();
|
||||
|
||||
article = am.addArticle("title article max","topic","Abstract", "url_article",
|
||||
"evaluationManagerTest", new ArrayList<String>(), Article.State.SUBMITED, confId);
|
||||
//article = am.getArticle(1);
|
||||
articleId = article.getId();
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanDB(){
|
||||
am.removeArticle(article.getId());
|
||||
if(am.existsArticle(articleId)){
|
||||
am.removeArticle(articleId);
|
||||
}
|
||||
if(em.getCriterion(critId)!=null){
|
||||
em.removeCriterion(critId);
|
||||
}
|
||||
if(cm.exists(confId)){
|
||||
cm.remove(confId);
|
||||
}
|
||||
um.removeUser("evaluationManagerTest");
|
||||
cm.remove(confId);
|
||||
um.removeUser("evaluationManagerTest2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void add_et_getCriterionsTest() {
|
||||
Criterion crit = em.addCriterion("name", 0, 4, confId);
|
||||
Criterion crit = em.getCriterion(critId);
|
||||
assertNotNull(crit);
|
||||
assertEquals(crit.getName(), em.getCriterion(crit.getId()).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCriterionsTest() throws NamingException{
|
||||
em.addCriterion("name", 0, 4, confId);
|
||||
List<Criterion> list = em.getCriterions(confId);
|
||||
assertFalse("liste vide",list.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateCriterionTest(){
|
||||
Criterion crit = em.addCriterion("name", 0, 4, confId);
|
||||
Criterion crit = em.getCriterion(critId);
|
||||
crit.setName("autre");
|
||||
em.updateCriterion(crit);
|
||||
crit = em.getCriterion(crit.getId());
|
||||
@@ -92,22 +108,27 @@ public class EvaluationManagerTest {
|
||||
|
||||
@Test
|
||||
public void removeCriterion(){
|
||||
Criterion crit = em.addCriterion("name", 0, 4, confId);
|
||||
Criterion crit = em.getCriterion(critId);
|
||||
em.removeCriterion(crit.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void AddReportTest(){
|
||||
List<Rating> ratings = new ArrayList<Rating>();
|
||||
Report report = em.addReport(article.getId(), "commentPCMember", "commentAuthor", ratings, "max");
|
||||
Report report = em.addReport(article.getId(), "commentPCMember", "commentAuthor", ratings, "evaluationManagerTest");
|
||||
|
||||
//assertNotNull(em.getReportforArticleAndReferee(article.getId(), "max"));
|
||||
assertEquals(report.getCommentAuthor(), em.getReport(report.getId()).getCommentAuthor());
|
||||
//assertNotNull(em.getReportforArticleAndReferee(article.getId(), "evaluationManagerTest"));
|
||||
|
||||
Report testReport = em.getReport(report.getId());
|
||||
assertNotNull(testReport);
|
||||
|
||||
assertEquals("commentAuthor", testReport.getCommentAuthor());
|
||||
em.removeReport(testReport.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateReportTest(){
|
||||
Report report = em.addReport(article.getId(), "commentPCMember", "commentAuthor", new ArrayList<Rating>(), "max");
|
||||
Report report = em.addReport(article.getId(), "commentPCMember", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest");
|
||||
report.setCommentPCMember("autre");
|
||||
em.updateReport(report);
|
||||
assertEquals("autre", em.getReport(report.getId()).getCommentPCMember());
|
||||
@@ -115,33 +136,34 @@ public class EvaluationManagerTest {
|
||||
|
||||
@Test
|
||||
public void removeReportTest(){
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "max");
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest");
|
||||
int reportId = report.getId();
|
||||
em.removeReport(report.getId());
|
||||
assertNull(em.getReport(report.getId()));
|
||||
assertNull(em.getReport(reportId));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getReportforArticleAndRefereeTest(){
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "max");
|
||||
Report report2 =em.getReportforArticleAndReferee(article.getId(), "max");
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest");
|
||||
Report report2 =em.getReportforArticleAndReferee(article.getId(), "evaluationManagerTest");
|
||||
assertEquals(report.getId(), report2.getId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getReportsForArticleTest(){
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "admin");
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "max");
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest");
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest2");
|
||||
List <Report> list = em.getReportsForArticle(article.getId());
|
||||
assertTrue(list.size() == 2);
|
||||
|
||||
}
|
||||
@Test
|
||||
public void getReportsForRefereeTest(){
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "admin");
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "max");
|
||||
List <Report> list = em.getReportsForReferee("max");
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest");
|
||||
em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest2");
|
||||
List <Report> list = em.getReportsForReferee("evaluationManagerTest");
|
||||
assertFalse(list.isEmpty());
|
||||
//assertTrue(list.size() == 1);
|
||||
}
|
||||
@@ -149,7 +171,7 @@ public class EvaluationManagerTest {
|
||||
@Test
|
||||
public void getRatingsFromReportTest(){
|
||||
Criterion criterion = em.addCriterion("crit<EFBFBD>re1", 0, 3, confId);
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "max");
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest");
|
||||
em.addRating(2,criterion.getId(),report.getId());
|
||||
assertFalse(em.getRatingForReport(report.getId()).isEmpty());
|
||||
em.removeRating(criterion, report);
|
||||
@@ -158,11 +180,12 @@ public class EvaluationManagerTest {
|
||||
@Test
|
||||
public void updateRatingTest(){
|
||||
Criterion criterion = em.addCriterion("crit<EFBFBD>re1", 0, 3, confId);
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "max");
|
||||
Report report = em.addReport(article.getId(), "report a virer", "commentAuthor", new ArrayList<Rating>(), "evaluationManagerTest");
|
||||
Rating rating = em.addRating(2,criterion.getId(),report.getId());
|
||||
rating.setValue(1);
|
||||
em.updateRating(rating);
|
||||
rating = em.getRatingForReport(report.getId()).get(1);
|
||||
assertEquals(1, em.getRatingForReport(report.getId()).size());
|
||||
rating = em.getRatingForReport(report.getId()).get(0);
|
||||
assertEquals(1, rating.getValue());
|
||||
em.removeRating(criterion, report);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user