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

refactor: 즐겨찾기 도메인 리팩토링 #133

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
JeongUijeong marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.fc.shimpyo_be.domain.favorite.dto;

import com.fc.shimpyo_be.domain.favorite.entity.Favorite;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class FavoriteResponseDto {

private Long favoriteId;
private Long memberId;
private Long productId;

@Builder
public FavoriteResponseDto(Long favoriteId, Long memberId, Long productId) {
private FavoriteResponseDto(Long favoriteId, Long memberId, Long productId) {
this.favoriteId = favoriteId;
this.memberId = memberId;
this.productId = productId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import com.fc.shimpyo_be.domain.product.dto.response.ProductResponse;
import java.util.List;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class FavoritesResponseDto {

private int pageCount;
private List<ProductResponse> products;

@Builder
public FavoritesResponseDto(int pageCount, List<ProductResponse> products) {
private FavoritesResponseDto(int pageCount, List<ProductResponse> products) {
this.pageCount = pageCount;
this.products = products;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Favorite {
private Product product;

@Builder
public Favorite(Long id, Member member, Product product) {
private Favorite(Long id, Member member, Product product) {
this.id = id;
this.member = member;
this.product = product;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ void register() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(favoriteService.register(any(Long.TYPE), any(Long.TYPE))).willReturn(
favoriteResponseDto);
given(favoriteService.register(any(Long.TYPE), any(Long.TYPE)))
.willReturn(favoriteResponseDto);

// when then
mockMvc.perform(post("/api/favorites/{productId}", 1L))
Expand Down Expand Up @@ -141,8 +141,8 @@ void cancel() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE))).willReturn(
favoriteResponseDto);
given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE)))
.willReturn(favoriteResponseDto);

// when then
mockMvc.perform(delete("/api/favorites/{productId}", 1L))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fc.shimpyo_be.config.AbstractContainersSupport;
import com.fc.shimpyo_be.domain.favorite.dto.FavoriteResponseDto;
import com.fc.shimpyo_be.domain.favorite.dto.FavoritesResponseDto;
Expand Down Expand Up @@ -49,8 +48,6 @@ public class FavoriteRestControllerTest extends AbstractContainersSupport {
@MockBean
SecurityUtil securityUtil;

ObjectMapper objectMapper = new ObjectMapper();

@BeforeEach
public void setup() {
mockMvc = MockMvcBuilders
Expand All @@ -75,8 +72,8 @@ void _willSuccess() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(favoriteService.register(any(Long.TYPE), any(Long.TYPE))).willReturn(
favoriteResponseDto);
given(favoriteService.register(any(Long.TYPE), any(Long.TYPE)))
.willReturn(favoriteResponseDto);

// when then
mockMvc.perform(post("/api/favorites/{productId}", 1L))
Expand Down Expand Up @@ -117,8 +114,8 @@ void _willSuccess() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(favoriteService.getFavorites(any(Long.TYPE), any(Pageable.class))).willReturn(
favoritesResponseDto);
given(favoriteService.getFavorites(any(Long.TYPE), any(Pageable.class)))
.willReturn(favoritesResponseDto);

// when then
mockMvc.perform(get("/api/favorites")
Expand Down Expand Up @@ -158,8 +155,8 @@ void _willSuccess() throws Exception {
.build();

given(securityUtil.getCurrentMemberId()).willReturn(1L);
given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE))).willReturn(
favoriteResponseDto);
given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE)))
.willReturn(favoriteResponseDto);

// when then
mockMvc.perform(delete("/api/favorites/{productId}", 1L))
Expand Down