コード例 #1
0
  /** Test of selectByFatherPK method, of class PublicationDAO. */
  @Test
  public void testSelectByFatherPK_Connection_NodePK() throws Exception {
    IDatabaseConnection connection = getConnection();
    try {
      Connection con = connection.getConnection();
      NodePK fatherPK = new NodePK("110", "kmelia200");
      Collection<PublicationDetail> result = PublicationDAO.selectByFatherPK(con, fatherPK);
      assertNotNull(result);
      assertEquals(2, result.size());
      Iterator<PublicationDetail> iter = result.iterator();
      PublicationDetail detail = iter.next();
      PublicationPK primaryKey = new PublicationPK("100", "kmelia200");
      assertEquals(primaryKey, 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());

      detail = iter.next();
      primaryKey = new PublicationPK("101", "kmelia200");
      assertEquals(primaryKey, detail.getPK());
      assertEquals("Bart Simpson", detail.getAuthor());
      assertEquals("2009/10/18", DateUtil.formatDate(detail.getBeginDate()));
      assertEquals("01:10", detail.getBeginHour());
      assertEquals("Contenu de la publication 2", detail.getContent());
      assertEquals("2008/11/18", DateUtil.formatDate(detail.getCreationDate()));
      assertEquals("101", detail.getCreatorId());
      assertEquals("2ème publication de test", detail.getDescription());
      assertEquals("2020/12/18", DateUtil.formatDate(detail.getEndDate()));
      assertEquals("20:35", detail.getEndHour());
      assertEquals(5, detail.getImportance());
      assertEquals("0", detail.getInfoId());
      assertEquals("kmelia200", detail.getInstanceId());
      assertEquals("test", detail.getKeywords());
      assertEquals("Publication 2", detail.getName());
      assertEquals("Valid", detail.getStatus());
      assertEquals("300", detail.getValidatorId());
      assertEquals("Publication 2", detail.getTitle());
    } finally {
      connection.close();
    }
  }
コード例 #2
0
 /** Test of changeInstanceId method, of class PublicationDAO. */
 @Test
 public void testChangeInstanceId() 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());
     String targetInstance = "kmelia" + RandomGenerator.getRandomInt(600);
     PublicationDAO.changeInstanceId(con, pk, targetInstance);
     pk = new PublicationPK("100", targetInstance);
     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(targetInstance, detail.getInstanceId());
     assertEquals("test", detail.getKeywords());
     assertEquals("Publication 1", detail.getName());
     assertEquals("Valid", detail.getStatus());
     assertEquals("300", detail.getValidatorId());
     assertEquals("Publication 1", detail.getTitle());
   } finally {
     connection.close();
   }
 }
コード例 #3
0
 /** Test of selectByNameAndNodeId method, of class PublicationDAO. */
 @Test
 public void testSelectByNameAndNodeId() throws Exception {
   IDatabaseConnection connection = getConnection();
   try {
     Connection con = connection.getConnection();
     PublicationPK pubPK = new PublicationPK("100", "kmelia200");
     String name = "Publication 1";
     int nodeId = 110;
     PublicationDetail result = PublicationDAO.selectByNameAndNodeId(con, pubPK, name, nodeId);
     assertEquals(pubPK, result.getPK());
     assertEquals("Homer Simpson", result.getAuthor());
     assertEquals("2009/10/18", DateUtil.formatDate(result.getBeginDate()));
     assertEquals("00:00", result.getBeginHour());
     assertEquals("Contenu de la publication 1", result.getContent());
     assertEquals("2008/11/18", DateUtil.formatDate(result.getCreationDate()));
     assertEquals("100", result.getCreatorId());
     assertEquals("Première publication de test", result.getDescription());
     assertEquals("2020/12/18", DateUtil.formatDate(result.getEndDate()));
     assertEquals("23:59", result.getEndHour());
     assertEquals(1, result.getImportance());
     assertEquals("0", result.getInfoId());
     assertEquals("kmelia200", result.getInstanceId());
     assertEquals("test", result.getKeywords());
     assertEquals("Publication 1", result.getName());
     assertEquals("Valid", result.getStatus());
     assertEquals("300", result.getValidatorId());
     assertEquals("Publication 1", result.getTitle());
   } finally {
     connection.close();
   }
 }
コード例 #4
0
 /** 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();
   }
 }
コード例 #5
0
 /** 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();
   }
 }
コード例 #6
0
  /** Test of selectByFatherPK method, of class PublicationDAO. */
  @Test
  public void testSelectByFatherPK_5args() throws Exception {
    IDatabaseConnection connection = getConnection();
    try {
      Connection con = connection.getConnection();
      NodePK fatherPK = new NodePK("110", "kmelia200");
      String sorting = null;
      boolean filterOnVisibilityPeriod = false;
      String userId = "100";
      Collection<PublicationDetail> result =
          PublicationDAO.selectByFatherPK(con, fatherPK, sorting, filterOnVisibilityPeriod, userId);
      assertNotNull(result);
      assertEquals(1, result.size());
      Iterator<PublicationDetail> iter = result.iterator();
      PublicationDetail detail = iter.next();
      PublicationPK primaryKey = new PublicationPK("100", "kmelia200");
      assertEquals(primaryKey, 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());

      filterOnVisibilityPeriod = true;
      result =
          PublicationDAO.selectByFatherPK(con, fatherPK, sorting, filterOnVisibilityPeriod, userId);
      assertNotNull(result);
      assertEquals(1, result.size());
      iter = result.iterator();
      detail = iter.next();
      primaryKey = new PublicationPK("100", "kmelia200");
      assertEquals(primaryKey, 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());
    } finally {
      connection.close();
    }
  }