@Test void testAdd() { EntityIdentity entityIdentity = new EntityIdentity("MyQuestionnaire", "id"); when(entity.getString("owner")).thenReturn("username"); when(entity.getIdValue()).thenReturn("id"); when(entity.getEntityType()).thenReturn(entityType); when(entityType.getId()).thenReturn("MyQuestionnaire"); AclImpl acl = new AclImpl(entityIdentity, 1, authorizationStrategy, auditLogger); acl.insertAce(0, PermissionSet.WRITE, new PrincipalSid("otheruser"), true); when(mutableAclService.readAclById(entityIdentity)).thenReturn(acl); ownershipDecorator.add(entity); verify(delegate).add(entity); verify(mutableAclService).updateAcl(acl); PrincipalSid ownerSid = new PrincipalSid("username"); assertEquals(ownerSid, acl.getOwner()); assertEquals(1, acl.getEntries().size()); AccessControlEntry ace = acl.getEntries().get(0); assertEquals(ownerSid, ace.getSid()); assertEquals(WRITE, ace.getPermission()); assertTrue(ace.isGranting()); }
@Override public Integer add(Stream<Entity> entities) { List<Entity> batch = entities.collect(toList()); Integer result = super.add(batch.stream()); batch.forEach(this::assignToOwner); return result; }
OwnershipDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Integer add(Stream<Entity> entities) { List<Entity> batch = entities.collect(toList()); Integer result = super.add(batch.stream()); batch.forEach(this::assignToOwner); return result; } }
OwnershipDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Integer add(Stream<Entity> entities) { List<Entity> batch = entities.collect(toList()); Integer result = super.add(batch.stream()); batch.forEach(this::assignToOwner); return result; } OwnershipDecorator(
      Repository<Entity> delegateRepository,
      MutableAclService mutableAclService,
      String ownerAttributeName); }
OwnershipDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Integer add(Stream<Entity> entities) { List<Entity> batch = entities.collect(toList()); Integer result = super.add(batch.stream()); batch.forEach(this::assignToOwner); return result; } OwnershipDecorator(
      Repository<Entity> delegateRepository,
      MutableAclService mutableAclService,
      String ownerAttributeName); @Override Integer add(Stream<Entity> entities); @Override void add(Entity entity); }
OwnershipDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Integer add(Stream<Entity> entities) { List<Entity> batch = entities.collect(toList()); Integer result = super.add(batch.stream()); batch.forEach(this::assignToOwner); return result; } OwnershipDecorator(
      Repository<Entity> delegateRepository,
      MutableAclService mutableAclService,
      String ownerAttributeName); @Override Integer add(Stream<Entity> entities); @Override void add(Entity entity);  }