|
7 | 7 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
8 | 8 |
|
9 | 9 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 10 | +import java.time.LocalDate; |
10 | 11 | import java.time.LocalDateTime; |
11 | 12 | import java.util.List; |
12 | 13 | import org.clokey.domain.coordinate.dto.request.CoordinateAutoCreateRequest; |
@@ -1663,47 +1664,106 @@ class 최애_코디_조회_요청_시 { |
1663 | 1664 | } |
1664 | 1665 |
|
1665 | 1666 | @Nested |
1666 | | - class 오늘의_코디_조회_요청_시 { |
| 1667 | + class 오늘의_코디_Preview_조회_요청_시 { |
1667 | 1668 |
|
1668 | 1669 | @Test |
1669 | | - void 유효한_요청이면_오늘의_코디_정보를_반환한다() throws Exception { |
| 1670 | + void 유효한_요청이면_오늘의_코디_Preview를_반환한다() throws Exception { |
1670 | 1671 | // given |
1671 | | - List<DailyCoordinateClothResponse> response = |
| 1672 | + LocalDate today = LocalDate.now(); |
| 1673 | + DailyCoordinatePreviewResponse response = |
| 1674 | + new DailyCoordinatePreviewResponse(1L, "testImageUrl", LocalDate.now()); |
| 1675 | + given(coordinateService.getTodayCoordinatePreview()).willReturn(response); |
| 1676 | + |
| 1677 | + // when & then |
| 1678 | + ResultActions perform = |
| 1679 | + mockMvc.perform( |
| 1680 | + get("/coordinate/daily/today/preview") |
| 1681 | + .contentType(MediaType.APPLICATION_JSON)); |
| 1682 | + |
| 1683 | + perform.andExpect(status().isOk()) |
| 1684 | + .andExpect(jsonPath("$.isSuccess").value(true)) |
| 1685 | + .andExpect(jsonPath("$.code").value("COMMON200")) |
| 1686 | + .andExpect(jsonPath("$.message").value("성공입니다.")) |
| 1687 | + .andExpect(jsonPath("$.result.coordinateId").value(1)) |
| 1688 | + .andExpect(jsonPath("$.result.imageUrl").value("testImageUrl")) |
| 1689 | + .andExpect(jsonPath("$.result.date").value(today.toString())); |
| 1690 | + } |
| 1691 | + } |
| 1692 | + |
| 1693 | + @Nested |
| 1694 | + class 오늘의_코디_Details_조회_요청_시 { |
| 1695 | + |
| 1696 | + @Test |
| 1697 | + void 유효한_요청이면_오늘의_코디_Details를_반환한다() throws Exception { |
| 1698 | + // given |
| 1699 | + List<CoordinateDetailsListResponse> response = |
1672 | 1700 | List.of( |
1673 | | - new DailyCoordinateClothResponse( |
1674 | | - "https://image.example/cloth1.jpg", |
1675 | | - "brand1", |
1676 | | - "name1", |
1677 | | - "category1", |
1678 | | - "parent1"), |
1679 | | - new DailyCoordinateClothResponse( |
1680 | | - "https://image.example/cloth2.jpg", |
1681 | | - "brand2", |
1682 | | - "name2", |
1683 | | - "category2", |
1684 | | - "parent2")); |
1685 | | - |
1686 | | - given(coordinateService.getTodayDailyCoordinateClothes()).willReturn(response); |
1687 | | - |
1688 | | - ResultActions perform = mockMvc.perform(get("/coordinate/daily/today")); |
| 1701 | + new CoordinateDetailsListResponse( |
| 1702 | + 1L, |
| 1703 | + 50.2, |
| 1704 | + 60.1, |
| 1705 | + 1.5, |
| 1706 | + 240.1, |
| 1707 | + 1, |
| 1708 | + 14L, |
| 1709 | + "testImageUrl1", |
| 1710 | + "testBrand1", |
| 1711 | + "testName1", |
| 1712 | + "testCategoryName1", |
| 1713 | + "testParentCategoryName1"), |
| 1714 | + new CoordinateDetailsListResponse( |
| 1715 | + 2L, |
| 1716 | + 50.2, |
| 1717 | + 60.1, |
| 1718 | + 1.5, |
| 1719 | + 240.1, |
| 1720 | + 2, |
| 1721 | + 15L, |
| 1722 | + "testImageUrl2", |
| 1723 | + "testBrand2", |
| 1724 | + "testName2", |
| 1725 | + "testCategoryName2", |
| 1726 | + "testParentCategoryName2")); |
| 1727 | + |
| 1728 | + given(coordinateService.getTodayCoordinateDetails()).willReturn(response); |
| 1729 | + |
1689 | 1730 | // when & then |
| 1731 | + ResultActions perform = |
| 1732 | + mockMvc.perform( |
| 1733 | + get("/coordinate/daily/today/details") |
| 1734 | + .contentType(MediaType.APPLICATION_JSON)); |
| 1735 | + |
1690 | 1736 | perform.andExpect(status().isOk()) |
1691 | 1737 | .andExpect(jsonPath("$.isSuccess").value(true)) |
1692 | 1738 | .andExpect(jsonPath("$.code").value("COMMON200")) |
| 1739 | + .andExpect(jsonPath("$.message").value("성공입니다.")) |
| 1740 | + .andExpect(jsonPath("$.result[0].coordinateClothId").value(1)) |
| 1741 | + .andExpect(jsonPath("$.result[0].locationX").value(50.2)) |
| 1742 | + .andExpect(jsonPath("$.result[0].locationY").value(60.1)) |
| 1743 | + .andExpect(jsonPath("$.result[0].ratio").value(1.5)) |
| 1744 | + .andExpect(jsonPath("$.result[0].degree").value(240.1)) |
| 1745 | + .andExpect(jsonPath("$.result[0].order").value(1)) |
| 1746 | + .andExpect(jsonPath("$.result[0].clothId").value(14)) |
| 1747 | + .andExpect(jsonPath("$.result[0].imageUrl").value("testImageUrl1")) |
| 1748 | + .andExpect(jsonPath("$.result[0].brand").value("testBrand1")) |
| 1749 | + .andExpect(jsonPath("$.result[0].name").value("testName1")) |
| 1750 | + .andExpect(jsonPath("$.result[0].category").value("testCategoryName1")) |
1693 | 1751 | .andExpect( |
1694 | | - jsonPath("$.result[0].imageUrl") |
1695 | | - .value("https://image.example/cloth1.jpg")) |
1696 | | - .andExpect(jsonPath("$.result[0].brand").value("brand1")) |
1697 | | - .andExpect(jsonPath("$.result[0].name").value("name1")) |
1698 | | - .andExpect(jsonPath("$.result[0].category").value("category1")) |
1699 | | - .andExpect(jsonPath("$.result[0].parentCategory").value("parent1")) |
| 1752 | + jsonPath("$.result[0].parentCategory").value("testParentCategoryName1")) |
| 1753 | + .andExpect(jsonPath("$.result[1].coordinateClothId").value(2)) |
| 1754 | + .andExpect(jsonPath("$.result[1].locationX").value(50.2)) |
| 1755 | + .andExpect(jsonPath("$.result[1].locationY").value(60.1)) |
| 1756 | + .andExpect(jsonPath("$.result[1].ratio").value(1.5)) |
| 1757 | + .andExpect(jsonPath("$.result[1].degree").value(240.1)) |
| 1758 | + .andExpect(jsonPath("$.result[1].order").value(2)) |
| 1759 | + .andExpect(jsonPath("$.result[1].clothId").value(15)) |
| 1760 | + .andExpect(jsonPath("$.result[1].imageUrl").value("testImageUrl2")) |
| 1761 | + .andExpect(jsonPath("$.result[1].brand").value("testBrand2")) |
| 1762 | + .andExpect(jsonPath("$.result[1].name").value("testName2")) |
| 1763 | + .andExpect(jsonPath("$.result[1].category").value("testCategoryName2")) |
1700 | 1764 | .andExpect( |
1701 | | - jsonPath("$.result[1].imageUrl") |
1702 | | - .value("https://image.example/cloth2.jpg")) |
1703 | | - .andExpect(jsonPath("$.result[1].brand").value("brand2")) |
1704 | | - .andExpect(jsonPath("$.result[1].name").value("name2")) |
1705 | | - .andExpect(jsonPath("$.result[1].category").value("category2")) |
1706 | | - .andExpect(jsonPath("$.result[1].parentCategory").value("parent2")); |
| 1765 | + jsonPath("$.result[1].parentCategory") |
| 1766 | + .value("testParentCategoryName2")); |
1707 | 1767 | } |
1708 | 1768 | } |
1709 | 1769 | } |
0 commit comments