Skip to content

Commit

Permalink
Merge pull request #803 from woowacourse-teams/BE/hotfix-pairroom-create
Browse files Browse the repository at this point in the history
[BE] 페어룸 생성 요청 API 변경
  • Loading branch information
reddevilmidzy authored Oct 16, 2024
2 parents a253391 + bfc3ae8 commit 04f21bd
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public boolean existsByAccessCode(final String accessCode) {

private PairRoom createPairRoom(final PairRoomCreateRequest request) {
final AccessCode accessCode = generateAccessCode();
final PairRoomStatus status = PairRoomStatus.findByName(request.status());
final PairRoomStatus status = PairRoomStatus.IN_PROGRESS;
final Pair pair = new Pair(new PairName(request.navigator()), new PairName(request.driver()));
final MissionUrl missionUrl = new MissionUrl(request.missionUrl());
return new PairRoom(status, pair, missionUrl, accessCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ public record PairRoomCreateRequest(

@Schema(description = "미션 리포지토리 링크. '그냥 시작할래요'로 생성하면 빈 문자열")
@NotNull
String missionUrl,

@Schema(description = "페어룸의 상태", example = "IN_PROGRESS")
@NotBlank
String status
String missionUrl
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.transaction.annotation.Transactional;

import io.restassured.RestAssured;
import site.coduo.pairroom.domain.PairRoomStatus;
import site.coduo.pairroom.service.dto.PairRoomCreateRequest;
import site.coduo.pairroom.service.dto.PairRoomCreateResponse;
import site.coduo.referencelink.service.dto.CategoryCreateRequest;
Expand Down Expand Up @@ -39,8 +38,7 @@ static CategoryCreateResponse createCategory(final String accessCode, final Cate
void show_category() {
//given
final PairRoomCreateResponse pairRoomUrl = PairRoomAcceptanceTest.createPairRoom(
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name()));
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx"));

createCategory(pairRoomUrl.accessCode(), new CategoryCreateRequest("새로운 카테고리"));

Expand All @@ -65,8 +63,7 @@ void show_category() {
void update_category() {
//given
final PairRoomCreateResponse pairRoomUrl = PairRoomAcceptanceTest.createPairRoom(
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name()));
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx"));

final CategoryCreateResponse previousCategory = createCategory(pairRoomUrl.accessCode(),
new CategoryCreateRequest("이전 카테고리"));
Expand Down Expand Up @@ -101,8 +98,7 @@ void update_category() {
void delete_category() {
//given
final PairRoomCreateResponse pairRoomUrl = PairRoomAcceptanceTest.createPairRoom(
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name()));
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx"));

final CategoryCreateResponse category = createCategory(pairRoomUrl.accessCode(),
new CategoryCreateRequest("자바"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void show_pair_room() {
//given
final PairRoomCreateResponse pairRoomUrl =
createPairRoom(
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx", "IN_PROGRESS"));
new PairRoomCreateRequest("레디", "프람", 10000L, 10000L, "https://missionUrl.xxx"));

//when & then
RestAssured
Expand All @@ -62,7 +62,7 @@ void update_pair_room_status() {
//given
final PairRoomCreateResponse accessCode =
createPairRoom(
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx", "IN_PROGRESS"));
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx"));
final Map<String, String> status = Map.of("status", PairRoomStatus.IN_PROGRESS.name());

// when & then
Expand All @@ -88,7 +88,7 @@ void update_driver_navigator() {
// given
final PairRoomCreateResponse accessCode =
createPairRoom(
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx", "IN_PROGRESS"));
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx"));

// when & then
RestAssured
Expand All @@ -109,7 +109,7 @@ void exist_pair_room_true() {
//given
final PairRoomCreateResponse accessCode =
createPairRoom(
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx", "IN_PROGRESS"));
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx"));

// when & then
final PairRoomExistResponse response = RestAssured
Expand Down Expand Up @@ -162,7 +162,7 @@ void delete_pair_room() {
// given
final PairRoomCreateResponse accessCode =
createPairRoom(
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx", "IN_PROGRESS"));
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx"));

// when & then
RestAssured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void reference_link_create_request() {
// given
final PairRoomCreateResponse pairRoom =
createPairRoom(new PairRoomCreateRequest("레모네", "프람", 10000L, 10000L,
"https://missionUrl.xxx", "IN_PROGRESS"));
"https://missionUrl.xxx"));
final CategoryCreateResponse category = CategoryAcceptanceTest.createCategory(
pairRoom.accessCode(), new CategoryCreateRequest("타입스크립트"));

Expand Down Expand Up @@ -55,7 +55,7 @@ void read_all_reference_link_request() {
// given
final PairRoomCreateResponse pairRoom =
createPairRoom(new PairRoomCreateRequest("레모네", "프람", 10000L, 10000L,
"https://missionUrl.xxx", "IN_PROGRESS"));
"https://missionUrl.xxx"));
createReferenceLink("http://www.some1.url", pairRoom.accessCode(), "카테고리1");
createReferenceLink("http://www.some2.url", pairRoom.accessCode(), "카테고리2");

Expand All @@ -79,7 +79,7 @@ void read_reference_link_without_open_graph() {
// given
final PairRoomCreateResponse pairRoom =
createPairRoom(
new PairRoomCreateRequest("잉크", "해시", 1000L, 100L, "https://missionUrl.xxx", "IN_PROGRESS"));
new PairRoomCreateRequest("잉크", "해시", 1000L, 100L, "https://missionUrl.xxx"));
final String expectedUrl = "http://www.deleasfsdte.com";
createReferenceLink(expectedUrl, pairRoom.accessCode(), "카테고리");

Expand Down Expand Up @@ -125,7 +125,7 @@ void delete_reference_link_request() {
// given
final PairRoomCreateResponse pairRoom =
createPairRoom(
new PairRoomCreateRequest("레모네", "프람", 1000L, 1000L, "https://missionUrl.xxx", "IN_PROGRESS"));
new PairRoomCreateRequest("레모네", "프람", 1000L, 1000L, "https://missionUrl.xxx"));

final ReferenceLinkResponse response = createReferenceLink("http://www.delete.com", pairRoom.accessCode(),
"카테고리 이름");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.junit.jupiter.api.Test;

import io.restassured.RestAssured;
import site.coduo.pairroom.domain.PairRoomStatus;
import site.coduo.pairroom.service.dto.PairRoomCreateRequest;

class SseAcceptanceTest extends AcceptanceFixture {
Expand All @@ -29,7 +28,7 @@ static void createConnect(final String accessCode) {
void create_sse_connection() {
// given
final PairRoomCreateRequest request = new PairRoomCreateRequest("프람", "레모네", 10000L,
10000L, "https://missionUrl.xxx", PairRoomStatus.IN_PROGRESS.name());
10000L, "https://missionUrl.xxx");
final String accessCode = createPairRoom(request).accessCode();

// when & then
Expand All @@ -54,8 +53,7 @@ void delete_sse_connection() {
"잉크",
1000L,
1000L,
"https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name()
"https://missionUrl.xxx"
);
final String accessCode = createPairRoom(request).accessCode();
createConnect(accessCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.http.MediaType;

import io.restassured.RestAssured;
import site.coduo.pairroom.domain.PairRoomStatus;
import site.coduo.pairroom.service.dto.PairRoomCreateRequest;
import site.coduo.pairroom.service.dto.PairRoomCreateResponse;
import site.coduo.timer.service.dto.TimerUpdateRequest;
Expand Down Expand Up @@ -52,8 +51,7 @@ void get_timer() {
"파란",
10000L,
10000L,
"https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name())
"https://missionUrl.xxx")
);

// when & then
Expand All @@ -76,8 +74,7 @@ void update_timer_duration() {
"파슬리",
10000L,
10000L,
"https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name())
"https://missionUrl.xxx")
);
final TimerUpdateRequest request = new TimerUpdateRequest(20000L, 3000L);
createConnect(accessCode);
Expand All @@ -99,8 +96,7 @@ void update_timer_duration() {
void start_timer() {
// given
final String accessCode = createPairRoom(
new PairRoomCreateRequest("fram", "lemone", 10000L, 10000L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name()));
new PairRoomCreateRequest("fram", "lemone", 10000L, 10000L, "https://missionUrl.xxx"));
createConnect(accessCode);

// when & then
Expand All @@ -119,8 +115,7 @@ void start_timer() {
void stop_timer() {
// given
final String accessCode = createPairRoom(
new PairRoomCreateRequest("fram", "lemone", 10000L, 10000L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name()));
new PairRoomCreateRequest("fram", "lemone", 10000L, 10000L, "https://missionUrl.xxx"));
timerStart(accessCode);

// when & then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class PairRoomServiceTest {
void create_pair_room() {
// given
final PairRoomCreateRequest request =
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name());
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx");

// when
final String accessCode = pairRoomService.savePairRoom(request, null);
Expand All @@ -70,8 +69,7 @@ void create_pair_room() {
void create_timer_when_create_pair_room() {
// given
final PairRoomCreateRequest request =
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name());
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx");

// when
pairRoomService.savePairRoom(request, null);
Expand All @@ -98,9 +96,12 @@ void throw_exception_when_find_delete_pair_room_access_code() {
// given
final PairRoomCreateRequest request =
new PairRoomCreateRequest("레디", "프람", 1000L, 100L,
"https://missionUrl.xxx", PairRoomStatus.DELETED.name());
"https://missionUrl.xxx");
final String accessCode = pairRoomService.savePairRoom(request, null);

final PairRoomEntity pairRoomEntity = pairRoomRepository.fetchByAccessCode(accessCode);
pairRoomEntity.updateStatus(PairRoomStatus.DELETED);

// when & then
assertThatThrownBy(() -> pairRoomService.findPairRoomAndTimer(accessCode))
.isExactlyInstanceOf(DeletePairRoomException.class);
Expand All @@ -111,8 +112,7 @@ void throw_exception_when_find_delete_pair_room_access_code() {
void update_pair_room_status() {
// given
final PairRoomCreateRequest request =
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx",
PairRoomStatus.IN_PROGRESS.name());
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx");
final String accessCode = pairRoomService.savePairRoom(request, null);

// when
Expand All @@ -128,9 +128,10 @@ void update_pair_room_status() {
void update_delete_pair_room_status() {
// given
final PairRoomCreateRequest request =
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx",
PairRoomStatus.DELETED.name());
new PairRoomCreateRequest("레디", "프람", 1000L, 100L, "https://missionUrl.xxx");
final String accessCode = pairRoomService.savePairRoom(request, null);
final PairRoomEntity pairRoomEntity = pairRoomRepository.fetchByAccessCode(accessCode);
pairRoomEntity.updateStatus(PairRoomStatus.DELETED);

// when & then
assertThatThrownBy(() -> pairRoomService.updatePairRoomStatus(accessCode, PairRoomStatus.COMPLETED.name()))
Expand Down Expand Up @@ -175,7 +176,6 @@ void change_delete_pair_room_role() {
.isExactlyInstanceOf(DeletePairRoomException.class);
}


@DisplayName("삭제되지 않은, 멤버의 방 목록을 가져온다.")
@Test
void find_rooms_by_member() {
Expand All @@ -184,19 +184,22 @@ void find_rooms_by_member() {
final Member memberB = createMember("test");

final PairRoomCreateRequest pairRoomCreateRequest = new PairRoomCreateRequest("레디", "잉크", 1, 1,
"https://missionUrl.xxx",
"IN_PROGRESS");
"https://missionUrl.xxx");

final String accessCodeA_1 = pairRoomService.savePairRoom(pairRoomCreateRequest, memberA.getAccessToken());
final String accessCodeA_2 = pairRoomService.savePairRoom(pairRoomCreateRequest, memberA.getAccessToken());
final String accessCodeB_1 = pairRoomService.savePairRoom(pairRoomCreateRequest, memberB.getAccessToken());
pairRoomService.savePairRoom(pairRoomCreateRequest, null);

final PairRoomCreateRequest deletePairRoomCreateRequest = new PairRoomCreateRequest("레디", "잉크", 1, 1,
"https://missionUrl.xxx", PairRoomStatus.DELETED.name());
pairRoomService.savePairRoom(deletePairRoomCreateRequest, memberA.getAccessToken());
pairRoomService.savePairRoom(deletePairRoomCreateRequest, memberA.getAccessToken());
pairRoomService.savePairRoom(deletePairRoomCreateRequest, memberA.getAccessToken());
"https://missionUrl.xxx");
final String accessToken1 = pairRoomService.savePairRoom(deletePairRoomCreateRequest, memberA.getAccessToken());
final String accessToken2 = pairRoomService.savePairRoom(deletePairRoomCreateRequest, memberA.getAccessToken());
final String accessToken3 = pairRoomService.savePairRoom(deletePairRoomCreateRequest, memberA.getAccessToken());

pairRoomRepository.fetchByAccessCode(accessToken1).updateStatus(PairRoomStatus.DELETED);
pairRoomRepository.fetchByAccessCode(accessToken2).updateStatus(PairRoomStatus.DELETED);
pairRoomRepository.fetchByAccessCode(accessToken3).updateStatus(PairRoomStatus.DELETED);

final List<String> memberAExpected = List.of(accessCodeA_1, accessCodeA_2);
final List<String> memberBExpected = List.of(accessCodeB_1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;

import site.coduo.pairroom.domain.PairRoomStatus;
import site.coduo.pairroom.domain.accesscode.AccessCode;
import site.coduo.pairroom.service.PairRoomService;
import site.coduo.pairroom.service.dto.PairRoomCreateRequest;
Expand Down Expand Up @@ -43,7 +42,7 @@ void tearDown() {
void create_timer() {
// given
final PairRoomCreateRequest request = new PairRoomCreateRequest("켈리", "레모네", 10000L,
1000L, "https://missionUrl.xxx", PairRoomStatus.IN_PROGRESS.name());
1000L, "https://missionUrl.xxx");

// when & then
assertThatCode(() -> pairRoomService.savePairRoom(request, null))
Expand All @@ -55,7 +54,7 @@ void create_timer() {
void get_latest_timer() {
// given
final PairRoomCreateRequest request = new PairRoomCreateRequest("잉크", "레디", 1000L,
1000L, "https://missionUrl.xxx", PairRoomStatus.IN_PROGRESS.name());
1000L, "https://missionUrl.xxx");
final String accessCode = pairRoomService.savePairRoom(request, null);

// when
Expand All @@ -73,7 +72,7 @@ void get_latest_timer() {
void update_timer() {
// given
final PairRoomCreateRequest request = new PairRoomCreateRequest("잉크", "레디", 10000000L,
100L, "https://missionUrl.xxx", PairRoomStatus.IN_PROGRESS.name());
100L, "https://missionUrl.xxx");
final String accessCode = pairRoomService.savePairRoom(request, null);

final TimerUpdateRequest timerRequest = new TimerUpdateRequest(10000, 5000);
Expand All @@ -93,7 +92,7 @@ void update_timer() {
void get_remaining_time_when_exist_timestamp() {
// given
final PairRoomCreateRequest pairRoomCreateRequest = new PairRoomCreateRequest("켈리", "레모네",
3000L, 3000L, "https://missionUrl.xxx", PairRoomStatus.IN_PROGRESS.name());
3000L, 3000L, "https://missionUrl.xxx");
final String accessCode = pairRoomService.savePairRoom(pairRoomCreateRequest, null);
final Timer timeStamp = new Timer(new AccessCode(accessCode), 10000L, 10000L);
timestampRegistry.register(accessCode, timeStamp);
Expand All @@ -110,7 +109,7 @@ void get_remaining_time_when_exist_timestamp() {
void get_remaining_time_when_not_exist_timestamp() {
// given
final PairRoomCreateRequest pairRoomCreateRequest = new PairRoomCreateRequest("켈리", "레모네",
3000L, 3000L, "https://missionUrl.xxx", PairRoomStatus.IN_PROGRESS.name());
3000L, 3000L, "https://missionUrl.xxx");
final String accessCode = pairRoomService.savePairRoom(pairRoomCreateRequest, null);

// when
Expand Down
Loading

0 comments on commit 04f21bd

Please sign in to comment.