Skip to content

Test: add unit tests for ActivityLog entity (constructor and prePersist)#151

Merged
TatjanaTrajkovic merged 2 commits intomainfrom
test/unit_tests_activity_log_entity
Apr 7, 2026
Merged

Test: add unit tests for ActivityLog entity (constructor and prePersist)#151
TatjanaTrajkovic merged 2 commits intomainfrom
test/unit_tests_activity_log_entity

Conversation

@TatjanaTrajkovic
Copy link
Copy Markdown
Contributor

@TatjanaTrajkovic TatjanaTrajkovic commented Apr 7, 2026

Summary by CodeRabbit

  • Tests
    • Added test coverage for the ActivityLog entity, validating constructor initialization and all relevant getters.
    • Added tests for lifecycle behavior to verify creation timestamps are set and fall within expected time bounds when the entity is persisted.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e936ccc-0a84-42d9-928c-76ce16bd99de

📥 Commits

Reviewing files that changed from the base of the PR and between 6958c78 and dc6e116.

📒 Files selected for processing (1)
  • src/test/java/org/example/vet1177/entities/ActivityLogTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/org/example/vet1177/entities/ActivityLogTest.java

📝 Walkthrough

Walkthrough

Added a JUnit 5 test class ActivityLogTest that verifies the ActivityLog constructor/getters and that onCreate() (JPA @PrePersist) sets createdAt within an expected time window.

Changes

Cohort / File(s) Summary
ActivityLog Test Suite
src/test/java/org/example/vet1177/entities/ActivityLogTest.java
New test class with two tests: constructor/getter assertions using mocked User/MedicalRecord, and onCreate() timestamp verification for createdAt.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • johanbriger
  • annikaholmqvist94
  • lindaeskilsson

Poem

🐰 I hopped in code to run a test,

Checked the getters, then the timestamp's nest,
CreatedAt set within the span,
ActivityLog passed — that's my plan! 🥕

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding unit tests for the ActivityLog entity covering constructor and prePersist lifecycle methods.

✏️ 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_entity

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/entities/ActivityLogTest.java`:
- Around line 47-54: The test's timestamp assertion is too broad; update
ActivityLogTest to capture Instant before = Instant.now() immediately before
calling log.onCreate(), then call log.onCreate(), capture Instant after =
Instant.now() immediately after, and replace the loose isBefore check with
assertions that log.getCreatedAt() is not null and that createdAt is
!before.isAfter(createdAt) (i.e., createdAt.compareTo(before) >= 0) and
!after.isBefore(createdAt) (i.e., createdAt.compareTo(after) <= 0) so createdAt
falls between the before and after timestamps; reference the test method that
calls log.onCreate() and uses log.getCreatedAt().
🪄 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: e7d9be63-ce60-4735-84af-a423d99d352d

📥 Commits

Reviewing files that changed from the base of the PR and between 1cf45a8 and 6958c78.

📒 Files selected for processing (1)
  • src/test/java/org/example/vet1177/entities/ActivityLogTest.java

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: Add Unit tests for ActivityLog entity

1 participant