protected void initActionableDynamicQuery(ActionableDynamicQuery actionableDynamicQuery) { actionableDynamicQuery.setBaseLocalService( com.liferay.message.boards.kernel.service.MBDiscussionLocalServiceUtil.getService()); actionableDynamicQuery.setClassLoader(getClassLoader()); actionableDynamicQuery.setModelClass(MBDiscussion.class); actionableDynamicQuery.setPrimaryKeyPropertyName("discussionId"); }
@Override public ActionableDynamicQuery getActionableDynamicQuery() { ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery(); actionableDynamicQuery.setBaseLocalService( com.liferay.message.boards.kernel.service.MBDiscussionLocalServiceUtil.getService()); actionableDynamicQuery.setClassLoader(getClassLoader()); actionableDynamicQuery.setModelClass(MBDiscussion.class); actionableDynamicQuery.setPrimaryKeyPropertyName("discussionId"); return actionableDynamicQuery; }
@Test public void testActionableDynamicQuery() throws Exception { final IntegerWrapper count = new IntegerWrapper(); ActionableDynamicQuery actionableDynamicQuery = MBDiscussionLocalServiceUtil.getActionableDynamicQuery(); actionableDynamicQuery.setPerformActionMethod( new ActionableDynamicQuery.PerformActionMethod<MBDiscussion>() { @Override public void performAction(MBDiscussion mbDiscussion) { Assert.assertNotNull(mbDiscussion); count.increment(); } }); actionableDynamicQuery.performActions(); Assert.assertEquals(count.getValue(), _persistence.countAll()); }