@Test public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception { DLFileVersion newDLFileVersion = addDLFileVersion(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newDLFileVersion.getPrimaryKey()); Map<Serializable, DLFileVersion> dlFileVersions = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, dlFileVersions.size()); Assert.assertEquals(newDLFileVersion, dlFileVersions.get(newDLFileVersion.getPrimaryKey())); }
@Test public void testResetOriginalValues() throws Exception { if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { return; } DLFileVersion newDLFileVersion = addDLFileVersion(); _persistence.clearCache(); DLFileVersionModelImpl existingDLFileVersionModelImpl = (DLFileVersionModelImpl) _persistence.findByPrimaryKey(newDLFileVersion.getPrimaryKey()); Assert.assertTrue( Validator.equals( existingDLFileVersionModelImpl.getUuid(), existingDLFileVersionModelImpl.getOriginalUuid())); Assert.assertEquals( existingDLFileVersionModelImpl.getGroupId(), existingDLFileVersionModelImpl.getOriginalGroupId()); Assert.assertEquals( existingDLFileVersionModelImpl.getFileEntryId(), existingDLFileVersionModelImpl.getOriginalFileEntryId()); Assert.assertTrue( Validator.equals( existingDLFileVersionModelImpl.getVersion(), existingDLFileVersionModelImpl.getOriginalVersion())); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception { DLFileVersion newDLFileVersion = addDLFileVersion(); long pk = RandomTestUtil.nextLong(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newDLFileVersion.getPrimaryKey()); primaryKeys.add(pk); Map<Serializable, DLFileVersion> dlFileVersions = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, dlFileVersions.size()); Assert.assertEquals(newDLFileVersion, dlFileVersions.get(newDLFileVersion.getPrimaryKey())); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception { DLFileVersion newDLFileVersion1 = addDLFileVersion(); DLFileVersion newDLFileVersion2 = addDLFileVersion(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newDLFileVersion1.getPrimaryKey()); primaryKeys.add(newDLFileVersion2.getPrimaryKey()); Map<Serializable, DLFileVersion> dlFileVersions = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(2, dlFileVersions.size()); Assert.assertEquals(newDLFileVersion1, dlFileVersions.get(newDLFileVersion1.getPrimaryKey())); Assert.assertEquals(newDLFileVersion2, dlFileVersions.get(newDLFileVersion2.getPrimaryKey())); }
@Test public void testFetchByPrimaryKeyExisting() throws Exception { DLFileVersion newDLFileVersion = addDLFileVersion(); DLFileVersion existingDLFileVersion = _persistence.fetchByPrimaryKey(newDLFileVersion.getPrimaryKey()); Assert.assertEquals(existingDLFileVersion, newDLFileVersion); }
@Test public void testCreate() throws Exception { long pk = RandomTestUtil.nextLong(); DLFileVersion dlFileVersion = _persistence.create(pk); Assert.assertNotNull(dlFileVersion); Assert.assertEquals(dlFileVersion.getPrimaryKey(), pk); }
@Test public void testRemove() throws Exception { DLFileVersion newDLFileVersion = addDLFileVersion(); _persistence.remove(newDLFileVersion); DLFileVersion existingDLFileVersion = _persistence.fetchByPrimaryKey(newDLFileVersion.getPrimaryKey()); Assert.assertNull(existingDLFileVersion); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); DLFileVersion newDLFileVersion = _persistence.create(pk); newDLFileVersion.setUuid(RandomTestUtil.randomString()); newDLFileVersion.setGroupId(RandomTestUtil.nextLong()); newDLFileVersion.setCompanyId(RandomTestUtil.nextLong()); newDLFileVersion.setUserId(RandomTestUtil.nextLong()); newDLFileVersion.setUserName(RandomTestUtil.randomString()); newDLFileVersion.setCreateDate(RandomTestUtil.nextDate()); newDLFileVersion.setModifiedDate(RandomTestUtil.nextDate()); newDLFileVersion.setRepositoryId(RandomTestUtil.nextLong()); newDLFileVersion.setFolderId(RandomTestUtil.nextLong()); newDLFileVersion.setFileEntryId(RandomTestUtil.nextLong()); newDLFileVersion.setTreePath(RandomTestUtil.randomString()); newDLFileVersion.setExtension(RandomTestUtil.randomString()); newDLFileVersion.setMimeType(RandomTestUtil.randomString()); newDLFileVersion.setTitle(RandomTestUtil.randomString()); newDLFileVersion.setDescription(RandomTestUtil.randomString()); newDLFileVersion.setChangeLog(RandomTestUtil.randomString()); newDLFileVersion.setExtraSettings(RandomTestUtil.randomString()); newDLFileVersion.setFileEntryTypeId(RandomTestUtil.nextLong()); newDLFileVersion.setVersion(RandomTestUtil.randomString()); newDLFileVersion.setSize(RandomTestUtil.nextLong()); newDLFileVersion.setChecksum(RandomTestUtil.randomString()); newDLFileVersion.setStatus(RandomTestUtil.nextInt()); newDLFileVersion.setStatusByUserId(RandomTestUtil.nextLong()); newDLFileVersion.setStatusByUserName(RandomTestUtil.randomString()); newDLFileVersion.setStatusDate(RandomTestUtil.nextDate()); _persistence.update(newDLFileVersion); DLFileVersion existingDLFileVersion = _persistence.findByPrimaryKey(newDLFileVersion.getPrimaryKey()); Assert.assertEquals(existingDLFileVersion.getUuid(), newDLFileVersion.getUuid()); Assert.assertEquals( existingDLFileVersion.getFileVersionId(), newDLFileVersion.getFileVersionId()); Assert.assertEquals(existingDLFileVersion.getGroupId(), newDLFileVersion.getGroupId()); Assert.assertEquals(existingDLFileVersion.getCompanyId(), newDLFileVersion.getCompanyId()); Assert.assertEquals(existingDLFileVersion.getUserId(), newDLFileVersion.getUserId()); Assert.assertEquals(existingDLFileVersion.getUserName(), newDLFileVersion.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingDLFileVersion.getCreateDate()), Time.getShortTimestamp(newDLFileVersion.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingDLFileVersion.getModifiedDate()), Time.getShortTimestamp(newDLFileVersion.getModifiedDate())); Assert.assertEquals( existingDLFileVersion.getRepositoryId(), newDLFileVersion.getRepositoryId()); Assert.assertEquals(existingDLFileVersion.getFolderId(), newDLFileVersion.getFolderId()); Assert.assertEquals(existingDLFileVersion.getFileEntryId(), newDLFileVersion.getFileEntryId()); Assert.assertEquals(existingDLFileVersion.getTreePath(), newDLFileVersion.getTreePath()); Assert.assertEquals(existingDLFileVersion.getExtension(), newDLFileVersion.getExtension()); Assert.assertEquals(existingDLFileVersion.getMimeType(), newDLFileVersion.getMimeType()); Assert.assertEquals(existingDLFileVersion.getTitle(), newDLFileVersion.getTitle()); Assert.assertEquals(existingDLFileVersion.getDescription(), newDLFileVersion.getDescription()); Assert.assertEquals(existingDLFileVersion.getChangeLog(), newDLFileVersion.getChangeLog()); Assert.assertEquals( existingDLFileVersion.getExtraSettings(), newDLFileVersion.getExtraSettings()); Assert.assertEquals( existingDLFileVersion.getFileEntryTypeId(), newDLFileVersion.getFileEntryTypeId()); Assert.assertEquals(existingDLFileVersion.getVersion(), newDLFileVersion.getVersion()); Assert.assertEquals(existingDLFileVersion.getSize(), newDLFileVersion.getSize()); Assert.assertEquals(existingDLFileVersion.getChecksum(), newDLFileVersion.getChecksum()); Assert.assertEquals(existingDLFileVersion.getStatus(), newDLFileVersion.getStatus()); Assert.assertEquals( existingDLFileVersion.getStatusByUserId(), newDLFileVersion.getStatusByUserId()); Assert.assertEquals( existingDLFileVersion.getStatusByUserName(), newDLFileVersion.getStatusByUserName()); Assert.assertEquals( Time.getShortTimestamp(existingDLFileVersion.getStatusDate()), Time.getShortTimestamp(newDLFileVersion.getStatusDate())); }