Skip to content

Add dedicated unit tests for ReadonlyDataContextEnhancer#795

Merged
Schmarvinius merged 4 commits intomainfrom
unit1-readonly-data-context-enhancer-test
Apr 14, 2026
Merged

Add dedicated unit tests for ReadonlyDataContextEnhancer#795
Schmarvinius merged 4 commits intomainfrom
unit1-readonly-data-context-enhancer-test

Conversation

@Schmarvinius
Copy link
Copy Markdown
Collaborator

@Schmarvinius Schmarvinius commented Apr 13, 2026

Add Dedicated Unit Tests for ReadonlyDataContextEnhancer

Test

🧪 Adds a new test class ReadonlyDataContextEnhancerTest covering the preserveReadonlyFields and restoreReadonlyFields methods with 5 targeted unit tests. Tests use real CDS entities from RuntimeHelper with zero Mockito usage.

Changes

  • ReadonlyDataContextEnhancerTest.java: New test class with 5 tests covering:
    • preserveReadonlyFields_isDraft_backupCreated — verifies that a readonly backup (DRAFT_READONLY_CONTEXT) is created with the correct field values (contentId, status, scannedAt) when the draft flag is true.
    • preserveReadonlyFields_isNotDraft_backupRemoved — verifies that any existing readonly backup is removed when the draft flag is false.
    • preserveReadonlyFields_isDraft_noAttachmentEntity_nothingHappens — confirms no backup is created for non-attachment entities.
    • restoreReadonlyFields_withBackup_fieldsRestoredAndBackupRemoved — verifies that readonly fields are restored from the backup and the backup entry is subsequently removed.
    • restoreReadonlyFields_withoutBackup_noOp — confirms no modifications occur when no backup exists.
  • 🔄 Regenerate and Update Summary

📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!

PR Bot Information

Version: 1.20.11 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • Event Trigger: issue_comment.edited
  • Correlation ID: 295ad2d0-3777-11f1-9c0b-e94530c31a11

Covers preserveReadonlyFields (draft/non-draft paths) and
restoreReadonlyFields (with/without backup), using real CDS
entities from RuntimeHelper instead of mocks.

Refs: cap/cds-calesi#419
@Schmarvinius Schmarvinius requested a review from a team as a code owner April 13, 2026 20:12
Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights bot left a comment

Choose a reason for hiding this comment

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

The new test class covers the main happy paths well and uses real CDS entities instead of mocks, which is commendable. However, there are three gaps worth addressing: the backup's exclusion of content should be explicitly asserted, the partial-backup/null-overwrite behavior in restoreReadonlyFields is untested, and the non-draft path with no pre-existing backup has no coverage.

PR Bot Information

Version: 1.20.11 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • Correlation ID: 0f5a1820-3775-11f1-836a-cfdbc740c472
  • LLM: anthropic--claude-4.6-sonnet
  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened

@Schmarvinius Schmarvinius merged commit f240256 into main Apr 14, 2026
3 checks passed
@Schmarvinius Schmarvinius deleted the unit1-readonly-data-context-enhancer-test branch April 14, 2026 08:53
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.

2 participants