Search in sources :

Example 11 with Roster

use of com.liferay.roster.model.Roster 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)

Example 12 with Roster

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

the class RosterPersistenceTest method testActionableDynamicQuery.

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();
    ActionableDynamicQuery actionableDynamicQuery = RosterLocalServiceUtil.getActionableDynamicQuery();
    actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Roster>() {

        @Override
        public void performAction(Roster roster) {
            Assert.assertNotNull(roster);
            count.increment();
        }
    });
    actionableDynamicQuery.performActions();
    Assert.assertEquals(count.getValue(), _persistence.countAll());
}
Also used : Roster(com.liferay.roster.model.Roster) IntegerWrapper(com.liferay.portal.kernel.util.IntegerWrapper) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Test(org.junit.Test)

Example 13 with Roster

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

the class RosterPersistenceTest method testDynamicQueryByPrimaryKeyMissing.

@Test
public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Roster.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("rosterId", RandomTestUtil.nextLong()));
    List<Roster> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(0, result.size());
}
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 14 with Roster

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

the class RosterPersistenceTest method testUpdateExisting.

@Test
public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Roster newRoster = _persistence.create(pk);
    newRoster.setUuid(RandomTestUtil.randomString());
    newRoster.setCreateDate(RandomTestUtil.nextDate());
    newRoster.setModifiedDate(RandomTestUtil.nextDate());
    newRoster.setClubId(RandomTestUtil.nextLong());
    newRoster.setName(RandomTestUtil.randomString());
    _rosters.add(_persistence.update(newRoster));
    Roster existingRoster = _persistence.findByPrimaryKey(newRoster.getPrimaryKey());
    Assert.assertEquals(existingRoster.getUuid(), newRoster.getUuid());
    Assert.assertEquals(existingRoster.getRosterId(), newRoster.getRosterId());
    Assert.assertEquals(Time.getShortTimestamp(existingRoster.getCreateDate()), Time.getShortTimestamp(newRoster.getCreateDate()));
    Assert.assertEquals(Time.getShortTimestamp(existingRoster.getModifiedDate()), Time.getShortTimestamp(newRoster.getModifiedDate()));
    Assert.assertEquals(existingRoster.getClubId(), newRoster.getClubId());
    Assert.assertEquals(existingRoster.getName(), newRoster.getName());
}
Also used : Roster(com.liferay.roster.model.Roster) Test(org.junit.Test)

Example 15 with Roster

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

the class RosterModelImpl method toModel.

/**
 * Converts the soap model instance into a normal model instance.
 *
 * @param soapModel the soap model instance to convert
 * @return the normal model instance
 */
public static Roster toModel(RosterSoap soapModel) {
    if (soapModel == null) {
        return null;
    }
    Roster model = new RosterImpl();
    model.setUuid(soapModel.getUuid());
    model.setRosterId(soapModel.getRosterId());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setClubId(soapModel.getClubId());
    model.setName(soapModel.getName());
    return model;
}
Also used : Roster(com.liferay.roster.model.Roster)

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