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

[PDS-171/test] 회의실 목록조회 실패 case 테스트 코드 구현 #228

Merged
merged 1 commit into from
Nov 25, 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 @@ -46,6 +46,70 @@ void searchOffice() throws Exception {
.andExpect(status().isOk());
}

@DisplayName("회의실 목록 조회 실패 case1->날짜나 시간이 입력되지 않은 경우")
@Test
@WithMockUser
void searchOffice_whenDateOrTimeNotProvided_thenThrowsException() throws Exception {
// given
LocalDate date = LocalDate.of(2023, 11, 30);
String facilityName = "빔 프로젝터";
Pageable pageable = PageRequest.of(0, 10);

// when-then
mockMvc.perform(get("/offices")
.param("date", date.toString())
.param("facilityName", facilityName)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest());
Comment on lines +59 to +64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 -

}
@DisplayName("회의실 목록 조회 실패 case2->과거의 날짜와 시간을 예약으로 시도할 경우")
@Test
@WithMockUser
void searchOffice_whenPastDateAndTime_thenThrowsException() throws Exception {
// given
LocalDate date = LocalDate.now().minusDays(1); //과거날짜 주입
LocalTime startTime = LocalTime.of(12, 0);
LocalTime endTime = LocalTime.of(13, 0);
String facilityName = "빔 프로젝터";
Pageable pageable = PageRequest.of(0, 10);

// when-then
mockMvc.perform(get("/offices")
.param("date", date.toString())
.param("startTime", startTime.toString())
.param("endTime", endTime.toString())
.param("facilityName", facilityName)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest());
}

@DisplayName("회의실 목록 조회 실패 case3->시작 시간이 종료 시간보다 늦거나 같은 경우")
@Test
@WithMockUser
void searchOffice_whenStartTimeAfterEndTime_thenThrowsException() throws Exception {
// given
LocalDate date = LocalDate.of(2023, 11, 30);
LocalTime startTime = LocalTime.of(13, 0);
LocalTime endTime = LocalTime.of(12, 0); // 시작 시간이 종료 시간보다 늦은 시간 주입
String facilityName = "빔 프로젝터";
Pageable pageable = PageRequest.of(0, 10);

// when-then
mockMvc.perform(get("/offices")
.param("date", date.toString())
.param("startTime", startTime.toString())
.param("endTime", endTime.toString())
.param("facilityName", facilityName)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest());
}




@DisplayName("회의실 개별 조회")
@Test
void getOffice() throws Exception{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public class OfficeServiceTest extends IntegrationTestSupport {
@Autowired private AffiliationRepository affiliationRepository;
@Autowired private DepartmentRepository departmentRepository;

@AfterEach
void tearDown(){
// 참조하는 엔티티 먼저 삭제
officeBookingRepository.deleteAllInBatch();
officeFacilityRepository.deleteAllInBatch();
// 참조되는 엔티티 삭제
officeRepository.deleteAllInBatch();
facilityRepository.deleteAllInBatch();

}
// @AfterEach
// void tearDown(){
// // 참조하는 엔티티 먼저 삭제
// officeBookingRepository.deleteAllInBatch();
// officeFacilityRepository.deleteAllInBatch();
// // 참조되는 엔티티 삭제
// officeRepository.deleteAllInBatch();
// facilityRepository.deleteAllInBatch();
//
// }

@Test
@DisplayName("회의실 목록 조회 테스트")
Expand Down