@Test public void testGetFolderParticipantsFromAssignedObjectReturnsCorrectParticipants() { List<AcmParticipant> assignedObjectParticipants = new ArrayList<>(); AcmParticipant participantAssignee = new AcmParticipant(); participantAssignee.setParticipantLdapId("userId1"); participantAssignee.setParticipantType("assignee"); assignedObjectParticipants.add(participantAssignee); AcmParticipant participantOwner = new AcmParticipant(); participantOwner.setParticipantLdapId("userId2"); participantOwner.setParticipantType("owner"); assignedObjectParticipants.add(participantOwner); AcmParticipant participantReader = new AcmParticipant(); participantReader.setParticipantLdapId("userId3"); participantReader.setParticipantType("reader"); assignedObjectParticipants.add(participantReader); AcmParticipant participantFollower = new AcmParticipant(); participantFollower.setParticipantLdapId("userId4"); participantFollower.setParticipantType("follower"); assignedObjectParticipants.add(participantFollower); AcmParticipant participantNoAccess = new AcmParticipant(); participantNoAccess.setParticipantLdapId("userId5"); participantNoAccess.setParticipantType("No Access"); assignedObjectParticipants.add(participantNoAccess); AcmParticipant participantOwningGroup = new AcmParticipant(); participantOwningGroup.setParticipantLdapId("groupId1"); participantOwningGroup.setParticipantType("owning group"); assignedObjectParticipants.add(participantOwningGroup); AcmParticipant participantFollowerGroup = new AcmParticipant(); participantFollowerGroup.setParticipantLdapId("groupId2"); participantFollowerGroup.setParticipantType("follower group"); assignedObjectParticipants.add(participantFollowerGroup); expect(ecmFileConfigMock.getFileParticipant("write")).andReturn("assignee,owner").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("read")).andReturn("follower,reader").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("no-access")).andReturn("No Access").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-write")).andReturn("owning group").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-read")).andReturn("follower group").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("*")).andReturn("*").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-no-access")).andReturn("owning group").anyTimes(); replayAll(); List<AcmParticipant> returnedFileParticipants = fileParticipantService .getFolderParticipantsFromAssignedObject(assignedObjectParticipants); verifyAll(); assertEquals(7, returnedFileParticipants.size()); for (AcmParticipant participant : returnedFileParticipants) { switch (participant.getParticipantLdapId()) { case "userId1": assertEquals("write", participant.getParticipantType()); break; case "userId2": assertEquals("write", participant.getParticipantType()); break; case "userId3": assertEquals("read", participant.getParticipantType()); break; case "userId4": assertEquals("read", participant.getParticipantType()); break; case "userId5": assertEquals("no-access", participant.getParticipantType()); break; case "groupId1": assertEquals("group-write", participant.getParticipantType()); break; case "groupId2": assertEquals("group-read", participant.getParticipantType()); break; default: fail("Unknown participantLdapId: [" + participant.getParticipantLdapId() + "] returned!"); break; } } }
public List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants) { List<AcmParticipant> participants = new ArrayList<>(); assignedObjectParticipants.forEach(parentObjectParticipant -> { AcmParticipant participant = new AcmParticipant(); participant.setParticipantType( getDocumentParticipantTypeFromAssignedObjectParticipantType(parentObjectParticipant.getParticipantType())); participant.setParticipantLdapId(parentObjectParticipant.getParticipantLdapId()); if (participants.stream() .noneMatch(existingParticipant -> existingParticipant.getParticipantLdapId().equals(participant.getParticipantLdapId()))) { participants.add(participant); } }); return participants; }
EcmFileParticipantService { public List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants) { List<AcmParticipant> participants = new ArrayList<>(); assignedObjectParticipants.forEach(parentObjectParticipant -> { AcmParticipant participant = new AcmParticipant(); participant.setParticipantType( getDocumentParticipantTypeFromAssignedObjectParticipantType(parentObjectParticipant.getParticipantType())); participant.setParticipantLdapId(parentObjectParticipant.getParticipantLdapId()); if (participants.stream() .noneMatch(existingParticipant -> existingParticipant.getParticipantLdapId().equals(participant.getParticipantLdapId()))) { participants.add(participant); } }); return participants; } }
EcmFileParticipantService { public List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants) { List<AcmParticipant> participants = new ArrayList<>(); assignedObjectParticipants.forEach(parentObjectParticipant -> { AcmParticipant participant = new AcmParticipant(); participant.setParticipantType( getDocumentParticipantTypeFromAssignedObjectParticipantType(parentObjectParticipant.getParticipantType())); participant.setParticipantLdapId(parentObjectParticipant.getParticipantLdapId()); if (participants.stream() .noneMatch(existingParticipant -> existingParticipant.getParticipantLdapId().equals(participant.getParticipantLdapId()))) { participants.add(participant); } }); return participants; }  }
EcmFileParticipantService { public List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants) { List<AcmParticipant> participants = new ArrayList<>(); assignedObjectParticipants.forEach(parentObjectParticipant -> { AcmParticipant participant = new AcmParticipant(); participant.setParticipantType( getDocumentParticipantTypeFromAssignedObjectParticipantType(parentObjectParticipant.getParticipantType())); participant.setParticipantLdapId(parentObjectParticipant.getParticipantLdapId()); if (participants.stream() .noneMatch(existingParticipant -> existingParticipant.getParticipantLdapId().equals(participant.getParticipantLdapId()))) { participants.add(participant); } }); return participants; }  @Transactional(rollbackFor = Exception.class) EcmFile setFileParticipantsFromParentFolder(EcmFile file); @Transactional(rollbackFor = Exception.class) void setFolderParticipantsFromParentFolder(AcmFolder folder); List<AcmParticipant> getFolderParticipantsFromParentAssignedObject(String objectType, Long objectId); List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants); @Transactional(rollbackFor = Exception.class) void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants,
            List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); AcmParticipantService getParticipantService(); void setParticipantService(AcmParticipantService participantService); AcmFolderService getFolderService(); void setFolderService(AcmFolderService folderService); EcmFileParticipantServiceHelper getFileParticipantServiceHelper(); void setFileParticipantServiceHelper(EcmFileParticipantServiceHelper fileParticipantServiceHelper); AcmFolderDao getFolderDao(); void setFolderDao(AcmFolderDao folderDao); EcmFileConfig getEcmFileConfig(); void setEcmFileConfig(EcmFileConfig ecmFileConfig); }
EcmFileParticipantService { public List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants) { List<AcmParticipant> participants = new ArrayList<>(); assignedObjectParticipants.forEach(parentObjectParticipant -> { AcmParticipant participant = new AcmParticipant(); participant.setParticipantType( getDocumentParticipantTypeFromAssignedObjectParticipantType(parentObjectParticipant.getParticipantType())); participant.setParticipantLdapId(parentObjectParticipant.getParticipantLdapId()); if (participants.stream() .noneMatch(existingParticipant -> existingParticipant.getParticipantLdapId().equals(participant.getParticipantLdapId()))) { participants.add(participant); } }); return participants; }  @Transactional(rollbackFor = Exception.class) EcmFile setFileParticipantsFromParentFolder(EcmFile file); @Transactional(rollbackFor = Exception.class) void setFolderParticipantsFromParentFolder(AcmFolder folder); List<AcmParticipant> getFolderParticipantsFromParentAssignedObject(String objectType, Long objectId); List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants); @Transactional(rollbackFor = Exception.class) void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants,
            List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); AcmParticipantService getParticipantService(); void setParticipantService(AcmParticipantService participantService); AcmFolderService getFolderService(); void setFolderService(AcmFolderService folderService); EcmFileParticipantServiceHelper getFileParticipantServiceHelper(); void setFileParticipantServiceHelper(EcmFileParticipantServiceHelper fileParticipantServiceHelper); AcmFolderDao getFolderDao(); void setFolderDao(AcmFolderDao folderDao); EcmFileConfig getEcmFileConfig(); void setEcmFileConfig(EcmFileConfig ecmFileConfig);  }