@Test public void testExecuteUserIsParentOrgCoord() { final List<Long> admins = new ArrayList<Long>(); admins.add(userPersonId); context.checking(new Expectations() { { allowing(parentActivity).getDestinationStream(); will(returnValue(activityDestinationStream)); allowing(activityDestinationStream).getType(); will(returnValue(EntityType.PERSON)); allowing(activityDestinationStream).getUniqueIdentifier(); will(returnValue("notSmithers")); oneOf(adminIdsMapper).execute(null); will(returnValue(admins)); allowing(getPersonIdByAccountIdMapper).execute(userAcctId); will(returnValue(userPersonId)); oneOf(parentActivity).isDeletable(); will(returnValue(false)); oneOf(comment).setDeletable(true); } }); sut.execute(userAcctId, parentActivity, comments); context.assertIsSatisfied(); }
public void execute(final String inUserAccountId, final ActivityDTO inParentActivity, final List<CommentDTO> inComments) { if (inUserAccountId == null) { setAll(inComments, false); return; } if (inParentActivity.isDeletable()) { setAll(inComments, true); return; } if (inParentActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } Long userPersonId = getUserPersonIdByAccountId(inUserAccountId); if (inParentActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserCoordinator(userPersonId, inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } List<Long> administratorIds = systemAdminIdsMapper.execute(null); if (administratorIds.contains(userPersonId)) { setAll(inComments, true); return; } for (CommentDTO comment : inComments) { comment.setDeletable(comment.getAuthorId() == userPersonId); } }
CommentDeletePropertyStrategy { public void execute(final String inUserAccountId, final ActivityDTO inParentActivity, final List<CommentDTO> inComments) { if (inUserAccountId == null) { setAll(inComments, false); return; } if (inParentActivity.isDeletable()) { setAll(inComments, true); return; } if (inParentActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } Long userPersonId = getUserPersonIdByAccountId(inUserAccountId); if (inParentActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserCoordinator(userPersonId, inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } List<Long> administratorIds = systemAdminIdsMapper.execute(null); if (administratorIds.contains(userPersonId)) { setAll(inComments, true); return; } for (CommentDTO comment : inComments) { comment.setDeletable(comment.getAuthorId() == userPersonId); } } }
CommentDeletePropertyStrategy { public void execute(final String inUserAccountId, final ActivityDTO inParentActivity, final List<CommentDTO> inComments) { if (inUserAccountId == null) { setAll(inComments, false); return; } if (inParentActivity.isDeletable()) { setAll(inComments, true); return; } if (inParentActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } Long userPersonId = getUserPersonIdByAccountId(inUserAccountId); if (inParentActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserCoordinator(userPersonId, inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } List<Long> administratorIds = systemAdminIdsMapper.execute(null); if (administratorIds.contains(userPersonId)) { setAll(inComments, true); return; } for (CommentDTO comment : inComments) { comment.setDeletable(comment.getAuthorId() == userPersonId); } } CommentDeletePropertyStrategy(final DomainMapper<String, Long> inGetPersonIdByAccountIdMapper,
            final GetDomainGroupsByShortNames inGroupByShortNameDAO,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupAccessMapper,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsMapper); }
CommentDeletePropertyStrategy { public void execute(final String inUserAccountId, final ActivityDTO inParentActivity, final List<CommentDTO> inComments) { if (inUserAccountId == null) { setAll(inComments, false); return; } if (inParentActivity.isDeletable()) { setAll(inComments, true); return; } if (inParentActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } Long userPersonId = getUserPersonIdByAccountId(inUserAccountId); if (inParentActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserCoordinator(userPersonId, inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } List<Long> administratorIds = systemAdminIdsMapper.execute(null); if (administratorIds.contains(userPersonId)) { setAll(inComments, true); return; } for (CommentDTO comment : inComments) { comment.setDeletable(comment.getAuthorId() == userPersonId); } } CommentDeletePropertyStrategy(final DomainMapper<String, Long> inGetPersonIdByAccountIdMapper,
            final GetDomainGroupsByShortNames inGroupByShortNameDAO,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupAccessMapper,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsMapper); void execute(final String inUserAccountId, final ActivityDTO inParentActivity,
            final List<CommentDTO> inComments); }
CommentDeletePropertyStrategy { public void execute(final String inUserAccountId, final ActivityDTO inParentActivity, final List<CommentDTO> inComments) { if (inUserAccountId == null) { setAll(inComments, false); return; } if (inParentActivity.isDeletable()) { setAll(inComments, true); return; } if (inParentActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } Long userPersonId = getUserPersonIdByAccountId(inUserAccountId); if (inParentActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserCoordinator(userPersonId, inParentActivity.getDestinationStream().getUniqueIdentifier())) { setAll(inComments, true); return; } List<Long> administratorIds = systemAdminIdsMapper.execute(null); if (administratorIds.contains(userPersonId)) { setAll(inComments, true); return; } for (CommentDTO comment : inComments) { comment.setDeletable(comment.getAuthorId() == userPersonId); } } CommentDeletePropertyStrategy(final DomainMapper<String, Long> inGetPersonIdByAccountIdMapper,
            final GetDomainGroupsByShortNames inGroupByShortNameDAO,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupAccessMapper,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsMapper); void execute(final String inUserAccountId, final ActivityDTO inParentActivity,
            final List<CommentDTO> inComments);  }