@Test public void testPublicStickyActivityMissing() { final Long activityId = 888L; final ActivityDTO activity = context.mock(ActivityDTO.class); groupFoundExpectations(); context.checking(new Expectations() { { allowing(dgmv).getStickyActivityId(); will(returnValue(activityId)); allowing(dgmv).isPublic(); will(returnValue(true)); oneOf(dgmv).setRestricted(false); oneOf(activityMapper).execute(activityId); will(returnValue(null)); } }); PrincipalActionContext pac = TestContextCreator.createPrincipalActionContext(shortname, null, USER_ID); sut.execute(pac); context.assertIsSatisfied(); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String shortName = (String) inActionContext.getParams(); log.debug("shortName = " + shortName); DomainGroupModelView result = groupByShortNameMapper.fetchUniqueResult(shortName); log.debug("result = " + result); if (result != null) { result.setBannerEntityId(result.getId()); if (!isAccessPermitted(inActionContext.getPrincipal(), result)) { DomainGroupModelView restricted = new DomainGroupModelView(); restricted.setRestricted(true); restricted.setEntityId(result.getId()); restricted.setBannerId(result.getBannerId()); restricted.setName(result.getName()); restricted.setShortName(result.getShortName()); restricted.setAvatarId(result.getAvatarId()); return restricted; } else { result.setRestricted(false); if (result.getStickyActivityId() != null) { final ActivityDTO activity = activityMapper.execute(result.getStickyActivityId()); if (activity != null) { result.setStickyActivity(activity); activity.setShareable(result.isPublic()); } } } result.setCoordinators(personModelViewsByIdMapper.execute(groupCoordinatorIdsByGroupIdMapper.execute(result .getId()))); result.setCapabilities(getCapabilities(result.getId())); } return result; }
GetDomainGroupModelViewByShortNameExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String shortName = (String) inActionContext.getParams(); log.debug("shortName = " + shortName); DomainGroupModelView result = groupByShortNameMapper.fetchUniqueResult(shortName); log.debug("result = " + result); if (result != null) { result.setBannerEntityId(result.getId()); if (!isAccessPermitted(inActionContext.getPrincipal(), result)) { DomainGroupModelView restricted = new DomainGroupModelView(); restricted.setRestricted(true); restricted.setEntityId(result.getId()); restricted.setBannerId(result.getBannerId()); restricted.setName(result.getName()); restricted.setShortName(result.getShortName()); restricted.setAvatarId(result.getAvatarId()); return restricted; } else { result.setRestricted(false); if (result.getStickyActivityId() != null) { final ActivityDTO activity = activityMapper.execute(result.getStickyActivityId()); if (activity != null) { result.setStickyActivity(activity); activity.setShareable(result.isPublic()); } } } result.setCoordinators(personModelViewsByIdMapper.execute(groupCoordinatorIdsByGroupIdMapper.execute(result .getId()))); result.setCapabilities(getCapabilities(result.getId())); } return result; } }
GetDomainGroupModelViewByShortNameExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String shortName = (String) inActionContext.getParams(); log.debug("shortName = " + shortName); DomainGroupModelView result = groupByShortNameMapper.fetchUniqueResult(shortName); log.debug("result = " + result); if (result != null) { result.setBannerEntityId(result.getId()); if (!isAccessPermitted(inActionContext.getPrincipal(), result)) { DomainGroupModelView restricted = new DomainGroupModelView(); restricted.setRestricted(true); restricted.setEntityId(result.getId()); restricted.setBannerId(result.getBannerId()); restricted.setName(result.getName()); restricted.setShortName(result.getShortName()); restricted.setAvatarId(result.getAvatarId()); return restricted; } else { result.setRestricted(false); if (result.getStickyActivityId() != null) { final ActivityDTO activity = activityMapper.execute(result.getStickyActivityId()); if (activity != null) { result.setStickyActivity(activity); activity.setShareable(result.isPublic()); } } } result.setCoordinators(personModelViewsByIdMapper.execute(groupCoordinatorIdsByGroupIdMapper.execute(result .getId()))); result.setCapabilities(getCapabilities(result.getId())); } return result; } GetDomainGroupModelViewByShortNameExecution(final GetDomainGroupsByShortNames inGroupByShortNameMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinatorIdsDAO,
            final DomainMapper<Long, List<Long>> inGroupFollowerIdsMapper,
            final DomainMapper<Long, List<Long>> inGroupCoordinatorIdsByGroupIdMapper,
            final DomainMapper<List<Long>, List<PersonModelView>> inPersonModelViewsByIdMapper,
            final DomainMapper<FindByIdRequest, DomainGroup> inGroupEntityMapper,
            final DomainMapper<Long, ActivityDTO> inActivityMapper); }
GetDomainGroupModelViewByShortNameExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String shortName = (String) inActionContext.getParams(); log.debug("shortName = " + shortName); DomainGroupModelView result = groupByShortNameMapper.fetchUniqueResult(shortName); log.debug("result = " + result); if (result != null) { result.setBannerEntityId(result.getId()); if (!isAccessPermitted(inActionContext.getPrincipal(), result)) { DomainGroupModelView restricted = new DomainGroupModelView(); restricted.setRestricted(true); restricted.setEntityId(result.getId()); restricted.setBannerId(result.getBannerId()); restricted.setName(result.getName()); restricted.setShortName(result.getShortName()); restricted.setAvatarId(result.getAvatarId()); return restricted; } else { result.setRestricted(false); if (result.getStickyActivityId() != null) { final ActivityDTO activity = activityMapper.execute(result.getStickyActivityId()); if (activity != null) { result.setStickyActivity(activity); activity.setShareable(result.isPublic()); } } } result.setCoordinators(personModelViewsByIdMapper.execute(groupCoordinatorIdsByGroupIdMapper.execute(result .getId()))); result.setCapabilities(getCapabilities(result.getId())); } return result; } GetDomainGroupModelViewByShortNameExecution(final GetDomainGroupsByShortNames inGroupByShortNameMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinatorIdsDAO,
            final DomainMapper<Long, List<Long>> inGroupFollowerIdsMapper,
            final DomainMapper<Long, List<Long>> inGroupCoordinatorIdsByGroupIdMapper,
            final DomainMapper<List<Long>, List<PersonModelView>> inPersonModelViewsByIdMapper,
            final DomainMapper<FindByIdRequest, DomainGroup> inGroupEntityMapper,
            final DomainMapper<Long, ActivityDTO> inActivityMapper); @Override Serializable execute(final PrincipalActionContext inActionContext); }
GetDomainGroupModelViewByShortNameExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { String shortName = (String) inActionContext.getParams(); log.debug("shortName = " + shortName); DomainGroupModelView result = groupByShortNameMapper.fetchUniqueResult(shortName); log.debug("result = " + result); if (result != null) { result.setBannerEntityId(result.getId()); if (!isAccessPermitted(inActionContext.getPrincipal(), result)) { DomainGroupModelView restricted = new DomainGroupModelView(); restricted.setRestricted(true); restricted.setEntityId(result.getId()); restricted.setBannerId(result.getBannerId()); restricted.setName(result.getName()); restricted.setShortName(result.getShortName()); restricted.setAvatarId(result.getAvatarId()); return restricted; } else { result.setRestricted(false); if (result.getStickyActivityId() != null) { final ActivityDTO activity = activityMapper.execute(result.getStickyActivityId()); if (activity != null) { result.setStickyActivity(activity); activity.setShareable(result.isPublic()); } } } result.setCoordinators(personModelViewsByIdMapper.execute(groupCoordinatorIdsByGroupIdMapper.execute(result .getId()))); result.setCapabilities(getCapabilities(result.getId())); } return result; } GetDomainGroupModelViewByShortNameExecution(final GetDomainGroupsByShortNames inGroupByShortNameMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinatorIdsDAO,
            final DomainMapper<Long, List<Long>> inGroupFollowerIdsMapper,
            final DomainMapper<Long, List<Long>> inGroupCoordinatorIdsByGroupIdMapper,
            final DomainMapper<List<Long>, List<PersonModelView>> inPersonModelViewsByIdMapper,
            final DomainMapper<FindByIdRequest, DomainGroup> inGroupEntityMapper,
            final DomainMapper<Long, ActivityDTO> inActivityMapper); @Override Serializable execute(final PrincipalActionContext inActionContext);  }