@Test public void testNotAllPass() { final ArrayList<ActivityDTO> activityDTOs = new ArrayList<ActivityDTO>(Arrays.asList(activity1, activity2)); final ArrayList<Long> activityIds = new ArrayList<Long>(Arrays.asList(4L, 5L)); context.checking(new Expectations() { { allowing(actionContext).getParams(); will(returnValue(activityIds)); allowing(actionContext).getPrincipal(); will(returnValue(principal)); allowing(principal).getId(); will(returnValue(principalId)); allowing(activityMapper).execute(activityIds); will(returnValue(activityDTOs)); allowing(activity1).getActor(); will(returnValue(actor1)); allowing(activity2).getActor(); will(returnValue(actor2)); allowing(activity1).getId(); will(returnValue(4L)); allowing(activity2).getId(); will(returnValue(5L)); allowing(actor1).getId(); will(returnValue(principalId)); allowing(actor2).getId(); will(returnValue(principalId + 1)); } }); sut.validate(actionContext); assertEquals(1, activityIds.size()); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") @Override public void validate(final PrincipalActionContext inActionContext) { List<Long> activityIds = (List<Long>) inActionContext.getParams(); Long principalId = inActionContext.getPrincipal().getId(); List<ActivityDTO> activities = activityMapper.execute(activityIds); for (ActivityDTO activity : activities) { if (activity.getActor().getId() != principalId) { activityIds.remove(activity.getId()); } } }
DeleteUserActivityValidation implements ValidationStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public void validate(final PrincipalActionContext inActionContext) { List<Long> activityIds = (List<Long>) inActionContext.getParams(); Long principalId = inActionContext.getPrincipal().getId(); List<ActivityDTO> activities = activityMapper.execute(activityIds); for (ActivityDTO activity : activities) { if (activity.getActor().getId() != principalId) { activityIds.remove(activity.getId()); } } } }
DeleteUserActivityValidation implements ValidationStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public void validate(final PrincipalActionContext inActionContext) { List<Long> activityIds = (List<Long>) inActionContext.getParams(); Long principalId = inActionContext.getPrincipal().getId(); List<ActivityDTO> activities = activityMapper.execute(activityIds); for (ActivityDTO activity : activities) { if (activity.getActor().getId() != principalId) { activityIds.remove(activity.getId()); } } } DeleteUserActivityValidation(final DomainMapper<List<Long>, List<ActivityDTO>> inActivityMapper); }
DeleteUserActivityValidation implements ValidationStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public void validate(final PrincipalActionContext inActionContext) { List<Long> activityIds = (List<Long>) inActionContext.getParams(); Long principalId = inActionContext.getPrincipal().getId(); List<ActivityDTO> activities = activityMapper.execute(activityIds); for (ActivityDTO activity : activities) { if (activity.getActor().getId() != principalId) { activityIds.remove(activity.getId()); } } } DeleteUserActivityValidation(final DomainMapper<List<Long>, List<ActivityDTO>> inActivityMapper); @SuppressWarnings("unchecked") @Override void validate(final PrincipalActionContext inActionContext); }
DeleteUserActivityValidation implements ValidationStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public void validate(final PrincipalActionContext inActionContext) { List<Long> activityIds = (List<Long>) inActionContext.getParams(); Long principalId = inActionContext.getPrincipal().getId(); List<ActivityDTO> activities = activityMapper.execute(activityIds); for (ActivityDTO activity : activities) { if (activity.getActor().getId() != principalId) { activityIds.remove(activity.getId()); } } } DeleteUserActivityValidation(final DomainMapper<List<Long>, List<ActivityDTO>> inActivityMapper); @SuppressWarnings("unchecked") @Override void validate(final PrincipalActionContext inActionContext);  }