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
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ public class SessionService {
@Transactional
public SessionResult create(Long userId, SessionCreateCommand command) {
User user = loadUser(userId);
String title = resolveTitle(command);
InterviewSession session = sessionRepository.save(InterviewSession.create(
user,
command.title(),
title,
command.memo(),
command.mode(),
command.jobCategory(),
Expand Down Expand Up @@ -145,6 +146,16 @@ public SessionResult updateMeta(Long userId, Long sessionId, String title, Strin
return SessionResult.of(session, contextDocumentIds(sessionId));
}

// 제목 미입력 시 모드+직군으로 규칙 기반 제목 생성 (예: "백엔드 기술 면접").
// 히스토리에서 "면접 #id" 대신 의미 있는 제목을 보이게 한다.
private String resolveTitle(SessionCreateCommand command) {
String title = command.title();
if (title != null && !title.isBlank()) {
return title;
}
return command.jobCategory().koreanLabel() + " " + command.mode().koreanLabel();
}

private User loadUser(Long userId) {
return userRepository.findByIdAndDeletedFalse(userId)
.orElseThrow(() -> new DomainException(ApiErrorCode.USER_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@ public enum JobCategory {
FRONTEND,
BACKEND,
INFRA,
DBA
DBA;

public String koreanLabel() {
return switch (this) {
case FRONTEND -> "프론트엔드";
case BACKEND -> "백엔드";
case INFRA -> "인프라";
case DBA -> "DBA";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
public enum SessionMode {
TECHNICAL,
PERSONALITY,
INTEGRATED
INTEGRATED;

public String koreanLabel() {
return switch (this) {
case TECHNICAL -> "기술 면접";
case PERSONALITY -> "인성 면접";
case INTEGRATED -> "종합 면접";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.stackup.stackup.session.domain.MessageVoiceAnalysisRepository;
import com.stackup.stackup.session.domain.SessionContextRepository;
import com.stackup.stackup.session.domain.SessionFeedbackRepository;
import com.stackup.stackup.session.domain.SessionQuestionPoolRepository;
import com.stackup.stackup.user.domain.UserRepository;
import com.stackup.stackup.user.domain.consent.UserConsentRepository;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -61,6 +62,9 @@ class StackupApplicationTests {
@MockitoBean
private SessionFeedbackRepository sessionFeedbackRepository;

@MockitoBean
private SessionQuestionPoolRepository sessionQuestionPoolRepository;

@MockitoBean
private MessageVoiceAnalysisRepository messageVoiceAnalysisRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ void create_savesSessionAndPublishesEvent() {
verify(events).publishEvent(any(SessionCreatedEvent.class));
}

@Test
void create_generatesTitleFromModeAndJobWhenBlank() {
User user = userFixture(1L);
when(userRepository.findByIdAndDeletedFalse(1L)).thenReturn(Optional.of(user));
when(sessionRepository.save(any(InterviewSession.class))).thenAnswer(inv -> inv.getArgument(0));

SessionResult result = service.create(1L, new SessionCreateCommand(
" ", null, SessionMode.TECHNICAL, JobCategory.BACKEND,
5, 30, null, null, List.of()
));

assertThat(result.title()).isEqualTo("백엔드 기술 면접");
}

@Test
void create_keepsProvidedTitle() {
User user = userFixture(1L);
when(userRepository.findByIdAndDeletedFalse(1L)).thenReturn(Optional.of(user));
when(sessionRepository.save(any(InterviewSession.class))).thenAnswer(inv -> inv.getArgument(0));

SessionResult result = service.create(1L, new SessionCreateCommand(
"내가 정한 제목", null, SessionMode.INTEGRATED, JobCategory.FRONTEND,
5, 30, null, null, List.of()
));

assertThat(result.title()).isEqualTo("내가 정한 제목");
}

@Test
void create_linksAnalyzedContextDocuments() {
User user = userFixture(1L);
Expand Down