@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); Team newTeam = _persistence.create(pk); newTeam.setMvccVersion(RandomTestUtil.nextLong()); newTeam.setUuid(RandomTestUtil.randomString()); newTeam.setCompanyId(RandomTestUtil.nextLong()); newTeam.setUserId(RandomTestUtil.nextLong()); newTeam.setUserName(RandomTestUtil.randomString()); newTeam.setCreateDate(RandomTestUtil.nextDate()); newTeam.setModifiedDate(RandomTestUtil.nextDate()); newTeam.setGroupId(RandomTestUtil.nextLong()); newTeam.setName(RandomTestUtil.randomString()); newTeam.setDescription(RandomTestUtil.randomString()); newTeam.setLastPublishDate(RandomTestUtil.nextDate()); _teams.add(_persistence.update(newTeam)); Team existingTeam = _persistence.findByPrimaryKey(newTeam.getPrimaryKey()); Assert.assertEquals(existingTeam.getMvccVersion(), newTeam.getMvccVersion()); Assert.assertEquals(existingTeam.getUuid(), newTeam.getUuid()); Assert.assertEquals(existingTeam.getTeamId(), newTeam.getTeamId()); Assert.assertEquals(existingTeam.getCompanyId(), newTeam.getCompanyId()); Assert.assertEquals(existingTeam.getUserId(), newTeam.getUserId()); Assert.assertEquals(existingTeam.getUserName(), newTeam.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingTeam.getCreateDate()), Time.getShortTimestamp(newTeam.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingTeam.getModifiedDate()), Time.getShortTimestamp(newTeam.getModifiedDate())); Assert.assertEquals(existingTeam.getGroupId(), newTeam.getGroupId()); Assert.assertEquals(existingTeam.getName(), newTeam.getName()); Assert.assertEquals(existingTeam.getDescription(), newTeam.getDescription()); Assert.assertEquals( Time.getShortTimestamp(existingTeam.getLastPublishDate()), Time.getShortTimestamp(newTeam.getLastPublishDate())); }
/** * Removes the user groups from the group. * * @param groupId the primary key of the group * @param userGroupIds the primary keys of the user groups */ @Override public void unsetGroupUserGroups(long groupId, long[] userGroupIds) { List<Team> teams = teamPersistence.findByGroupId(groupId); for (Team team : teams) { teamPersistence.removeUserGroups(team.getTeamId(), userGroupIds); } userGroupGroupRoleLocalService.deleteUserGroupGroupRoles(userGroupIds, groupId); groupPersistence.removeUserGroups(groupId, userGroupIds); PermissionCacheUtil.clearCache(); }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { Team newTeam = addTeam(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Team.class, _dynamicQueryClassLoader); dynamicQuery.add(RestrictionsFactoryUtil.eq("teamId", newTeam.getTeamId())); List<Team> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Team existingTeam = result.get(0); Assert.assertEquals(existingTeam, newTeam); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { Team newTeam = addTeam(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Team.class, _dynamicQueryClassLoader); dynamicQuery.setProjection(ProjectionFactoryUtil.property("teamId")); Object newTeamId = newTeam.getTeamId(); dynamicQuery.add(RestrictionsFactoryUtil.in("teamId", new Object[] {newTeamId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingTeamId = result.get(0); Assert.assertEquals(existingTeamId, newTeamId); }