Search in sources :

Example 1 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class ClubPersistenceTest method testDynamicQueryByProjectionMissing.

@Test
public void testDynamicQueryByProjectionMissing() throws Exception {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Club.class, _dynamicQueryClassLoader);
    dynamicQuery.setProjection(ProjectionFactoryUtil.property("clubId"));
    dynamicQuery.add(RestrictionsFactoryUtil.in("clubId", new Object[] { RandomTestUtil.nextLong() }));
    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(0, result.size());
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 2 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class RosterMemberPersistenceTest method testDynamicQueryByProjectionExisting.

@Test
public void testDynamicQueryByProjectionExisting() throws Exception {
    RosterMember newRosterMember = addRosterMember();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(RosterMember.class, _dynamicQueryClassLoader);
    dynamicQuery.setProjection(ProjectionFactoryUtil.property("rosterMemberId"));
    Object newRosterMemberId = newRosterMember.getRosterMemberId();
    dynamicQuery.add(RestrictionsFactoryUtil.in("rosterMemberId", new Object[] { newRosterMemberId }));
    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    Object existingRosterMemberId = result.get(0);
    Assert.assertEquals(existingRosterMemberId, newRosterMemberId);
}
Also used : RosterMember(com.liferay.roster.model.RosterMember) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 3 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class RosterMemberPersistenceTest method testDynamicQueryByPrimaryKeyMissing.

@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(RosterMember.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("rosterMemberId", RandomTestUtil.nextLong()));
    List<RosterMember> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(0, result.size());
}
Also used : RosterMember(com.liferay.roster.model.RosterMember) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 4 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class RosterMemberPersistenceTest method testDynamicQueryByProjectionMissing.

@Test
public void testDynamicQueryByProjectionMissing() throws Exception {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(RosterMember.class, _dynamicQueryClassLoader);
    dynamicQuery.setProjection(ProjectionFactoryUtil.property("rosterMemberId"));
    dynamicQuery.add(RestrictionsFactoryUtil.in("rosterMemberId", new Object[] { RandomTestUtil.nextLong() }));
    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(0, result.size());
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 5 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-ide by liferay.

the class RosterPersistenceTest method testDynamicQueryByPrimaryKeyExisting.

@Test
public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    Roster newRoster = addRoster();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Roster.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("rosterId", newRoster.getRosterId()));
    List<Roster> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    Roster existingRoster = result.get(0);
    Assert.assertEquals(existingRoster, newRoster);
}
Also used : Roster(com.liferay.roster.model.Roster) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Aggregations

DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)23 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)21 Test (org.junit.Test)16 Foo (com.liferay.blade.samples.servicebuilder.model.Foo)4 Property (com.liferay.portal.kernel.dao.orm.Property)3 Document (com.liferay.portal.kernel.search.Document)3 Club (com.liferay.roster.model.Club)3 Roster (com.liferay.roster.model.Roster)3 RosterMember (com.liferay.roster.model.RosterMember)3 Conjunction (com.liferay.portal.kernel.dao.orm.Conjunction)2 Criterion (com.liferay.portal.kernel.dao.orm.Criterion)2 Disjunction (com.liferay.portal.kernel.dao.orm.Disjunction)2 Junction (com.liferay.portal.kernel.dao.orm.Junction)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 KBArticleActionableDynamicQuery (com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery)1