-
Notifications
You must be signed in to change notification settings - Fork 1
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 #117 from modu-menu/feat/add-save-choice
투표 생성 API 수정, 투표, 재투표 API 구현
- Loading branch information
Showing
10 changed files
with
227 additions
and
5 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
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package modu.menu.vote.api.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Positive; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Schema(description = "투표 요청 DTO") | ||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class VoteRequest { | ||
|
||
@Schema(description = "투표하려는 음식점 ID") | ||
@Positive(message = "placeId는 양수여야 합니다.") | ||
private Long placeId; | ||
} |
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
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 |
---|---|---|
|
@@ -77,6 +77,9 @@ class VoteServiceTest extends IntegrationTestSupporter { | |
@Test | ||
void saveVote() { | ||
// given | ||
User user1 = createUser("[email protected]"); | ||
User user2 = createUser("[email protected]"); | ||
User user3 = createUser("[email protected]"); | ||
Place place1 = createPlace("타코벨"); | ||
Place place2 = createPlace("이자카야모리"); | ||
Place place3 = createPlace("서가앤쿡 노원역점"); | ||
|
@@ -89,9 +92,11 @@ void saveVote() { | |
place2.addPlaceVibe(placeVibe2); | ||
PlaceVibe placeVibe3 = createPlaceVibe(place3, vibe3); | ||
place3.addPlaceVibe(placeVibe3); | ||
userRepository.saveAll(List.of(user1, user2, user3)); | ||
placeRepository.saveAll(List.of(place1, place2, place3)); | ||
vibeRepository.saveAll(List.of(vibe1, vibe2, vibe3)); | ||
placeVibeRepository.saveAll(List.of(placeVibe1, placeVibe2, placeVibe3)); | ||
|
||
Food food1 = createFood(FoodType.LATIN); | ||
Food food2 = createFood(FoodType.MEAT); | ||
PlaceFood placeFood1 = createPlaceFood(place1, food1); | ||
|
@@ -107,12 +112,15 @@ void saveVote() { | |
.placeIds(List.of(1L, 2L, 3L)) | ||
.build(); | ||
|
||
request.setAttribute("userId", user1.getId()); | ||
|
||
// when | ||
voteService.saveVote(saveVoteRequest); | ||
|
||
|
||
// then | ||
assertThat(voteRepository.findAll()).isNotEmpty(); | ||
assertThat(participantRepository.findByUserId(user1.getId()).get().getVoteRole()).isEqualTo(VoteRole.ORGANIZER); | ||
} | ||
|
||
@DisplayName("투표를 생성할 때 ID 목록에 있는 음식점들이 존재하지 않으면 실패한다.") | ||
|