Search in sources :

Example 26 with Roster

use of com.liferay.roster.model.Roster in project liferay-ide by liferay.

the class RosterPersistenceTest method testDynamicQueryByProjectionExisting.

@Test
public void testDynamicQueryByProjectionExisting() throws Exception {
    Roster newRoster = addRoster();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Roster.class, _dynamicQueryClassLoader);
    dynamicQuery.setProjection(ProjectionFactoryUtil.property("rosterId"));
    Object newRosterId = newRoster.getRosterId();
    dynamicQuery.add(RestrictionsFactoryUtil.in("rosterId", new Object[] { newRosterId }));
    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    Object existingRosterId = result.get(0);
    Assert.assertEquals(existingRosterId, newRosterId);
}
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)

Example 27 with Roster

use of com.liferay.roster.model.Roster in project liferay-ide by liferay.

the class RosterPersistenceTest method testFetchByPrimaryKeyExisting.

@Test
public void testFetchByPrimaryKeyExisting() throws Exception {
    Roster newRoster = addRoster();
    Roster existingRoster = _persistence.fetchByPrimaryKey(newRoster.getPrimaryKey());
    Assert.assertEquals(existingRoster, newRoster);
}
Also used : Roster(com.liferay.roster.model.Roster) Test(org.junit.Test)

Example 28 with Roster

use of com.liferay.roster.model.Roster in project liferay-ide by liferay.

the class RosterPersistenceTest method testFetchByPrimaryKeyMissing.

@Test
public void testFetchByPrimaryKeyMissing() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Roster missingRoster = _persistence.fetchByPrimaryKey(pk);
    Assert.assertNull(missingRoster);
}
Also used : Roster(com.liferay.roster.model.Roster) Test(org.junit.Test)

Example 29 with Roster

use of com.liferay.roster.model.Roster in project liferay-ide by liferay.

the class RosterPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist.

@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist() throws Exception {
    Roster newRoster1 = addRoster();
    Roster newRoster2 = addRoster();
    Set<Serializable> primaryKeys = new HashSet<Serializable>();
    primaryKeys.add(newRoster1.getPrimaryKey());
    primaryKeys.add(newRoster2.getPrimaryKey());
    Map<Serializable, Roster> rosters = _persistence.fetchByPrimaryKeys(primaryKeys);
    Assert.assertEquals(2, rosters.size());
    Assert.assertEquals(newRoster1, rosters.get(newRoster1.getPrimaryKey()));
    Assert.assertEquals(newRoster2, rosters.get(newRoster2.getPrimaryKey()));
}
Also used : Serializable(java.io.Serializable) Roster(com.liferay.roster.model.Roster) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 30 with Roster

use of com.liferay.roster.model.Roster in project liferay-ide by liferay.

the class RosterPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist.

@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception {
    Roster newRoster = addRoster();
    long pk = RandomTestUtil.nextLong();
    Set<Serializable> primaryKeys = new HashSet<Serializable>();
    primaryKeys.add(newRoster.getPrimaryKey());
    primaryKeys.add(pk);
    Map<Serializable, Roster> rosters = _persistence.fetchByPrimaryKeys(primaryKeys);
    Assert.assertEquals(1, rosters.size());
    Assert.assertEquals(newRoster, rosters.get(newRoster.getPrimaryKey()));
}
Also used : Serializable(java.io.Serializable) Roster(com.liferay.roster.model.Roster) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Roster (com.liferay.roster.model.Roster)34 Test (org.junit.Test)13 NoSuchRosterException (com.liferay.roster.exception.NoSuchRosterException)12 StringBundler (com.liferay.portal.kernel.util.StringBundler)10 Session (com.liferay.portal.kernel.dao.orm.Session)8 Query (com.liferay.portal.kernel.dao.orm.Query)6 RosterImpl (com.liferay.roster.model.impl.RosterImpl)6 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)4 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)4 Serializable (java.io.Serializable)4 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)3 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)3 HashSet (java.util.HashSet)3 IntegerWrapper (com.liferay.portal.kernel.util.IntegerWrapper)1 HashMap (java.util.HashMap)1 List (java.util.List)1