Test/integration tests activitylog#189
Conversation
- Added end-to-end integration test for ActivityLog - Configured H2 in-memory DB for test profile - Updated application-test.properties - Ensured entity relationships and constraints are correctly handled Foundation for further integration testing
- Added integration tests for ActivityLog (owner, vet access, missing header) - Introduced TestDataFactory for reusable test setup - Updated application-test.properties to use H2 in-memory DB - Added exception handling for missing request headers (400 instead of 500)
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 27 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds H2 as the test database, a MissingRequestHeaderException handler, a TestDataFactory for integration tests, and new ActivityLog integration tests exercising GET /api/activity-logs/record/{recordId}, including a missing Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.java (1)
44-106: Remove the large commented-out legacy test block.Keeping disabled test code in the class adds noise and makes maintenance harder. Please delete it now that
TestDataFactory-based setup is in place.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.java` around lines 44 - 106, Remove the large disabled test block for should_return_logs_for_owner_only in ActivityLogIntegrationTest: delete the entire commented-out test (the lines starting with // `@Test` and ending with the closing comment) so the file no longer contains the legacy commented test that duplicates TestDataFactory-based setup; ensure you only remove the commented block and do not alter other tests or imports in ActivityLogIntegrationTest.
🤖 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/test/resources/application-test.properties`:
- Around line 18-19: The comment "Kör schema.sql men INTE data.sql" conflicts
with the properties: currently spring.sql.init.mode=never disables Spring SQL
initialization so schema.sql won't run; decide which behavior you want and make
one of two fixes: if you want Spring to run schema.sql but not data.sql, set
spring.sql.init.mode=embedded (or always) and keep
spring.sql.init.data-locations= (or set spring.sql.init.data-locations=none) and
update the comment accordingly; if you do not want schema.sql and rely on
Hibernate ddl-auto, update the comment to state that schema.sql is not run and
keep spring.sql.init.mode=never (and optionally remove or empty
spring.sql.init.data-locations). Ensure changes reference the properties
spring.sql.init.mode and spring.sql.init.data-locations and the comment text
"Kör schema.sql men INTE data.sql".
---
Nitpick comments:
In
`@src/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.java`:
- Around line 44-106: Remove the large disabled test block for
should_return_logs_for_owner_only in ActivityLogIntegrationTest: delete the
entire commented-out test (the lines starting with // `@Test` and ending with
the closing comment) so the file no longer contains the legacy commented test
that duplicates TestDataFactory-based setup; ensure you only remove the
commented block and do not alter other tests or imports in
ActivityLogIntegrationTest.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 13f2b87f-30c6-4486-822e-deea769fd856
📒 Files selected for processing (5)
pom.xmlsrc/main/java/org/example/vet1177/exception/GlobalExceptionHandler.javasrc/test/java/org/example/vet1177/integration/TestDataFactory.javasrc/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.javasrc/test/resources/application-test.properties
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/test/resources/application-test.properties (1)
19-20:⚠️ Potential issue | 🟡 MinorComment and SQL-init behavior are still contradictory.
Line 19 says schema.sql should run, but Line 20 (
spring.sql.init.mode=never) disables Spring SQL initialization entirely. Please either update the comment or switch init mode to match the intended behavior.#!/bin/bash # Verify current test SQL init intent vs effective configuration. cat -n src/test/resources/application-test.properties | sed -n '16,22p' fd -i "schema.sql" src fd -i "data.sql" src🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/resources/application-test.properties` around lines 19 - 20, The comment and property disagree: the comment says "Kör schema.sql men INTE data.sql" (run schema.sql but not data.sql) while spring.sql.init.mode=never disables SQL init entirely; fix by either (A) updating spring.sql.init.mode to an init mode that runs schema.sql (e.g., set spring.sql.init.mode=embedded or always depending on your test DB) and ensure only schema.sql is present (no data.sql), or (B) change the comment to reflect that SQL init is disabled; adjust the file around the spring.sql.init.mode property and the schema/data files accordingly so the intent and configuration match.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/test/resources/application-test.properties`:
- Around line 19-20: The comment and property disagree: the comment says "Kör
schema.sql men INTE data.sql" (run schema.sql but not data.sql) while
spring.sql.init.mode=never disables SQL init entirely; fix by either (A)
updating spring.sql.init.mode to an init mode that runs schema.sql (e.g., set
spring.sql.init.mode=embedded or always depending on your test DB) and ensure
only schema.sql is present (no data.sql), or (B) change the comment to reflect
that SQL init is disabled; adjust the file around the spring.sql.init.mode
property and the schema/data files accordingly so the intent and configuration
match.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 80be89ba-2206-4080-b64c-bc8b47a9b53b
📒 Files selected for processing (1)
src/test/resources/application-test.properties
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.java (1)
54-116: Remove the commented-out legacy test implementation.This block is dead code now that
TestDataFactory-based setup is in place; keeping it increases maintenance noise.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.java` around lines 54 - 116, Remove the commented-out legacy test block for should_return_logs_for_owner_only from ActivityLogIntegrationTest.java (the large commented region that creates Clinic, User, Pet, MedicalRecord, ActivityLog instances) since TestDataFactory-based setup replaces it; delete the entire commented method and any nearby commented helper code to reduce noise, then run tests to ensure no unused imports or references remain (adjust imports if the removal makes any unused).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.java`:
- Around line 54-116: Remove the commented-out legacy test block for
should_return_logs_for_owner_only from ActivityLogIntegrationTest.java (the
large commented region that creates Clinic, User, Pet, MedicalRecord,
ActivityLog instances) since TestDataFactory-based setup replaces it; delete the
entire commented method and any nearby commented helper code to reduce noise,
then run tests to ensure no unused imports or references remain (adjust imports
if the removal makes any unused).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 29a16c78-2ff6-4c63-8099-1070feb72421
📒 Files selected for processing (1)
src/test/java/org/example/vet1177/integration/activitylog/ActivityLogIntegrationTest.java
Summary by CodeRabbit
Bug Fixes
Tests