Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 면접완료되지 않은 경우 에러처리 문제 해결 및 테스트 추가 #173

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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