Skip to content

Commit

Permalink
refactor: 북마크 조회 API 테스트 구체적으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
carsago committed Mar 25, 2024
1 parent 5dbd257 commit 3a25bdc
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.festago.bookmark.application;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.SoftAssertions.assertSoftly;

import com.festago.bookmark.domain.Bookmark;
import com.festago.bookmark.domain.BookmarkType;
import com.festago.bookmark.dto.v1.SchoolBookmarkV1Response;
import com.festago.bookmark.repository.BookmarkRepository;
import com.festago.member.repository.MemberRepository;
import com.festago.school.dto.v1.SchoolSearchV1Response;
import com.festago.school.repository.SchoolRepository;
import com.festago.support.ApplicationIntegrationTest;
import com.festago.support.MemberFixture;
Expand Down Expand Up @@ -37,13 +40,11 @@ class SchoolBookmarkV1QueryServiceTest extends ApplicationIntegrationTest {
var 회원A_ID = saveMember("socialId_A");
var 회원B_ID = saveMember("socialId_B");

var 학교A_ID = saveSchool("A대학교", "a.ac.kr");
var 학교B_ID = saveSchool("B대학교", "b.ac.kr");
var 학교C_ID = saveSchool("C대학교", "c.ac.kr");
var 학교A_ID = saveSchool("A대학교", "a.ac.kr", "https://www.festago.com/A.png");
var 학교B_ID = saveSchool("B대학교", "b.ac.kr", "https://www.festago.com/B.png");

saveBookmark(학교A_ID, 회원A_ID);
saveBookmark(학교B_ID, 회원A_ID);
saveBookmark(학교C_ID, 회원A_ID);

saveBookmark(학교A_ID, 회원B_ID);
saveBookmark(학교B_ID, 회원B_ID);
Expand All @@ -52,7 +53,15 @@ class SchoolBookmarkV1QueryServiceTest extends ApplicationIntegrationTest {
var actual = schoolBookmarkV1QueryService.findAllByMemberId(회원A_ID);

// then
assertThat(actual).hasSize(3);
assertSoftly(softly -> {
softly.assertThat(actual).hasSize(2);
softly.assertThat(actual).allSatisfy(it -> assertThat(it).hasNoNullFieldsOrProperties());
softly.assertThat(actual).map(SchoolBookmarkV1Response::school)
.containsExactly(
new SchoolSearchV1Response(학교A_ID, "A대학교", "https://www.festago.com/A.png"),
new SchoolSearchV1Response(학교B_ID, "B대학교", "https://www.festago.com/B.png")
);
});
}

private Long saveMember(String socialId) {
Expand All @@ -61,10 +70,11 @@ private Long saveMember(String socialId) {
.build()).getId();
}

private Long saveSchool(String name, String domain) {
private Long saveSchool(String name, String domain, String logoUrl) {
return schoolRepository.save(SchoolFixture.school()
.name(name)
.domain(domain)
.logoUrl(logoUrl)
.build()).getId();
}

Expand Down

0 comments on commit 3a25bdc

Please sign in to comment.