Skip to content

Commit

Permalink
modify: record로 전환함에 따른 get 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
rookedsysc committed Oct 13, 2024
1 parent fdcbe4a commit 2d36e65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/main/java/com/gamemoonchul/domain/entity/VoteOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class VoteOptions {
@OneToMany(fetch = FetchType.LAZY, mappedBy = "voteOption", cascade = CascadeType.ALL, orphanRemoval = true)
final private List<Vote> votes = new ArrayList<>();
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "post_id")
private Post post;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "match_user_id")
private MatchUser matchUser;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "voteOption", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Vote> votes = new ArrayList<>();

public void addVote(Vote vote) {
this.votes.add(vote);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void unauthorizedDeleteTest() {
PostDetailResponse response = postService.upload(PostDummy.createRequest(), member1);

// then
assertThatThrownBy(() -> postDeleteService.delete(response.getId(), member2.getId())).isInstanceOf(UnauthorizedException.class)
assertThatThrownBy(() -> postDeleteService.delete(response.id(), member2.getId())).isInstanceOf(UnauthorizedException.class)
.hasMessageContaining(PostStatus.UNAUTHORIZED_REQUEST.getMessage());
}

Expand All @@ -59,13 +59,13 @@ public void deletePostAndComment() {
// given
Member member = memberRepository.save(MemberDummy.create());
PostDetailResponse response = postService.upload(PostDummy.createRequest(), member);
Post savedPost = postRepository.findById(response.getId())
Post savedPost = postRepository.findById(response.id())
.orElseThrow(() -> new BadRequestException(PostStatus.POST_NOT_FOUND));
Comment comment = CommentDummy.create(savedPost, member);
commentRepository.save(comment);

// when
postDeleteService.delete(response.getId(), member.getId());
postDeleteService.delete(response.id(), member.getId());

// then
assertThat(commentRepository.findAllByPost(savedPost)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public void defaultUploadTest() {

// then
assertThat(allSavedPost.size()).isEqualTo(1);
assertThat(response.getTimesAgo()).isNotNull();
assertThat(response.timesAgo()).isNotNull();
assertThat(response).isNotNull();
assertThat(response.getVoteDetail()
assertThat(response.voteDetail()
.size()).isEqualTo(2);
assertThat(response.getViewCount()).isEqualTo(0);
assertThat(response.viewCount()).isEqualTo(0);
}
}

0 comments on commit 2d36e65

Please sign in to comment.