PageRenderTime 58ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/test/persistence-test/src/testIntegration/java/com/liferay/portlet/documentlibrary/service/persistence/test/DLFileVersionPersistenceTest.java

http://github.com/liferay/liferay-portal
Java | 724 lines | 510 code | 198 blank | 16 comment | 1 complexity | 6300d0947bd931970b31e398b53aa510 MD5 | raw file
Possible License(s): LGPL-2.0
  1. /**
  2. * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.portlet.documentlibrary.service.persistence.test;
  15. import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
  16. import com.liferay.document.library.kernel.exception.NoSuchFileVersionException;
  17. import com.liferay.document.library.kernel.model.DLFileVersion;
  18. import com.liferay.document.library.kernel.service.DLFileVersionLocalServiceUtil;
  19. import com.liferay.document.library.kernel.service.persistence.DLFileVersionPersistence;
  20. import com.liferay.document.library.kernel.service.persistence.DLFileVersionUtil;
  21. import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
  22. import com.liferay.portal.kernel.dao.orm.DynamicQuery;
  23. import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
  24. import com.liferay.portal.kernel.dao.orm.ProjectionFactoryUtil;
  25. import com.liferay.portal.kernel.dao.orm.QueryUtil;
  26. import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
  27. import com.liferay.portal.kernel.test.ReflectionTestUtil;
  28. import com.liferay.portal.kernel.test.rule.AggregateTestRule;
  29. import com.liferay.portal.kernel.test.util.RandomTestUtil;
  30. import com.liferay.portal.kernel.transaction.Propagation;
  31. import com.liferay.portal.kernel.util.IntegerWrapper;
  32. import com.liferay.portal.kernel.util.OrderByComparator;
  33. import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;
  34. import com.liferay.portal.kernel.util.Time;
  35. import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
  36. import com.liferay.portal.test.rule.PersistenceTestRule;
  37. import com.liferay.portal.test.rule.TransactionalTestRule;
  38. import java.io.Serializable;
  39. import java.util.ArrayList;
  40. import java.util.HashSet;
  41. import java.util.Iterator;
  42. import java.util.List;
  43. import java.util.Map;
  44. import java.util.Objects;
  45. import java.util.Set;
  46. import org.junit.After;
  47. import org.junit.Assert;
  48. import org.junit.Before;
  49. import org.junit.ClassRule;
  50. import org.junit.Rule;
  51. import org.junit.Test;
  52. import org.junit.runner.RunWith;
  53. /**
  54. * @generated
  55. */
  56. @RunWith(Arquillian.class)
  57. public class DLFileVersionPersistenceTest {
  58. @ClassRule
  59. @Rule
  60. public static final AggregateTestRule aggregateTestRule =
  61. new AggregateTestRule(
  62. new LiferayIntegrationTestRule(), PersistenceTestRule.INSTANCE,
  63. new TransactionalTestRule(Propagation.REQUIRED));
  64. @Before
  65. public void setUp() {
  66. _persistence = DLFileVersionUtil.getPersistence();
  67. Class<?> clazz = _persistence.getClass();
  68. _dynamicQueryClassLoader = clazz.getClassLoader();
  69. }
  70. @After
  71. public void tearDown() throws Exception {
  72. Iterator<DLFileVersion> iterator = _dlFileVersions.iterator();
  73. while (iterator.hasNext()) {
  74. _persistence.remove(iterator.next());
  75. iterator.remove();
  76. }
  77. }
  78. @Test
  79. public void testCreate() throws Exception {
  80. long pk = RandomTestUtil.nextLong();
  81. DLFileVersion dlFileVersion = _persistence.create(pk);
  82. Assert.assertNotNull(dlFileVersion);
  83. Assert.assertEquals(dlFileVersion.getPrimaryKey(), pk);
  84. }
  85. @Test
  86. public void testRemove() throws Exception {
  87. DLFileVersion newDLFileVersion = addDLFileVersion();
  88. _persistence.remove(newDLFileVersion);
  89. DLFileVersion existingDLFileVersion = _persistence.fetchByPrimaryKey(
  90. newDLFileVersion.getPrimaryKey());
  91. Assert.assertNull(existingDLFileVersion);
  92. }
  93. @Test
  94. public void testUpdateNew() throws Exception {
  95. addDLFileVersion();
  96. }
  97. @Test
  98. public void testUpdateExisting() throws Exception {
  99. long pk = RandomTestUtil.nextLong();
  100. DLFileVersion newDLFileVersion = _persistence.create(pk);
  101. newDLFileVersion.setMvccVersion(RandomTestUtil.nextLong());
  102. newDLFileVersion.setCtCollectionId(RandomTestUtil.nextLong());
  103. newDLFileVersion.setUuid(RandomTestUtil.randomString());
  104. newDLFileVersion.setGroupId(RandomTestUtil.nextLong());
  105. newDLFileVersion.setCompanyId(RandomTestUtil.nextLong());
  106. newDLFileVersion.setUserId(RandomTestUtil.nextLong());
  107. newDLFileVersion.setUserName(RandomTestUtil.randomString());
  108. newDLFileVersion.setCreateDate(RandomTestUtil.nextDate());
  109. newDLFileVersion.setModifiedDate(RandomTestUtil.nextDate());
  110. newDLFileVersion.setRepositoryId(RandomTestUtil.nextLong());
  111. newDLFileVersion.setFolderId(RandomTestUtil.nextLong());
  112. newDLFileVersion.setFileEntryId(RandomTestUtil.nextLong());
  113. newDLFileVersion.setTreePath(RandomTestUtil.randomString());
  114. newDLFileVersion.setFileName(RandomTestUtil.randomString());
  115. newDLFileVersion.setExtension(RandomTestUtil.randomString());
  116. newDLFileVersion.setMimeType(RandomTestUtil.randomString());
  117. newDLFileVersion.setTitle(RandomTestUtil.randomString());
  118. newDLFileVersion.setDescription(RandomTestUtil.randomString());
  119. newDLFileVersion.setChangeLog(RandomTestUtil.randomString());
  120. newDLFileVersion.setExtraSettings(RandomTestUtil.randomString());
  121. newDLFileVersion.setFileEntryTypeId(RandomTestUtil.nextLong());
  122. newDLFileVersion.setVersion(RandomTestUtil.randomString());
  123. newDLFileVersion.setSize(RandomTestUtil.nextLong());
  124. newDLFileVersion.setChecksum(RandomTestUtil.randomString());
  125. newDLFileVersion.setLastPublishDate(RandomTestUtil.nextDate());
  126. newDLFileVersion.setStatus(RandomTestUtil.nextInt());
  127. newDLFileVersion.setStatusByUserId(RandomTestUtil.nextLong());
  128. newDLFileVersion.setStatusByUserName(RandomTestUtil.randomString());
  129. newDLFileVersion.setStatusDate(RandomTestUtil.nextDate());
  130. _dlFileVersions.add(_persistence.update(newDLFileVersion));
  131. DLFileVersion existingDLFileVersion = _persistence.findByPrimaryKey(
  132. newDLFileVersion.getPrimaryKey());
  133. Assert.assertEquals(
  134. existingDLFileVersion.getMvccVersion(),
  135. newDLFileVersion.getMvccVersion());
  136. Assert.assertEquals(
  137. existingDLFileVersion.getCtCollectionId(),
  138. newDLFileVersion.getCtCollectionId());
  139. Assert.assertEquals(
  140. existingDLFileVersion.getUuid(), newDLFileVersion.getUuid());
  141. Assert.assertEquals(
  142. existingDLFileVersion.getFileVersionId(),
  143. newDLFileVersion.getFileVersionId());
  144. Assert.assertEquals(
  145. existingDLFileVersion.getGroupId(), newDLFileVersion.getGroupId());
  146. Assert.assertEquals(
  147. existingDLFileVersion.getCompanyId(),
  148. newDLFileVersion.getCompanyId());
  149. Assert.assertEquals(
  150. existingDLFileVersion.getUserId(), newDLFileVersion.getUserId());
  151. Assert.assertEquals(
  152. existingDLFileVersion.getUserName(),
  153. newDLFileVersion.getUserName());
  154. Assert.assertEquals(
  155. Time.getShortTimestamp(existingDLFileVersion.getCreateDate()),
  156. Time.getShortTimestamp(newDLFileVersion.getCreateDate()));
  157. Assert.assertEquals(
  158. Time.getShortTimestamp(existingDLFileVersion.getModifiedDate()),
  159. Time.getShortTimestamp(newDLFileVersion.getModifiedDate()));
  160. Assert.assertEquals(
  161. existingDLFileVersion.getRepositoryId(),
  162. newDLFileVersion.getRepositoryId());
  163. Assert.assertEquals(
  164. existingDLFileVersion.getFolderId(),
  165. newDLFileVersion.getFolderId());
  166. Assert.assertEquals(
  167. existingDLFileVersion.getFileEntryId(),
  168. newDLFileVersion.getFileEntryId());
  169. Assert.assertEquals(
  170. existingDLFileVersion.getTreePath(),
  171. newDLFileVersion.getTreePath());
  172. Assert.assertEquals(
  173. existingDLFileVersion.getFileName(),
  174. newDLFileVersion.getFileName());
  175. Assert.assertEquals(
  176. existingDLFileVersion.getExtension(),
  177. newDLFileVersion.getExtension());
  178. Assert.assertEquals(
  179. existingDLFileVersion.getMimeType(),
  180. newDLFileVersion.getMimeType());
  181. Assert.assertEquals(
  182. existingDLFileVersion.getTitle(), newDLFileVersion.getTitle());
  183. Assert.assertEquals(
  184. existingDLFileVersion.getDescription(),
  185. newDLFileVersion.getDescription());
  186. Assert.assertEquals(
  187. existingDLFileVersion.getChangeLog(),
  188. newDLFileVersion.getChangeLog());
  189. Assert.assertEquals(
  190. existingDLFileVersion.getExtraSettings(),
  191. newDLFileVersion.getExtraSettings());
  192. Assert.assertEquals(
  193. existingDLFileVersion.getFileEntryTypeId(),
  194. newDLFileVersion.getFileEntryTypeId());
  195. Assert.assertEquals(
  196. existingDLFileVersion.getVersion(), newDLFileVersion.getVersion());
  197. Assert.assertEquals(
  198. existingDLFileVersion.getSize(), newDLFileVersion.getSize());
  199. Assert.assertEquals(
  200. existingDLFileVersion.getChecksum(),
  201. newDLFileVersion.getChecksum());
  202. Assert.assertEquals(
  203. Time.getShortTimestamp(existingDLFileVersion.getLastPublishDate()),
  204. Time.getShortTimestamp(newDLFileVersion.getLastPublishDate()));
  205. Assert.assertEquals(
  206. existingDLFileVersion.getStatus(), newDLFileVersion.getStatus());
  207. Assert.assertEquals(
  208. existingDLFileVersion.getStatusByUserId(),
  209. newDLFileVersion.getStatusByUserId());
  210. Assert.assertEquals(
  211. existingDLFileVersion.getStatusByUserName(),
  212. newDLFileVersion.getStatusByUserName());
  213. Assert.assertEquals(
  214. Time.getShortTimestamp(existingDLFileVersion.getStatusDate()),
  215. Time.getShortTimestamp(newDLFileVersion.getStatusDate()));
  216. }
  217. @Test
  218. public void testCountByUuid() throws Exception {
  219. _persistence.countByUuid("");
  220. _persistence.countByUuid("null");
  221. _persistence.countByUuid((String)null);
  222. }
  223. @Test
  224. public void testCountByUUID_G() throws Exception {
  225. _persistence.countByUUID_G("", RandomTestUtil.nextLong());
  226. _persistence.countByUUID_G("null", 0L);
  227. _persistence.countByUUID_G((String)null, 0L);
  228. }
  229. @Test
  230. public void testCountByUuid_C() throws Exception {
  231. _persistence.countByUuid_C("", RandomTestUtil.nextLong());
  232. _persistence.countByUuid_C("null", 0L);
  233. _persistence.countByUuid_C((String)null, 0L);
  234. }
  235. @Test
  236. public void testCountByCompanyId() throws Exception {
  237. _persistence.countByCompanyId(RandomTestUtil.nextLong());
  238. _persistence.countByCompanyId(0L);
  239. }
  240. @Test
  241. public void testCountByFileEntryId() throws Exception {
  242. _persistence.countByFileEntryId(RandomTestUtil.nextLong());
  243. _persistence.countByFileEntryId(0L);
  244. }
  245. @Test
  246. public void testCountByMimeType() throws Exception {
  247. _persistence.countByMimeType("");
  248. _persistence.countByMimeType("null");
  249. _persistence.countByMimeType((String)null);
  250. }
  251. @Test
  252. public void testCountByC_NotS() throws Exception {
  253. _persistence.countByC_NotS(
  254. RandomTestUtil.nextLong(), RandomTestUtil.nextInt());
  255. _persistence.countByC_NotS(0L, 0);
  256. }
  257. @Test
  258. public void testCountByF_V() throws Exception {
  259. _persistence.countByF_V(RandomTestUtil.nextLong(), "");
  260. _persistence.countByF_V(0L, "null");
  261. _persistence.countByF_V(0L, (String)null);
  262. }
  263. @Test
  264. public void testCountByF_S() throws Exception {
  265. _persistence.countByF_S(
  266. RandomTestUtil.nextLong(), RandomTestUtil.nextInt());
  267. _persistence.countByF_S(0L, 0);
  268. }
  269. @Test
  270. public void testCountByG_F_S() throws Exception {
  271. _persistence.countByG_F_S(
  272. RandomTestUtil.nextLong(), RandomTestUtil.nextLong(),
  273. RandomTestUtil.nextInt());
  274. _persistence.countByG_F_S(0L, 0L, 0);
  275. }
  276. @Test
  277. public void testCountByG_F_T_V() throws Exception {
  278. _persistence.countByG_F_T_V(
  279. RandomTestUtil.nextLong(), RandomTestUtil.nextLong(), "", "");
  280. _persistence.countByG_F_T_V(0L, 0L, "null", "null");
  281. _persistence.countByG_F_T_V(0L, 0L, (String)null, (String)null);
  282. }
  283. @Test
  284. public void testFindByPrimaryKeyExisting() throws Exception {
  285. DLFileVersion newDLFileVersion = addDLFileVersion();
  286. DLFileVersion existingDLFileVersion = _persistence.findByPrimaryKey(
  287. newDLFileVersion.getPrimaryKey());
  288. Assert.assertEquals(existingDLFileVersion, newDLFileVersion);
  289. }
  290. @Test(expected = NoSuchFileVersionException.class)
  291. public void testFindByPrimaryKeyMissing() throws Exception {
  292. long pk = RandomTestUtil.nextLong();
  293. _persistence.findByPrimaryKey(pk);
  294. }
  295. @Test
  296. public void testFindAll() throws Exception {
  297. _persistence.findAll(
  298. QueryUtil.ALL_POS, QueryUtil.ALL_POS, getOrderByComparator());
  299. }
  300. protected OrderByComparator<DLFileVersion> getOrderByComparator() {
  301. return OrderByComparatorFactoryUtil.create(
  302. "DLFileVersion", "mvccVersion", true, "ctCollectionId", true,
  303. "uuid", true, "fileVersionId", true, "groupId", true, "companyId",
  304. true, "userId", true, "userName", true, "createDate", true,
  305. "modifiedDate", true, "repositoryId", true, "folderId", true,
  306. "fileEntryId", true, "treePath", true, "fileName", true,
  307. "extension", true, "mimeType", true, "title", true, "description",
  308. true, "changeLog", true, "fileEntryTypeId", true, "version", true,
  309. "size", true, "checksum", true, "lastPublishDate", true, "status",
  310. true, "statusByUserId", true, "statusByUserName", true,
  311. "statusDate", true);
  312. }
  313. @Test
  314. public void testFetchByPrimaryKeyExisting() throws Exception {
  315. DLFileVersion newDLFileVersion = addDLFileVersion();
  316. DLFileVersion existingDLFileVersion = _persistence.fetchByPrimaryKey(
  317. newDLFileVersion.getPrimaryKey());
  318. Assert.assertEquals(existingDLFileVersion, newDLFileVersion);
  319. }
  320. @Test
  321. public void testFetchByPrimaryKeyMissing() throws Exception {
  322. long pk = RandomTestUtil.nextLong();
  323. DLFileVersion missingDLFileVersion = _persistence.fetchByPrimaryKey(pk);
  324. Assert.assertNull(missingDLFileVersion);
  325. }
  326. @Test
  327. public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
  328. throws Exception {
  329. DLFileVersion newDLFileVersion1 = addDLFileVersion();
  330. DLFileVersion newDLFileVersion2 = addDLFileVersion();
  331. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  332. primaryKeys.add(newDLFileVersion1.getPrimaryKey());
  333. primaryKeys.add(newDLFileVersion2.getPrimaryKey());
  334. Map<Serializable, DLFileVersion> dlFileVersions =
  335. _persistence.fetchByPrimaryKeys(primaryKeys);
  336. Assert.assertEquals(2, dlFileVersions.size());
  337. Assert.assertEquals(
  338. newDLFileVersion1,
  339. dlFileVersions.get(newDLFileVersion1.getPrimaryKey()));
  340. Assert.assertEquals(
  341. newDLFileVersion2,
  342. dlFileVersions.get(newDLFileVersion2.getPrimaryKey()));
  343. }
  344. @Test
  345. public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereNoPrimaryKeysExist()
  346. throws Exception {
  347. long pk1 = RandomTestUtil.nextLong();
  348. long pk2 = RandomTestUtil.nextLong();
  349. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  350. primaryKeys.add(pk1);
  351. primaryKeys.add(pk2);
  352. Map<Serializable, DLFileVersion> dlFileVersions =
  353. _persistence.fetchByPrimaryKeys(primaryKeys);
  354. Assert.assertTrue(dlFileVersions.isEmpty());
  355. }
  356. @Test
  357. public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
  358. throws Exception {
  359. DLFileVersion newDLFileVersion = addDLFileVersion();
  360. long pk = RandomTestUtil.nextLong();
  361. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  362. primaryKeys.add(newDLFileVersion.getPrimaryKey());
  363. primaryKeys.add(pk);
  364. Map<Serializable, DLFileVersion> dlFileVersions =
  365. _persistence.fetchByPrimaryKeys(primaryKeys);
  366. Assert.assertEquals(1, dlFileVersions.size());
  367. Assert.assertEquals(
  368. newDLFileVersion,
  369. dlFileVersions.get(newDLFileVersion.getPrimaryKey()));
  370. }
  371. @Test
  372. public void testFetchByPrimaryKeysWithNoPrimaryKeys() throws Exception {
  373. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  374. Map<Serializable, DLFileVersion> dlFileVersions =
  375. _persistence.fetchByPrimaryKeys(primaryKeys);
  376. Assert.assertTrue(dlFileVersions.isEmpty());
  377. }
  378. @Test
  379. public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
  380. DLFileVersion newDLFileVersion = addDLFileVersion();
  381. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  382. primaryKeys.add(newDLFileVersion.getPrimaryKey());
  383. Map<Serializable, DLFileVersion> dlFileVersions =
  384. _persistence.fetchByPrimaryKeys(primaryKeys);
  385. Assert.assertEquals(1, dlFileVersions.size());
  386. Assert.assertEquals(
  387. newDLFileVersion,
  388. dlFileVersions.get(newDLFileVersion.getPrimaryKey()));
  389. }
  390. @Test
  391. public void testActionableDynamicQuery() throws Exception {
  392. final IntegerWrapper count = new IntegerWrapper();
  393. ActionableDynamicQuery actionableDynamicQuery =
  394. DLFileVersionLocalServiceUtil.getActionableDynamicQuery();
  395. actionableDynamicQuery.setPerformActionMethod(
  396. new ActionableDynamicQuery.PerformActionMethod<DLFileVersion>() {
  397. @Override
  398. public void performAction(DLFileVersion dlFileVersion) {
  399. Assert.assertNotNull(dlFileVersion);
  400. count.increment();
  401. }
  402. });
  403. actionableDynamicQuery.performActions();
  404. Assert.assertEquals(count.getValue(), _persistence.countAll());
  405. }
  406. @Test
  407. public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
  408. DLFileVersion newDLFileVersion = addDLFileVersion();
  409. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  410. DLFileVersion.class, _dynamicQueryClassLoader);
  411. dynamicQuery.add(
  412. RestrictionsFactoryUtil.eq(
  413. "fileVersionId", newDLFileVersion.getFileVersionId()));
  414. List<DLFileVersion> result = _persistence.findWithDynamicQuery(
  415. dynamicQuery);
  416. Assert.assertEquals(1, result.size());
  417. DLFileVersion existingDLFileVersion = result.get(0);
  418. Assert.assertEquals(existingDLFileVersion, newDLFileVersion);
  419. }
  420. @Test
  421. public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
  422. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  423. DLFileVersion.class, _dynamicQueryClassLoader);
  424. dynamicQuery.add(
  425. RestrictionsFactoryUtil.eq(
  426. "fileVersionId", RandomTestUtil.nextLong()));
  427. List<DLFileVersion> result = _persistence.findWithDynamicQuery(
  428. dynamicQuery);
  429. Assert.assertEquals(0, result.size());
  430. }
  431. @Test
  432. public void testDynamicQueryByProjectionExisting() throws Exception {
  433. DLFileVersion newDLFileVersion = addDLFileVersion();
  434. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  435. DLFileVersion.class, _dynamicQueryClassLoader);
  436. dynamicQuery.setProjection(
  437. ProjectionFactoryUtil.property("fileVersionId"));
  438. Object newFileVersionId = newDLFileVersion.getFileVersionId();
  439. dynamicQuery.add(
  440. RestrictionsFactoryUtil.in(
  441. "fileVersionId", new Object[] {newFileVersionId}));
  442. List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
  443. Assert.assertEquals(1, result.size());
  444. Object existingFileVersionId = result.get(0);
  445. Assert.assertEquals(existingFileVersionId, newFileVersionId);
  446. }
  447. @Test
  448. public void testDynamicQueryByProjectionMissing() throws Exception {
  449. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  450. DLFileVersion.class, _dynamicQueryClassLoader);
  451. dynamicQuery.setProjection(
  452. ProjectionFactoryUtil.property("fileVersionId"));
  453. dynamicQuery.add(
  454. RestrictionsFactoryUtil.in(
  455. "fileVersionId", new Object[] {RandomTestUtil.nextLong()}));
  456. List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
  457. Assert.assertEquals(0, result.size());
  458. }
  459. @Test
  460. public void testResetOriginalValues() throws Exception {
  461. DLFileVersion newDLFileVersion = addDLFileVersion();
  462. _persistence.clearCache();
  463. DLFileVersion existingDLFileVersion = _persistence.findByPrimaryKey(
  464. newDLFileVersion.getPrimaryKey());
  465. Assert.assertTrue(
  466. Objects.equals(
  467. existingDLFileVersion.getUuid(),
  468. ReflectionTestUtil.invoke(
  469. existingDLFileVersion, "getOriginalUuid",
  470. new Class<?>[0])));
  471. Assert.assertEquals(
  472. Long.valueOf(existingDLFileVersion.getGroupId()),
  473. ReflectionTestUtil.<Long>invoke(
  474. existingDLFileVersion, "getOriginalGroupId", new Class<?>[0]));
  475. Assert.assertEquals(
  476. Long.valueOf(existingDLFileVersion.getFileEntryId()),
  477. ReflectionTestUtil.<Long>invoke(
  478. existingDLFileVersion, "getOriginalFileEntryId",
  479. new Class<?>[0]));
  480. Assert.assertTrue(
  481. Objects.equals(
  482. existingDLFileVersion.getVersion(),
  483. ReflectionTestUtil.invoke(
  484. existingDLFileVersion, "getOriginalVersion",
  485. new Class<?>[0])));
  486. }
  487. protected DLFileVersion addDLFileVersion() throws Exception {
  488. long pk = RandomTestUtil.nextLong();
  489. DLFileVersion dlFileVersion = _persistence.create(pk);
  490. dlFileVersion.setMvccVersion(RandomTestUtil.nextLong());
  491. dlFileVersion.setCtCollectionId(RandomTestUtil.nextLong());
  492. dlFileVersion.setUuid(RandomTestUtil.randomString());
  493. dlFileVersion.setGroupId(RandomTestUtil.nextLong());
  494. dlFileVersion.setCompanyId(RandomTestUtil.nextLong());
  495. dlFileVersion.setUserId(RandomTestUtil.nextLong());
  496. dlFileVersion.setUserName(RandomTestUtil.randomString());
  497. dlFileVersion.setCreateDate(RandomTestUtil.nextDate());
  498. dlFileVersion.setModifiedDate(RandomTestUtil.nextDate());
  499. dlFileVersion.setRepositoryId(RandomTestUtil.nextLong());
  500. dlFileVersion.setFolderId(RandomTestUtil.nextLong());
  501. dlFileVersion.setFileEntryId(RandomTestUtil.nextLong());
  502. dlFileVersion.setTreePath(RandomTestUtil.randomString());
  503. dlFileVersion.setFileName(RandomTestUtil.randomString());
  504. dlFileVersion.setExtension(RandomTestUtil.randomString());
  505. dlFileVersion.setMimeType(RandomTestUtil.randomString());
  506. dlFileVersion.setTitle(RandomTestUtil.randomString());
  507. dlFileVersion.setDescription(RandomTestUtil.randomString());
  508. dlFileVersion.setChangeLog(RandomTestUtil.randomString());
  509. dlFileVersion.setExtraSettings(RandomTestUtil.randomString());
  510. dlFileVersion.setFileEntryTypeId(RandomTestUtil.nextLong());
  511. dlFileVersion.setVersion(RandomTestUtil.randomString());
  512. dlFileVersion.setSize(RandomTestUtil.nextLong());
  513. dlFileVersion.setChecksum(RandomTestUtil.randomString());
  514. dlFileVersion.setLastPublishDate(RandomTestUtil.nextDate());
  515. dlFileVersion.setStatus(RandomTestUtil.nextInt());
  516. dlFileVersion.setStatusByUserId(RandomTestUtil.nextLong());
  517. dlFileVersion.setStatusByUserName(RandomTestUtil.randomString());
  518. dlFileVersion.setStatusDate(RandomTestUtil.nextDate());
  519. _dlFileVersions.add(_persistence.update(dlFileVersion));
  520. return dlFileVersion;
  521. }
  522. private List<DLFileVersion> _dlFileVersions =
  523. new ArrayList<DLFileVersion>();
  524. private DLFileVersionPersistence _persistence;
  525. private ClassLoader _dynamicQueryClassLoader;
  526. }