Skip to content

Test: add unit tests for ActivityLogResponse DTO#152

Open
TatjanaTrajkovic wants to merge 2 commits intomainfrom
test/unit_tests_activity_log_dto
Open

Test: add unit tests for ActivityLogResponse DTO#152
TatjanaTrajkovic wants to merge 2 commits intomainfrom
test/unit_tests_activity_log_dto

Conversation

@TatjanaTrajkovic
Copy link
Copy Markdown
Contributor

@TatjanaTrajkovic TatjanaTrajkovic commented Apr 7, 2026

Summary by CodeRabbit

  • Tests
    • Added a unit test to verify activity log → response mapping, ensuring all response fields (IDs, action, description, actor info, related record ID, and timestamp) are populated correctly and match source values.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

A new JUnit 5 test class ActivityLogResponseTest was added. It constructs User, MedicalRecord, and ActivityLog instances with fixed IDs and timestamp, calls ActivityLogResponse.from(log), and asserts each response field (id, action, description, performedById, performedByName, recordId, createdAt) matches the source values.

Changes

Cohort / File(s) Summary
Activity Log Response Test
src/test/java/org/example/vet1177/dto/response/activitylog/ActivityLogResponseTest.java
Added new JUnit 5 test verifying ActivityLogResponse.from(...) maps entity fields to DTO fields exactly, using fixed UUIDs and a deterministic Instant for assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #66: Adds/implements the ActivityLogResponse.from(...) mapping method that this test exercises and validates.

Poem

🐰 I hop with a test and a tidy plan,
IDs and time aligned by my paw-hand,
From log to response the fields all gleam,
Assertions cheer—mapping’s a dream! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Test: add unit tests for ActivityLogResponse DTO' directly and clearly describes the main change: adding unit tests for the ActivityLogResponse DTO class, which matches the content of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/unit_tests_activity_log_dto

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.

@TatjanaTrajkovic TatjanaTrajkovic linked an issue Apr 7, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/java/org/example/vet1177/dto/response/activitylog/ActivityLogResponseTest.java`:
- Line 13: The test ActivityLogResponseTest currently only asserts createdAt is
non-null; change the test to use a fixed Instant (e.g.,
Instant.parse("2020-01-01T00:00:00Z")) when building the source object and
assert that ActivityLogResponse.getCreatedAt() equals that exact Instant rather
than just not-null; update the setup in the test method(s) that construct the
DTO (references: ActivityLogResponseTest, the test method building the source
object and the getCreatedAt assertion) to use the fixed Instant and replace
assertNotNull with an equality assertion.
🪄 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: 658601d1-df4c-4b25-a7f3-344ff0541f36

📥 Commits

Reviewing files that changed from the base of the PR and between ba13529 and 3f1a62a.

📒 Files selected for processing (1)
  • src/test/java/org/example/vet1177/dto/response/activitylog/ActivityLogResponseTest.java

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/test/java/org/example/vet1177/dto/response/activitylog/ActivityLogResponseTest.java (1)

22-24: Optional: use fixed UUID constants for fully reproducible fixtures.

Line 22 through Line 24 currently uses UUID.randomUUID(). The test is still correct, but fixed UUIDs can make failures easier to diff/debug across runs.

♻️ Optional refactor
-        UUID logId = UUID.randomUUID();
-        UUID userId = UUID.randomUUID();
-        UUID recordId = UUID.randomUUID();
+        UUID logId = UUID.fromString("11111111-1111-1111-1111-111111111111");
+        UUID userId = UUID.fromString("22222222-2222-2222-2222-222222222222");
+        UUID recordId = UUID.fromString("33333333-3333-3333-3333-333333333333");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/test/java/org/example/vet1177/dto/response/activitylog/ActivityLogResponseTest.java`
around lines 22 - 24, Replace the non-deterministic UUIDs in
ActivityLogResponseTest by using fixed UUID constants so fixtures are
reproducible: instead of calling UUID.randomUUID() for the logId, userId, and
recordId variables in ActivityLogResponseTest, define and use static/final UUID
constants (e.g., LOG_ID, USER_ID, RECORD_ID) with hard-coded UUID strings and
reference those constants when constructing the test data.
🤖 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/dto/response/activitylog/ActivityLogResponseTest.java`:
- Around line 22-24: Replace the non-deterministic UUIDs in
ActivityLogResponseTest by using fixed UUID constants so fixtures are
reproducible: instead of calling UUID.randomUUID() for the logId, userId, and
recordId variables in ActivityLogResponseTest, define and use static/final UUID
constants (e.g., LOG_ID, USER_ID, RECORD_ID) with hard-coded UUID strings and
reference those constants when constructing the test data.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17049b47-b452-44ab-8521-608289c6fd0c

📥 Commits

Reviewing files that changed from the base of the PR and between 3f1a62a and c1a6b67.

📒 Files selected for processing (1)
  • src/test/java/org/example/vet1177/dto/response/activitylog/ActivityLogResponseTest.java

Copy link
Copy Markdown
Contributor

@annikaholmqvist94 annikaholmqvist94 left a comment

Choose a reason for hiding this comment

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

Ser bra ut :)

Copy link
Copy Markdown
Contributor

@lindaeskilsson lindaeskilsson left a comment

Choose a reason for hiding this comment

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

Snygggt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: add unit tests for ActivityLogResponse DTO

3 participants