-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from IhorTrokhymchuk/fix-dev
Fixed get bookings by check dates query
- Loading branch information
Showing
2 changed files
with
5 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
package org.example.bookingappliation.controller; | ||
|
||
import static org.example.bookingappliation.testutil.BookingControllerDtoUtil.getBookingPatchRequestDto; | ||
import static org.example.bookingappliation.testutil.BookingControllerDtoUtil.getFirstBookingDtoFromDb; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
|
@@ -19,7 +17,6 @@ | |
import java.util.List; | ||
import javax.sql.DataSource; | ||
import lombok.SneakyThrows; | ||
import org.example.bookingappliation.dto.bookings.request.BookingPatchRequestDto; | ||
import org.example.bookingappliation.dto.bookings.request.BookingRequestDto; | ||
import org.example.bookingappliation.dto.bookings.responce.BookingDto; | ||
import org.example.bookingappliation.dto.bookingstatuses.response.BookingStatusDto; | ||
|
@@ -230,32 +227,6 @@ void cancelBookingById_cancelBookingByIdWithValidData_isOk() throws Exception { | |
assertEquals(firstBookingDtoFromDb, resultDto); | ||
} | ||
|
||
@Test | ||
@WithMockUser(username = "[email protected]", authorities = {"CUSTOMER"}) | ||
@DisplayName("Update booking by id with valid data") | ||
void update_updateBookingByIdWithValidData_isOk() throws Exception { | ||
Long id = 1L; | ||
BookingPatchRequestDto bookingPatchRequestDto = getBookingPatchRequestDto(); | ||
String jsonRequest = objectMapper.writeValueAsString(bookingPatchRequestDto); | ||
|
||
BookingDto firstBookingDtoFromDb = getFirstBookingDtoFromDb(); | ||
firstBookingDtoFromDb.getCheckDates().setCheckInDate( | ||
bookingPatchRequestDto.getCheckDates().getCheckInDate()); | ||
firstBookingDtoFromDb.getCheckDates().setCheckOutDate( | ||
bookingPatchRequestDto.getCheckDates().getCheckOutDate()); | ||
|
||
MvcResult result = mockMvc.perform(put(BASE_URL + SLASH + id) | ||
.content(jsonRequest) | ||
.contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isOk()) | ||
.andReturn(); | ||
|
||
BookingDto resultDto = objectMapper.readValue( | ||
result.getResponse().getContentAsString(), BookingDto.class); | ||
assertNotNull(resultDto); | ||
assertEquals(firstBookingDtoFromDb, resultDto); | ||
} | ||
|
||
@AfterEach | ||
void tearDown(@Autowired DataSource dataSource) { | ||
teardown(dataSource); | ||
|