예제 #1
0
  protected Date getCreateDate(Object obj) {
    if (obj instanceof DLFileEntry) {
      DLFileEntry dlFileEntry = (DLFileEntry) obj;

      return dlFileEntry.getCreateDate();
    } else if (obj instanceof DLFileShortcut) {
      DLFileShortcut dlFileShortcut = (DLFileShortcut) obj;

      return dlFileShortcut.getCreateDate();
    } else if (obj instanceof DLFolder) {
      DLFolder dlFolder = (DLFolder) obj;

      return dlFolder.getCreateDate();
    } else if (obj instanceof FileEntry) {
      FileEntry fileEntry = (FileEntry) obj;

      return fileEntry.getCreateDate();
    } else {
      Folder folder = (Folder) obj;

      return folder.getCreateDate();
    }
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    DLFileShortcut newDLFileShortcut = _persistence.create(pk);

    newDLFileShortcut.setUuid(RandomTestUtil.randomString());

    newDLFileShortcut.setGroupId(RandomTestUtil.nextLong());

    newDLFileShortcut.setCompanyId(RandomTestUtil.nextLong());

    newDLFileShortcut.setUserId(RandomTestUtil.nextLong());

    newDLFileShortcut.setUserName(RandomTestUtil.randomString());

    newDLFileShortcut.setCreateDate(RandomTestUtil.nextDate());

    newDLFileShortcut.setModifiedDate(RandomTestUtil.nextDate());

    newDLFileShortcut.setRepositoryId(RandomTestUtil.nextLong());

    newDLFileShortcut.setFolderId(RandomTestUtil.nextLong());

    newDLFileShortcut.setToFileEntryId(RandomTestUtil.nextLong());

    newDLFileShortcut.setTreePath(RandomTestUtil.randomString());

    newDLFileShortcut.setActive(RandomTestUtil.randomBoolean());

    newDLFileShortcut.setStatus(RandomTestUtil.nextInt());

    newDLFileShortcut.setStatusByUserId(RandomTestUtil.nextLong());

    newDLFileShortcut.setStatusByUserName(RandomTestUtil.randomString());

    newDLFileShortcut.setStatusDate(RandomTestUtil.nextDate());

    _dlFileShortcuts.add(_persistence.update(newDLFileShortcut));

    DLFileShortcut existingDLFileShortcut =
        _persistence.findByPrimaryKey(newDLFileShortcut.getPrimaryKey());

    Assert.assertEquals(existingDLFileShortcut.getUuid(), newDLFileShortcut.getUuid());
    Assert.assertEquals(
        existingDLFileShortcut.getFileShortcutId(), newDLFileShortcut.getFileShortcutId());
    Assert.assertEquals(existingDLFileShortcut.getGroupId(), newDLFileShortcut.getGroupId());
    Assert.assertEquals(existingDLFileShortcut.getCompanyId(), newDLFileShortcut.getCompanyId());
    Assert.assertEquals(existingDLFileShortcut.getUserId(), newDLFileShortcut.getUserId());
    Assert.assertEquals(existingDLFileShortcut.getUserName(), newDLFileShortcut.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileShortcut.getCreateDate()),
        Time.getShortTimestamp(newDLFileShortcut.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileShortcut.getModifiedDate()),
        Time.getShortTimestamp(newDLFileShortcut.getModifiedDate()));
    Assert.assertEquals(
        existingDLFileShortcut.getRepositoryId(), newDLFileShortcut.getRepositoryId());
    Assert.assertEquals(existingDLFileShortcut.getFolderId(), newDLFileShortcut.getFolderId());
    Assert.assertEquals(
        existingDLFileShortcut.getToFileEntryId(), newDLFileShortcut.getToFileEntryId());
    Assert.assertEquals(existingDLFileShortcut.getTreePath(), newDLFileShortcut.getTreePath());
    Assert.assertEquals(existingDLFileShortcut.getActive(), newDLFileShortcut.getActive());
    Assert.assertEquals(existingDLFileShortcut.getStatus(), newDLFileShortcut.getStatus());
    Assert.assertEquals(
        existingDLFileShortcut.getStatusByUserId(), newDLFileShortcut.getStatusByUserId());
    Assert.assertEquals(
        existingDLFileShortcut.getStatusByUserName(), newDLFileShortcut.getStatusByUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileShortcut.getStatusDate()),
        Time.getShortTimestamp(newDLFileShortcut.getStatusDate()));
  }