test: ParsingValidationService 테스트 시그니처 정합화#19
Conversation
Summary of ChangesHello @coldmans, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 Pull Request는 ParsingValidationServiceTest의 테스트 시그니처를 최신 서비스 변경 사항에 맞춰 업데이트하여 테스트 실패를 해결합니다. PdfParseService 의존성 제거 및 ExcelParseService 메서드 시그니처 변경을 반영하고, PDF 검증 테스트를 현재 서비스의 미구현 상태에 맞게 조정하여 테스트의 정합성을 확보했습니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 ParsingValidationService의 시그니처 변경에 따라 ParsingValidationServiceTest의 테스트 코드를 수정하는 것을 주 내용으로 합니다. PdfParseService 의존성 제거, validatePdfParsing 테스트 로직 변경, validateExcelParsing 테스트의 메서드 시그니처 업데이트 등이 포함되어 있습니다. 전반적으로 변경 사항은 명확하며, 리팩토링된 코드에 맞춰 테스트를 성공적으로 정합시켰습니다. 한 가지 개선점으로, Map<String, Object> 대신 DTO를 사용하여 타입 안정성을 높이는 방안을 제안했습니다.
There was a problem hiding this comment.
Pull request overview
ParsingValidationServiceTest가 최신 ParsingValidationService/ExcelParseService 메서드 시그니처를 참조하도록 업데이트해 ./gradlew test 실패를 해소하는 PR입니다.
Changes:
ParsingValidationService생성자 변경에 맞춰 테스트에서PdfParseService의존성 제거ExcelParseService.parseWithoutSaving(file, maxChunks)및validateExcelParsing(file, semester, maxChunks)시그니처에 맞게 테스트 수정- PDF 검증 테스트를 “미구현 기본 리포트” 반환 검증으로 단순화
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| when(excelParseService.parseWithoutSaving(file, 10)) | ||
| .thenReturn(List.of(parsedOne, parsedTwo)); | ||
| when(subjectRepository.findAll()) | ||
| .thenReturn(List.of(dbOne, dbTwo)); | ||
|
|
||
| Map<String, Object> report = service.validateExcelParsing(file, ""); | ||
| Map<String, Object> report = service.validateExcelParsing(file, "", 10); |
There was a problem hiding this comment.
테스트에서 maxChunks로 10을 하드코딩해 stubbing/호출에 중복 사용하고 있습니다. 향후 값 변경 시 한쪽만 수정해도 테스트가 의미 없이 깨질 수 있으니, 상수로 추출하거나 지역 변수로 한 번만 선언해 재사용하는 형태가 더 안전합니다.
| void validatePdfParsing_notImplementedReturnsDefaultReport() { | ||
| MockMultipartFile file = mockFile("timetable.pdf", "application/pdf"); | ||
|
|
||
| Subject parsedMismatch = subject("Data Structures", "Kim", | ||
| schedule("Mon", 1.0, 3.0)); | ||
| Subject parsedOnly = subject("Operating Systems", "Lee", | ||
| schedule("Wed", 2.0, 4.0)); | ||
| Subject parsedMatch = subject("Algorithms", "Park", | ||
| schedule("Fri", 2.0, 3.0)); | ||
|
|
||
| Subject dbMismatch = subject("Data Structures", "Kim", | ||
| schedule("Mon", 1.0, 2.0)); | ||
| Subject dbOnly = subject("Networks", "Choi", | ||
| schedule("Tue", 1.0, 2.0)); | ||
| Subject dbMatch = subject("Algorithms", "Park", | ||
| schedule("Fri", 2.0, 3.0)); | ||
|
|
||
| when(pdfParseService.parseWithoutSaving(file)) | ||
| .thenReturn(List.of(parsedMismatch, parsedOnly, parsedMatch)); | ||
| when(subjectRepository.findAll()) | ||
| .thenReturn(List.of(dbMismatch, dbOnly, dbMatch)); | ||
|
|
||
| Map<String, Object> report = service.validatePdfParsing(file, ""); | ||
|
|
||
| assertEquals("PDF", report.get("sourceType")); | ||
| assertEquals(3, report.get("parsedCount")); | ||
| assertEquals(3, report.get("dbCount")); | ||
|
|
||
| List<String> onlyInParsed = (List<String>) report.get("onlyInParsed"); | ||
| assertEquals(1, onlyInParsed.size()); | ||
| assertTrue(onlyInParsed.contains("Operating Systems")); | ||
|
|
||
| List<String> onlyInDb = (List<String>) report.get("onlyInDb"); | ||
| assertEquals(1, onlyInDb.size()); | ||
| assertTrue(onlyInDb.contains("Networks")); | ||
|
|
||
| List<Map<String, Object>> differences = (List<Map<String, Object>>) report.get("differences"); | ||
| assertEquals(1, differences.size()); | ||
| Map<String, Object> diff = differences.get(0); | ||
| assertEquals("Data Structures", diff.get("subjectName")); | ||
| assertTrue(diff.containsKey("schedule")); | ||
|
|
||
| Map<String, Object> scheduleDiff = (Map<String, Object>) diff.get("schedule"); | ||
| assertEquals("Mon 1.0-3.0", scheduleDiff.get("parsed")); | ||
| assertEquals("Mon 1.0-2.0", scheduleDiff.get("db")); | ||
|
|
||
| Map<String, Object> summary = (Map<String, Object>) report.get("summary"); | ||
| assertEquals("HAS_DIFFERENCES", summary.get("status")); | ||
| assertEquals(3, summary.get("totalIssues")); | ||
| assertEquals(0, report.get("parsedCount")); | ||
| assertEquals(0, report.get("dbCount")); | ||
| assertEquals("Not implemented", report.get("message")); | ||
| } |
There was a problem hiding this comment.
validatePdfParsing 기본 리포트 테스트가 parsedCount/dbCount/message만 검증하고 있는데, 현재 admin/validate-result.html에서는 report.sourceType, report.accuracy, report.summary.status/totalIssues, onlyInParsedCount 등 여러 키를 전제로 렌더링합니다. PDF 검증 기능이 노출돼 있다면(컨트롤러에서도 동일 템플릿 사용) 최소한 기본 리포트에도 동일한 스키마(기본값 포함)를 넣어 템플릿/클라이언트가 깨지지 않도록 하고, 테스트도 그 계약을 검증하는 편이 안전합니다.
배경
./gradlew test실패 원인이 리팩토링 코드가 아니라ParsingValidationServiceTest의 구버전 시그니처 참조였습니다.변경 사항
ParsingValidationService생성자 변경 반영(pdfParseService, excelParseService, subjectRepository)->(excelParseService, subjectRepository)ExcelParseService.parseWithoutSaving(file, maxChunks)시그니처 반영validateExcelParsing(file, semester, maxChunks)시그니처 반영검증
./gradlew test --no-daemon✅ 통과충돌 영향