Skip to content

Commit 2376490

Browse files
authored
Merge pull request #857 from Clubber2024/test/#845-모집글-수정-테스트-코드-작성
test : recruit 테이블 관련 테스트코드 데이터 수정
2 parents 07278b6 + 4444365 commit 2376490

3 files changed

Lines changed: 54 additions & 28 deletions

File tree

src/test/java/com/clubber/ClubberServer/integration/domain/recruit/service/RecruitServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ void updateRecruitWithEverytimeUrl() {
241241
UPDATE_NO_IMAGE_RECRUIT_REQUEST.getTitle()),
242242
() -> assertThat(updatedRecruit.get().getContent()).isEqualTo(
243243
UPDATE_NO_IMAGE_RECRUIT_REQUEST.getContent()),
244-
() -> assertThat(updatedRecruit.get().getEverytimeUrl()).isEqualTo(
245-
UPDATE_NO_IMAGE_RECRUIT_REQUEST.getEverytimeUrl()));
244+
() -> assertThat(updatedRecruit.get().getApplyLink()).isEqualTo(
245+
UPDATE_NO_IMAGE_RECRUIT_REQUEST.getApplyLink()));
246246
}
247247
}
248248
}

src/test/java/com/clubber/ClubberServer/integration/util/DatabaseCleaner.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ public void insertInitialData() {
110110

111111
//recruit1 추가
112112
entityManager.createNativeQuery(
113-
"insert into recruit(id, start_at, end_at, semester, year, title, content, everytime_url, total_view, is_deleted, club_id) "
114-
+ "values (1, '2025-02-01 00:00:00','2025-02-20 23:59:59','ONE',2025, 'title', 'content', 'everytimeUrl', 100, false, 1)"
113+
"insert into recruit(id, start_at, end_at, recruit_type, title, content, apply_link, total_view, is_deleted, club_id,calendar_id) "
114+
+ "values (1, '2025-02-01 00:00:00','2025-02-20 23:59:59','REGULAR','title', 'content', 'aoplyLink', 100, false, 1, null)"
115115
).executeUpdate();
116116

117117
//recruit2 추가
118118
entityManager.createNativeQuery(
119-
"insert into recruit(id, start_at, end_at, semester, year, title, content, everytime_url, total_view, is_deleted, club_id) "
120-
+ "values (2, '2025-02-01 00:00:00','2025-02-20 23:59:59','ONE',2025, 'title', 'content', 'everytimeUrl', 100, false, 1)"
119+
"insert into recruit(id, start_at, end_at, recruit_type, title, content, apply_link, total_view, is_deleted, club_id,calendar_id) "
120+
+ "values (2, '2025-02-01 00:00:00','2025-02-20 23:59:59','REGULAR','title', 'content', 'aoplyLink', 100, false, 1, null)"
121121
).executeUpdate();
122122

123123
//recruit3 추가
124124
entityManager.createNativeQuery(
125-
"insert into recruit(id, start_at, end_at, semester, year, title, content, everytime_url, total_view, is_deleted, club_id) "
126-
+ "values (3, '2025-01-01 00:00:00','2025-02-25 23:59:59','ONE',2025, 'title', 'content', 'everytimeUrl', 100, false, 1)"
125+
"insert into recruit(id, start_at, end_at, recruit_type, title, content, apply_link, total_view, is_deleted, club_id,calendar_id) "
126+
+ "values (3, '2025-02-01 00:00:00','2025-02-20 23:59:59','REGULAR','title', 'content', 'aoplyLink', 100, false, 1, null)"
127127
).executeUpdate();
128128

129129
//recruitImage1 추가

src/test/java/com/clubber/ClubberServer/integration/util/fixture/RecruitFixture.java

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,90 +3,116 @@
33
import com.clubber.ClubberServer.domain.recruit.domain.RecruitType;
44
import com.clubber.ClubberServer.domain.recruit.dto.PostRecruitRequest;
55
import com.clubber.ClubberServer.domain.recruit.dto.UpdateRecruitRequest;
6+
import java.time.LocalDateTime;
7+
import java.time.format.DateTimeFormatter;
68
import java.util.List;
79

810
public class RecruitFixture {
911

12+
private static final LocalDateTime startAt = LocalDateTime.parse("2025-07-10 00:00",
13+
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
14+
15+
private static final LocalDateTime endAt1 = LocalDateTime.parse("2025-07-25 23:59",
16+
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
17+
18+
private static final LocalDateTime endAt2 = LocalDateTime.parse("2025-07-01 23:59",
19+
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
20+
1021
// 모집글 작성 테스트 데이터
1122
public static final PostRecruitRequest VALID_RECRUIT_POST_REQUEST = new PostRecruitRequest(
12-
"title", RecruitType.REGULAR, "content", "linkedUrl",
23+
"title", RecruitType.REGULAR, startAt, endAt1, "content",
24+
"applyLink",
1325
List.of("imagekey1", "imagekey2"), false);
1426

1527
// 모집글 title 유효성 검사
1628
public static final PostRecruitRequest NULL_TITLE_RECRUIT_POST_REQUEST = new PostRecruitRequest(
17-
null, RecruitType.REGULAR, "content", "linkedUrl",
29+
null, RecruitType.REGULAR, startAt, endAt1, "content",
30+
"applyLink",
1831
List.of("imagekey1", "imagekey2"), false);
1932

2033
public static final PostRecruitRequest EMPTY_TITLE_RECRUIT_POST_REQUEST = new PostRecruitRequest(
21-
"", RecruitType.REGULAR, "content", "linkedUrl",
22-
List.of("imagekey1", "imagekey2"),false);
34+
"", RecruitType.REGULAR, startAt, endAt1, "content",
35+
"applyLink",
36+
List.of("imagekey1", "imagekey2"), false);
2337

2438
public static final PostRecruitRequest SPACE_TITLE_RECRUIT_POST_REQUEST = new PostRecruitRequest(
25-
" ", RecruitType.REGULAR, "content", "linkedUrl",
26-
List.of("imagekey1", "imagekey2"),false);
39+
" ", RecruitType.REGULAR, startAt, endAt1, "content",
40+
"applyLink",
41+
List.of("imagekey1", "imagekey2"), false);
2742

2843
// 모집글 content 유효성 검사
2944
public static final PostRecruitRequest NULL_CONTENT_RECRUIT_POST_REQUEST = new PostRecruitRequest(
30-
"title", RecruitType.REGULAR, null, "linkedUrl",
31-
List.of("imagekey1", "imagekey2"),false);
45+
"", RecruitType.REGULAR, startAt, endAt1, null,
46+
"applyLink",
47+
List.of("imagekey1", "imagekey2"), false);
3248

3349
public static final PostRecruitRequest EMPTY_CONTENT_RECRUIT_POST_REQUEST = new PostRecruitRequest(
34-
"title", RecruitType.REGULAR, "", "linkedUrl",
35-
List.of("imagekey1", "imagekey2"),false);
50+
"", RecruitType.REGULAR, startAt, endAt1, "",
51+
"applyLink",
52+
List.of("imagekey1", "imagekey2"), false);
3653

3754
public static final PostRecruitRequest SPACE_CONTENT_RECRUIT_POST_REQUEST = new PostRecruitRequest(
38-
"title", RecruitType.REGULAR, " ", "linkedUrl",
39-
List.of("imagekey1", "imagekey2"),false);
40-
55+
"", RecruitType.REGULAR, startAt, endAt1, " ",
56+
"applyLink",
57+
List.of("imagekey1", "imagekey2"), false);
4158
// 모집글 수정 테이스 데이터
4259

4360
// 성공 데이터
4461
public static final UpdateRecruitRequest VALID_UPDATE_RECRUIT_REQUEST = new UpdateRecruitRequest(
45-
"newTitle", RecruitType.REGULAR, "newContent", "newLinkedUrl", false, List.of("https://image.ssuclubber.com/image2"),
62+
"newTitle", RecruitType.REGULAR, startAt, endAt1, "newContent", "newApplyLink", false,
63+
List.of("https://image.ssuclubber.com/image2"),
4664
List.of("newImage1", "newImage2"), List.of("https://image.ssuclubber.com/image1"),
4765
List.of("newImage2", "https://image.ssuclubber.com/image1", "newImage1"));
4866

4967
public static final UpdateRecruitRequest UPDATE_NO_IMAGE_RECRUIT_REQUEST = new UpdateRecruitRequest(
50-
"newTitle", RecruitType.REGULAR, "newContent", "newLinkedUrl", false, List.of(),
68+
"newTitle", RecruitType.REGULAR, startAt, endAt1, "newContent", "newLinkedUrl", false,
69+
List.of(),
5170
List.of("newImage1", "newImage2"), List.of(),
5271
List.of("newImage2", "newImage1"));
5372

5473
// 실패 데이터
5574

5675
// 존재하지 않는 이미지 삭제 처리
5776
public static final UpdateRecruitRequest INVALID_DELETE_IMAGE_RECRUIT_REQUEST = new UpdateRecruitRequest(
58-
"newTitle", RecruitType.REGULAR, "newContent","newLinkedUrl", false,
77+
"newTitle", RecruitType.REGULAR, startAt, endAt1, "newContent", "newLinkedUrl", false,
5978
List.of("https://image.ssuclubber.com/image1", "https://image.ssuclubber.com/image3"),
6079
List.of("newImage1", "newImage2"), List.of("https://image.ssuclubber.com/image1"),
6180
List.of("newImage2", "https://image.ssuclubber.com/image1", "newImage1"));
6281

6382
// 존재하지 않는 이미지에 대해 유지 처리
6483
public static final UpdateRecruitRequest REMAIN_NOT_EXIST_RECRUIT_REQUEST = new UpdateRecruitRequest(
65-
"newTitle", RecruitType.REGULAR, "newContent", "newEverytimeUrl", false,
84+
"newTitle", RecruitType.REGULAR, startAt, endAt1, "newContent", "newEverytimeUrl", false,
6685
List.of("https://image.ssuclubber.com/image2"),
6786
List.of("newImage1", "newImage2"),
6887
List.of("https://image.ssuclubber.com/image1", "https://image.ssuclubber.com/image3"),
6988
List.of("newImage2", "https://image.ssuclubber.com/image1", "newImage1"));
7089

7190
// 삭제할 이미지와 유지할 이미지 중복 지정
7291
public static final UpdateRecruitRequest REMAIN_DELETE_DUPLICATED_RECRUIT_REQUEST = new UpdateRecruitRequest(
73-
"newTitle", RecruitType.REGULAR, "newContent","newEverytimeUrl", false,
92+
"newTitle", RecruitType.REGULAR, startAt, endAt1, "newContent", "newEverytimeUrl", false,
7493
List.of("https://image.ssuclubber.com/image1"),
7594
List.of("newImage1", "newImage2"), List.of("https://image.ssuclubber.com/image1"),
7695
List.of("newImage2", "https://image.ssuclubber.com/image1", "newImage1"));
7796

7897
// 추가 데이터와 최종 데이터 불일치
7998
public static final UpdateRecruitRequest NEW_FINAL_IMAGE_DIFFERENT_RECRUIT_REQUEST = new UpdateRecruitRequest(
80-
"newTitle", RecruitType.REGULAR,"newContent","newEverytimeUrl", false,
99+
"newTitle", RecruitType.REGULAR, startAt, endAt1, "newContent", "newEverytimeUrl", false,
81100
List.of(),
82101
List.of("newImage1", "newImage2"), List.of(),
83102
List.of("newImage2", "newImage3"));
84103

85104
public static final UpdateRecruitRequest NEW_NOT_IN_FINAL_IMAGE_RECRUIT_REQUEST = new UpdateRecruitRequest(
86-
"newTitle", RecruitType.REGULAR,"newContent","newEverytimeUrl",false,
105+
"newTitle", RecruitType.REGULAR, startAt, endAt1, "newContent", "newEverytimeUrl", false,
87106
List.of(),
88107
List.of("newImage1", "newImage2", "newImage3"), List.of(),
89108
List.of("newImage2", "newImage1"));
90109

110+
// 마감일이 시작일보다 앞서는 경우
111+
public static final UpdateRecruitRequest ENDAT_EARLIER_THAN_STARTAT_RECRUIT_REQUEST = new UpdateRecruitRequest(
112+
"newTitle", RecruitType.REGULAR, startAt, endAt2, "newContent", "newApplyLink", false,
113+
List.of("https://image.ssuclubber.com/image2"),
114+
List.of("newImage1", "newImage2"), List.of("https://image.ssuclubber.com/image1"),
115+
List.of("newImage2", "https://image.ssuclubber.com/image1", "newImage1"));
116+
91117

92118
}

0 commit comments

Comments
 (0)