PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/test/persistence-test/src/testIntegration/java/com/liferay/portlet/asset/service/persistence/test/AssetCategoryPersistenceTest.java

http://github.com/liferay/liferay-portal
Java | 720 lines | 513 code | 191 blank | 16 comment | 1 complexity | 503c198343e46c559a70c7fb349ec6c1 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.asset.service.persistence.test;
  15. import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
  16. import com.liferay.asset.kernel.exception.NoSuchCategoryException;
  17. import com.liferay.asset.kernel.model.AssetCategory;
  18. import com.liferay.asset.kernel.service.AssetCategoryLocalServiceUtil;
  19. import com.liferay.asset.kernel.service.persistence.AssetCategoryPersistence;
  20. import com.liferay.asset.kernel.service.persistence.AssetCategoryUtil;
  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 AssetCategoryPersistenceTest {
  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 = AssetCategoryUtil.getPersistence();
  67. Class<?> clazz = _persistence.getClass();
  68. _dynamicQueryClassLoader = clazz.getClassLoader();
  69. }
  70. @After
  71. public void tearDown() throws Exception {
  72. Iterator<AssetCategory> iterator = _assetCategories.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. AssetCategory assetCategory = _persistence.create(pk);
  82. Assert.assertNotNull(assetCategory);
  83. Assert.assertEquals(assetCategory.getPrimaryKey(), pk);
  84. }
  85. @Test
  86. public void testRemove() throws Exception {
  87. AssetCategory newAssetCategory = addAssetCategory();
  88. _persistence.remove(newAssetCategory);
  89. AssetCategory existingAssetCategory = _persistence.fetchByPrimaryKey(
  90. newAssetCategory.getPrimaryKey());
  91. Assert.assertNull(existingAssetCategory);
  92. }
  93. @Test
  94. public void testUpdateNew() throws Exception {
  95. addAssetCategory();
  96. }
  97. @Test
  98. public void testUpdateExisting() throws Exception {
  99. long pk = RandomTestUtil.nextLong();
  100. AssetCategory newAssetCategory = _persistence.create(pk);
  101. newAssetCategory.setMvccVersion(RandomTestUtil.nextLong());
  102. newAssetCategory.setCtCollectionId(RandomTestUtil.nextLong());
  103. newAssetCategory.setUuid(RandomTestUtil.randomString());
  104. newAssetCategory.setExternalReferenceCode(
  105. RandomTestUtil.randomString());
  106. newAssetCategory.setGroupId(RandomTestUtil.nextLong());
  107. newAssetCategory.setCompanyId(RandomTestUtil.nextLong());
  108. newAssetCategory.setUserId(RandomTestUtil.nextLong());
  109. newAssetCategory.setUserName(RandomTestUtil.randomString());
  110. newAssetCategory.setCreateDate(RandomTestUtil.nextDate());
  111. newAssetCategory.setModifiedDate(RandomTestUtil.nextDate());
  112. newAssetCategory.setParentCategoryId(RandomTestUtil.nextLong());
  113. newAssetCategory.setTreePath(RandomTestUtil.randomString());
  114. newAssetCategory.setName(RandomTestUtil.randomString());
  115. newAssetCategory.setTitle(RandomTestUtil.randomString());
  116. newAssetCategory.setDescription(RandomTestUtil.randomString());
  117. newAssetCategory.setVocabularyId(RandomTestUtil.nextLong());
  118. newAssetCategory.setLastPublishDate(RandomTestUtil.nextDate());
  119. _assetCategories.add(_persistence.update(newAssetCategory));
  120. AssetCategory existingAssetCategory = _persistence.findByPrimaryKey(
  121. newAssetCategory.getPrimaryKey());
  122. Assert.assertEquals(
  123. existingAssetCategory.getMvccVersion(),
  124. newAssetCategory.getMvccVersion());
  125. Assert.assertEquals(
  126. existingAssetCategory.getCtCollectionId(),
  127. newAssetCategory.getCtCollectionId());
  128. Assert.assertEquals(
  129. existingAssetCategory.getUuid(), newAssetCategory.getUuid());
  130. Assert.assertEquals(
  131. existingAssetCategory.getExternalReferenceCode(),
  132. newAssetCategory.getExternalReferenceCode());
  133. Assert.assertEquals(
  134. existingAssetCategory.getCategoryId(),
  135. newAssetCategory.getCategoryId());
  136. Assert.assertEquals(
  137. existingAssetCategory.getGroupId(), newAssetCategory.getGroupId());
  138. Assert.assertEquals(
  139. existingAssetCategory.getCompanyId(),
  140. newAssetCategory.getCompanyId());
  141. Assert.assertEquals(
  142. existingAssetCategory.getUserId(), newAssetCategory.getUserId());
  143. Assert.assertEquals(
  144. existingAssetCategory.getUserName(),
  145. newAssetCategory.getUserName());
  146. Assert.assertEquals(
  147. Time.getShortTimestamp(existingAssetCategory.getCreateDate()),
  148. Time.getShortTimestamp(newAssetCategory.getCreateDate()));
  149. Assert.assertEquals(
  150. Time.getShortTimestamp(existingAssetCategory.getModifiedDate()),
  151. Time.getShortTimestamp(newAssetCategory.getModifiedDate()));
  152. Assert.assertEquals(
  153. existingAssetCategory.getParentCategoryId(),
  154. newAssetCategory.getParentCategoryId());
  155. Assert.assertEquals(
  156. existingAssetCategory.getTreePath(),
  157. newAssetCategory.getTreePath());
  158. Assert.assertEquals(
  159. existingAssetCategory.getName(), newAssetCategory.getName());
  160. Assert.assertEquals(
  161. existingAssetCategory.getTitle(), newAssetCategory.getTitle());
  162. Assert.assertEquals(
  163. existingAssetCategory.getDescription(),
  164. newAssetCategory.getDescription());
  165. Assert.assertEquals(
  166. existingAssetCategory.getVocabularyId(),
  167. newAssetCategory.getVocabularyId());
  168. Assert.assertEquals(
  169. Time.getShortTimestamp(existingAssetCategory.getLastPublishDate()),
  170. Time.getShortTimestamp(newAssetCategory.getLastPublishDate()));
  171. }
  172. @Test
  173. public void testCountByUuid() throws Exception {
  174. _persistence.countByUuid("");
  175. _persistence.countByUuid("null");
  176. _persistence.countByUuid((String)null);
  177. }
  178. @Test
  179. public void testCountByUUID_G() throws Exception {
  180. _persistence.countByUUID_G("", RandomTestUtil.nextLong());
  181. _persistence.countByUUID_G("null", 0L);
  182. _persistence.countByUUID_G((String)null, 0L);
  183. }
  184. @Test
  185. public void testCountByUuid_C() throws Exception {
  186. _persistence.countByUuid_C("", RandomTestUtil.nextLong());
  187. _persistence.countByUuid_C("null", 0L);
  188. _persistence.countByUuid_C((String)null, 0L);
  189. }
  190. @Test
  191. public void testCountByGroupId() throws Exception {
  192. _persistence.countByGroupId(RandomTestUtil.nextLong());
  193. _persistence.countByGroupId(0L);
  194. }
  195. @Test
  196. public void testCountByParentCategoryId() throws Exception {
  197. _persistence.countByParentCategoryId(RandomTestUtil.nextLong());
  198. _persistence.countByParentCategoryId(0L);
  199. }
  200. @Test
  201. public void testCountByVocabularyId() throws Exception {
  202. _persistence.countByVocabularyId(RandomTestUtil.nextLong());
  203. _persistence.countByVocabularyId(0L);
  204. }
  205. @Test
  206. public void testCountByG_P() throws Exception {
  207. _persistence.countByG_P(
  208. RandomTestUtil.nextLong(), RandomTestUtil.nextLong());
  209. _persistence.countByG_P(0L, 0L);
  210. }
  211. @Test
  212. public void testCountByG_V() throws Exception {
  213. _persistence.countByG_V(
  214. RandomTestUtil.nextLong(), RandomTestUtil.nextLong());
  215. _persistence.countByG_V(0L, 0L);
  216. }
  217. @Test
  218. public void testCountByG_VArrayable() throws Exception {
  219. _persistence.countByG_V(
  220. RandomTestUtil.nextLong(),
  221. new long[] {RandomTestUtil.nextLong(), 0L});
  222. }
  223. @Test
  224. public void testCountByP_N() throws Exception {
  225. _persistence.countByP_N(RandomTestUtil.nextLong(), "");
  226. _persistence.countByP_N(0L, "null");
  227. _persistence.countByP_N(0L, (String)null);
  228. }
  229. @Test
  230. public void testCountByP_V() throws Exception {
  231. _persistence.countByP_V(
  232. RandomTestUtil.nextLong(), RandomTestUtil.nextLong());
  233. _persistence.countByP_V(0L, 0L);
  234. }
  235. @Test
  236. public void testCountByN_V() throws Exception {
  237. _persistence.countByN_V("", RandomTestUtil.nextLong());
  238. _persistence.countByN_V("null", 0L);
  239. _persistence.countByN_V((String)null, 0L);
  240. }
  241. @Test
  242. public void testCountByG_P_V() throws Exception {
  243. _persistence.countByG_P_V(
  244. RandomTestUtil.nextLong(), RandomTestUtil.nextLong(),
  245. RandomTestUtil.nextLong());
  246. _persistence.countByG_P_V(0L, 0L, 0L);
  247. }
  248. @Test
  249. public void testCountByG_LikeT_V() throws Exception {
  250. _persistence.countByG_LikeT_V(
  251. RandomTestUtil.nextLong(), "", RandomTestUtil.nextLong());
  252. _persistence.countByG_LikeT_V(0L, "null", 0L);
  253. _persistence.countByG_LikeT_V(0L, (String)null, 0L);
  254. }
  255. @Test
  256. public void testCountByG_LikeN_V() throws Exception {
  257. _persistence.countByG_LikeN_V(
  258. RandomTestUtil.nextLong(), "", RandomTestUtil.nextLong());
  259. _persistence.countByG_LikeN_V(0L, "null", 0L);
  260. _persistence.countByG_LikeN_V(0L, (String)null, 0L);
  261. }
  262. @Test
  263. public void testCountByG_LikeN_VArrayable() throws Exception {
  264. _persistence.countByG_LikeN_V(
  265. RandomTestUtil.nextLong(), RandomTestUtil.randomString(),
  266. new long[] {RandomTestUtil.nextLong(), 0L});
  267. }
  268. @Test
  269. public void testCountByP_N_V() throws Exception {
  270. _persistence.countByP_N_V(
  271. RandomTestUtil.nextLong(), "", RandomTestUtil.nextLong());
  272. _persistence.countByP_N_V(0L, "null", 0L);
  273. _persistence.countByP_N_V(0L, (String)null, 0L);
  274. }
  275. @Test
  276. public void testCountByC_ERC() throws Exception {
  277. _persistence.countByC_ERC(RandomTestUtil.nextLong(), "");
  278. _persistence.countByC_ERC(0L, "null");
  279. _persistence.countByC_ERC(0L, (String)null);
  280. }
  281. @Test
  282. public void testFindByPrimaryKeyExisting() throws Exception {
  283. AssetCategory newAssetCategory = addAssetCategory();
  284. AssetCategory existingAssetCategory = _persistence.findByPrimaryKey(
  285. newAssetCategory.getPrimaryKey());
  286. Assert.assertEquals(existingAssetCategory, newAssetCategory);
  287. }
  288. @Test(expected = NoSuchCategoryException.class)
  289. public void testFindByPrimaryKeyMissing() throws Exception {
  290. long pk = RandomTestUtil.nextLong();
  291. _persistence.findByPrimaryKey(pk);
  292. }
  293. @Test
  294. public void testFindAll() throws Exception {
  295. _persistence.findAll(
  296. QueryUtil.ALL_POS, QueryUtil.ALL_POS, getOrderByComparator());
  297. }
  298. @Test
  299. public void testFilterFindByGroupId() throws Exception {
  300. _persistence.filterFindByGroupId(
  301. 0, QueryUtil.ALL_POS, QueryUtil.ALL_POS, getOrderByComparator());
  302. }
  303. protected OrderByComparator<AssetCategory> getOrderByComparator() {
  304. return OrderByComparatorFactoryUtil.create(
  305. "AssetCategory", "mvccVersion", true, "ctCollectionId", true,
  306. "uuid", true, "externalReferenceCode", true, "categoryId", true,
  307. "groupId", true, "companyId", true, "userId", true, "userName",
  308. true, "createDate", true, "modifiedDate", true, "parentCategoryId",
  309. true, "treePath", true, "name", true, "title", true, "description",
  310. true, "vocabularyId", true, "lastPublishDate", true);
  311. }
  312. @Test
  313. public void testFetchByPrimaryKeyExisting() throws Exception {
  314. AssetCategory newAssetCategory = addAssetCategory();
  315. AssetCategory existingAssetCategory = _persistence.fetchByPrimaryKey(
  316. newAssetCategory.getPrimaryKey());
  317. Assert.assertEquals(existingAssetCategory, newAssetCategory);
  318. }
  319. @Test
  320. public void testFetchByPrimaryKeyMissing() throws Exception {
  321. long pk = RandomTestUtil.nextLong();
  322. AssetCategory missingAssetCategory = _persistence.fetchByPrimaryKey(pk);
  323. Assert.assertNull(missingAssetCategory);
  324. }
  325. @Test
  326. public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
  327. throws Exception {
  328. AssetCategory newAssetCategory1 = addAssetCategory();
  329. AssetCategory newAssetCategory2 = addAssetCategory();
  330. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  331. primaryKeys.add(newAssetCategory1.getPrimaryKey());
  332. primaryKeys.add(newAssetCategory2.getPrimaryKey());
  333. Map<Serializable, AssetCategory> assetCategories =
  334. _persistence.fetchByPrimaryKeys(primaryKeys);
  335. Assert.assertEquals(2, assetCategories.size());
  336. Assert.assertEquals(
  337. newAssetCategory1,
  338. assetCategories.get(newAssetCategory1.getPrimaryKey()));
  339. Assert.assertEquals(
  340. newAssetCategory2,
  341. assetCategories.get(newAssetCategory2.getPrimaryKey()));
  342. }
  343. @Test
  344. public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereNoPrimaryKeysExist()
  345. throws Exception {
  346. long pk1 = RandomTestUtil.nextLong();
  347. long pk2 = RandomTestUtil.nextLong();
  348. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  349. primaryKeys.add(pk1);
  350. primaryKeys.add(pk2);
  351. Map<Serializable, AssetCategory> assetCategories =
  352. _persistence.fetchByPrimaryKeys(primaryKeys);
  353. Assert.assertTrue(assetCategories.isEmpty());
  354. }
  355. @Test
  356. public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
  357. throws Exception {
  358. AssetCategory newAssetCategory = addAssetCategory();
  359. long pk = RandomTestUtil.nextLong();
  360. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  361. primaryKeys.add(newAssetCategory.getPrimaryKey());
  362. primaryKeys.add(pk);
  363. Map<Serializable, AssetCategory> assetCategories =
  364. _persistence.fetchByPrimaryKeys(primaryKeys);
  365. Assert.assertEquals(1, assetCategories.size());
  366. Assert.assertEquals(
  367. newAssetCategory,
  368. assetCategories.get(newAssetCategory.getPrimaryKey()));
  369. }
  370. @Test
  371. public void testFetchByPrimaryKeysWithNoPrimaryKeys() throws Exception {
  372. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  373. Map<Serializable, AssetCategory> assetCategories =
  374. _persistence.fetchByPrimaryKeys(primaryKeys);
  375. Assert.assertTrue(assetCategories.isEmpty());
  376. }
  377. @Test
  378. public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
  379. AssetCategory newAssetCategory = addAssetCategory();
  380. Set<Serializable> primaryKeys = new HashSet<Serializable>();
  381. primaryKeys.add(newAssetCategory.getPrimaryKey());
  382. Map<Serializable, AssetCategory> assetCategories =
  383. _persistence.fetchByPrimaryKeys(primaryKeys);
  384. Assert.assertEquals(1, assetCategories.size());
  385. Assert.assertEquals(
  386. newAssetCategory,
  387. assetCategories.get(newAssetCategory.getPrimaryKey()));
  388. }
  389. @Test
  390. public void testActionableDynamicQuery() throws Exception {
  391. final IntegerWrapper count = new IntegerWrapper();
  392. ActionableDynamicQuery actionableDynamicQuery =
  393. AssetCategoryLocalServiceUtil.getActionableDynamicQuery();
  394. actionableDynamicQuery.setPerformActionMethod(
  395. new ActionableDynamicQuery.PerformActionMethod<AssetCategory>() {
  396. @Override
  397. public void performAction(AssetCategory assetCategory) {
  398. Assert.assertNotNull(assetCategory);
  399. count.increment();
  400. }
  401. });
  402. actionableDynamicQuery.performActions();
  403. Assert.assertEquals(count.getValue(), _persistence.countAll());
  404. }
  405. @Test
  406. public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
  407. AssetCategory newAssetCategory = addAssetCategory();
  408. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  409. AssetCategory.class, _dynamicQueryClassLoader);
  410. dynamicQuery.add(
  411. RestrictionsFactoryUtil.eq(
  412. "categoryId", newAssetCategory.getCategoryId()));
  413. List<AssetCategory> result = _persistence.findWithDynamicQuery(
  414. dynamicQuery);
  415. Assert.assertEquals(1, result.size());
  416. AssetCategory existingAssetCategory = result.get(0);
  417. Assert.assertEquals(existingAssetCategory, newAssetCategory);
  418. }
  419. @Test
  420. public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
  421. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  422. AssetCategory.class, _dynamicQueryClassLoader);
  423. dynamicQuery.add(
  424. RestrictionsFactoryUtil.eq(
  425. "categoryId", RandomTestUtil.nextLong()));
  426. List<AssetCategory> result = _persistence.findWithDynamicQuery(
  427. dynamicQuery);
  428. Assert.assertEquals(0, result.size());
  429. }
  430. @Test
  431. public void testDynamicQueryByProjectionExisting() throws Exception {
  432. AssetCategory newAssetCategory = addAssetCategory();
  433. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  434. AssetCategory.class, _dynamicQueryClassLoader);
  435. dynamicQuery.setProjection(
  436. ProjectionFactoryUtil.property("categoryId"));
  437. Object newCategoryId = newAssetCategory.getCategoryId();
  438. dynamicQuery.add(
  439. RestrictionsFactoryUtil.in(
  440. "categoryId", new Object[] {newCategoryId}));
  441. List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
  442. Assert.assertEquals(1, result.size());
  443. Object existingCategoryId = result.get(0);
  444. Assert.assertEquals(existingCategoryId, newCategoryId);
  445. }
  446. @Test
  447. public void testDynamicQueryByProjectionMissing() throws Exception {
  448. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
  449. AssetCategory.class, _dynamicQueryClassLoader);
  450. dynamicQuery.setProjection(
  451. ProjectionFactoryUtil.property("categoryId"));
  452. dynamicQuery.add(
  453. RestrictionsFactoryUtil.in(
  454. "categoryId", new Object[] {RandomTestUtil.nextLong()}));
  455. List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
  456. Assert.assertEquals(0, result.size());
  457. }
  458. @Test
  459. public void testResetOriginalValues() throws Exception {
  460. AssetCategory newAssetCategory = addAssetCategory();
  461. _persistence.clearCache();
  462. AssetCategory existingAssetCategory = _persistence.findByPrimaryKey(
  463. newAssetCategory.getPrimaryKey());
  464. Assert.assertTrue(
  465. Objects.equals(
  466. existingAssetCategory.getUuid(),
  467. ReflectionTestUtil.invoke(
  468. existingAssetCategory, "getOriginalUuid",
  469. new Class<?>[0])));
  470. Assert.assertEquals(
  471. Long.valueOf(existingAssetCategory.getGroupId()),
  472. ReflectionTestUtil.<Long>invoke(
  473. existingAssetCategory, "getOriginalGroupId", new Class<?>[0]));
  474. Assert.assertEquals(
  475. Long.valueOf(existingAssetCategory.getParentCategoryId()),
  476. ReflectionTestUtil.<Long>invoke(
  477. existingAssetCategory, "getOriginalParentCategoryId",
  478. new Class<?>[0]));
  479. Assert.assertTrue(
  480. Objects.equals(
  481. existingAssetCategory.getName(),
  482. ReflectionTestUtil.invoke(
  483. existingAssetCategory, "getOriginalName",
  484. new Class<?>[0])));
  485. Assert.assertEquals(
  486. Long.valueOf(existingAssetCategory.getVocabularyId()),
  487. ReflectionTestUtil.<Long>invoke(
  488. existingAssetCategory, "getOriginalVocabularyId",
  489. new Class<?>[0]));
  490. Assert.assertEquals(
  491. Long.valueOf(existingAssetCategory.getCompanyId()),
  492. ReflectionTestUtil.<Long>invoke(
  493. existingAssetCategory, "getOriginalCompanyId",
  494. new Class<?>[0]));
  495. Assert.assertTrue(
  496. Objects.equals(
  497. existingAssetCategory.getExternalReferenceCode(),
  498. ReflectionTestUtil.invoke(
  499. existingAssetCategory, "getOriginalExternalReferenceCode",
  500. new Class<?>[0])));
  501. }
  502. protected AssetCategory addAssetCategory() throws Exception {
  503. long pk = RandomTestUtil.nextLong();
  504. AssetCategory assetCategory = _persistence.create(pk);
  505. assetCategory.setMvccVersion(RandomTestUtil.nextLong());
  506. assetCategory.setCtCollectionId(RandomTestUtil.nextLong());
  507. assetCategory.setUuid(RandomTestUtil.randomString());
  508. assetCategory.setExternalReferenceCode(RandomTestUtil.randomString());
  509. assetCategory.setGroupId(RandomTestUtil.nextLong());
  510. assetCategory.setCompanyId(RandomTestUtil.nextLong());
  511. assetCategory.setUserId(RandomTestUtil.nextLong());
  512. assetCategory.setUserName(RandomTestUtil.randomString());
  513. assetCategory.setCreateDate(RandomTestUtil.nextDate());
  514. assetCategory.setModifiedDate(RandomTestUtil.nextDate());
  515. assetCategory.setParentCategoryId(RandomTestUtil.nextLong());
  516. assetCategory.setTreePath(RandomTestUtil.randomString());
  517. assetCategory.setName(RandomTestUtil.randomString());
  518. assetCategory.setTitle(RandomTestUtil.randomString());
  519. assetCategory.setDescription(RandomTestUtil.randomString());
  520. assetCategory.setVocabularyId(RandomTestUtil.nextLong());
  521. assetCategory.setLastPublishDate(RandomTestUtil.nextDate());
  522. _assetCategories.add(_persistence.update(assetCategory));
  523. return assetCategory;
  524. }
  525. private List<AssetCategory> _assetCategories =
  526. new ArrayList<AssetCategory>();
  527. private AssetCategoryPersistence _persistence;
  528. private ClassLoader _dynamicQueryClassLoader;
  529. }