EPMRPP-115026 || Added a command for record download#18
Conversation
WalkthroughThis PR adds external recording download and attachment capabilities to the Mobitru plugin. It introduces a REST-based client for downloading recordings, a new command to attach them to logs, refactors the existing REST client infrastructure, removes the deprecated ChangesRecording Download and Attachment Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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: 2
🧹 Nitpick comments (1)
src/main/java/com/epam/reportportal/mobitru/model/RecordingAttachmentData.java (1)
26-27: ⚡ Quick winDefensively copy
contentto prevent mutable state leakage.Line 26 stores and exposes a raw
byte[]; any caller can mutate it after construction or through the accessor. Since this object crosses client/command boundaries, make it immutable-by-contract.Proposed fix
-public record RecordingAttachmentData(String fileName, String contentType, byte[] content) { -} +import java.util.Arrays; + +public record RecordingAttachmentData(String fileName, String contentType, byte[] content) { + public RecordingAttachmentData { + content = content == null ? null : Arrays.copyOf(content, content.length); + } + + `@Override` + public byte[] content() { + return content == null ? null : Arrays.copyOf(content, content.length); + } +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/epam/reportportal/mobitru/model/RecordingAttachmentData.java` around lines 26 - 27, RecordingAttachmentData currently stores and exposes the raw byte[] content allowing callers to mutate its internal state; make it immutable by defensively copying the array in the record’s canonical/compact constructor (assign content = content == null ? null : content.clone()) and override the generated accessor (public byte[] content()) to return a defensive copy (return content == null ? null : content.clone()); reference the RecordingAttachmentData record and the content component when applying these changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/com/epam/reportportal/mobitru/client/MobitruRecordingClient.java`:
- Around line 92-95: The code in MobitruRecordingClient currently sets
contentType to the raw header string which may include parameters (e.g.,
"video/mp4;charset=UTF-8"), and later equality checks use the full string so the
fallback extension logic fails; update the logic that derives the fallback file
extension to normalize the media type by stripping any parameters (split on ';'
and trim) or parse via a MediaType utility, then compare the base type (e.g.,
"video/mp4") against the known cases before returning the extension; ensure the
variable contentType (and the method(s) that compute the fallback
filename/extension in MobitruRecordingClient) use the normalized base media type
for the comparisons.
In
`@src/main/java/com/epam/reportportal/mobitru/command/LoadExternalAttachmentCommand.java`:
- Around line 87-95: The code currently lets request params override the
already-loaded Log context (via resolveProjectId(params, logEntity) and
resolveLaunch(params, logEntity)), causing mixed metadata; change the logic in
LoadExternalAttachmentCommand so project and launch are derived from the loaded
Log first (use values on logEntity/Log if present) and only fall back to params
when the Log lacks them, and ensure resolveProjectId and resolveLaunch are
updated or called in a consistent order so logId/logUuid, launchId/launchUuid
and projectId all come from the same source (the Log) rather than mixing params
and logEntity.
---
Nitpick comments:
In
`@src/main/java/com/epam/reportportal/mobitru/model/RecordingAttachmentData.java`:
- Around line 26-27: RecordingAttachmentData currently stores and exposes the
raw byte[] content allowing callers to mutate its internal state; make it
immutable by defensively copying the array in the record’s canonical/compact
constructor (assign content = content == null ? null : content.clone()) and
override the generated accessor (public byte[] content()) to return a defensive
copy (return content == null ? null : content.clone()); reference the
RecordingAttachmentData record and the content component when applying these
changes.
🪄 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: 10f40260-b10c-4d61-9307-edf7f8076563
📒 Files selected for processing (14)
src/main/java/com/epam/reportportal/mobitru/MobitruExtension.javasrc/main/java/com/epam/reportportal/mobitru/client/MobitruRecordingClient.javasrc/main/java/com/epam/reportportal/mobitru/client/RestClientBuilder.javasrc/main/java/com/epam/reportportal/mobitru/command/GetDevicesCommand.javasrc/main/java/com/epam/reportportal/mobitru/command/LoadExternalAttachmentCommand.javasrc/main/java/com/epam/reportportal/mobitru/command/TestConnectionCommand.javasrc/main/java/com/epam/reportportal/mobitru/file/ByteArrayMultipartFile.javasrc/main/java/com/epam/reportportal/mobitru/model/Constants.javasrc/main/java/com/epam/reportportal/mobitru/model/IntegrationParametersNames.javasrc/main/java/com/epam/reportportal/mobitru/model/IntegrationProperties.javasrc/main/java/com/epam/reportportal/mobitru/model/RecordingAttachmentData.javasrc/main/java/com/epam/reportportal/mobitru/utils/ValidationUtils.javasrc/test/java/com/epam/reportportal/mobitru/client/MobitruRecordingClientTest.javasrc/test/java/com/epam/reportportal/mobitru/command/LoadExternalAttachmentCommandTest.java
💤 Files with no reviewable changes (3)
- src/main/java/com/epam/reportportal/mobitru/model/IntegrationParametersNames.java
- src/main/java/com/epam/reportportal/mobitru/utils/ValidationUtils.java
- src/main/java/com/epam/reportportal/mobitru/model/IntegrationProperties.java
Summary by CodeRabbit
New Features
Changes