@Test public void testExecuteUserIsNobody() { final List<Long> systemAdminIds = new ArrayList<Long>(); context.checking(new Expectations() { { allowing(activity).getActor(); will(returnValue(activityActorStream)); oneOf(activityActorStream).getType(); will(returnValue(EntityType.PERSON)); oneOf(activityActorStream).getUniqueIdentifier(); will(returnValue("notSmithers")); allowing(activity).getDestinationStream(); will(returnValue(activityDestinationStream)); allowing(activityDestinationStream).getType(); will(returnValue(EntityType.GROUP)); allowing(activityDestinationStream).getUniqueIdentifier(); will(returnValue(groupShortName)); oneOf(groupByShortNameDAO).fetchId(groupShortName); will(returnValue(groupId)); oneOf(groupAccessMapper).hasGroupCoordinatorAccessRecursively(userPersonId, groupId); will(returnValue(false)); oneOf(systemAdminIdsMapper).execute(null); will(returnValue(systemAdminIds)); oneOf(activity).setDeletable(false); } }); sut.execute(userAcctId, userPersonId, activity); context.assertIsSatisfied(); }
public void execute(final String inUserAccountId, final Long inUserPersonId, final ActivityDTO inActivity) { if (inUserAccountId == null || inUserPersonId == null) { inActivity.setDeletable(false); return; } if (inActivity.getActor().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getActor().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getDestinationStream().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserGroupCoordinator(inUserPersonId, inActivity.getDestinationStream() .getUniqueIdentifier())) { inActivity.setDeletable(true); return; } List<Long> adminIds = systemAdminIdsMapper.execute(null); if (adminIds.contains(inUserPersonId)) { inActivity.setDeletable(true); return; } inActivity.setDeletable(false); }
ActivityDeletePropertyStrategy { public void execute(final String inUserAccountId, final Long inUserPersonId, final ActivityDTO inActivity) { if (inUserAccountId == null || inUserPersonId == null) { inActivity.setDeletable(false); return; } if (inActivity.getActor().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getActor().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getDestinationStream().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserGroupCoordinator(inUserPersonId, inActivity.getDestinationStream() .getUniqueIdentifier())) { inActivity.setDeletable(true); return; } List<Long> adminIds = systemAdminIdsMapper.execute(null); if (adminIds.contains(inUserPersonId)) { inActivity.setDeletable(true); return; } inActivity.setDeletable(false); } }
ActivityDeletePropertyStrategy { public void execute(final String inUserAccountId, final Long inUserPersonId, final ActivityDTO inActivity) { if (inUserAccountId == null || inUserPersonId == null) { inActivity.setDeletable(false); return; } if (inActivity.getActor().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getActor().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getDestinationStream().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserGroupCoordinator(inUserPersonId, inActivity.getDestinationStream() .getUniqueIdentifier())) { inActivity.setDeletable(true); return; } List<Long> adminIds = systemAdminIdsMapper.execute(null); if (adminIds.contains(inUserPersonId)) { inActivity.setDeletable(true); return; } inActivity.setDeletable(false); } ActivityDeletePropertyStrategy(final GetDomainGroupsByShortNames inGroupByShortNameDAO,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinatorIdsDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsMapper); }
ActivityDeletePropertyStrategy { public void execute(final String inUserAccountId, final Long inUserPersonId, final ActivityDTO inActivity) { if (inUserAccountId == null || inUserPersonId == null) { inActivity.setDeletable(false); return; } if (inActivity.getActor().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getActor().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getDestinationStream().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserGroupCoordinator(inUserPersonId, inActivity.getDestinationStream() .getUniqueIdentifier())) { inActivity.setDeletable(true); return; } List<Long> adminIds = systemAdminIdsMapper.execute(null); if (adminIds.contains(inUserPersonId)) { inActivity.setDeletable(true); return; } inActivity.setDeletable(false); } ActivityDeletePropertyStrategy(final GetDomainGroupsByShortNames inGroupByShortNameDAO,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinatorIdsDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsMapper); void execute(final String inUserAccountId, final Long inUserPersonId, final ActivityDTO inActivity); }
ActivityDeletePropertyStrategy { public void execute(final String inUserAccountId, final Long inUserPersonId, final ActivityDTO inActivity) { if (inUserAccountId == null || inUserPersonId == null) { inActivity.setDeletable(false); return; } if (inActivity.getActor().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getActor().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.PERSON && inUserAccountId.equalsIgnoreCase(inActivity.getDestinationStream().getUniqueIdentifier())) { inActivity.setDeletable(true); return; } if (inActivity.getDestinationStream().getType() == EntityType.GROUP && isCurrentUserGroupCoordinator(inUserPersonId, inActivity.getDestinationStream() .getUniqueIdentifier())) { inActivity.setDeletable(true); return; } List<Long> adminIds = systemAdminIdsMapper.execute(null); if (adminIds.contains(inUserPersonId)) { inActivity.setDeletable(true); return; } inActivity.setDeletable(false); } ActivityDeletePropertyStrategy(final GetDomainGroupsByShortNames inGroupByShortNameDAO,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinatorIdsDAO,
            final DomainMapper<Serializable, List<Long>> inSystemAdminIdsMapper); void execute(final String inUserAccountId, final Long inUserPersonId, final ActivityDTO inActivity);  }