Skip to content

Commit

Permalink
Merge pull request #173 from Funssion-SWM/employer
Browse files Browse the repository at this point in the history
fix: 면접완료되지 않은 경우 에러처리 문제 해결 및 테스트 추가
  • Loading branch information
goathoon authored Nov 4, 2023
2 parents a2859cb + 289fd2f commit 3943cf4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<Employee> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class EmployerIntegrationTestV2 {

SaveMemberResponseDto saveEmployeeDto;
SaveMemberResponseDto saveEmployerDto;
QuestionsDto questionsDto = new QuestionsDto("1번 질문", "2번 질문", "3번 질문");

SaveProfessionalProfileDto createdProfessionalProfileDto = SaveProfessionalProfileDto.builder()
.introduce("hi")
Expand Down Expand Up @@ -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);
Expand All @@ -180,6 +180,38 @@ void getInterviewUserList() throws Exception{
List<String> 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")
Expand Down

0 comments on commit 3943cf4

Please sign in to comment.