Skip to content
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

[BE] 사용하지 않는 타이머 API 제거 #1024

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import jakarta.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -14,7 +13,6 @@
import site.coduo.sync.service.SchedulerService;
import site.coduo.timer.controller.docs.TimerDocs;
import site.coduo.timer.service.TimerService;
import site.coduo.timer.service.dto.TimerReadResponse;
import site.coduo.timer.service.dto.TimerUpdateRequest;
import site.coduo.websocket.PairRoomWebSocketService;
import site.coduo.websocket.message.EventAndDataMessage;
Expand Down Expand Up @@ -54,13 +52,4 @@ public ResponseEntity<Void> updateTimer(
return ResponseEntity.noContent()
.build();
}

@GetMapping("/{accessCode}/timer")
public ResponseEntity<TimerReadResponse> getTimer(
@PathVariable("accessCode") final String accessCode
) {
final TimerReadResponse response = timerService.readTimer(accessCode);

return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import site.coduo.common.controller.response.ApiErrorResponse;
import site.coduo.timer.service.dto.TimerReadResponse;
import site.coduo.timer.service.dto.TimerUpdateRequest;

@Tag(name = "타이머 API")
Expand All @@ -34,11 +33,4 @@ ResponseEntity<Void> updateTimer(
@Parameter(description = "타이머 업데이트 요청", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE), required = true)
TimerUpdateRequest request
);

@Operation(summary = "타이머를 조회한다.")
@ApiResponse(responseCode = "200", description = "페어룸 히스토리 조회 성공", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = TimerReadResponse.class)))
@ApiResponse(responseCode = "4xx", description = "페어룸 히스토리 생성 실패", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ApiErrorResponse.class)))
ResponseEntity<TimerReadResponse> getTimer(
String accessCode
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import site.coduo.timer.domain.Timer;
import site.coduo.timer.repository.TimerEntity;
import site.coduo.timer.repository.TimerRepository;
import site.coduo.timer.service.dto.TimerReadResponse;
import site.coduo.timer.service.dto.TimerUpdateRequest;

@Transactional(readOnly = true)
Expand All @@ -22,12 +21,6 @@ public class TimerService {
private final TimestampRegistry timestampRegistry;
private final PairRoomRepository pairRoomRepository;

public TimerReadResponse readTimer(final String accessCode) {
final PairRoomEntity pairRoomEntity = pairRoomRepository.fetchByAccessCode(accessCode);
final TimerEntity timerEntity = timerRepository.fetchTimerByPairRoomEntity(pairRoomEntity);
return TimerReadResponse.of(timerEntity.getId(), timerEntity.toDomain());
}

public long readTimerRemainingTime(final String accessCode) {
if (timestampRegistry.has(accessCode)) {
return timestampRegistry.get(accessCode)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.jupiter.api.Assertions.assertAll;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -15,8 +15,8 @@
import site.coduo.pairroom.domain.accesscode.AccessCode;
import site.coduo.pairroom.service.PairRoomService;
import site.coduo.pairroom.service.dto.PairRoomCreateRequest;
import site.coduo.pairroom.service.dto.PairRoomEntireResponse;
import site.coduo.timer.domain.Timer;
import site.coduo.timer.service.dto.TimerReadResponse;
import site.coduo.timer.service.dto.TimerUpdateRequest;
import site.coduo.utils.CascadeCleaner;

Expand Down Expand Up @@ -49,23 +49,6 @@ void create_timer() {
.doesNotThrowAnyException();
}

@Test
@DisplayName("타이머를 반환한다.")
void get_latest_timer() {
// given
final PairRoomCreateRequest request = PairRoomCreateRequestFixture.PAIR_ROOM_CREATE_REQUEST;
final String accessCode = pairRoomService.savePairRoom(request, null);

// when
final TimerReadResponse actual = timerService.readTimer(accessCode);

// then
assertAll(
() -> assertThat(actual.duration()).isEqualTo(request.timerDuration()),
() -> assertThat(actual.remainingTime()).isEqualTo(request.timerRemainingTime())
);
}

@Test
@DisplayName("타이머를 업데이트 한다.")
void update_timer() {
Expand All @@ -79,10 +62,11 @@ void update_timer() {
timerService.updateTimer(accessCode, timerRequest);

// then
final TimerReadResponse actual = timerService.readTimer(accessCode);
assertThat(actual)
.extracting("duration", "remainingTime")
.contains(timerRequest.duration(), timerRequest.remainingTime());
final PairRoomEntireResponse entirePairRoom = pairRoomService.findEntirePairRoom(accessCode);
Assertions.assertAll(
() -> assertThat(entirePairRoom.duration()).isEqualTo(timerRequest.duration()),
() -> assertThat(entirePairRoom.remainingTime()).isEqualTo(timerRequest.remainingTime())
);
}

@Test
Expand Down
Loading