@Test public void testFetchByPrimaryKeyExisting() throws Exception { JournalArticleImage newJournalArticleImage = addJournalArticleImage(); JournalArticleImage existingJournalArticleImage = _persistence.fetchByPrimaryKey(newJournalArticleImage.getPrimaryKey()); Assert.assertEquals(existingJournalArticleImage, newJournalArticleImage); }
@Test public void testCreate() throws Exception { long pk = RandomTestUtil.nextLong(); JournalArticleImage journalArticleImage = _persistence.create(pk); Assert.assertNotNull(journalArticleImage); Assert.assertEquals(journalArticleImage.getPrimaryKey(), pk); }
@Test public void testRemove() throws Exception { JournalArticleImage newJournalArticleImage = addJournalArticleImage(); _persistence.remove(newJournalArticleImage); JournalArticleImage existingJournalArticleImage = _persistence.fetchByPrimaryKey(newJournalArticleImage.getPrimaryKey()); Assert.assertNull(existingJournalArticleImage); }
@Test public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception { JournalArticleImage newJournalArticleImage = addJournalArticleImage(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newJournalArticleImage.getPrimaryKey()); Map<Serializable, JournalArticleImage> journalArticleImages = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, journalArticleImages.size()); Assert.assertEquals( newJournalArticleImage, journalArticleImages.get(newJournalArticleImage.getPrimaryKey())); }
/** * Adds the journal article image to the database. Also notifies the appropriate model listeners. * * @param journalArticleImage the journal article image * @return the journal article image that was added * @throws SystemException if a system exception occurred */ @Indexable(type = IndexableType.REINDEX) @Override public JournalArticleImage addJournalArticleImage(JournalArticleImage journalArticleImage) throws SystemException { journalArticleImage.setNew(true); return journalArticleImagePersistence.update(journalArticleImage); }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { JournalArticleImage newJournalArticleImage = addJournalArticleImage(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( JournalArticleImage.class, JournalArticleImage.class.getClassLoader()); dynamicQuery.add( RestrictionsFactoryUtil.eq("articleImageId", newJournalArticleImage.getArticleImageId())); List<JournalArticleImage> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); JournalArticleImage existingJournalArticleImage = result.get(0); Assert.assertEquals(existingJournalArticleImage, newJournalArticleImage); }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception { JournalArticleImage newJournalArticleImage = addJournalArticleImage(); long pk = RandomTestUtil.nextLong(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newJournalArticleImage.getPrimaryKey()); primaryKeys.add(pk); Map<Serializable, JournalArticleImage> journalArticleImages = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(1, journalArticleImages.size()); Assert.assertEquals( newJournalArticleImage, journalArticleImages.get(newJournalArticleImage.getPrimaryKey())); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { JournalArticleImage newJournalArticleImage = addJournalArticleImage(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( JournalArticleImage.class, JournalArticleImage.class.getClassLoader()); dynamicQuery.setProjection(ProjectionFactoryUtil.property("articleImageId")); Object newArticleImageId = newJournalArticleImage.getArticleImageId(); dynamicQuery.add( RestrictionsFactoryUtil.in("articleImageId", new Object[] {newArticleImageId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingArticleImageId = result.get(0); Assert.assertEquals(existingArticleImageId, newArticleImageId); }
@Test public void testResetOriginalValues() throws Exception { if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { return; } JournalArticleImage newJournalArticleImage = addJournalArticleImage(); _persistence.clearCache(); JournalArticleImageModelImpl existingJournalArticleImageModelImpl = (JournalArticleImageModelImpl) _persistence.findByPrimaryKey(newJournalArticleImage.getPrimaryKey()); Assert.assertEquals( existingJournalArticleImageModelImpl.getGroupId(), existingJournalArticleImageModelImpl.getOriginalGroupId()); Assert.assertTrue( Validator.equals( existingJournalArticleImageModelImpl.getArticleId(), existingJournalArticleImageModelImpl.getOriginalArticleId())); AssertUtils.assertEquals( existingJournalArticleImageModelImpl.getVersion(), existingJournalArticleImageModelImpl.getOriginalVersion()); Assert.assertTrue( Validator.equals( existingJournalArticleImageModelImpl.getElInstanceId(), existingJournalArticleImageModelImpl.getOriginalElInstanceId())); Assert.assertTrue( Validator.equals( existingJournalArticleImageModelImpl.getElName(), existingJournalArticleImageModelImpl.getOriginalElName())); Assert.assertTrue( Validator.equals( existingJournalArticleImageModelImpl.getLanguageId(), existingJournalArticleImageModelImpl.getOriginalLanguageId())); }
protected JournalArticleImage addJournalArticleImage() throws Exception { long pk = RandomTestUtil.nextLong(); JournalArticleImage journalArticleImage = _persistence.create(pk); journalArticleImage.setGroupId(RandomTestUtil.nextLong()); journalArticleImage.setArticleId(RandomTestUtil.randomString()); journalArticleImage.setVersion(RandomTestUtil.nextDouble()); journalArticleImage.setElInstanceId(RandomTestUtil.randomString()); journalArticleImage.setElName(RandomTestUtil.randomString()); journalArticleImage.setLanguageId(RandomTestUtil.randomString()); journalArticleImage.setTempImage(RandomTestUtil.randomBoolean()); _journalArticleImages.add(_persistence.update(journalArticleImage)); return journalArticleImage; }
@Test public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception { JournalArticleImage newJournalArticleImage1 = addJournalArticleImage(); JournalArticleImage newJournalArticleImage2 = addJournalArticleImage(); Set<Serializable> primaryKeys = new HashSet<Serializable>(); primaryKeys.add(newJournalArticleImage1.getPrimaryKey()); primaryKeys.add(newJournalArticleImage2.getPrimaryKey()); Map<Serializable, JournalArticleImage> journalArticleImages = _persistence.fetchByPrimaryKeys(primaryKeys); Assert.assertEquals(2, journalArticleImages.size()); Assert.assertEquals( newJournalArticleImage1, journalArticleImages.get(newJournalArticleImage1.getPrimaryKey())); Assert.assertEquals( newJournalArticleImage2, journalArticleImages.get(newJournalArticleImage2.getPrimaryKey())); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); JournalArticleImage newJournalArticleImage = _persistence.create(pk); newJournalArticleImage.setGroupId(RandomTestUtil.nextLong()); newJournalArticleImage.setArticleId(RandomTestUtil.randomString()); newJournalArticleImage.setVersion(RandomTestUtil.nextDouble()); newJournalArticleImage.setElInstanceId(RandomTestUtil.randomString()); newJournalArticleImage.setElName(RandomTestUtil.randomString()); newJournalArticleImage.setLanguageId(RandomTestUtil.randomString()); newJournalArticleImage.setTempImage(RandomTestUtil.randomBoolean()); _journalArticleImages.add(_persistence.update(newJournalArticleImage)); JournalArticleImage existingJournalArticleImage = _persistence.findByPrimaryKey(newJournalArticleImage.getPrimaryKey()); Assert.assertEquals( existingJournalArticleImage.getArticleImageId(), newJournalArticleImage.getArticleImageId()); Assert.assertEquals( existingJournalArticleImage.getGroupId(), newJournalArticleImage.getGroupId()); Assert.assertEquals( existingJournalArticleImage.getArticleId(), newJournalArticleImage.getArticleId()); AssertUtils.assertEquals( existingJournalArticleImage.getVersion(), newJournalArticleImage.getVersion()); Assert.assertEquals( existingJournalArticleImage.getElInstanceId(), newJournalArticleImage.getElInstanceId()); Assert.assertEquals( existingJournalArticleImage.getElName(), newJournalArticleImage.getElName()); Assert.assertEquals( existingJournalArticleImage.getLanguageId(), newJournalArticleImage.getLanguageId()); Assert.assertEquals( existingJournalArticleImage.getTempImage(), newJournalArticleImage.getTempImage()); }