Skip to content

Commit

Permalink
MATE-91 : [FEAT] 메이트 게시글 상세 조회 반환값 수정 (#84)
Browse files Browse the repository at this point in the history
* MATE-91 : [FEAT] 메이트 게시글 상세 조회 반환값 수정

- 1. 메이트 게시글 상세 조회 반환값에 authorId값 추가

* MATE-91 : [FEAT] 테스트 H2 데이터베이스 초기화
-1. merge 후 H2 데이터베이스 사용에서의 로컬 환경이 달라 에러 발생
  • Loading branch information
juchan204 authored Dec 5, 2024
1 parent d807f97 commit d62a418
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MatePostDetailResponse {
private String content;
private Long postId;
private Long matchId;
private Long authorId;

public static MatePostDetailResponse from(MatePost post) {
String myTeamName = TeamInfo.getById(post.getTeamId()).shortName;
Expand All @@ -55,6 +56,7 @@ public static MatePostDetailResponse from(MatePost post) {
.content(post.getContent())
.postId(post.getId())
.matchId(post.getMatch().getId())
.authorId(post.getAuthor().getId())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ private MatePostDetailResponse createMatePostDetailResponse() {
.manner(36.5f)
.content("테스트 내용입니다.")
.postId(1L)
.matchId(1L)
.authorId(1L)
.build();
}

Expand Down Expand Up @@ -414,6 +416,8 @@ void getMatePostDetail_success() throws Exception {
.andExpect(jsonPath("$.data.maxParticipants").value(response.getMaxParticipants()))
.andExpect(jsonPath("$.data.nickname").value(response.getNickname()))
.andExpect(jsonPath("$.data.manner").value(response.getManner()))
.andExpect(jsonPath("$.data.matchId").value(response.getMatchId()))
.andExpect(jsonPath("$.data.authorId").value(response.getAuthorId()))
.andExpect(jsonPath("$.code").value(200));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ void getMatePostDetail_Success() throws Exception {
.andExpect(jsonPath("$.status").value("SUCCESS"))
.andExpect(jsonPath("$.code").value(200))
.andExpect(jsonPath("$.data.postId").value(openPost.getId()))
.andExpect(jsonPath("$.data.authorId").value(testMember.getId()))
.andExpect(jsonPath("$.data.matchId").value(futureMatch.getId()))
.andExpect(jsonPath("$.data.title").value("테스트 제목"))
.andExpect(jsonPath("$.data.content").value("테스트 내용"))
.andExpect(jsonPath("$.data.status").value("모집중"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ void getMatePostDetail_Success() {
assertThat(response.getManner()).isEqualTo(0.3f);
assertThat(response.getContent()).isEqualTo("테스트 내용");
assertThat(response.getPostId()).isEqualTo(POST_ID);
assertThat(response.getAuthorId()).isEqualTo(testMember.getId());
assertThat(response.getMatchId()).isEqualTo(testMatch.getId());

verify(mateRepository).findById(POST_ID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class FollowIntegrationTest {

@BeforeEach
void setUp() {

// H2 데이터베이스의 ID 초기화 문법
jdbcTemplate.execute("ALTER TABLE member ALTER COLUMN id RESTART WITH 1");
jdbcTemplate.execute("ALTER TABLE follow ALTER COLUMN id RESTART WITH 1");

jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY FALSE");
jdbcTemplate.execute("TRUNCATE TABLE member");
jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY TRUE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ class MemberIntegrationTest {

@BeforeEach
void setUp() {

// H2 데이터베이스의 ID 초기화 문법
jdbcTemplate.execute("ALTER TABLE member ALTER COLUMN id RESTART WITH 1");

jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY FALSE");
jdbcTemplate.execute("TRUNCATE TABLE member");
jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY TRUE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public class ProfileIntegrationTest {

@BeforeEach
void setUp() {
// H2 데이터베이스의 ID 초기화 문법
jdbcTemplate.execute("ALTER TABLE member ALTER COLUMN id RESTART WITH 1");

jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY FALSE");
jdbcTemplate.execute("TRUNCATE TABLE member");
jdbcTemplate.execute("SET REFERENTIAL_INTEGRITY TRUE");
Expand Down

0 comments on commit d62a418

Please sign in to comment.