-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix/#495 (#496) * fix:다락방 초대링크 코드 수정 * fix:다락방 참여 api를 사용할 때 내 모임으로 제대로 가지지 않는 버그 수정 * fix: 알림이 undefined로 오는 문제를 수정 * fix: 채팅방 알림에 사용되는 경로 수정 --------- Co-authored-by: ss0526100 <[email protected]> Co-authored-by: jaeml06 <[email protected]> * feat: 채팅방 목록을 조회할 때 가장 최근에 온 메시지를 기준으로 정렬하는 기능 추가 * refactor: 채팅방 목록 정렬시 같은 기준이면 참여 순서대로 정렬하도록 수정 * feat: 해주세요 목록 조회시 관심이 많은 순서대로 조회하고, 관심이 같다면 생성된 순서대로 정렬하는 기능 추가 * refactor: 채팅방 목록 정렬에서 동일한 조건시 모임 생성 순으로 정렬하도록 수정 * refactor: 기능 수정으로 인해 실패하는 테스트 수정 * feat: 프록시 헤더를 받아들이는 설정 추가 * refactor: 사용하지 않는 메서드 제거 * feat: 비관적 쓰기 락을 통해 동시성 문제 해결 * test: 같은 회원이 동시에 참여하는 경우에 대한 동시성 테스트 * refactor: 참여 서비스 테스트에 동시성 테스트를 추가 --------- Co-authored-by: 이상진 <[email protected]> Co-authored-by: ss0526100 <[email protected]> Co-authored-by: jaeml06 <[email protected]> Co-authored-by: MingyeomKim <[email protected]>
- Loading branch information
1 parent
2431797
commit 651d44e
Showing
16 changed files
with
38,416 additions
and
14 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 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 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
112 changes: 112 additions & 0 deletions
112
backend/src/test/java/mouda/backend/chamyo/service/ChamyoServiceTest.java
This file contains 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,112 @@ | ||
package mouda.backend.chamyo.service; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import mouda.backend.chamyo.exception.ChamyoException; | ||
import mouda.backend.darakbang.domain.Darakbang; | ||
import mouda.backend.darakbang.repository.DarakbangRepository; | ||
import mouda.backend.darakbangmember.domain.DarakbangMember; | ||
import mouda.backend.darakbangmember.repository.repository.DarakbangMemberRepository; | ||
import mouda.backend.fixture.DarakbangFixture; | ||
import mouda.backend.fixture.DarakbangMemberFixture; | ||
import mouda.backend.fixture.MemberFixture; | ||
import mouda.backend.fixture.MoimFixture; | ||
import mouda.backend.member.domain.Member; | ||
import mouda.backend.member.repository.MemberRepository; | ||
import mouda.backend.moim.domain.Moim; | ||
import mouda.backend.moim.repository.MoimRepository; | ||
|
||
@SpringBootTest | ||
class ChamyoServiceTest { | ||
|
||
@Autowired | ||
private ChamyoService chamyoService; | ||
|
||
@Autowired | ||
private DarakbangRepository darakbangRepository; | ||
|
||
@Autowired | ||
private DarakbangMemberRepository darakbangMemberRepository; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private MoimRepository moimRepository; | ||
|
||
@DisplayName("같은 회원이 따로 따로 여러 번 참여 요청을 하면 두 번째 요청 시 참여에 실패한다.") | ||
@Test | ||
void chamyoMoim() throws InterruptedException { | ||
Darakbang darakbang = DarakbangFixture.getDarakbangWithMouda(); | ||
darakbangRepository.save(darakbang); | ||
|
||
Member member = MemberFixture.getAnna(); | ||
memberRepository.save(member); | ||
|
||
DarakbangMember darakbangMember = DarakbangMemberFixture | ||
.getDarakbangMemberWithWooteco(darakbang, member); | ||
darakbangMemberRepository.save(darakbangMember); | ||
|
||
Moim moim = MoimFixture.getBasketballMoim(darakbang.getId()); | ||
moimRepository.save(moim); | ||
|
||
chamyoService.chamyoMoim(darakbang.getId(), moim.getId(), darakbangMember); | ||
assertThatThrownBy(() -> chamyoService.chamyoMoim(darakbang.getId(), moim.getId(), darakbangMember)) | ||
.isInstanceOf(ChamyoException.class); | ||
assertThat(chamyoService.findAllChamyo(darakbang.getId(), moim.getId()).chamyos()).hasSize(1); | ||
} | ||
|
||
@DisplayName("동시 참여 테스트") | ||
@Nested | ||
class ConcurrencyTest { | ||
|
||
@DisplayName("같은 회원이 동시에 여러 번 참여 요청을 하면 동시 참여가 불가능하다.") | ||
@Test | ||
void chamyoMoimConcurrently() throws InterruptedException { | ||
int threadCount = 2; | ||
ExecutorService executorService = Executors.newFixedThreadPool(threadCount); | ||
CountDownLatch latch = new CountDownLatch(threadCount); | ||
|
||
Darakbang darakbang = DarakbangFixture.getDarakbangWithMouda(); | ||
darakbangRepository.save(darakbang); | ||
|
||
Moim moim = MoimFixture.getBasketballMoim(darakbang.getId()); | ||
moimRepository.save(moim); | ||
|
||
Member member = MemberFixture.getAnna(); | ||
memberRepository.save(member); | ||
|
||
DarakbangMember darakbangMember = DarakbangMemberFixture | ||
.getDarakbangMemberWithWooteco(darakbang, member); | ||
darakbangMemberRepository.save(darakbangMember); | ||
|
||
long startTime = System.currentTimeMillis(); | ||
for (int i = 0; i < threadCount; i++) { | ||
executorService.execute(() -> { | ||
try { | ||
chamyoService.chamyoMoim(darakbang.getId(), moim.getId(), darakbangMember); | ||
} finally { | ||
latch.countDown(); | ||
} | ||
}); | ||
} | ||
latch.await(); | ||
executorService.shutdown(); | ||
|
||
long endTime = System.currentTimeMillis(); | ||
System.out.printf("Test time : %d ms\n", endTime - startTime); | ||
|
||
assertThat(chamyoService.findAllChamyo(darakbang.getId(), moim.getId()).chamyos()).hasSize(1); | ||
} | ||
} | ||
} |
This file contains 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 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 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