test_class.declarator: PROJECT_ID = "project"
test_class.modifier: private final
test_class.original_string: private final String PROJECT_ID = "project";
test_class.type: String
test_class.var_name: PROJECT_ID
test_class.declarator: APPLICATION_FORBIDDEN_STATUS = "closed"
test_class.modifier: private final
test_class.original_string: private final String APPLICATION_FORBIDDEN_STATUS = "closed";
test_class.type: String
test_class.var_name: APPLICATION_FORBIDDEN_STATUS
test_class.declarator: APPLICATION_ALOWED_STATUS = "open"
test_class.modifier: private final
test_class.original_string: private final String APPLICATION_ALOWED_STATUS = "open";
test_class.type: String
test_class.var_name: APPLICATION_ALOWED_STATUS
test_class.declarator: projectServiceMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ProjectService projectServiceMock;
test_class.type: ProjectService
test_class.var_name: projectServiceMock
test_class.declarator: applicationRepoMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ProjectApplicationRepository applicationRepoMock;
test_class.type: ProjectApplicationRepository
test_class.var_name: applicationRepoMock
test_class.declarator: applicationEventHandlerMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ProjectApplicationEventHandler applicationEventHandlerMock;
test_class.type: ProjectApplicationEventHandler
test_class.var_name: applicationEventHandlerMock
test_class.declarator: propertiesMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ProjectBoardConfigurationProperties propertiesMock;
test_class.type: ProjectBoardConfigurationProperties
test_class.var_name: propertiesMock
test_class.declarator: userMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private User userMock;
test_class.type: User
test_class.var_name: userMock
test_class.declarator: projectMock
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Project projectMock;
test_class.type: Project
test_class.var_name: projectMock
test_class.declarator: clock
test_class.modifier: private
test_class.original_string: private Clock clock;
test_class.type: Clock
test_class.var_name: clock
test_class.declarator: applicationService
test_class.modifier: private
test_class.original_string: private RepositoryApplicationService applicationService;
test_class.type: RepositoryApplicationService
test_class.var_name: applicationService
test_class.file: backend/project-board/src/test/java/de/adesso/projectboard/ad/application/service/RepositoryApplicationServiceTest.java
test_class.identifier: RepositoryApplicationServiceTest
test_case.body: @Test
      public void createApplicationForUserThrowsExceptionWhenAlreadyApplied() {
          // given
          given(projectServiceMock.getProjectById(PROJECT_ID)).willReturn(projectMock);
          given(applicationRepoMock.existsByUserAndProject(userMock, projectMock)).willReturn(true);
  
          given(projectMock.getStatus()).willReturn(APPLICATION_ALOWED_STATUS);
  
          // when
          assertThatThrownBy(() -> applicationService.createApplicationForUser(userMock, PROJECT_ID, ""))
                  .isInstanceOf(AlreadyAppliedException.class);
      }
test_case.class_method_signature: RepositoryApplicationServiceTest.createApplicationForUserThrowsExceptionWhenAlreadyApplied()
test_case.full_signature: @Test public void createApplicationForUserThrowsExceptionWhenAlreadyApplied()
test_case.identifier: createApplicationForUserThrowsExceptionWhenAlreadyApplied
test_case.invocations: willReturn given getProjectById willReturn given existsByUserAndProject willReturn given getStatus isInstanceOf assertThatThrownBy createApplicationForUser
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void createApplicationForUserThrowsExceptionWhenAlreadyApplied()
focal_class.declarator: projectService
focal_class.modifier: private final
focal_class.original_string: private final ProjectService projectService;
focal_class.type: ProjectService
focal_class.var_name: projectService
focal_class.declarator: applicationRepo
focal_class.modifier: private final
focal_class.original_string: private final ProjectApplicationRepository applicationRepo;
focal_class.type: ProjectApplicationRepository
focal_class.var_name: applicationRepo
focal_class.declarator: applicationEventHandler
focal_class.modifier: private final
focal_class.original_string: private final ProjectApplicationEventHandler applicationEventHandler;
focal_class.type: ProjectApplicationEventHandler
focal_class.var_name: applicationEventHandler
focal_class.declarator: clock
focal_class.modifier: private final
focal_class.original_string: private final Clock clock;
focal_class.type: Clock
focal_class.var_name: clock
focal_class.declarator: applicationsForbiddenStatus
focal_class.modifier: private final
focal_class.original_string: private final Set<String> applicationsForbiddenStatus;
focal_class.type: Set<String>
focal_class.var_name: applicationsForbiddenStatus
focal_class.file: backend/project-board/src/main/java/de/adesso/projectboard/ad/application/service/RepositoryApplicationService.java
focal_class.identifier: RepositoryApplicationService
focal_class.interfaces: implements ApplicationService
focal_class.class_method_signature: RepositoryApplicationService.RepositoryApplicationService(ProjectService projectService,
                                          ProjectApplicationRepository applicationRepo,
                                          ProjectApplicationEventHandler applicationEventHandler,
                                          Clock clock,
                                          ProjectBoardConfigurationProperties properties)
focal_class.full_signature: @Autowired public  RepositoryApplicationService(ProjectService projectService,
                                          ProjectApplicationRepository applicationRepo,
                                          ProjectApplicationEventHandler applicationEventHandler,
                                          Clock clock,
                                          ProjectBoardConfigurationProperties properties)
focal_class.identifier: RepositoryApplicationService
focal_class.modifiers: @Autowired public
focal_class.parameters: (ProjectService projectService,
                                          ProjectApplicationRepository applicationRepo,
                                          ProjectApplicationEventHandler applicationEventHandler,
                                          Clock clock,
                                          ProjectBoardConfigurationProperties properties)
focal_class.signature:  RepositoryApplicationService(ProjectService projectService,
                                          ProjectApplicationRepository applicationRepo,
                                          ProjectApplicationEventHandler applicationEventHandler,
                                          Clock clock,
                                          ProjectBoardConfigurationProperties properties)
focal_class.class_method_signature: RepositoryApplicationService.userHasAppliedForProject(User user, Project project)
focal_class.full_signature: @Override public boolean userHasAppliedForProject(User user, Project project)
focal_class.identifier: userHasAppliedForProject
focal_class.modifiers: @Override public
focal_class.parameters: (User user, Project project)
focal_class.return: boolean
focal_class.signature: boolean userHasAppliedForProject(User user, Project project)
focal_class.class_method_signature: RepositoryApplicationService.createApplicationForUser(User user, String projectId, String comment)
focal_class.full_signature: @Override @Transactional public ProjectApplication createApplicationForUser(User user, String projectId, String comment)
focal_class.identifier: createApplicationForUser
focal_class.modifiers: @Override @Transactional public
focal_class.parameters: (User user, String projectId, String comment)
focal_class.return: ProjectApplication
focal_class.signature: ProjectApplication createApplicationForUser(User user, String projectId, String comment)
focal_class.class_method_signature: RepositoryApplicationService.getApplicationsOfUser(User user, Sort sort)
focal_class.full_signature: @Override public List<ProjectApplication> getApplicationsOfUser(User user, Sort sort)
focal_class.identifier: getApplicationsOfUser
focal_class.modifiers: @Override public
focal_class.parameters: (User user, Sort sort)
focal_class.return: List<ProjectApplication>
focal_class.signature: List<ProjectApplication> getApplicationsOfUser(User user, Sort sort)
focal_class.class_method_signature: RepositoryApplicationService.getApplicationsOfUsers(Collection<User> users, Sort sort)
focal_class.full_signature: @Override public List<ProjectApplication> getApplicationsOfUsers(Collection<User> users, Sort sort)
focal_class.identifier: getApplicationsOfUsers
focal_class.modifiers: @Override public
focal_class.parameters: (Collection<User> users, Sort sort)
focal_class.return: List<ProjectApplication>
focal_class.signature: List<ProjectApplication> getApplicationsOfUsers(Collection<User> users, Sort sort)
focal_class.class_method_signature: RepositoryApplicationService.deleteApplication(User user, long applicationId)
focal_class.full_signature: @Transactional @Override public ProjectApplication deleteApplication(User user, long applicationId)
focal_class.identifier: deleteApplication
focal_class.modifiers: @Transactional @Override public
focal_class.parameters: (User user, long applicationId)
focal_class.return: ProjectApplication
focal_class.signature: ProjectApplication deleteApplication(User user, long applicationId)
focal_method.body: @Override
      @Transactional
      public ProjectApplication createApplicationForUser(User user, String projectId, String comment) {
          var project = projectService.getProjectById(projectId);
          var projectStatus = project.getStatus().toLowerCase();
  
          if(userHasAppliedForProject(user, project)) {
              throw new AlreadyAppliedException();
          }
  
          if(applicationsForbiddenStatus.contains(projectStatus)) {
              throw new ProjectStatusPreventsApplicationException();
          }
  
          // use a clock for testing
          var applicationDate = LocalDateTime.now(clock);
          var application = new ProjectApplication(project, comment, user, applicationDate);
  
          var savedApplication = applicationRepo.save(application);
          applicationEventHandler.onApplicationReceived(savedApplication);
  
          return savedApplication;
      }
focal_method.class_method_signature: RepositoryApplicationService.createApplicationForUser(User user, String projectId, String comment)
focal_method.full_signature: @Override @Transactional public ProjectApplication createApplicationForUser(User user, String projectId, String comment)
focal_method.identifier: createApplicationForUser
focal_method.invocations: getProjectById toLowerCase getStatus userHasAppliedForProject contains now save onApplicationReceived
focal_method.modifiers: @Override @Transactional public
focal_method.parameters: (User user, String projectId, String comment)
focal_method.return: ProjectApplication
focal_method.signature: ProjectApplication createApplicationForUser(User user, String projectId, String comment)