Skip to content

EPMRPP-115026 || Added a command for record download#18

Merged
pbortnik merged 2 commits into
developfrom
EPMRPP-115026-mobirtu
Jun 8, 2026
Merged

EPMRPP-115026 || Added a command for record download#18
pbortnik merged 2 commits into
developfrom
EPMRPP-115026-mobirtu

Conversation

@pbortnik

@pbortnik pbortnik commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added ability to download and attach external recordings from Mobitru and BrowserHub directly to test logs via the external attachment integration.
  • Changes

    • Removed URL as a required integration parameter; only API Key and Billing Unit are now needed for configuration.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This 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 URL integration parameter, and adapts existing commands to the new authentication pattern.

Changes

Recording Download and Attachment Feature

Layer / File(s) Summary
Infrastructure foundation and models
src/main/java/com/epam/reportportal/mobitru/model/Constants.java, src/main/java/com/epam/reportportal/mobitru/model/RecordingAttachmentData.java, src/main/java/com/epam/reportportal/mobitru/client/RestClientBuilder.java, src/main/java/com/epam/reportportal/mobitru/model/IntegrationParametersNames.java, src/main/java/com/epam/reportportal/mobitru/model/IntegrationProperties.java, src/main/java/com/epam/reportportal/mobitru/utils/ValidationUtils.java, src/main/java/com/epam/reportportal/mobitru/file/ByteArrayMultipartFile.java
Base URLs and recording endpoints are defined; RestClientBuilder gains auth header helper methods (bearerAuthHeader, basicAuthHeader) and exposes a pre-built RestTemplate via getter; deprecated URL parameter is removed from integration properties, validation, and parameter names; RecordingAttachmentData record models downloaded payloads; ByteArrayMultipartFile provides in-memory multipart file support.
Recording download client
src/main/java/com/epam/reportportal/mobitru/client/MobitruRecordingClient.java
MobitruRecordingClient downloads recording binaries via REST, selects Mobitru or BrowserHub base URL and basic or bearer auth based on attachment key, performs HTTP GET with payload validation, derives filename from Content-Disposition or content type, and returns RecordingAttachmentData.
External attachment command
src/main/java/com/epam/reportportal/mobitru/command/LoadExternalAttachmentCommand.java
LoadExternalAttachmentCommand validates log and attachment parameters, resolves project/launch/test-item IDs and UUIDs, downloads recording via MobitruRecordingClient, and attaches it to the target log using AttachmentBinaryDataService with populated metadata.
Existing commands adapted to new REST pattern
src/main/java/com/epam/reportportal/mobitru/command/GetDevicesCommand.java, src/main/java/com/epam/reportportal/mobitru/command/TestConnectionCommand.java
GetDevicesCommand and TestConnectionCommand now use restClient.getRestTemplate() with explicit HttpHeaders and bearer auth headers instead of delegating to the removed buildRestTemplate() method; simplified exception handling.
Extension wiring and command registration
src/main/java/com/epam/reportportal/mobitru/MobitruExtension.java
MobitruExtension injects attachment service and repository dependencies, creates a recordingClientSupplier memoizing the recording client, registers LoadExternalAttachmentCommand in the integration command map, and updates command accessor return types to use generic wildcards.
Test coverage
src/test/java/com/epam/reportportal/mobitru/client/MobitruRecordingClientTest.java, src/test/java/com/epam/reportportal/mobitru/command/LoadExternalAttachmentCommandTest.java
MobitruRecordingClientTest validates recording download with in-memory HTTP server for both Mobitru and BrowserHub endpoints, filename derivation, and auth header selection; LoadExternalAttachmentCommandTest verifies end-to-end attachment flow with stubbed client and repository dependencies.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • siarheirazuvalau

Poem

🐰 A rabbit hops through recordings so fine,
Downloads them swift with auth's rightful line,
From Mobitru's depths to the logs they attach,
Each frame now preserved, a perfect match!
The CodeRabbit

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 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 primary change: adding a LoadExternalAttachmentCommand for downloading Mobitru recordings. It is clear, specific, and directly relates to the main objective of this changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 EPMRPP-115026-mobirtu

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/java/com/epam/reportportal/mobitru/model/RecordingAttachmentData.java (1)

26-27: ⚡ Quick win

Defensively copy content to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c3d74b and b75eccc.

📒 Files selected for processing (14)
  • src/main/java/com/epam/reportportal/mobitru/MobitruExtension.java
  • src/main/java/com/epam/reportportal/mobitru/client/MobitruRecordingClient.java
  • src/main/java/com/epam/reportportal/mobitru/client/RestClientBuilder.java
  • src/main/java/com/epam/reportportal/mobitru/command/GetDevicesCommand.java
  • src/main/java/com/epam/reportportal/mobitru/command/LoadExternalAttachmentCommand.java
  • src/main/java/com/epam/reportportal/mobitru/command/TestConnectionCommand.java
  • src/main/java/com/epam/reportportal/mobitru/file/ByteArrayMultipartFile.java
  • src/main/java/com/epam/reportportal/mobitru/model/Constants.java
  • src/main/java/com/epam/reportportal/mobitru/model/IntegrationParametersNames.java
  • src/main/java/com/epam/reportportal/mobitru/model/IntegrationProperties.java
  • src/main/java/com/epam/reportportal/mobitru/model/RecordingAttachmentData.java
  • src/main/java/com/epam/reportportal/mobitru/utils/ValidationUtils.java
  • src/test/java/com/epam/reportportal/mobitru/client/MobitruRecordingClientTest.java
  • src/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

@pbortnik pbortnik merged commit c3fdc26 into develop Jun 8, 2026
3 checks passed
@pbortnik pbortnik deleted the EPMRPP-115026-mobirtu branch June 8, 2026 09:50
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.

1 participant