@Test(expected = IllegalStateException.class) public void testGetFolderParticipantsFromAssignedObjectThrowsIllegalStateExceptionWhenAnAssignedObjectParticipantTypeIsNotMapped() { String mappedParticipantType = "someType"; expect(ecmFileConfigMock.getFileParticipant("write")).andReturn(mappedParticipantType).anyTimes(); expect(ecmFileConfigMock.getFileParticipant("read")).andReturn(null).anyTimes(); expect(ecmFileConfigMock.getFileParticipant("no-access")).andReturn(null).anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-write")).andReturn(null).anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-read")).andReturn(null).anyTimes(); expect(ecmFileConfigMock.getFileParticipant("*")).andReturn("*").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-no-access")).andReturn(null).anyTimes(); List<AcmParticipant> assignedObjectParticipants = new ArrayList<>(); AcmParticipant participantWithMappedType = new AcmParticipant(); participantWithMappedType.setParticipantLdapId("userId"); participantWithMappedType.setParticipantType(mappedParticipantType); assignedObjectParticipants.add(participantWithMappedType); AcmParticipant participantWithNotMappedType = new AcmParticipant(); participantWithNotMappedType.setParticipantLdapId("userId"); participantWithNotMappedType.setParticipantType("unmappedType"); assignedObjectParticipants.add(participantWithNotMappedType); replayAll(); fileParticipantService.getFolderParticipantsFromAssignedObject(assignedObjectParticipants); verifyAll(); fail("IllegalStateException should have been thrown!"); }
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);  }