@Test public void testSetFileParticipantsFromParentFolderUpdatesExistingParticipantRoleAddsNotExistingParticipantRemovesExistingParticipant() { String addParticipantLdapId = "addUserId"; String addParticipantType = "write"; String updateParticipantLdapId = "updateUserId"; String updateParticipantType = "read"; String removeParticipantLdapId = "removeUserId"; String removeParticipantType = "no-access"; List<AcmParticipant> folderParticipants = new ArrayList<>(); AcmParticipant addFolderParticipant = new AcmParticipant(); addFolderParticipant.setParticipantLdapId(addParticipantLdapId); addFolderParticipant.setParticipantType(addParticipantType); folderParticipants.add(addFolderParticipant); AcmParticipant updateFolderParticipant = new AcmParticipant(); updateFolderParticipant.setParticipantLdapId(updateParticipantLdapId); updateFolderParticipant.setParticipantType(updateParticipantType); folderParticipants.add(updateFolderParticipant); AcmFolder folder = new AcmFolder(); folder.setParticipants(folderParticipants); List<AcmParticipant> fileParticipants = new ArrayList<>(); AcmParticipant updateFileParticipant = new AcmParticipant(); updateFileParticipant.setParticipantLdapId(updateParticipantLdapId); updateFileParticipant.setParticipantType("someRole"); fileParticipants.add(updateFileParticipant); AcmParticipant deleteFileParticipant = new AcmParticipant(); deleteFileParticipant.setParticipantLdapId(removeParticipantLdapId); deleteFileParticipant.setParticipantType(removeParticipantType); fileParticipants.add(deleteFileParticipant); EcmFile file = new EcmFile(); file.setParticipants(fileParticipants); file.setFolder(folder); expect(mockFileDao.save(file)).andReturn(file); replayAll(); EcmFile returnedFile = fileParticipantService.setFileParticipantsFromParentFolder(file); verifyAll(); assertEquals(2, returnedFile.getParticipants().size()); for (AcmParticipant acmParticipant : returnedFile.getParticipants()) { if (acmParticipant.getParticipantLdapId().equals(addParticipantLdapId)) { assertEquals(addParticipantType, acmParticipant.getParticipantType()); } else if (acmParticipant.getParticipantLdapId().equals(updateParticipantLdapId)) { assertEquals(updateParticipantType, acmParticipant.getParticipantType()); } else { fail("ParticipantLdapId not expected in the file's participants!"); } } }
@Transactional(rollbackFor = Exception.class) public EcmFile setFileParticipantsFromParentFolder(EcmFile file) { if (file.getFolder() == null) { throw new IllegalStateException("File doesn't have parent folder!"); } setFileParticipants(file, file.getFolder().getParticipants()); file.setModified(new Date()); return getFileDao().save(file); }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public EcmFile setFileParticipantsFromParentFolder(EcmFile file) { if (file.getFolder() == null) { throw new IllegalStateException("File doesn't have parent folder!"); } setFileParticipants(file, file.getFolder().getParticipants()); file.setModified(new Date()); return getFileDao().save(file); } }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public EcmFile setFileParticipantsFromParentFolder(EcmFile file) { if (file.getFolder() == null) { throw new IllegalStateException("File doesn't have parent folder!"); } setFileParticipants(file, file.getFolder().getParticipants()); file.setModified(new Date()); return getFileDao().save(file); }  }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public EcmFile setFileParticipantsFromParentFolder(EcmFile file) { if (file.getFolder() == null) { throw new IllegalStateException("File doesn't have parent folder!"); } setFileParticipants(file, file.getFolder().getParticipants()); file.setModified(new Date()); return getFileDao().save(file); }  @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 { @Transactional(rollbackFor = Exception.class) public EcmFile setFileParticipantsFromParentFolder(EcmFile file) { if (file.getFolder() == null) { throw new IllegalStateException("File doesn't have parent folder!"); } setFileParticipants(file, file.getFolder().getParticipants()); file.setModified(new Date()); return getFileDao().save(file); }  @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);  }