BelongsToRoleFunction implements DDMExpressionFunction.Function1<String[], Boolean>,
			   DDMExpressionParameterAccessorAware { @Override public Boolean apply(String[] roles) { if (_ddmExpressionParameterAccessor == null) { return false; } try { boolean belongsTo; long companyId = _ddmExpressionParameterAccessor.getCompanyId(); long groupId = _ddmExpressionParameterAccessor.getGroupId(); long userId = _ddmExpressionParameterAccessor.getUserId(); for (String roleName : roles) { Role role = roleLocalService.fetchRole(companyId, roleName); if (role == null) { continue; } if (userId == 0) { if (roleName.equals("Guest")) { return true; } continue; } if (role.getType() == RoleConstants.TYPE_REGULAR) { belongsTo = userLocalService.hasRoleUser( companyId, roleName, userId, true); } else { belongsTo = userGroupRoleLocalService.hasUserGroupRole( userId, groupId, roleName, true); } if (belongsTo) { return true; } } } catch (PortalException portalException) { if (_log.isDebugEnabled()) { _log.debug(portalException, portalException); } } return false; } BelongsToRoleFunction(
		RoleLocalService roleLocalService,
		UserGroupRoleLocalService userGroupRoleLocalService,
		UserLocalService userLocalService); @Override Boolean apply(String[] roles); @Override String getName(); @Override void setDDMExpressionParameterAccessor(
		DDMExpressionParameterAccessor ddmExpressionParameterAccessor); static final String NAME; }
@Test public void testNullObserver() { Assert.assertFalse(_belongsToRoleFunction.apply(new String[] {"test"})); }