ProjectService { public Attachment addProjectAttachment(String projectId, Attachment attachment, UserEntity savingUser) { ProjectEntity projectEntity = loadProjectEntity(projectId); projectEntity.addAttachmentAllowed(savingUser); AttachmentValue attachmentStored = new AttachmentValue(attachment.getName(), attachment.getType()); attachmentStored = projectAttachmentRepository.storeAttachment(attachmentStored, attachment.getPayload()); projectEntity.addAttachment(attachmentStored); projectRepository.save(projectEntity); return Attachment.asResponseWithoutPayload(attachmentStored, projectEntity); } @Autowired  ProjectService(ProjectRepository projectRepository,
                          PledgeRepository pledgeRepository,
                          UserRepository userRepository,
                          FinancingRoundRepository financingRoundRepository,
                          UserNotificationService userNotificationService,
                          FinancingRoundService financingRoundService,
                          LikeRepository likeRepository,
                          ProjectAttachmentRepository projectAttachmentRepository); Project getProject(String projectId, UserEntity requestingUser); List<Project> getProjects(UserEntity requestingUser); Project addProject(Project project, UserEntity creator); Project modifyProjectStatus(String projectId, ProjectStatus newStatusToApply, UserEntity requestingUser); Project modifyProjectMasterdata(String projectId, Project modifiedProject, UserEntity requestingUser); void pledge(String projectId, UserEntity userEntity, Pledge pledge); Attachment addProjectAttachment(String projectId, Attachment attachment, UserEntity savingUser); Attachment loadProjectAttachment(String projectId, Attachment attachmentRequest); void deleteProjectAttachment(String projectId, Attachment attachmentRequest, UserEntity deletingUser); void likeProject(String projectId, UserEntity user); void unlikeProject(String projectId, UserEntity user);  }
@Test(expected = ResourceNotFoundException.class) public void addAttachment_ThrowsResourceNotFoundExOnNotExistingProject() throws Exception { final String projectId = "test_ID"; when(projectRepository.findOne(projectId)).thenReturn(null); projectService.addProjectAttachment(projectId, aStoringRequestAttachment(), user("blub")); }