diff --git a/src/main/java/mocacong/server/domain/Cafe.java b/src/main/java/mocacong/server/domain/Cafe.java index 62bf598d..76dd11c5 100644 --- a/src/main/java/mocacong/server/domain/Cafe.java +++ b/src/main/java/mocacong/server/domain/Cafe.java @@ -29,6 +29,9 @@ public class Cafe extends BaseTime { @Column(name = "map_id", unique = true, nullable = false) private String mapId; + @Column(name = "road_address", nullable = false) + private String roadAddress; + @OneToMany(mappedBy = "cafe", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) private List score; @@ -44,9 +47,10 @@ public class Cafe extends BaseTime { @OneToMany(mappedBy = "cafe", fetch = FetchType.LAZY) private List comments; - public Cafe(String mapId, String name) { + public Cafe(String mapId, String name, String roadAddress) { this.mapId = mapId; this.name = name; + this.roadAddress = roadAddress; this.cafeDetail = new CafeDetail(); this.cafeImages = new ArrayList<>(); this.score = new ArrayList<>(); @@ -71,6 +75,10 @@ public void updateCafeDetails() { this.cafeDetail = new CafeDetail(studyType, wifi, parking, toilet, desk, power, sound); } + public void updateCafeRoadAddress(String roadAddress) { + this.roadAddress = roadAddress; + } + private StudyType getMostFrequentStudyType() { int solo = 0, group = 0; for (Review review : reviews) { diff --git a/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java b/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java index b74fcd39..7ac5f79a 100644 --- a/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java +++ b/src/main/java/mocacong/server/dto/request/CafeRegisterRequest.java @@ -14,4 +14,7 @@ public class CafeRegisterRequest { @NotBlank(message = "1012:공백일 수 없습니다.") private String name; + + @NotBlank(message = "1012:공백일 수 없습니다.") + private String roadAddress; } diff --git a/src/main/java/mocacong/server/dto/response/MyCommentCafeResponse.java b/src/main/java/mocacong/server/dto/response/MyCommentCafeResponse.java index 84aeabd4..a0dc3634 100644 --- a/src/main/java/mocacong/server/dto/response/MyCommentCafeResponse.java +++ b/src/main/java/mocacong/server/dto/response/MyCommentCafeResponse.java @@ -12,4 +12,5 @@ public class MyCommentCafeResponse { private String name; private String studyType; private String comment; + private String roadAddress; } diff --git a/src/main/java/mocacong/server/dto/response/MyFavoriteCafeResponse.java b/src/main/java/mocacong/server/dto/response/MyFavoriteCafeResponse.java index c8f552f6..8ba5a917 100644 --- a/src/main/java/mocacong/server/dto/response/MyFavoriteCafeResponse.java +++ b/src/main/java/mocacong/server/dto/response/MyFavoriteCafeResponse.java @@ -7,9 +7,9 @@ @AllArgsConstructor @ToString public class MyFavoriteCafeResponse { - private String mapId; private String name; private String studyType; private double score; + private String roadAddress; } diff --git a/src/main/java/mocacong/server/dto/response/MyReviewCafeResponse.java b/src/main/java/mocacong/server/dto/response/MyReviewCafeResponse.java index e49b21d2..1500b108 100644 --- a/src/main/java/mocacong/server/dto/response/MyReviewCafeResponse.java +++ b/src/main/java/mocacong/server/dto/response/MyReviewCafeResponse.java @@ -12,11 +12,13 @@ public class MyReviewCafeResponse { private String name; private String myStudyType; private int myScore; + private String roadAddress; - public MyReviewCafeResponse(String mapId, String name, StudyType myStudyType, int myScore) { + public MyReviewCafeResponse(String mapId, String name, StudyType myStudyType, int myScore, String roadAddress) { this.mapId = mapId; this.name = name; - this.myStudyType = myStudyType.getValue(); + this.myStudyType = myStudyType.toString(); this.myScore = myScore; + this.roadAddress = roadAddress; } } diff --git a/src/main/java/mocacong/server/repository/CafeRepository.java b/src/main/java/mocacong/server/repository/CafeRepository.java index f297f4e0..ed183c3c 100644 --- a/src/main/java/mocacong/server/repository/CafeRepository.java +++ b/src/main/java/mocacong/server/repository/CafeRepository.java @@ -28,10 +28,10 @@ public interface CafeRepository extends JpaRepository { "where m.id = :id") Slice findByMyFavoriteCafes(Long id, Pageable pageRequest); - @Query("select new mocacong.server.dto.response.MyReviewCafeResponse(c.mapId,c.name,r.cafeDetail.studyType,s.score) from Review r " + + @Query("select new mocacong.server.dto.response.MyReviewCafeResponse(c.mapId,c.name,r.cafeDetail.studyType,s.score,c.roadAddress) from Review r " + "join r.cafe c " + "join r.member m " + - "join c.score s "+ + "join c.score s " + "where m.id = :id and s.member.id = :id") Slice findMyReviewCafesById(Long id, Pageable pageRequest); } diff --git a/src/main/java/mocacong/server/service/CafeService.java b/src/main/java/mocacong/server/service/CafeService.java index 4256a75a..430caf4e 100644 --- a/src/main/java/mocacong/server/service/CafeService.java +++ b/src/main/java/mocacong/server/service/CafeService.java @@ -31,6 +31,7 @@ import javax.persistence.EntityManager; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -53,7 +54,14 @@ public class CafeService { @Transactional public void save(CafeRegisterRequest request) { - Cafe cafe = new Cafe(request.getId(), request.getName()); + Cafe cafe = new Cafe(request.getId(), request.getName(), request.getRoadAddress()); + + Optional cafeOptional = cafeRepository.findByMapId(request.getId()); + + if (cafeOptional.isPresent()) { + cafeOptional.get().updateCafeRoadAddress(request.getRoadAddress()); + return; + } try { cafeRepository.save(cafe); @@ -149,7 +157,7 @@ public MyFavoriteCafesResponse findMyFavoriteCafes(Long memberId, Integer page, List responses = myFavoriteCafes .getContent() .stream() - .map(cafe -> new MyFavoriteCafeResponse(cafe.getMapId(), cafe.getName(), cafe.getStudyType(), cafe.findAverageScore())) + .map(cafe -> new MyFavoriteCafeResponse(cafe.getMapId(), cafe.getName(), cafe.getStudyType(), cafe.findAverageScore(), cafe.getRoadAddress())) .collect(Collectors.toList()); return new MyFavoriteCafesResponse(myFavoriteCafes.isLast(), responses); } @@ -176,7 +184,8 @@ public MyCommentCafesResponse findMyCommentCafes(Long memberId, int page, int co comment.getCafe().getMapId(), comment.getCafe().getName(), comment.getCafe().getStudyType(), - comment.getContent() + comment.getContent(), + comment.getCafe().getRoadAddress() )) .collect(Collectors.toList()); return new MyCommentCafesResponse(comments.isLast(), responses); diff --git a/src/test/java/mocacong/server/acceptance/CafeAcceptanceTest.java b/src/test/java/mocacong/server/acceptance/CafeAcceptanceTest.java index 8811bd09..33537790 100644 --- a/src/test/java/mocacong/server/acceptance/CafeAcceptanceTest.java +++ b/src/test/java/mocacong/server/acceptance/CafeAcceptanceTest.java @@ -21,7 +21,7 @@ public class CafeAcceptanceTest extends AcceptanceTest { @Test @DisplayName("카페를 정상적으로 등록한다") void cafeSave() { - CafeRegisterRequest request = new CafeRegisterRequest("1", "메리네 카페"); + CafeRegisterRequest request = new CafeRegisterRequest("1", "메리네 카페", "서울시 강남구"); RestAssured.given().log().all() .contentType(MediaType.APPLICATION_JSON_VALUE) @@ -36,7 +36,7 @@ void cafeSave() { @DisplayName("특정 카페 정보를 조회한다") void findCafe() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -55,7 +55,7 @@ void findCafe() { @DisplayName("카페에 대한 리뷰를 작성한다") void saveCafeReview() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -83,7 +83,7 @@ void saveCafeReview() { @DisplayName("카페에 대해 내가 작성한 리뷰를 조회한다") void findMyCafeReview() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -103,7 +103,7 @@ void findMyCafeReview() { @DisplayName("카페에 대한 리뷰를 다시 작성할 수 없다") void saveCafeReviewManyTimes() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -126,7 +126,7 @@ void saveCafeReviewManyTimes() { @DisplayName("등록한 카페에 대한 리뷰를 수정한다") void updateCafeReview() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); @@ -157,7 +157,7 @@ void updateCafeReview() { @DisplayName("등록하지 않은 카페에 대한 리뷰는 수정할 수 없다") void updateCafeReviewNotFoundReview() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); @@ -178,7 +178,7 @@ void updateCafeReviewNotFoundReview() { @DisplayName("카페 정보를 미리보기한다") void previewCafe() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "100")); MemberSignUpRequest signUpRequest1 = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); MemberSignUpRequest signUpRequest2 = new MemberSignUpRequest("dlawotn3@naver.com", "a1b2c3d4", "메리"); @@ -206,9 +206,9 @@ void getCafesFilterStudyType() { String mapId1 = "12332312"; String mapId2 = "12355412"; String mapId3 = "18486512"; - 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페 본점")); - 카페_등록(new CafeRegisterRequest(mapId2, "메리네 카페 2호점")); - 카페_등록(new CafeRegisterRequest(mapId3, "메리네 카페 3호점")); + 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페 본점", "서울시 강남구")); + 카페_등록(new CafeRegisterRequest(mapId2, "메리네 카페 2호점", "서울시 강남구")); + 카페_등록(new CafeRegisterRequest(mapId3, "메리네 카페 3호점", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); @@ -242,9 +242,9 @@ void getCafesFilterFavorites() { String mapId1 = "12332312"; String mapId2 = "12355412"; String mapId3 = "18486512"; - 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페 본점")); - 카페_등록(new CafeRegisterRequest(mapId2, "메리네 카페 2호점")); - 카페_등록(new CafeRegisterRequest(mapId3, "메리네 카페 3호점")); + 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페 본점", "서울시 강남구")); + 카페_등록(new CafeRegisterRequest(mapId2, "메리네 카페 2호점", "서울시 강남구")); + 카페_등록(new CafeRegisterRequest(mapId3, "메리네 카페 3호점", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); @@ -270,7 +270,7 @@ void getCafesFilterFavorites() { @DisplayName("특정 카페 이미지들을 조회한다") void getCafeImages() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페 본점")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페 본점", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); diff --git a/src/test/java/mocacong/server/acceptance/CommentAcceptanceTest.java b/src/test/java/mocacong/server/acceptance/CommentAcceptanceTest.java index 6d1700b1..95d91162 100644 --- a/src/test/java/mocacong/server/acceptance/CommentAcceptanceTest.java +++ b/src/test/java/mocacong/server/acceptance/CommentAcceptanceTest.java @@ -24,7 +24,7 @@ public class CommentAcceptanceTest extends AcceptanceTest { void saveComment() { String expected = "공부하기 좋아요~🥰"; String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "100")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -51,7 +51,7 @@ void saveComment() { @DisplayName("카페 코멘트 목록을 조회한다") void findComments() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "100")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -71,7 +71,7 @@ void findComments() { @DisplayName("카페 코멘트 첫번째 목록을 조회한다") void findCommentsFirstPage() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "베어네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "베어네 카페", "100")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("rlawjddn103@naver.com", "a1b2c3d4", "베어"); 회원_가입(signUpRequest); @@ -94,7 +94,7 @@ void findCommentsFirstPage() { @DisplayName("카페 코멘트 첫번째 목록을 제외한 페이지를 조회한다") void findCommentsNotFirstPage() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "베어네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "베어네 카페", "100")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("rlawjddn103@naver.com", "a1b2c3d4", "베어"); 회원_가입(signUpRequest); @@ -117,7 +117,7 @@ void findCommentsNotFirstPage() { @DisplayName("카페 코멘트 목록 중 내가 작성한 코멘트만을 조회한다") void findOnlyMyComments() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "100")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -145,7 +145,7 @@ void findOnlyMyComments() { void updateComment() { String content = "공부하기 좋아요~🥰"; String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "100")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); @@ -179,7 +179,7 @@ void updateComment() { void deleteComment() { String content = "공부하기 좋아요~🥰"; String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "100")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); diff --git a/src/test/java/mocacong/server/acceptance/CommentLikeAcceptanceTest.java b/src/test/java/mocacong/server/acceptance/CommentLikeAcceptanceTest.java index 7a0a8023..cc9e1231 100644 --- a/src/test/java/mocacong/server/acceptance/CommentLikeAcceptanceTest.java +++ b/src/test/java/mocacong/server/acceptance/CommentLikeAcceptanceTest.java @@ -17,7 +17,7 @@ public class CommentLikeAcceptanceTest extends AcceptanceTest{ void saveCommentLike() { String mapId = "12332312"; String comment = "코딩하고 싶어지는 카페에요."; - 카페_등록(new CafeRegisterRequest(mapId, "정우네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "정우네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest1 = new MemberSignUpRequest("rlawjddn103@naver.com", "a1b2c3d4", "베어"); 회원_가입(signUpRequest1); @@ -43,7 +43,7 @@ void saveCommentLike() { void deleteCommentLike() { String mapId = "12332312"; String comment = "코딩하고 싶어지는 카페에요."; - 카페_등록(new CafeRegisterRequest(mapId, "정우네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "정우네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest1 = new MemberSignUpRequest("rlawjddn103@naver.com", "a1b2c3d4", "베어"); 회원_가입(signUpRequest1); diff --git a/src/test/java/mocacong/server/acceptance/FavoriteAcceptanceTest.java b/src/test/java/mocacong/server/acceptance/FavoriteAcceptanceTest.java index 0b29a1ec..aa6855fa 100644 --- a/src/test/java/mocacong/server/acceptance/FavoriteAcceptanceTest.java +++ b/src/test/java/mocacong/server/acceptance/FavoriteAcceptanceTest.java @@ -17,7 +17,7 @@ public class FavoriteAcceptanceTest extends AcceptanceTest { @DisplayName("회원이 카페 즐겨찾기 등록을 진행한다") void saveFavoriteCafe() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); @@ -34,7 +34,7 @@ void saveFavoriteCafe() { @DisplayName("회원이 카페 즐겨찾기 삭제를 진행한다") void deleteFavoriteCafe() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); diff --git a/src/test/java/mocacong/server/acceptance/MemberAcceptanceTest.java b/src/test/java/mocacong/server/acceptance/MemberAcceptanceTest.java index e9b38695..00d933f8 100644 --- a/src/test/java/mocacong/server/acceptance/MemberAcceptanceTest.java +++ b/src/test/java/mocacong/server/acceptance/MemberAcceptanceTest.java @@ -92,7 +92,7 @@ void deleteWhenSaveReviewsAndComments() { 회원_가입(memberSignUpRequest); String token = 로그인_토큰_발급(memberSignUpRequest.getEmail(), memberSignUpRequest.getPassword()); - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); 카페_리뷰_작성(token, mapId, new CafeReviewRequest(4, "solo", "빵빵해요", "여유로워요", "깨끗해요", "충분해요", "조용해요", "편해요")); 카페_코멘트_작성(token, mapId, new CommentSaveRequest("좋아요~")); @@ -113,7 +113,7 @@ void deleteWhenSaveFavorites() { 회원_가입(memberSignUpRequest); String token = 로그인_토큰_발급(memberSignUpRequest.getEmail(), memberSignUpRequest.getPassword()); - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); 즐겨찾기_등록(token, mapId); RestAssured.given().log().all() @@ -313,7 +313,7 @@ void findMyInfo() { @DisplayName("마이페이지에서 즐겨찾기 등록한 카페 목록을 조회한다") void findMyFavoriteCafes() { String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); String token = 로그인_토큰_발급(signUpRequest.getEmail(), signUpRequest.getPassword()); @@ -333,8 +333,8 @@ void findMyFavoriteCafes() { void findMyReviewCafes() { String mapId1 = "12332312"; String mapId2 = "12121212"; - 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페")); - 카페_등록(new CafeRegisterRequest(mapId2, "케이네 카페")); + 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페", "서울시 강남구")); + 카페_등록(new CafeRegisterRequest(mapId2, "케이네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest1 = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); MemberSignUpRequest signUpRequest2 = new MemberSignUpRequest("dlawotn3@naver.com", "a1b2c3d4", "메리"); 회원_가입(signUpRequest1); @@ -375,8 +375,8 @@ void findMyReviewCafes() { void findMyCommentCafes() { String mapId1 = "12332312"; String mapId2 = "12121212"; - 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페")); - 카페_등록(new CafeRegisterRequest(mapId2, "케이네 카페")); + 카페_등록(new CafeRegisterRequest(mapId1, "메리네 카페", "서울시 강남구")); + 카페_등록(new CafeRegisterRequest(mapId2, "케이네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); 회원_가입(signUpRequest); MemberSignUpRequest signUpRequest2 = new MemberSignUpRequest("mery@naver.com", "a1b2c3d4", "메리"); diff --git a/src/test/java/mocacong/server/acceptance/ReportAcceptanceTest.java b/src/test/java/mocacong/server/acceptance/ReportAcceptanceTest.java index b9335631..fade916f 100644 --- a/src/test/java/mocacong/server/acceptance/ReportAcceptanceTest.java +++ b/src/test/java/mocacong/server/acceptance/ReportAcceptanceTest.java @@ -24,7 +24,7 @@ public class ReportAcceptanceTest extends AcceptanceTest { void reportComment() { String reportReason = "insult"; String mapId = "12332312"; - 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페")); + 카페_등록(new CafeRegisterRequest(mapId, "메리네 카페", "서울시 강남구")); MemberSignUpRequest signUpRequest1 = new MemberSignUpRequest("kth990303@naver.com", "a1b2c3d4", "케이"); MemberSignUpRequest signUpRequest2 = new MemberSignUpRequest("dlawotn3@naver.com", "a1b2c3d4", "메리"); diff --git a/src/test/java/mocacong/server/domain/BaseTimeTest.java b/src/test/java/mocacong/server/domain/BaseTimeTest.java index 5467de19..e80c6687 100644 --- a/src/test/java/mocacong/server/domain/BaseTimeTest.java +++ b/src/test/java/mocacong/server/domain/BaseTimeTest.java @@ -38,7 +38,7 @@ public void memberCreatedAtNow() { public void updateCafeAtNow() { Member member = new Member("kth990303@naver.com", "a1b2c3d4", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "100"); cafeRepository.save(cafe); CafeDetail cafeDetail = new CafeDetail(StudyType.SOLO, Wifi.FAST, Parking.COMFORTABLE, Toilet.CLEAN, Desk.UNCOMFORTABLE, Power.MANY, Sound.LOUD); Review addReview = new Review(member, cafe, cafeDetail); diff --git a/src/test/java/mocacong/server/domain/CafeImageTest.java b/src/test/java/mocacong/server/domain/CafeImageTest.java index b35476d0..2e46bbee 100644 --- a/src/test/java/mocacong/server/domain/CafeImageTest.java +++ b/src/test/java/mocacong/server/domain/CafeImageTest.java @@ -25,7 +25,7 @@ private static Stream provideCafeImagesMember() { @DisplayName("해당 카페 이미지의 작성자가 해당 회원이 맞는지 여부를 반환한다") @MethodSource("provideCafeImagesMember") void isOwned(Member input, boolean expected) { - Cafe cafe = new Cafe("123454321", "케이카페"); + Cafe cafe = new Cafe("123454321", "케이카페", "100"); CafeImage cafeImage = new CafeImage("test_url", true, cafe, member); assertThat(cafeImage.isOwned(input)).isEqualTo(expected); @@ -34,7 +34,7 @@ void isOwned(Member input, boolean expected) { @Test @DisplayName("해당 카페 이미지 작성자가 없을 경우, 해당 회원이 맞는지 여부 반환은 항상 false 반환한다") void isOwnedWhenMemberNull() { - Cafe cafe = new Cafe("123454321", "케이카페"); + Cafe cafe = new Cafe("123454321", "케이카페", "100"); CafeImage cafeImage = new CafeImage("test_url", true, cafe, null); assertThat(cafeImage.isOwned(member)).isFalse(); @@ -43,7 +43,7 @@ void isOwnedWhenMemberNull() { @Test @DisplayName("카페 이미지 작성자를 null 처리한다") void removeMember() { - Cafe cafe = new Cafe("123454321", "케이카페"); + Cafe cafe = new Cafe("123454321", "케이카페", "100"); CafeImage cafeImage = new CafeImage("test_url", true, cafe, member); cafeImage.removeMember(); @@ -55,7 +55,7 @@ void removeMember() { @DisplayName("특정 카페 이미지 url을 수정한다") void updateCafeImageUrl() { String expected = "test_update_url"; - Cafe cafe = new Cafe("123454321", "케이카페"); + Cafe cafe = new Cafe("123454321", "케이카페", "100"); CafeImage cafeImage = new CafeImage("test_url", true, cafe, member); cafeImage.updateImgUrl(expected); diff --git a/src/test/java/mocacong/server/domain/CafeTest.java b/src/test/java/mocacong/server/domain/CafeTest.java index f0b6029a..c0f4af5b 100644 --- a/src/test/java/mocacong/server/domain/CafeTest.java +++ b/src/test/java/mocacong/server/domain/CafeTest.java @@ -11,7 +11,7 @@ class CafeTest { @Test @DisplayName("카페에 평점을 기여한 사람이 없으면 0점을 반환한다") void findScoreWithNoReviews() { - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); double actual = cafe.findAverageScore(); @@ -22,7 +22,7 @@ void findScoreWithNoReviews() { @DisplayName("카페의 평점을 올바르게 계산하여 반환한다") void findScore() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); Score score1 = new Score(5, member, cafe); Score score2 = new Score(2, member, cafe); @@ -36,7 +36,7 @@ void findScore() { void updateCafeDetails() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); CafeDetail cafeDetail1 = new CafeDetail(StudyType.SOLO, Wifi.FAST, Parking.COMFORTABLE, Toilet.CLEAN, Desk.COMFORTABLE, Power.MANY, Sound.LOUD); Review review1 = new Review(member, cafe, cafeDetail1); @@ -66,7 +66,7 @@ void updateCafeDetails() { @DisplayName("카페 세부정보 리뷰로 both가 작성될 경우 solo, group 포인트가 모두 1씩 증가한다") void updateCafeDetailsWhenStudyTypesAddBoth() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); // BOTH 리뷰 추가 -> SOLO, GROUP 모두 1포인트 CafeDetail cafeDetail1 = new CafeDetail(StudyType.BOTH, Wifi.NORMAL, Parking.COMFORTABLE, Toilet.NORMAL, Desk.UNCOMFORTABLE, Power.FEW, Sound.NOISY); @@ -101,7 +101,7 @@ void updateCafeDetailsWhenStudyTypesAddBoth() { void updateCafeDetailsWhenStudyTypesEqual() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); CafeDetail cafeDetail1 = new CafeDetail(StudyType.SOLO, Wifi.FAST, Parking.COMFORTABLE, Toilet.CLEAN, Desk.COMFORTABLE, Power.MANY, Sound.LOUD); Review review1 = new Review(member, cafe, cafeDetail1); @@ -121,7 +121,7 @@ void updateCafeDetailsWhenStudyTypesEqual() { void updateCafeDetailsWhenSomeTypesNoReviews() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); CafeDetail cafeDetail = new CafeDetail(StudyType.SOLO, Wifi.FAST, null, Toilet.CLEAN, null, Power.MANY, Sound.LOUD); Review review = new Review(member, cafe, cafeDetail); @@ -136,7 +136,7 @@ void updateCafeDetailsWhenSomeTypesNoReviews() { @Test @DisplayName("카페에 리뷰가 하나도 없을 경우 모든 세부정보 타입에 null을 반환한다") void updateCafeDetailsWhenNoReviews() { - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); cafe.updateCafeDetails(); @@ -155,7 +155,7 @@ void updateCafeDetailsWhenNoReviews() { @DisplayName("카페의 스터디 타입을 반환한다") void getStudyType() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); CafeDetail cafeDetail = new CafeDetail(StudyType.SOLO, Wifi.FAST, null, Toilet.CLEAN, null, Power.MANY, Sound.LOUD); Review review = new Review(member, cafe, cafeDetail); cafe.addReview(review); @@ -167,8 +167,20 @@ void getStudyType() { @Test @DisplayName("리뷰가 없는 카페의 스터디 타입은 null 을 반환한다") void getStudyTypeWhenNotHasReviews() { - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); assertThat(cafe.getStudyType()).isNull(); } + + @Test + @DisplayName("카페의 도로명 주소를 업데이트한다") + void updateRoadAddress() { + Cafe cafe = new Cafe("1", "케이카페", "100"); + String expected = "서울시 강남구 테헤란로 123"; + + cafe.updateCafeRoadAddress(expected); + + assertThat(cafe.getRoadAddress()).isEqualTo(expected); + } + } diff --git a/src/test/java/mocacong/server/domain/CommentTest.java b/src/test/java/mocacong/server/domain/CommentTest.java index 9917515c..15929695 100644 --- a/src/test/java/mocacong/server/domain/CommentTest.java +++ b/src/test/java/mocacong/server/domain/CommentTest.java @@ -13,7 +13,7 @@ class CommentTest { @DisplayName("코멘트 길이가 200자를 초과하면 예외를 반환한다") void validateCommentLength() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); assertThatThrownBy(() -> new Comment(cafe, member, createLongComment(201))) .isInstanceOf(ExceedCommentLengthException.class); } @@ -30,7 +30,7 @@ private String createLongComment(int length) { @DisplayName("댓글 작성자 닉네임을 반환한다") void getWriterNickname() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); Comment comment = new Comment(cafe, member, "안녕하세요"); assertThat(comment.getWriterNickname()).isEqualTo(member.getNickname()); @@ -40,7 +40,7 @@ void getWriterNickname() { @DisplayName("댓글 작성자 프로필 이미지 url을 반환한다") void getWriterImgUrl() { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이", new MemberProfileImage("test_img.jpg")); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); Comment comment = new Comment(cafe, member, "안녕하세요"); assertThat(comment.getWriterImgUrl()).isEqualTo(member.getImgUrl()); @@ -51,7 +51,7 @@ void getWriterImgUrl() { void isWrittenByMember() { Member member1 = new Member("kth@naver.com", "a1b2c3d4", "케이"); Member member2 = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); Comment comment = new Comment(cafe, member1, "안녕하세요"); assertAll( diff --git a/src/test/java/mocacong/server/domain/ScoreTest.java b/src/test/java/mocacong/server/domain/ScoreTest.java index b2606243..02c17784 100644 --- a/src/test/java/mocacong/server/domain/ScoreTest.java +++ b/src/test/java/mocacong/server/domain/ScoreTest.java @@ -13,7 +13,7 @@ class ScoreTest { @DisplayName("평점이 1점 이상 5점 이하가 아니면 예외를 반환한다") void invalidRangeScore(int score) { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); assertThatThrownBy(() -> new Score(score, member, cafe)) .isInstanceOf(InvalidScoreException.class); @@ -24,7 +24,7 @@ void invalidRangeScore(int score) { @DisplayName("수정 시 평점이 1점 이상 5점 이하가 아니면 예외를 반환한다") void updateInvalidRangeScore(int score) { Member member = new Member("kth@naver.com", "a1b2c3d4", "케이"); - Cafe cafe = new Cafe("1", "케이카페"); + Cafe cafe = new Cafe("1", "케이카페", "100"); Score oldScore = new Score(3, member, cafe); assertThatThrownBy(() -> oldScore.updateScore(score)) .isInstanceOf(InvalidScoreException.class); diff --git a/src/test/java/mocacong/server/repository/CafeImageRepositoryTest.java b/src/test/java/mocacong/server/repository/CafeImageRepositoryTest.java index 948d494f..19352938 100644 --- a/src/test/java/mocacong/server/repository/CafeImageRepositoryTest.java +++ b/src/test/java/mocacong/server/repository/CafeImageRepositoryTest.java @@ -27,7 +27,7 @@ public class CafeImageRepositoryTest { @DisplayName("내가 올린 카페 이미지부터 등록 순으로 조회한다") void findAllByCafeIdAndIsUsedOrderByCafeImageIdDesc() { Pageable pageable = PageRequest.of(0, 5); - Cafe cafe = cafeRepository.save(new Cafe("1", "케이카페")); + Cafe cafe = cafeRepository.save(new Cafe("1", "케이카페", "서울시 강남구")); Member member1 = memberRepository.save(new Member("kth@naver.com", "abcd1234", "케이")); Member member2 = memberRepository.save(new Member("dla@naver.com", "abcd1234", "메리")); CafeImage cafeImage1 = new CafeImage("test_img.jpg", true, cafe, member1); diff --git a/src/test/java/mocacong/server/repository/CafeRepositoryTest.java b/src/test/java/mocacong/server/repository/CafeRepositoryTest.java index c706ba0b..e621e13e 100644 --- a/src/test/java/mocacong/server/repository/CafeRepositoryTest.java +++ b/src/test/java/mocacong/server/repository/CafeRepositoryTest.java @@ -35,10 +35,10 @@ void findNearCafeMapIdsByMyFavoriteCafes() { String mapId2 = "2"; String mapId3 = "3"; String mapId4 = "4"; - Cafe savedCafe1 = cafeRepository.save(new Cafe(mapId1, "케이카페1")); - Cafe savedCafe2 = cafeRepository.save(new Cafe(mapId2, "케이카페2")); - Cafe savedCafe3 = cafeRepository.save(new Cafe(mapId3, "케이카페3")); - Cafe savedCafe4 = cafeRepository.save(new Cafe(mapId4, "케이카페4")); + Cafe savedCafe1 = cafeRepository.save(new Cafe(mapId1, "케이카페", "1001")); + Cafe savedCafe2 = cafeRepository.save(new Cafe(mapId2, "케이카페", "1002")); + Cafe savedCafe3 = cafeRepository.save(new Cafe(mapId3, "케이카페", "1003")); + Cafe savedCafe4 = cafeRepository.save(new Cafe(mapId4, "케이카페", "1004")); Member member = memberRepository.save(new Member("kth@naver.com", "abcd1234", "케이")); favoriteRepository.save(new Favorite(member, savedCafe1)); favoriteRepository.save(new Favorite(member, savedCafe2)); @@ -58,10 +58,10 @@ void findNearCafeMapIdsByMyFavoriteCafes() { @Test @DisplayName("내가 즐겨찾기에 등록한 카페 목록을 조회한다") void findByMyFavoriteCafes() { - Cafe savedCafe1 = cafeRepository.save(new Cafe("1", "케이카페1")); - Cafe savedCafe2 = cafeRepository.save(new Cafe("2", "케이카페2")); - Cafe savedCafe3 = cafeRepository.save(new Cafe("3", "케이카페3")); - Cafe savedCafe4 = cafeRepository.save(new Cafe("4", "케이카페4")); + Cafe savedCafe1 = cafeRepository.save(new Cafe("1", "케이카페1", "100")); + Cafe savedCafe2 = cafeRepository.save(new Cafe("2", "케이카페2", "100")); + Cafe savedCafe3 = cafeRepository.save(new Cafe("3", "케이카페3", "100")); + Cafe savedCafe4 = cafeRepository.save(new Cafe("4", "케이카페4", "100")); Member member = memberRepository.save(new Member("kth@naver.com", "abcd1234", "케이")); favoriteRepository.save(new Favorite(member, savedCafe1)); favoriteRepository.save(new Favorite(member, savedCafe2)); @@ -84,9 +84,9 @@ void findByMyFavoriteCafes() { void findByMyReviewCafesById() { Member member = memberRepository.save(new Member("kth@naver.com", "abcd1234", "케이")); - Cafe savedCafe1 = cafeRepository.save(new Cafe("1", "케이카페1")); - Cafe savedCafe2 = cafeRepository.save(new Cafe("2", "케이카페2")); - Cafe savedCafe3 = cafeRepository.save(new Cafe("3", "케이카페3")); + Cafe savedCafe1 = cafeRepository.save(new Cafe("1", "케이카페1", "100")); + Cafe savedCafe2 = cafeRepository.save(new Cafe("2", "케이카페2", "100")); + Cafe savedCafe3 = cafeRepository.save(new Cafe("3", "케이카페3", "100")); Score score1 = new Score(1, member, savedCafe1); Score score2 = new Score(1, member, savedCafe2); diff --git a/src/test/java/mocacong/server/repository/CommentLikeRepositoryTest.java b/src/test/java/mocacong/server/repository/CommentLikeRepositoryTest.java index 9717f678..55df03ad 100644 --- a/src/test/java/mocacong/server/repository/CommentLikeRepositoryTest.java +++ b/src/test/java/mocacong/server/repository/CommentLikeRepositoryTest.java @@ -25,7 +25,7 @@ class CommentLikeRepositoryTest { @Test @DisplayName("comment id, 멤버 id로 댓글 좋아요 id를 조회한다") void findByCommentIdAndMemberId() { - Cafe savedCafe = cafeRepository.save(new Cafe("1", "베어카페")); + Cafe savedCafe = cafeRepository.save(new Cafe("1", "베어카페", "서울시 강남구")); Member savedMember = memberRepository.save(new Member("rlawjddn103@naver.com", "abcd1234", "베어")); Comment savedComment = commentRepository.save(new Comment(savedCafe, savedMember, "코딩하기 좋은 카페네요.")); CommentLike savedCommentLike = commentLikeRepository.save(new CommentLike(savedMember, savedComment)); diff --git a/src/test/java/mocacong/server/repository/CommentRepositoryTest.java b/src/test/java/mocacong/server/repository/CommentRepositoryTest.java index 82a88862..23831c12 100644 --- a/src/test/java/mocacong/server/repository/CommentRepositoryTest.java +++ b/src/test/java/mocacong/server/repository/CommentRepositoryTest.java @@ -26,7 +26,7 @@ class CommentRepositoryTest { @DisplayName("코멘트 id, 멤버 id로 댓글 좋아요 id를 조회한다") void findByCommentIdAndMemberId() { Cafe savedCafe = cafeRepository - .save(new Cafe("1", "베어카페")); + .save(new Cafe("1", "베어카페", "서울시 강남구")); Member savedMember = memberRepository .save(new Member("rlawjddn103@naver.com", "abcd1234", "베어")); Comment savedComment = commentRepository diff --git a/src/test/java/mocacong/server/repository/FavoriteRepositoryTest.java b/src/test/java/mocacong/server/repository/FavoriteRepositoryTest.java index 1b46accc..d0bf1f1b 100644 --- a/src/test/java/mocacong/server/repository/FavoriteRepositoryTest.java +++ b/src/test/java/mocacong/server/repository/FavoriteRepositoryTest.java @@ -24,7 +24,7 @@ class FavoriteRepositoryTest { @Test @DisplayName("카페 id, 멤버 id로 즐겨찾기 id를 조회한다") void findByCafeIdAndMemberId() { - Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페")); + Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페", "서울시 강남구")); Member savedMember = memberRepository.save(new Member("kth@naver.com", "abcd1234", "케이")); Favorite favorite = new Favorite(savedMember, savedCafe); favoriteRepository.save(favorite); @@ -41,7 +41,7 @@ void findByCafeIdAndMemberId() { @Test @DisplayName("멤버 id가 null인 즐겨찾기들을 모두 삭제한다") void deleteAllByMemberIdIsNull() { - Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페")); + Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페", "서울시 강남구")); Favorite favorite = new Favorite(null, savedCafe); favoriteRepository.save(favorite); diff --git a/src/test/java/mocacong/server/repository/ReviewRepositoryTest.java b/src/test/java/mocacong/server/repository/ReviewRepositoryTest.java index 70d3b5f0..9ba33a65 100644 --- a/src/test/java/mocacong/server/repository/ReviewRepositoryTest.java +++ b/src/test/java/mocacong/server/repository/ReviewRepositoryTest.java @@ -23,7 +23,7 @@ class ReviewRepositoryTest { @Test @DisplayName("카페 id, 멤버 id로 해당 멤버가 특정 카페에 작성한 리뷰의 id를 조회한다") void findIdByCafeIdAndMemberId() { - Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페")); + Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페", "서울시 강남구")); Member savedMember = memberRepository.save(new Member("kth@naver.com", "abcd1234", "케이")); CafeDetail cafeDetail = new CafeDetail(StudyType.SOLO, Wifi.FAST, Parking.COMFORTABLE, Toilet.CLEAN, Desk.COMFORTABLE, Power.MANY, Sound.LOUD); Review savedReview = reviewRepository.save(new Review(savedMember, savedCafe, cafeDetail)); diff --git a/src/test/java/mocacong/server/repository/ScoreRepositoryTest.java b/src/test/java/mocacong/server/repository/ScoreRepositoryTest.java index 738c325e..ee1c8158 100644 --- a/src/test/java/mocacong/server/repository/ScoreRepositoryTest.java +++ b/src/test/java/mocacong/server/repository/ScoreRepositoryTest.java @@ -21,7 +21,7 @@ class ScoreRepositoryTest { @Test @DisplayName("카페 id, 멤버 id로 해당 멤버가 특정 카페에 등록한 평점을 조회한다") void findScoreByCafeIdAndMemberId() { - Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페")); + Cafe savedCafe = cafeRepository.save(new Cafe("1", "케이카페", "서울시 강남구")); Member member = memberRepository.save(new Member("kth@naver.com", "abcd1234", "케이")); Score score = new Score(4, member, savedCafe); scoreRepository.save(score); diff --git a/src/test/java/mocacong/server/service/CafeConcurrentServiceTest.java b/src/test/java/mocacong/server/service/CafeConcurrentServiceTest.java index 114a0aa0..ec2fa8d5 100644 --- a/src/test/java/mocacong/server/service/CafeConcurrentServiceTest.java +++ b/src/test/java/mocacong/server/service/CafeConcurrentServiceTest.java @@ -36,7 +36,7 @@ public class CafeConcurrentServiceTest { @Test @DisplayName("등록되지 않은 카페를 동시에 여러 번 등록하려 해도 한 번만 등록된다") void saveCafeWithConcurrent() throws InterruptedException { - CafeRegisterRequest request = new CafeRegisterRequest("20", "메리네 카페"); + CafeRegisterRequest request = new CafeRegisterRequest("20", "메리네 카페", "서울시 강남구"); ExecutorService executorService = Executors.newFixedThreadPool(3); CountDownLatch latch = new CountDownLatch(3); List exceptions = Collections.synchronizedList(new ArrayList<>()); @@ -65,7 +65,7 @@ void saveCafeWithConcurrent() throws InterruptedException { void saveScoreWithConcurrent() throws InterruptedException { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "서울시 강남구"); cafeRepository.save(cafe); ExecutorService executorService = Executors.newFixedThreadPool(3); CountDownLatch latch = new CountDownLatch(3); @@ -97,7 +97,7 @@ void saveScoreWithConcurrent() throws InterruptedException { void saveCafeReviewWithConcurrent() throws InterruptedException { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "서울시 강남구"); cafeRepository.save(cafe); ExecutorService executorService = Executors.newFixedThreadPool(3); CountDownLatch latch = new CountDownLatch(3); diff --git a/src/test/java/mocacong/server/service/CafeServiceTest.java b/src/test/java/mocacong/server/service/CafeServiceTest.java index 9b49e535..f21339ca 100644 --- a/src/test/java/mocacong/server/service/CafeServiceTest.java +++ b/src/test/java/mocacong/server/service/CafeServiceTest.java @@ -57,7 +57,7 @@ class CafeServiceTest { @Test @DisplayName("등록되지 않은 카페를 성공적으로 등록한다") void cafeSave() { - CafeRegisterRequest request = new CafeRegisterRequest("20", "메리네 카페"); + CafeRegisterRequest request = new CafeRegisterRequest("20", "메리네 카페", "100"); cafeService.save(request); @@ -66,18 +66,17 @@ void cafeSave() { } @Test - @DisplayName("등록되어 있는 카페는 등록하지 않는다") + @DisplayName("등록되어 있는 카페를 등록하면 주소가 업데이트 된다") void cafeSaveDuplicate() { - CafeRegisterRequest request1 = new CafeRegisterRequest("20", "메리네 카페"); + CafeRegisterRequest request1 = new CafeRegisterRequest("20", "메리네 카페", "100"); cafeService.save(request1); - CafeRegisterRequest request2 = new CafeRegisterRequest("20", "카페"); + CafeRegisterRequest request2 = new CafeRegisterRequest("20", "카페", "200"); + cafeService.save(request2); List actual = cafeRepository.findAll(); - assertAll( - () -> assertThrows(DuplicateCafeException.class, () -> cafeService.save(request2)), - () -> assertThat(actual).hasSize(1) - ); + assertThat(actual).hasSize(1); + assertThat(actual.get(0).getRoadAddress()).isEqualTo("200"); } @Test @@ -85,7 +84,7 @@ void cafeSaveDuplicate() { void findCafe() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); FindCafeResponse actual = cafeService.findCafeByMapId(member.getId(), cafe.getMapId()); @@ -110,7 +109,7 @@ void findCafeWithScore() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Score score1 = new Score(4, member1, cafe); scoreRepository.save(score1); @@ -138,7 +137,7 @@ void findCafeWithReviewsAndComments() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(1, "group", "느려요", "없어요", @@ -176,7 +175,7 @@ void findCafeWithCommentLike() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(1, "group", "느려요", "없어요", @@ -219,7 +218,7 @@ void findCafeWithCommentLike() { void previewCafe() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); PreviewCafeResponse actual = cafeService.previewCafeByMapId(member.getId(), cafe.getMapId()); @@ -239,7 +238,7 @@ void previewCafeWithScore() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); scoreRepository.save(new Score(4, member1, cafe)); scoreRepository.save(new Score(5, member2, cafe)); @@ -262,7 +261,7 @@ void previewCafeWithScoreAndReview() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(3, "group", "느려요", "없어요", @@ -287,7 +286,7 @@ void previewCafeWithScoreAndReview() { void findCafeAndShowLimitComments() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Comment comment1 = new Comment(cafe, member, "댓글1"); commentRepository.save(comment1); @@ -313,7 +312,7 @@ void findCafeWithReviewsAndCommentsByDeleteMember() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(1, "group", "느려요", "없어요", @@ -344,7 +343,7 @@ void findCafeWithAll() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(1, "group", "느려요", "없어요", @@ -387,7 +386,7 @@ void findCafeAndShowLimitImages() throws IOException { memberRepository.save(member); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); String mapId = cafe.getMapId(); FileInputStream fileInputStream = new FileInputStream("src/test/resources/images/" + expected); @@ -417,7 +416,7 @@ void findMyFavoriteCafes() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(1, "group", "느려요", "없어요", @@ -443,8 +442,8 @@ void findMyReviewCafes() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe1 = new Cafe("2143154352323", "케이카페"); - Cafe cafe2 = new Cafe("2154122541112", "메리카페"); + Cafe cafe1 = new Cafe("2143154352323", "케이카페", "200"); + Cafe cafe2 = new Cafe("2154122541112", "메리카페", "100"); cafeRepository.save(cafe1); cafeRepository.save(cafe2); cafeService.saveCafeReview(member1.getId(), cafe1.getMapId(), @@ -463,10 +462,10 @@ void findMyReviewCafes() { () -> assertThat(actual.getIsEnd()).isTrue(), () -> assertThat(actual.getCafes().get(0).getMyScore()).isEqualTo(1), () -> assertThat(actual.getCafes().get(0).getMyStudyType()).isEqualTo("solo"), - () -> assertThat(actual.getCafes().get(0).getName()).isEqualTo("케이카페"), + () -> assertThat(actual.getCafes().get(0).getName()).isEqualTo("케이카페", "200"), () -> assertThat(actual.getCafes().get(1).getMyScore()).isEqualTo(5), () -> assertThat(actual.getCafes().get(1).getMyStudyType()).isEqualTo("group"), - () -> assertThat(actual.getCafes().get(1).getName()).isEqualTo("메리카페"), + () -> assertThat(actual.getCafes().get(1).getName()).isEqualTo("메리카페", "100"), () -> assertThat(actual.getCafes()).hasSize(2) ); } @@ -478,8 +477,8 @@ void findMyCommentCafes() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe1 = new Cafe("2143154352323", "케이카페"); - Cafe cafe2 = new Cafe("1212121212121", "메리카페"); + Cafe cafe1 = new Cafe("2143154352323", "케이카페", "200"); + Cafe cafe2 = new Cafe("1212121212121", "메리카페", "100"); cafeRepository.save(cafe1); cafeRepository.save(cafe2); commentRepository.save(new Comment(cafe1, member1, "댓글1")); @@ -505,7 +504,7 @@ void saveCafeReview() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(4, "solo", "빵빵해요", "여유로워요", @@ -536,7 +535,7 @@ void saveCafeAndStudyTypesEquals() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), @@ -556,7 +555,7 @@ void findMyCafeReview() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(4, "solo", "빵빵해요", "여유로워요", @@ -584,7 +583,7 @@ void findMyCafeReview() { void findNotRegisteredCafeReview() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); CafeMyReviewResponse actual = cafeService.findMyCafeReview(member.getId(), cafe.getMapId()); @@ -608,7 +607,7 @@ void cannotSaveManyReviews() { memberRepository.save(member1); Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member1.getId(), cafe.getMapId(), new CafeReviewRequest(4, "solo", "빵빵해요", "여유로워요", @@ -625,7 +624,7 @@ void cannotSaveManyReviews() { public void updateCafeReview() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member.getId(), cafe.getMapId(), new CafeReviewRequest(4, "solo", "빵빵해요", "여유로워요", @@ -653,7 +652,7 @@ public void updateCafeReview() { public void updateCafeReviewWhenDetailsNull() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member.getId(), cafe.getMapId(), new CafeReviewRequest(4, "solo", "빵빵해요", "여유로워요", @@ -681,7 +680,7 @@ public void updateCafeReviewWhenDetailsNull() { public void updateCafeReviewNotFoundReview() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); assertThatThrownBy(() -> cafeService.updateCafeReview(member.getId(), cafe.getMapId(), @@ -697,11 +696,11 @@ void getCafesFilterStudyType() { Member member2 = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member1); memberRepository.save(member2); - Cafe cafe1 = new Cafe("2143154352323", "케이카페"); - Cafe cafe2 = new Cafe("2143154311111", "메리카페"); - Cafe cafe3 = new Cafe("2111111125885", "메리카페 2호점"); - Cafe cafe4 = new Cafe("1585656565441", "메리벅스"); - Cafe cafe5 = new Cafe("1582212121441", "메리설빙"); + Cafe cafe1 = new Cafe("2143154352323", "케이카페", "200"); + Cafe cafe2 = new Cafe("2143154311111", "메리카페", "100"); + Cafe cafe3 = new Cafe("2111111125885", "메리카페 2호점", "300"); + Cafe cafe4 = new Cafe("1585656565441", "메리벅스", "400"); + Cafe cafe5 = new Cafe("1582212121441", "메리설빙", "500"); cafeRepository.save(cafe1); cafeRepository.save(cafe2); cafeRepository.save(cafe3); @@ -737,7 +736,7 @@ void getCafesFilterStudyType() { void getCafesFilterStudyTypeWhenNoMatch() { Member member = new Member("dlawotn3@naver.com", "encodePassword", "메리"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); cafeService.saveCafeReview(member.getId(), cafe.getMapId(), new CafeReviewRequest(4, "solo", "빵빵해요", "여유로워요", @@ -754,10 +753,10 @@ void getCafesFilterStudyTypeWhenNoMatch() { void getCafesFilterFavorites() { Member member = new Member("dlawotn3@naver.com", "encodePassword", "메리"); memberRepository.save(member); - Cafe cafe1 = new Cafe("2143154352323", "케이카페"); - Cafe cafe2 = new Cafe("2143154311111", "메리카페"); - Cafe cafe3 = new Cafe("2111111125885", "메리카페 2호점"); - Cafe cafe4 = new Cafe("1585656565441", "메리벅스"); + Cafe cafe1 = new Cafe("2143154352323", "케이카페", "200"); + Cafe cafe2 = new Cafe("2143154311111", "메리카페", "100"); + Cafe cafe3 = new Cafe("2111111125885", "메리카페 2호점", "300"); + Cafe cafe4 = new Cafe("1585656565441", "메리벅스", "400"); cafeRepository.save(cafe1); cafeRepository.save(cafe2); cafeRepository.save(cafe3); @@ -779,7 +778,7 @@ void getCafesFilterFavorites() { void getCafesFilterFavoritesWhenNoMatch() { Member member = new Member("dlawotn3@naver.com", "encodePassword", "메리"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); CafeFilterFavoritesRequest requestBody = new CafeFilterFavoritesRequest(List.of(cafe.getMapId())); @@ -793,7 +792,7 @@ void getCafesFilterFavoritesWhenNoMatch() { @DisplayName("카페 이미지를 성공적으로 저장한다") void saveCafeImage() throws IOException { String expected = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -817,7 +816,7 @@ void saveCafeImage() throws IOException { @Test @DisplayName("카페 이미지를 저장한 후 Response를 반환한다.") void saveCafeImageWithResponse() throws IOException { - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -838,7 +837,7 @@ void saveCafeImageWithResponse() throws IOException { @Test @DisplayName("카페 이미지를 한 번에 3개까지 저장할 수 있다") void saveCafeImagesPerRequest() throws IOException { - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("kth990303@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -864,7 +863,7 @@ void saveCafeImagesPerRequest() throws IOException { @Test @DisplayName("카페 이미지를 한 번에 세 개를 초과하여 저장하면 예외를 반환한다") void saveCafeImagesManyPerRequest() throws IOException { - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("kth990303@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -893,7 +892,7 @@ void saveCafeImagesManyPerRequest() throws IOException { @DisplayName("사용자가 카페 이미지를 여러 번 저장한다") void saveCafeImages() throws IOException { String expected = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -920,7 +919,7 @@ void saveCafeImages() throws IOException { @Test @DisplayName("사용자가 카페 이미지를 총 3개 보다 많이 저장하면 예외가 발생한다.") void saveCafeImagesOver3() throws IOException { - Cafe cafe = new Cafe("2143154352323", "베어카페"); + Cafe cafe = new Cafe("2143154352323", "베어카페", "200"); cafeRepository.save(cafe); Member member = new Member("rlawjddn103@naver.com", "a1b2c3d4", "베어", null); memberRepository.save(member); @@ -957,7 +956,7 @@ void saveCafeImagesOver3() throws IOException { @DisplayName("사용자가 카페 이미지를 조회한다") void findCafeImages() throws IOException { String expected = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -983,7 +982,7 @@ void findCafeImages() throws IOException { @DisplayName("자신이 등록한 카페 이미지를 조회하는 경우 isMe가 True로 반환된다") void findCafeMyImagesReturnTrue() throws IOException { String expected = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -1009,7 +1008,7 @@ void findCafeMyImagesReturnTrue() throws IOException { @DisplayName("타인이 등록한 카페이미지를 조회할 때 isMe가 false로 반환된다") void findOtherCafeImagesReturnFalse() throws IOException { String expected = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member1 = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member1); @@ -1039,7 +1038,7 @@ void findOtherCafeImagesReturnFalse() throws IOException { @DisplayName("자신이 등록한 이미지부터 등록 순으로 이미지를 조회한다") void findCafeImagesReturnOrderedImages() throws IOException { String expected = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member1 = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member1); @@ -1075,7 +1074,7 @@ void findCafeImagesReturnOrderedImages() throws IOException { @DisplayName("타인이 나중에 이미지를 등록해도 자신이 등록한 이미지부터 등록 순으로 조회한다") void findCafeImagesReturnOrderedMyImages() throws IOException { String expected = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member1 = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member1); @@ -1112,7 +1111,7 @@ void findCafeImagesReturnOrderedMyImages() throws IOException { void updateCafeImage() throws IOException { String oldImage = "test_img.jpg"; String newImage = "test_img2.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -1147,7 +1146,7 @@ void updateCafeImage() throws IOException { @DisplayName("존재하지 않는 카페 이미지를 수정 시도할 시 예외를 반환한다") void updateCafeImageNotFoundImage() throws IOException { String newImage = "test_img.jpg"; - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); Member member = new Member("dlawotn3@naver.com", "a1b2c3d4", "메리", null); memberRepository.save(member); @@ -1172,7 +1171,7 @@ void updateCafeImageAndShowLimitImages() throws IOException { memberRepository.save(member); memberRepository.save(member2); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); String mapId = cafe.getMapId(); FileInputStream oldFileInputStream = new FileInputStream("src/test/resources/images/" + oldImage); @@ -1215,7 +1214,7 @@ void updateCafeImageAndShowLimitImages() throws IOException { void cafeImagesWhenMemberDelete() throws IOException { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); FileInputStream fileInputStream = new FileInputStream("src/test/resources/images/test_img.jpg"); MockMultipartFile mockMultipartFile = new MockMultipartFile("test_img", "test_img.jpg", @@ -1238,7 +1237,7 @@ void deleteNotUsedCafeImages() { List notUsedImgUrls = List.of("test_img2.jpg", "test_img3.jpg"); Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "200"); cafeRepository.save(cafe); CafeImage cafeImage1 = new CafeImage("test_img.jpg", true, cafe, member); cafeImageRepository.save(cafeImage1); diff --git a/src/test/java/mocacong/server/service/CommentLikeConcurrentServiceTest.java b/src/test/java/mocacong/server/service/CommentLikeConcurrentServiceTest.java index 980dea14..1803d328 100644 --- a/src/test/java/mocacong/server/service/CommentLikeConcurrentServiceTest.java +++ b/src/test/java/mocacong/server/service/CommentLikeConcurrentServiceTest.java @@ -43,7 +43,7 @@ void saveCommentLikeWithConcurrent() throws InterruptedException { memberRepository.save(member1); Member member2 = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "100"); cafeRepository.save(cafe); Comment comment = new Comment(cafe, member2, commentContent); commentRepository.save(comment); diff --git a/src/test/java/mocacong/server/service/CommentLikeServiceTest.java b/src/test/java/mocacong/server/service/CommentLikeServiceTest.java index 27c76565..540eec98 100644 --- a/src/test/java/mocacong/server/service/CommentLikeServiceTest.java +++ b/src/test/java/mocacong/server/service/CommentLikeServiceTest.java @@ -42,7 +42,7 @@ void save() { memberRepository.save(member1); Member member2 = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "서울시 강남구"); cafeRepository.save(cafe); Comment comment = new Comment(cafe, member2, commentContent); commentRepository.save(comment); @@ -65,7 +65,7 @@ void saveDuplicateCommentLike() { memberRepository.save(member1); Member member2 = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "서울시 강남구"); cafeRepository.save(cafe); Comment comment = new Comment(cafe, member2, commentContent); commentRepository.save(comment); @@ -83,7 +83,7 @@ void saveInvalidCommentLike() { String commentContent = "코딩하고 싶어지는 카페에요."; Member member = new Member(email, "encodePassword", "베어"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "서울시 강남구"); cafeRepository.save(cafe); Comment comment = new Comment(cafe, member, commentContent); commentRepository.save(comment); @@ -100,7 +100,7 @@ void delete() { memberRepository.save(member1); Member member2 = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "서울시 강남구"); cafeRepository.save(cafe); Comment comment = new Comment(cafe, member2, commentContent); commentRepository.save(comment); @@ -120,7 +120,7 @@ void deleteNotExistCommentLike() { String commentContent = "코딩하고 싶어지는 카페에요."; Member member = new Member(email, "encodePassword", "베어"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "서울시 강남구"); cafeRepository.save(cafe); Comment comment = new Comment(cafe, member, commentContent); commentRepository.save(comment); diff --git a/src/test/java/mocacong/server/service/CommentServiceTest.java b/src/test/java/mocacong/server/service/CommentServiceTest.java index 13f4751f..55a6170f 100644 --- a/src/test/java/mocacong/server/service/CommentServiceTest.java +++ b/src/test/java/mocacong/server/service/CommentServiceTest.java @@ -49,7 +49,7 @@ void save() { String expected = "공부하기 좋아요~🥰"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); CommentSaveResponse savedComment = commentService.save(member.getId(), mapId, expected); @@ -78,7 +78,7 @@ void saveManyTimes() { String mapId = "2143154352323"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); commentService.save(member.getId(), mapId, "공부하기 좋아요~🥰"); @@ -93,7 +93,7 @@ void findComments() { String mapId = "2143154352323"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); commentRepository.save(new Comment(cafe, member, "댓글1")); commentRepository.save(new Comment(cafe, member, "댓글2")); @@ -118,7 +118,7 @@ void findCommentsWithCount() { String mapId = "2143154352323"; Member member = new Member(email, "encodePassword", "베어"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "100"); cafeRepository.save(cafe); commentRepository.save(new Comment(cafe, member, "댓글1")); commentRepository.save(new Comment(cafe, member, "댓글2")); @@ -148,7 +148,7 @@ void findOnlyMyComments() { Member member2 = new Member("mery@naver.com", "encodePassword", "메리"); memberRepository.save(member); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); commentRepository.save(new Comment(cafe, member, "댓글1")); commentRepository.save(new Comment(cafe, member2, "댓글2")); @@ -174,7 +174,7 @@ void updateComment() { String comment = "공부하기 좋아요~🥰"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); CommentSaveResponse savedComment = commentService.save(member.getId(), mapId, comment); String expected = "조용하고 좋네요"; @@ -194,7 +194,7 @@ void updateManyTimes() { String comment = "공부하기 좋아요~🥰"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); CommentSaveResponse savedComment = commentService.save(member.getId(), mapId, comment); String expected = "조용하고 좋네요"; @@ -214,7 +214,7 @@ void updateByNonWriter() { memberRepository.save(member1); Member member2 = new Member(email2, "encodePassword", "메리"); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); CommentSaveResponse savedComment = commentService.save(member1.getId(), mapId, "조용하고 좋네요"); @@ -229,7 +229,7 @@ void delete() { String mapId = "2143154352323"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); CommentSaveResponse response = commentService.save(member.getId(), mapId, "공부하기 좋아요~🥰"); @@ -246,7 +246,7 @@ void deleteNotExistsComment() { String mapId = "2143154352323"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); assertThatThrownBy(() -> commentService.delete(member.getId(), mapId, 9999L)) @@ -263,7 +263,7 @@ void deleteNotMyComment() { Member member2 = new Member(email2, "encodePassword", "메리"); memberRepository.save(member1); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "100"); cafeRepository.save(cafe); CommentSaveResponse response = commentService.save(member1.getId(), mapId, "공부하기 좋아요~🥰"); @@ -279,7 +279,7 @@ void deleteExistCommentLike() { String commentContent = "코딩하고 싶어지는 카페에요."; Member member = new Member(email, "encodePassword", "베어"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "베어카페"); + Cafe cafe = new Cafe(mapId, "베어카페", "100"); cafeRepository.save(cafe); Comment savedComment = commentRepository.save(new Comment(cafe, member, commentContent)); commentLikeRepository.save(new CommentLike(member, savedComment)); diff --git a/src/test/java/mocacong/server/service/FavoriteConcurrentServiceTest.java b/src/test/java/mocacong/server/service/FavoriteConcurrentServiceTest.java index b86b1d5c..77c0cd46 100644 --- a/src/test/java/mocacong/server/service/FavoriteConcurrentServiceTest.java +++ b/src/test/java/mocacong/server/service/FavoriteConcurrentServiceTest.java @@ -37,7 +37,7 @@ public class FavoriteConcurrentServiceTest { void saveFavoriteWithConcurrent() throws InterruptedException { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "서울시 강남구"); cafeRepository.save(cafe); ExecutorService executorService = Executors.newFixedThreadPool(3); CountDownLatch latch = new CountDownLatch(3); diff --git a/src/test/java/mocacong/server/service/FavoriteServiceTest.java b/src/test/java/mocacong/server/service/FavoriteServiceTest.java index 8e633909..aa5b8414 100644 --- a/src/test/java/mocacong/server/service/FavoriteServiceTest.java +++ b/src/test/java/mocacong/server/service/FavoriteServiceTest.java @@ -35,7 +35,7 @@ class FavoriteServiceTest { void save() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "서울시 강남구"); cafeRepository.save(cafe); FavoriteSaveResponse actual = favoriteService.save(member.getId(), cafe.getMapId()); @@ -52,7 +52,7 @@ void save() { void saveDuplicate() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "서울시 강남구"); cafeRepository.save(cafe); favoriteService.save(member.getId(), cafe.getMapId()); @@ -65,7 +65,7 @@ void saveDuplicate() { void delete() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "서울시 강남구"); cafeRepository.save(cafe); Favorite favorite = new Favorite(member, cafe); favoriteRepository.save(favorite); @@ -80,7 +80,7 @@ void delete() { void deleteWithException() { Member member = new Member("kth990303@naver.com", "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe("2143154352323", "케이카페"); + Cafe cafe = new Cafe("2143154352323", "케이카페", "서울시 강남구"); cafeRepository.save(cafe); assertThrows(NotFoundFavoriteException.class, diff --git a/src/test/java/mocacong/server/service/ReportConcurrentServiceTest.java b/src/test/java/mocacong/server/service/ReportConcurrentServiceTest.java index 21a7c152..9780e749 100644 --- a/src/test/java/mocacong/server/service/ReportConcurrentServiceTest.java +++ b/src/test/java/mocacong/server/service/ReportConcurrentServiceTest.java @@ -41,7 +41,7 @@ void reportCommentWithConcurrent() throws InterruptedException { Member member2 = new Member(email2, "encodePassword", "메리"); memberRepository.save(member1); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "서울시 강남구"); cafeRepository.save(cafe); CommentSaveResponse saveResponse = commentService.save(member1.getId(), mapId, "아~ 소설보고 싶다"); ExecutorService executorService = Executors.newFixedThreadPool(3); diff --git a/src/test/java/mocacong/server/service/ReportServiceTest.java b/src/test/java/mocacong/server/service/ReportServiceTest.java index fd178a1f..1d3193a1 100644 --- a/src/test/java/mocacong/server/service/ReportServiceTest.java +++ b/src/test/java/mocacong/server/service/ReportServiceTest.java @@ -53,7 +53,7 @@ void reportComment() { Member member2 = new Member(email2, "encodePassword", "메리"); memberRepository.save(member1); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "서울시 강남구"); cafeRepository.save(cafe); commentService.save(member1.getId(), mapId, "이 카페 완전 돈 아깝;;"); @@ -69,7 +69,7 @@ void reportMyComment() { String mapId = "2143154352323"; Member member = new Member(email, "encodePassword", "케이"); memberRepository.save(member); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "서울시 강남구"); cafeRepository.save(cafe); CommentSaveResponse saveResponse = commentService.save(member.getId(), mapId, "굳이 이런데 가야하나 ㅋ"); @@ -85,7 +85,7 @@ void reportByInvalidReportReason() { Member member2 = new Member("dlawotn3@naver.com", "encodePassword", "메리"); memberRepository.save(member1); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "서울시 강남구"); cafeRepository.save(cafe); commentService.save(member1.getId(), mapId, "이 카페 완전 돈 아깝;;"); @@ -104,7 +104,7 @@ void reportDuplicateComment() { Member member2 = new Member(email2, "encodePassword", "메리"); memberRepository.save(member1); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "서울시 강남구"); cafeRepository.save(cafe); CommentSaveResponse saveResponse = commentService.save(member1.getId(), mapId, "아~ 소설보고 싶다"); @@ -126,7 +126,7 @@ void maskCauseReport5timesReportedComment() { members.add(member); memberRepository.save(member); } - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "서울시 강남구"); cafeRepository.save(cafe); CommentSaveResponse saveResponse = commentService.save(members.get(0).getId(), mapId, "아~ 소설보고 싶다"); @@ -162,7 +162,7 @@ void setInactiveCause11timesReportedComment() { } for (int i = 1; i <= 11; i++) { String mapId = "abc" + (char) ('A' + i); - cafeRepository.save(new Cafe(mapId, "메리 카페")); + cafeRepository.save(new Cafe(mapId, "메리 카페", "서울시 강남구")); CommentSaveResponse saveResponse = commentService.save(members.get(0).getId(), mapId, "아~ 소설보고 싶다"); for (int j = 1; j <= 5; j ++) { @@ -192,7 +192,7 @@ void reportCommentPostedDeletedMember() { Member member2 = new Member(email2, "encodePassword", "메리"); memberRepository.save(member1); memberRepository.save(member2); - Cafe cafe = new Cafe(mapId, "케이카페"); + Cafe cafe = new Cafe(mapId, "케이카페", "서울시 강남구"); cafeRepository.save(cafe); Comment comment = new Comment(cafe, member1, "이 카페 완전 돈 아깝;;"); commentRepository.save(comment);