use of com.liferay.roster.model.RosterMember in project liferay-ide by liferay.
the class RosterMemberPersistenceTest method testCreate.
@Test
public void testCreate() throws Exception {
long pk = RandomTestUtil.nextLong();
RosterMember rosterMember = _persistence.create(pk);
Assert.assertNotNull(rosterMember);
Assert.assertEquals(rosterMember.getPrimaryKey(), pk);
}
use of com.liferay.roster.model.RosterMember in project liferay-ide by liferay.
the class RosterMemberPersistenceTest method testUpdateExisting.
@Test
public void testUpdateExisting() throws Exception {
long pk = RandomTestUtil.nextLong();
RosterMember newRosterMember = _persistence.create(pk);
newRosterMember.setUuid(RandomTestUtil.randomString());
newRosterMember.setCreateDate(RandomTestUtil.nextDate());
newRosterMember.setModifiedDate(RandomTestUtil.nextDate());
newRosterMember.setRosterId(RandomTestUtil.nextLong());
newRosterMember.setContactId(RandomTestUtil.nextLong());
_rosterMembers.add(_persistence.update(newRosterMember));
RosterMember existingRosterMember = _persistence.findByPrimaryKey(newRosterMember.getPrimaryKey());
Assert.assertEquals(existingRosterMember.getUuid(), newRosterMember.getUuid());
Assert.assertEquals(existingRosterMember.getRosterMemberId(), newRosterMember.getRosterMemberId());
Assert.assertEquals(Time.getShortTimestamp(existingRosterMember.getCreateDate()), Time.getShortTimestamp(newRosterMember.getCreateDate()));
Assert.assertEquals(Time.getShortTimestamp(existingRosterMember.getModifiedDate()), Time.getShortTimestamp(newRosterMember.getModifiedDate()));
Assert.assertEquals(existingRosterMember.getRosterId(), newRosterMember.getRosterId());
Assert.assertEquals(existingRosterMember.getContactId(), newRosterMember.getContactId());
}
use of com.liferay.roster.model.RosterMember in project liferay-ide by liferay.
the class RosterMemberPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist.
@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception {
RosterMember newRosterMember = addRosterMember();
long pk = RandomTestUtil.nextLong();
Set<Serializable> primaryKeys = new HashSet<Serializable>();
primaryKeys.add(newRosterMember.getPrimaryKey());
primaryKeys.add(pk);
Map<Serializable, RosterMember> rosterMembers = _persistence.fetchByPrimaryKeys(primaryKeys);
Assert.assertEquals(1, rosterMembers.size());
Assert.assertEquals(newRosterMember, rosterMembers.get(newRosterMember.getPrimaryKey()));
}
use of com.liferay.roster.model.RosterMember in project liferay-ide by liferay.
the class RosterMemberPersistenceTest method testActionableDynamicQuery.
@Test
public void testActionableDynamicQuery() throws Exception {
final IntegerWrapper count = new IntegerWrapper();
ActionableDynamicQuery actionableDynamicQuery = RosterMemberLocalServiceUtil.getActionableDynamicQuery();
actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<RosterMember>() {
@Override
public void performAction(RosterMember rosterMember) {
Assert.assertNotNull(rosterMember);
count.increment();
}
});
actionableDynamicQuery.performActions();
Assert.assertEquals(count.getValue(), _persistence.countAll());
}
use of com.liferay.roster.model.RosterMember in project liferay-ide by liferay.
the class RosterMemberPersistenceImpl method fetchByPrimaryKeys.
@Override
public Map<Serializable, RosterMember> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
if (primaryKeys.isEmpty()) {
return Collections.emptyMap();
}
Map<Serializable, RosterMember> map = new HashMap<Serializable, RosterMember>();
if (primaryKeys.size() == 1) {
Iterator<Serializable> iterator = primaryKeys.iterator();
Serializable primaryKey = iterator.next();
RosterMember rosterMember = fetchByPrimaryKey(primaryKey);
if (rosterMember != null) {
map.put(primaryKey, rosterMember);
}
return map;
}
Set<Serializable> uncachedPrimaryKeys = null;
for (Serializable primaryKey : primaryKeys) {
RosterMember rosterMember = (RosterMember) entityCache.getResult(RosterMemberModelImpl.ENTITY_CACHE_ENABLED, RosterMemberImpl.class, primaryKey);
if (rosterMember == null) {
if (uncachedPrimaryKeys == null) {
uncachedPrimaryKeys = new HashSet<Serializable>();
}
uncachedPrimaryKeys.add(primaryKey);
} else {
map.put(primaryKey, rosterMember);
}
}
if (uncachedPrimaryKeys == null) {
return map;
}
StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);
query.append(_SQL_SELECT_ROSTERMEMBER_WHERE_PKS_IN);
for (Serializable primaryKey : uncachedPrimaryKeys) {
query.append(String.valueOf(primaryKey));
query.append(StringPool.COMMA);
}
query.setIndex(query.index() - 1);
query.append(StringPool.CLOSE_PARENTHESIS);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
for (RosterMember rosterMember : (List<RosterMember>) q.list()) {
map.put(rosterMember.getPrimaryKeyObj(), rosterMember);
cacheResult(rosterMember);
uncachedPrimaryKeys.remove(rosterMember.getPrimaryKeyObj());
}
for (Serializable primaryKey : uncachedPrimaryKeys) {
entityCache.putResult(RosterMemberModelImpl.ENTITY_CACHE_ENABLED, RosterMemberImpl.class, primaryKey, _nullRosterMember);
}
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
return map;
}
Aggregations