Skip to content

refactor: BloodSugarMeasurementType byte->enum 비즈니스 로직 수정 - #227

Merged
jyun-KIM merged 1 commit into
mainfrom
refactor/blood-sugar-measurement-type
Mar 10, 2026
Merged

jyun-KIM merged 1 commit into
mainfrom
refactor/blood-sugar-measurement-type

Conversation

@jyun-KIM

@jyun-KIM jyun-KIM commented Feb 25, 2026 •

Copy link
Copy Markdown
Member

Desc

public enum BloodSugarMeasurementType {
    BEFORE_MEAL,
    AFTER_MEAL;
} 
  • 식전/식후 혈당 enum에서 byte값 삭제
  • 테스트 수정

HealthDataExtractionResponse 클래스의 BloodSugarData 에서 변수명이

@Schema(description = "측정 시각", example = "아침")
        private String measurementTime;
        
@Schema(
    description = "식전/식후 여부",
    example = "식후",
    allowableValues = {"식전", "식후"}
)
private BloodSugarMeasurementType measurementType;

위와 같이 되어있는데 테스트 수정하다보니 헷갈리는것 같네요. 어떤 식으로 수정하면 좋을까요?

@github-actions github-actions Bot added the refactoring Refactoring should not change Test codes label Feb 25, 2026
@coderabbitai

coderabbitai Bot commented Feb 25, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@jyun-KIM has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4cf1d902-f1a1-471c-8feb-8f73010a6dea

📥 Commits

Reviewing files that changed from the base of the PR and between 631aa2c and b74c2c7.

📒 Files selected for processing (6)
  • src/main/java/com/example/medicare_call/dto/data_processor/HealthDataExtractionResponse.java
  • src/main/java/com/example/medicare_call/global/enums/BloodSugarMeasurementType.java
  • src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java
  • src/test/java/com/example/medicare_call/global/enums/BloodSugarMeasurementTypeTest.java
  • src/test/java/com/example/medicare_call/service/carecall/analysis/HealthDataExtractionIntegrationTest.java
  • src/test/java/com/example/medicare_call/service/health_data/BloodSugarServiceTest.java

Walkthrough

BloodSugarData DTO의 필드를 mealTime (String)에서 measurementType (BloodSugarMeasurementType)로 변경했습니다. 관련 enum을 단순화하고, 서비스 로직과 테스트를 이 변경에 맞게 업데이트했습니다.

Changes

Cohort / File(s) Summary
Enum 단순화
src/main/java/com/example/medicare_call/global/enums/BloodSugarMeasurementType.java
Lombok @Getter 제거 및 enum 단순화: 기존의 description/value 필드와 fromDescription/fromValue 팩토리 메서드를 제거하고, BEFORE_MEAL과 AFTER_MEAL 두 가지 값만 남김
DTO 및 Service 수정
src/main/java/com/example/medicare_call/dto/data_processor/HealthDataExtractionResponse.java, src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java
BloodSugarData의 mealTime 필드를 measurementType으로 변경하고, 서비스에서 이를 사용하도록 업데이트
테스트 코드 정리 및 수정
src/test/java/com/example/medicare_call/global/enums/BloodSugarMeasurementTypeTest.java (삭제), src/test/java/com/example/medicare_call/service/carecall/analysis/HealthDataExtractionIntegrationTest.java, src/test/java/com/example/medicare_call/service/health_data/BloodSugarServiceTest.java
enum 관련 테스트 파일 삭제, 통합 테스트 및 서비스 테스트를 새로운 measurementType 필드에 맞춰 수정

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

refactoring

Suggested reviewers

  • mjkhub
  • kisusu115
  • sudo-Terry

Poem

🩺 혼란스러운 문자열 떨어내고,
타입 안전의 enum으로 우아하게 정렬하네,
불필요한 무게는 버리고,
깔끔하고 명확한 코드로 솔루션 완성! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항을 명확하게 요약하고 있습니다. BloodSugarMeasurementType을 byte에서 enum으로 리팩토링하고 비즈니스 로직을 수정한 내용이 정확히 반영되어 있습니다.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/blood-sugar-measurement-type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/example/medicare_call/dto/data_processor/HealthDataExtractionResponse.java (1)

106-111: ⚠️ Potential issue | 🟠 Major

measurementType 스키마 설명이 실제 enum 값과 불일치합니다

현재 타입은 BloodSugarMeasurementType인데, 스키마 예시/허용값은 "식전", "식후"로 남아 있어 API 계약이 어긋납니다. 문서/프롬프트/클라이언트가 잘못된 값을 생성할 가능성이 큽니다. enum 값 기준으로 스키마를 맞추거나, 별도 매핑 계층을 명시해 주세요.

🔧 제안 diff
         `@Schema`(
             description = "식전/식후 여부",
-            example = "식후",
-            allowableValues = {"식전", "식후"}
+            example = "AFTER_MEAL",
+            allowableValues = {"BEFORE_MEAL", "AFTER_MEAL"}
         )
         private BloodSugarMeasurementType measurementType;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/example/medicare_call/dto/data_processor/HealthDataExtractionResponse.java`
around lines 106 - 111, The `@Schema` on
HealthDataExtractionResponse.measurementType is inconsistent with the actual
BloodSugarMeasurementType enum; update the schema to reflect the enum constants
(or add an explicit mapping) so API docs match runtime values: locate the
measurementType field in HealthDataExtractionResponse and either replace the
example/allowableValues ("식전","식후") with the actual BloodSugarMeasurementType
constant names (or their string representations returned by the enum), or add a
clear mapping layer (e.g., a DTO/string field or a custom `@Schema` description)
that documents the enum-to-localized value mapping; ensure the chosen approach
updates example, allowableValues and description to reference
BloodSugarMeasurementType so clients and prompts receive correct values.
🧹 Nitpick comments (1)
src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java (1)

54-55: 로그 필드명 mealTime은 현재 의미와 맞지 않습니다

실제 출력 값은 measurementType인데 키가 mealTime으로 남아 있어 운영 로그 해석이 헷갈릴 수 있습니다.

🧹 제안 diff
-            log.info("혈당 데이터 저장 완료: value={}, mealTime={}, status={}",
-                    bloodSugarData.getBloodSugarValue(), bloodSugarData.getMeasurementType(), status);
+            log.info("혈당 데이터 저장 완료: value={}, measurementType={}, status={}",
+                    bloodSugarData.getBloodSugarValue(), bloodSugarData.getMeasurementType(), status);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java`
around lines 54 - 55, The log field name "mealTime" is incorrect for the value
being logged; update the log message in BloodSugarService so the placeholder key
matches the actual value: change the key from mealTime to measurementType (or
another accurate name) in the log.info call that uses
bloodSugarData.getMeasurementType() and status, ensuring the call in the
BloodSugarService class still passes bloodSugarData.getBloodSugarValue(),
bloodSugarData.getMeasurementType(), status in the same order; also scan for
other occurrences of "mealTime" in BloodSugarService to keep logging consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java`:
- Around line 35-36: BloodSugarMeasurementType returned by
bloodSugarData.getMeasurementType() can be null so calling
measurementType.name() may throw NPE; update BloodSugarService to guard this by
checking measurementType for null before using name() (either skip
processing/return early with a logged warning or substitute a sensible default
enum value), e.g., in the code paths around where measurementType is used (the
getMeasurementType() call and subsequent measurementType.name() usages) add a
null-check/Optional handling and ensure you handle/save accordingly.

In
`@src/test/java/com/example/medicare_call/service/carecall/analysis/HealthDataExtractionIntegrationTest.java`:
- Line 121: The test only asserts measurementTime and the mock JSON still uses
the old mealTime field, so update the test and mock payload to exercise the new
enum-based field: change the mock JSON to include "measurementType" with the
appropriate enum string (instead of "mealTime"), and in
HealthDataExtractionIntegrationTest update the assertion on bloodSugar to assert
the measurementType (e.g., compare to the expected MeasurementType enum value)
rather than or in addition to measurementTime so the enum mapping is validated
(reference the bloodSugar variable and the measurementType
property/MeasurementType enum in your changes).

---

Outside diff comments:
In
`@src/main/java/com/example/medicare_call/dto/data_processor/HealthDataExtractionResponse.java`:
- Around line 106-111: The `@Schema` on
HealthDataExtractionResponse.measurementType is inconsistent with the actual
BloodSugarMeasurementType enum; update the schema to reflect the enum constants
(or add an explicit mapping) so API docs match runtime values: locate the
measurementType field in HealthDataExtractionResponse and either replace the
example/allowableValues ("식전","식후") with the actual BloodSugarMeasurementType
constant names (or their string representations returned by the enum), or add a
clear mapping layer (e.g., a DTO/string field or a custom `@Schema` description)
that documents the enum-to-localized value mapping; ensure the chosen approach
updates example, allowableValues and description to reference
BloodSugarMeasurementType so clients and prompts receive correct values.

---

Nitpick comments:
In
`@src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java`:
- Around line 54-55: The log field name "mealTime" is incorrect for the value
being logged; update the log message in BloodSugarService so the placeholder key
matches the actual value: change the key from mealTime to measurementType (or
another accurate name) in the log.info call that uses
bloodSugarData.getMeasurementType() and status, ensuring the call in the
BloodSugarService class still passes bloodSugarData.getBloodSugarValue(),
bloodSugarData.getMeasurementType(), status in the same order; also scan for
other occurrences of "mealTime" in BloodSugarService to keep logging consistent.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18a76fe and 631aa2c.

📒 Files selected for processing (6)
  • src/main/java/com/example/medicare_call/dto/data_processor/HealthDataExtractionResponse.java
  • src/main/java/com/example/medicare_call/global/enums/BloodSugarMeasurementType.java
  • src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java
  • src/test/java/com/example/medicare_call/global/enums/BloodSugarMeasurementTypeTest.java
  • src/test/java/com/example/medicare_call/service/carecall/analysis/HealthDataExtractionIntegrationTest.java
  • src/test/java/com/example/medicare_call/service/health_data/BloodSugarServiceTest.java
💤 Files with no reviewable changes (1)
  • src/test/java/com/example/medicare_call/global/enums/BloodSugarMeasurementTypeTest.java

Comment on lines +35 to 36
BloodSugarMeasurementType measurementType = bloodSugarData.getMeasurementType();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

measurementType null 가드가 없어 런타임 NPE가 발생할 수 있습니다

measurementType이 비어 있으면 name() 호출 시 바로 예외가 납니다. 저장 스킵/기본값 처리 중 하나를 명시적으로 넣어 주세요.

🛠️ 제안 diff
-            // measurementType 결정 (식전/식후)
-            BloodSugarMeasurementType measurementType = bloodSugarData.getMeasurementType();
+            // measurementType 결정 (식전/식후)
+            BloodSugarMeasurementType measurementType = bloodSugarData.getMeasurementType();
+            if (measurementType == null) {
+                log.warn("혈당 측정 유형이 없어서 저장하지 않습니다. measurementTime={}", bloodSugarData.getMeasurementTime());
+                continue;
+            }
@@
             BloodSugarRecord bloodSugarRecord = BloodSugarRecord.builder()
@@
                     .responseSummary(String.format("측정시각: %s, 식전/식후: %s",
-                            bloodSugarData.getMeasurementTime(), bloodSugarData.getMeasurementType().name()))
+                            bloodSugarData.getMeasurementTime(), measurementType.name()))
                     .build();

Also applies to: 49-50

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/example/medicare_call/service/health_data/BloodSugarService.java`
around lines 35 - 36, BloodSugarMeasurementType returned by
bloodSugarData.getMeasurementType() can be null so calling
measurementType.name() may throw NPE; update BloodSugarService to guard this by
checking measurementType for null before using name() (either skip
processing/return early with a logged warning or substitute a sensible default
enum value), e.g., in the code paths around where measurementType is used (the
getMeasurementType() call and subsequent measurementType.name() usages) add a
null-check/Optional handling and ensure you handle/save accordingly.

HealthDataExtractionResponse.BloodSugarData bloodSugar = result.getBloodSugarData().get(0);
assertThat(bloodSugar.getBloodSugarValue()).isEqualTo(120);
assertThat(bloodSugar.getMealTime()).isEqualTo("식후");
assertThat(bloodSugar.getMeasurementTime()).isEqualTo("아침");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

핵심 변경점인 measurementType 검증이 빠져 회귀를 놓칠 수 있습니다

지금은 measurementTime만 확인하고, mock JSON도 구 필드(mealTime)를 사용하고 있어 enum 전환이 실제로 동작하는지 보장하지 못합니다. payload와 assertion을 measurementType 기준으로 맞춰 주세요.

✅ 제안 diff
+import com.example.medicare_call.global.enums.BloodSugarMeasurementType;
@@
-                    "mealTime": "식후",
+                    "measurementType": "AFTER_MEAL",
@@
         assertThat(bloodSugar.getBloodSugarValue()).isEqualTo(120);
         assertThat(bloodSugar.getMeasurementTime()).isEqualTo("아침");
+        assertThat(bloodSugar.getMeasurementType()).isEqualTo(BloodSugarMeasurementType.AFTER_MEAL);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
assertThat(bloodSugar.getMeasurementTime()).isEqualTo("아침");
assertThat(bloodSugar.getMeasurementTime()).isEqualTo("아침");
assertThat(bloodSugar.getMeasurementType()).isEqualTo(BloodSugarMeasurementType.AFTER_MEAL);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/test/java/com/example/medicare_call/service/carecall/analysis/HealthDataExtractionIntegrationTest.java`
at line 121, The test only asserts measurementTime and the mock JSON still uses
the old mealTime field, so update the test and mock payload to exercise the new
enum-based field: change the mock JSON to include "measurementType" with the
appropriate enum string (instead of "mealTime"), and in
HealthDataExtractionIntegrationTest update the assertion on bloodSugar to assert
the measurementType (e.g., compare to the expected MeasurementType enum value)
rather than or in addition to measurementTime so the enum mapping is validated
(reference the bloodSugar variable and the measurementType
property/MeasurementType enum in your changes).

@kisusu115

Copy link
Copy Markdown
Contributor

HealthDataExtractionResponse 클래스의 BloodSugarData 에서 변수명이

@Schema(description = "측정 시각", example = "아침")
        private String measurementTime;
        
@Schema(
    description = "식전/식후 여부",
    example = "식후",
    allowableValues = {"식전", "식후"}
)
private BloodSugarMeasurementType measurementType;

위와 같이 되어있는데 테스트 수정하다보니 헷갈리는것 같네요. 어떤 식으로 수정하면 좋을까요?

개인적으로는 mealTime -> measurementType으로 Enum 이름하고 통일해서
measurementTime / measurementType 으로 가도 좋아보여요
mealTime은 확실히 모호하네요..

@jyun-KIM
jyun-KIM force-pushed the refactor/blood-sugar-measurement-type branch from 631aa2c to b74c2c7 Compare March 10, 2026 04:58
@jyun-KIM
jyun-KIM merged commit 62a9598 into main Mar 10, 2026
4 checks passed
@jyun-KIM
jyun-KIM deleted the refactor/blood-sugar-measurement-type branch March 10, 2026 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Refactoring should not change Test codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants