@Test void testDeleteAll1() { Package package1 = mock(Package.class); Package package2 = mock(Package.class); Package package3 = mock(Package.class); Package package4 = mock(Package.class); when(package1.getId()).thenReturn("1"); when(package2.getId()).thenReturn("2"); when(package3.getId()).thenReturn("3"); when(package4.getId()).thenReturn("4"); when(package1.getParent()).thenReturn(package3); when(package2.getParent()).thenReturn(package4); doReturn(true).when(userPermissionEvaluator).hasPermission(new PackageIdentity("3"), UPDATE); doReturn(false).when(userPermissionEvaluator).hasPermission(new PackageIdentity("4"), UPDATE); doReturn(package1).when(delegateRepository).findOneById("1"); doReturn(package2).when(delegateRepository).findOneById("2"); Stream<Object> ids = Stream.of("1", "2"); repo.deleteAll(ids); @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Object>> captor = ArgumentCaptor.forClass(Stream.class); verify(delegateRepository).deleteAll(captor.capture()); assertEquals(singletonList("1"), captor.getValue().collect(toList())); }
@Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } PackageRepositorySecurityDecorator(
      Repository<Package> delegateRepository,
      MutableAclService mutableAclService,
      UserPermissionEvaluator userPermissionEvaluator); }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } PackageRepositorySecurityDecorator(
      Repository<Package> delegateRepository,
      MutableAclService mutableAclService,
      UserPermissionEvaluator userPermissionEvaluator); @Override boolean isActionPermitted(Package updatedPack, Action action); @Override boolean isActionPermitted(Object id, Action action); @Override void throwPermissionException(Package pack, Action action); @Override Package findOneById(Object id); @Override void add(Package pack); @Override void update(Package pack); @Override Integer add(Stream<Package> packages); @Override void createAcl(Package pack); @Override void deleteAcl(Object id); @Override void deleteAcl(Package pack); @Override void updateAcl(Package pack); }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } PackageRepositorySecurityDecorator(
      Repository<Package> delegateRepository,
      MutableAclService mutableAclService,
      UserPermissionEvaluator userPermissionEvaluator); @Override boolean isActionPermitted(Package updatedPack, Action action); @Override boolean isActionPermitted(Object id, Action action); @Override void throwPermissionException(Package pack, Action action); @Override Package findOneById(Object id); @Override void add(Package pack); @Override void update(Package pack); @Override Integer add(Stream<Package> packages); @Override void createAcl(Package pack); @Override void deleteAcl(Object id); @Override void deleteAcl(Package pack); @Override void updateAcl(Package pack);  }