/** Test of insertRow method, of class PublicationDAO. */
 @Test
 public void testInsertRow() throws Exception {
   IDatabaseConnection connection = getConnection();
   try {
     Connection con = connection.getConnection();
     PublicationPK pk = new PublicationPK("500", "kmelia36");
     Calendar now = Calendar.getInstance();
     now.set(Calendar.SECOND, 0);
     now.set(Calendar.MILLISECOND, 0);
     now.set(Calendar.MINUTE, 0);
     now.set(Calendar.HOUR_OF_DAY, 0);
     Calendar beginDate = RandomGenerator.getCalendarAfter(now);
     Calendar endDate = RandomGenerator.getCalendarAfter(beginDate);
     String name = RandomGenerator.getRandomString();
     String description = RandomGenerator.getRandomString();
     String creatorId = "" + RandomGenerator.getRandomInt();
     int importance = RandomGenerator.getRandomInt(5);
     String version = RandomGenerator.getRandomString();
     String contenu = RandomGenerator.getRandomString();
     StringBuilder buffer = new StringBuilder();
     int nbKeywords = RandomGenerator.getRandomInt(5) + 2;
     for (int i = 0; i < nbKeywords; i++) {
       buffer.append(RandomGenerator.getRandomString());
       if (i < (nbKeywords - 1)) {
         buffer.append(' ');
       }
     }
     String keywords = buffer.toString();
     PublicationDetail detail =
         new PublicationDetail(
             pk,
             name,
             description,
             now.getTime(),
             beginDate.getTime(),
             endDate.getTime(),
             creatorId,
             importance,
             version,
             keywords,
             contenu);
     detail.setBeginHour(DateUtil.formatTime(beginDate));
     detail.setEndHour(DateUtil.formatTime(endDate));
     PublicationDAO.insertRow(con, detail);
     PublicationDetail result = PublicationDAO.loadRow(con, pk);
     detail.setUpdateDate(now.getTime());
     detail.setUpdaterId(creatorId);
     detail.setInfoId("0");
     assertEquals(detail.getPK(), result.getPK());
     assertEquals(detail.getAuthor(), result.getAuthor());
     assertEquals(detail.getBeginDate(), result.getBeginDate());
     assertEquals(detail.getBeginHour(), result.getBeginHour());
     assertEquals(detail.getContent(), result.getContent());
     assertEquals(detail.getCreationDate(), result.getCreationDate());
     assertEquals(detail.getUpdateDate(), result.getCreationDate());
     assertEquals(detail.getCreatorId(), result.getCreatorId());
     assertEquals(detail.getDescription(), result.getDescription());
     assertEquals(detail.getEndDate(), result.getEndDate());
     assertEquals(detail.getEndHour(), result.getEndHour());
     assertEquals(detail.getImportance(), result.getImportance());
     assertEquals(detail.getInfoId(), result.getInfoId());
     assertEquals(detail.getInstanceId(), result.getInstanceId());
     assertEquals(detail.getKeywords(), result.getKeywords());
     assertEquals(detail.getName(), result.getName());
     assertEquals(detail.getStatus(), result.getStatus());
     assertEquals(detail.getTitle(), result.getTitle());
   } finally {
     connection.close();
   }
 }
 /** Test of storeRow method, of class PublicationDAO. */
 @Test
 public void testStoreRow() throws Exception {
   IDatabaseConnection connection = getConnection();
   try {
     Connection con = connection.getConnection();
     PublicationPK pk = new PublicationPK("100", "kmelia200");
     PublicationDetail detail = PublicationDAO.loadRow(con, pk);
     assertEquals(pk, detail.getPK());
     assertEquals("Homer Simpson", detail.getAuthor());
     assertEquals("2009/10/18", DateUtil.formatDate(detail.getBeginDate()));
     assertEquals("00:00", detail.getBeginHour());
     assertEquals("Contenu de la publication 1", detail.getContent());
     assertEquals("2008/11/18", DateUtil.formatDate(detail.getCreationDate()));
     assertEquals("100", detail.getCreatorId());
     assertEquals("Première publication de test", detail.getDescription());
     assertEquals("2020/12/18", DateUtil.formatDate(detail.getEndDate()));
     assertEquals("23:59", detail.getEndHour());
     assertEquals(1, detail.getImportance());
     assertEquals("0", detail.getInfoId());
     assertEquals("kmelia200", detail.getInstanceId());
     assertEquals("test", detail.getKeywords());
     assertEquals("Publication 1", detail.getName());
     assertEquals("Valid", detail.getStatus());
     assertEquals("300", detail.getValidatorId());
     assertEquals("Publication 1", detail.getTitle());
     Calendar now = Calendar.getInstance();
     now.set(Calendar.SECOND, 0);
     now.set(Calendar.MILLISECOND, 0);
     now.set(Calendar.MINUTE, 0);
     now.set(Calendar.HOUR_OF_DAY, 0);
     Calendar beginDate = RandomGenerator.getCalendarAfter(now);
     Calendar endDate = RandomGenerator.getCalendarAfter(beginDate);
     String name = RandomGenerator.getRandomString();
     String description = RandomGenerator.getRandomString();
     String creatorId = "" + RandomGenerator.getRandomInt();
     int importance = RandomGenerator.getRandomInt(5);
     String version = RandomGenerator.getRandomString();
     String contenu = RandomGenerator.getRandomString();
     StringBuilder buffer = new StringBuilder();
     int nbKeywords = RandomGenerator.getRandomInt(5) + 2;
     for (int i = 0; i < nbKeywords; i++) {
       buffer.append(RandomGenerator.getRandomString());
       if (i < (nbKeywords - 1)) {
         buffer.append(' ');
       }
     }
     String keywords = buffer.toString();
     detail.setName(name);
     detail.setDescription(description);
     detail.setCreationDate(now.getTime());
     detail.setBeginDateAndHour(beginDate.getTime());
     detail.setEndDateAndHour(endDate.getTime());
     detail.setCreatorId(creatorId);
     detail.setImportance(importance);
     detail.setVersion(version);
     detail.setKeywords(keywords);
     detail.setContent(contenu);
     detail.setBeginHour(DateUtil.formatTime(beginDate));
     detail.setEndHour(DateUtil.formatTime(endDate));
     PublicationDAO.storeRow(con, detail);
     PublicationDetail result = PublicationDAO.loadRow(con, pk);
     detail.setUpdateDate(now.getTime());
     detail.setUpdaterId(creatorId);
     detail.setInfoId("0");
     assertEquals(detail.getPK(), result.getPK());
     assertEquals(detail.getAuthor(), result.getAuthor());
     assertEquals(detail.getBeginDate(), result.getBeginDate());
     assertEquals(detail.getBeginHour(), result.getBeginHour());
     assertEquals(detail.getContent(), result.getContent());
     assertEquals(detail.getCreationDate(), result.getCreationDate());
     assertEquals(detail.getUpdateDate(), result.getCreationDate());
     assertEquals(detail.getCreatorId(), result.getCreatorId());
     assertEquals(detail.getDescription(), result.getDescription());
     assertEquals(detail.getEndDate(), result.getEndDate());
     assertEquals(detail.getEndHour(), result.getEndHour());
     assertEquals(detail.getImportance(), result.getImportance());
     assertEquals(detail.getInfoId(), result.getInfoId());
     assertEquals(detail.getInstanceId(), result.getInstanceId());
     assertEquals(detail.getKeywords(), result.getKeywords());
     assertEquals(detail.getName(), result.getName());
     assertEquals(detail.getStatus(), result.getStatus());
     assertEquals(detail.getTitle(), result.getTitle());
   } finally {
     connection.close();
   }
 }