Skip to content
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
11 changes: 0 additions & 11 deletions src/main/java/com/mr/domain/analysis/service/AnalysisService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.mr.domain.playing.repository.PlayingRepository;
import com.mr.global.apipayload.exception.GeneralException;
import com.mr.global.file.s3.service.S3FileService;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -57,16 +56,6 @@ public AnalysisCreateResponseDTO createAnalysis(
if (playing.getStatus() != PlayingStatus.COMPLETED) {
throw new GeneralException(PlayingErrorStatus.INVALID_PLAYING_STATUS);
}
if (analysisRepository.existsByPlayingIdAndStatusIn(
playing.getId(),
List.of(
AnalysisStatus.PENDING,
AnalysisStatus.PROCESSING,
AnalysisStatus.COMPLETED
)
)) {
throw new GeneralException(AnalysisErrorStatus.ANALYSIS_ALREADY_IN_PROGRESS);
}

String requestJson;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ public String startGenerating(Duration staleAfter) {
if (this.status != MentorChatStatus.ACTIVE && this.status != MentorChatStatus.GENERATING) {
throw new GeneralException(MentorErrorStatus.MENTOR_SESSION_NOT_ACTIVE);
}
if (this.questionCount >= 3) {
throw new GeneralException(MentorErrorStatus.MENTOR_QUESTION_LIMIT_EXCEEDED);
}
this.status = MentorChatStatus.GENERATING;
this.generationToken = UUID.randomUUID().toString();
this.generationStartedAt = LocalDateTime.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ void createAnalysis_success() {
given(playing.getUser()).willReturn(user);
given(playing.getStatus()).willReturn(PlayingStatus.COMPLETED);
given(playingRepository.findByIdWithBackingTrackForUpdate(31L)).willReturn(Optional.of(playing));
given(analysisRepository.existsByPlayingIdAndStatusIn(eq(31L), any())).willReturn(false);
given(analysisRequestFactory.create(playing, 1, 8))
.willReturn(new AiAnalysisRequest(null, List.of(), List.of()));
given(analysisRepository.save(any(Analysis.class)))
Expand All @@ -242,14 +241,6 @@ void createAnalysis_success() {
1L, new AnalysisCreateRequestDTO(31L, 1, 8)
);

verify(analysisRepository).existsByPlayingIdAndStatusIn(
31L,
List.of(
AnalysisStatus.PENDING,
AnalysisStatus.PROCESSING,
AnalysisStatus.COMPLETED
)
);
assertThat(response.playingId()).isEqualTo(31L);
assertThat(response.status()).isEqualTo(AnalysisStatus.PENDING);
verify(eventPublisher).publishEvent(any(AnalysisRequestedEvent.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,6 @@ void prepare_incompleteAnalysis_throwsConflict() {
verify(sessionRepository, never()).findByAnalysisIdForUpdate(any());
}

@Test
void prepare_questionLimitExceeded_throwsTooManyRequests() {
Analysis analysis = analysis(1L, AnalysisStatus.COMPLETED);
User owner = analysis.getUser();
MentorChatSession session = MentorChatSession.createActive(analysis, owner);
session.increaseQuestionCount();
session.increaseQuestionCount();
session.increaseQuestionCount();
given(analysisRepository.findByIdForUpdate(10L)).willReturn(Optional.of(analysis));
given(sessionRepository.findByAnalysisIdForUpdate(10L)).willReturn(Optional.of(session));

assertThatThrownBy(() -> service.prepare(1L, 10L, "question"))
.isInstanceOf(GeneralException.class)
.hasFieldOrPropertyWithValue("code", MentorErrorStatus.MENTOR_QUESTION_LIMIT_EXCEEDED);
verify(messageRepository, never()).saveAndFlush(any());
}

@Test
void prepare_existingSession_reusesSession() {
Analysis analysis = analysis(1L, AnalysisStatus.COMPLETED);
Expand Down
Loading