-
Notifications
You must be signed in to change notification settings - Fork 1
fix: 시트 동기화 시 사전 회원 유지 #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
79 changes: 79 additions & 0 deletions
79
src/test/java/gg/agit/konect/domain/club/service/ClubMemberSheetServiceTest.java
This file contains hidden or 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,79 @@ | ||
| package gg.agit.konect.domain.club.service; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.mockito.BDDMockito.given; | ||
| import static org.mockito.Mockito.verify; | ||
|
|
||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.InjectMocks; | ||
| import org.mockito.Mock; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
|
||
| import gg.agit.konect.domain.club.dto.ClubMemberSheetSyncResponse; | ||
| import gg.agit.konect.domain.club.enums.ClubSheetSortKey; | ||
| import gg.agit.konect.domain.club.model.Club; | ||
| import gg.agit.konect.domain.club.repository.ClubMemberRepository; | ||
| import gg.agit.konect.domain.club.repository.ClubPreMemberRepository; | ||
| import gg.agit.konect.domain.club.repository.ClubRepository; | ||
| import gg.agit.konect.support.ServiceTestSupport; | ||
| import gg.agit.konect.support.fixture.ClubFixture; | ||
| import gg.agit.konect.support.fixture.UniversityFixture; | ||
|
|
||
| class ClubMemberSheetServiceTest extends ServiceTestSupport { | ||
|
|
||
| @Mock | ||
| private ClubRepository clubRepository; | ||
|
|
||
| @Mock | ||
| private ClubMemberRepository clubMemberRepository; | ||
|
|
||
| @Mock | ||
| private ClubPreMemberRepository clubPreMemberRepository; | ||
|
|
||
| @Mock | ||
| private ClubPermissionValidator clubPermissionValidator; | ||
|
|
||
| @Mock | ||
| private SheetSyncExecutor sheetSyncExecutor; | ||
|
|
||
| @Mock | ||
| private SheetHeaderMapper sheetHeaderMapper; | ||
|
|
||
| @Mock | ||
| private ObjectMapper objectMapper; | ||
|
|
||
| @InjectMocks | ||
| private ClubMemberSheetService clubMemberSheetService; | ||
|
|
||
| @Test | ||
| @DisplayName("시트 동기화 수에 사전 회원도 포함한다") | ||
| void syncMembersToSheetIncludesPreMembersInCount() { | ||
| // given | ||
| Integer clubId = 1; | ||
| Integer requesterId = 2; | ||
| String spreadsheetId = "spreadsheet-id"; | ||
| Club club = ClubFixture.create(UniversityFixture.create()); | ||
| club.updateGoogleSheetId(spreadsheetId); | ||
|
|
||
| given(clubRepository.getById(clubId)).willReturn(club); | ||
| given(clubMemberRepository.countByClubId(clubId)).willReturn(2L); | ||
| given(clubPreMemberRepository.countByClubId(clubId)).willReturn(3L); | ||
|
|
||
| // when | ||
| ClubMemberSheetSyncResponse response = clubMemberSheetService.syncMembersToSheet( | ||
| clubId, | ||
| requesterId, | ||
| ClubSheetSortKey.POSITION, | ||
| true | ||
| ); | ||
|
|
||
| // then | ||
| verify(clubPermissionValidator).validateManagerAccess(clubId, requesterId); | ||
| verify(sheetSyncExecutor).executeWithSort(clubId, ClubSheetSortKey.POSITION, true); | ||
| assertThat(response.syncedMemberCount()).isEqualTo(5); | ||
| assertThat(response.sheetUrl()) | ||
| .isEqualTo("https://docs.google.com/spreadsheets/d/" + spreadsheetId + "/edit"); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 추가된 테스트는 club.getSheetColumnMapping()이 null인 경우(전체 clear 후 values.update로 덮어쓰기)만 검증합니다. 실제 운영에서는 시트 등록 시 sheetColumnMapping이 저장되어 updateMappedColumns(values.batchUpdate 경로)로 동작하는 경우가 많으니, 해당 경로에서도 사전 회원이 함께 반영되는지(예: BatchUpdateValuesRequest에 preMember row가 포함되는지) 테스트를 추가하는 것이 좋겠습니다.