From 289fd2fe35548aa650b11cae3004339e36bc5a71 Mon Sep 17 00:00:00 2001 From: Goathoon Date: Sat, 4 Nov 2023 16:46:45 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A9=B4=EC=A0=91=EC=99=84=EB=A3=8C?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EC=B2=98=EB=A6=AC=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../employer/service/EmployerService.java | 2 +- .../employer/EmployerIntegrationTestV2.java | 34 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/Funssion/Inforum/domain/employer/service/EmployerService.java b/src/main/java/Funssion/Inforum/domain/employer/service/EmployerService.java index fb692272..043a4935 100644 --- a/src/main/java/Funssion/Inforum/domain/employer/service/EmployerService.java +++ b/src/main/java/Funssion/Inforum/domain/employer/service/EmployerService.java @@ -67,7 +67,7 @@ public List getEmployeesOfInterview(Boolean done) { public InterviewResult getResultOfInterview(Long employeeId){ Long employerId = SecurityContextUtils.getAuthorizedUserId(); - if(!interviewRepository.getInterviewStatusOfUser(employerId, employeeId).getStatus().equals(InterviewStatus.DONE.toString())) + if(!interviewRepository.getInterviewStatusOfUser(employerId, employeeId).equals(InterviewStatus.DONE)) throw new BadRequestException("면접이 완료되지 않은 지원자입니다."); return employerRepository.getInterviewResultOf(employeeId); diff --git a/src/test/java/Funssion/Inforum/domain/employer/EmployerIntegrationTestV2.java b/src/test/java/Funssion/Inforum/domain/employer/EmployerIntegrationTestV2.java index bb4e7ce7..d407d463 100644 --- a/src/test/java/Funssion/Inforum/domain/employer/EmployerIntegrationTestV2.java +++ b/src/test/java/Funssion/Inforum/domain/employer/EmployerIntegrationTestV2.java @@ -59,6 +59,7 @@ public class EmployerIntegrationTestV2 { SaveMemberResponseDto saveEmployeeDto; SaveMemberResponseDto saveEmployerDto; + QuestionsDto questionsDto = new QuestionsDto("1번 질문", "2번 질문", "3번 질문"); SaveProfessionalProfileDto createdProfessionalProfileDto = SaveProfessionalProfileDto.builder() .introduce("hi") @@ -164,7 +165,6 @@ void getInterviewUserList() throws Exception{ saveEmployeeDto3.getId(), saveProfessionalProfileDto ); - QuestionsDto questionsDto = new QuestionsDto("1번 질문", "2번 질문", "3번 질문"); interviewRepository.saveQuestions(saveEmployeeDto.getId(),questionsDto); interviewRepository.saveQuestions(saveEmployeeDto2.getId(),questionsDto); interviewRepository.saveQuestions(saveEmployeeDto3.getId(),questionsDto); @@ -180,6 +180,38 @@ void getInterviewUserList() throws Exception{ List employeesTechStack = JsonPath.read(contentAsString, "$[*].techStack"); assertThat(employeesTechStack).hasSize(1); + } + + @Test + @DisplayName("면접이 완료되지 않은 지원자의 면접 결과를 가져올 수 없다.") + void cannotAccessResultWhenEmployeeNotDone() throws Exception { + memberRepository.authorizeEmployer(saveEmployerDto.getId()); + SecurityContextHolder.getContext().setAuthentication( + new UsernamePasswordAuthenticationToken(saveEmployerDto.getId(), "a1234567!", List.of(new SimpleGrantedAuthority("ROLE_EMPLOYER"))) + ); + interviewRepository.saveQuestions(saveEmployeeDto.getId(),questionsDto); + UserDetails employerUserDetails = authService.loadUserByUsername(saveEmployerDto.getEmail()); + mvc.perform(get("/employer/interview-result/"+saveEmployeeDto.getId()) + .with(user(employerUserDetails))) + .andExpect(status().isBadRequest()); + + } + + @Test + @DisplayName("면접이 완료된 사람의 면접 결과를 가져올 수 있다..") + void canOnlyAccessResultWhenEmployeeDone() throws Exception { + memberRepository.authorizeEmployer(saveEmployerDto.getId()); + SecurityContextHolder.getContext().setAuthentication( + new UsernamePasswordAuthenticationToken(saveEmployerDto.getId(), "a1234567!", List.of(new SimpleGrantedAuthority("ROLE_EMPLOYER"))) + ); + interviewRepository.saveQuestions(saveEmployeeDto.getId(),questionsDto); + interviewRepository.updateStatus(saveEmployerDto.getId(),saveEmployeeDto.getId(), InterviewStatus.DONE); + + UserDetails employerUserDetails = authService.loadUserByUsername(saveEmployerDto.getEmail()); + mvc.perform(get("/employer/interview-result/"+saveEmployeeDto.getId()) + .with(user(employerUserDetails))) + .andExpect(status().isOk()); + } @Test @WithMockUser(roles="USER")