@Test public void testSetFileParticipantsSetsParticipantsCorrectlyOnFile() throws AcmParticipantsException { final Long objectId = 1L; final String participantLdapId1 = "userId1"; final String participantType1 = "write"; final String participantLdapId2 = "userId2"; final String participantType2 = "read"; List<AcmParticipant> participants = new ArrayList<>(); AcmParticipant participant1 = new AcmParticipant(); participant1.setParticipantLdapId(participantLdapId1); participant1.setParticipantType(participantType1); participants.add(participant1); AcmParticipant participant2 = new AcmParticipant(); participant2.setParticipantLdapId(participantLdapId2); participant2.setParticipantType(participantType2); participants.add(participant2); EcmFile file = new EcmFile(); expect(mockFileDao.find(objectId)).andReturn(file); expect(mockFileDao.save(file)).andReturn(file); EntityManager em = mock(EntityManager.class); expect(mockFileDao.getEm()).andReturn(em); em.flush(); expectLastCall(); replayAll(); List<AcmParticipant> returnedParticipants = fileParticipantService.setFileParticipants(objectId, participants); verifyAll(); assertEquals(2, returnedParticipants.size()); for (AcmParticipant participant : returnedParticipants) { switch (participant.getParticipantLdapId()) { case participantLdapId1: assertEquals(participantType1, participant.getParticipantType()); break; case participantLdapId2: assertEquals(participantType2, participant.getParticipantType()); break; default: fail("Unknown participantLdapId: [" + participant.getParticipantLdapId() + "] returned!"); break; } } }
@Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); EcmFile file = getFileDao().find(objectId); setFileParticipants(file, participants); file.setModified(new Date()); EcmFile savedFile = getFileDao().save(file); getFileDao().getEm().flush(); return savedFile.getParticipants(); }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); EcmFile file = getFileDao().find(objectId); setFileParticipants(file, participants); file.setModified(new Date()); EcmFile savedFile = getFileDao().save(file); getFileDao().getEm().flush(); return savedFile.getParticipants(); } }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); EcmFile file = getFileDao().find(objectId); setFileParticipants(file, participants); file.setModified(new Date()); EcmFile savedFile = getFileDao().save(file); getFileDao().getEm().flush(); return savedFile.getParticipants(); }  }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); EcmFile file = getFileDao().find(objectId); setFileParticipants(file, participants); file.setModified(new Date()); EcmFile savedFile = getFileDao().save(file); getFileDao().getEm().flush(); return savedFile.getParticipants(); }  @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 List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); EcmFile file = getFileDao().find(objectId); setFileParticipants(file, participants); file.setModified(new Date()); EcmFile savedFile = getFileDao().save(file); getFileDao().getEm().flush(); return savedFile.getParticipants(); }  @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);  }