Skip to content

Remaining TMS tasks#2685

Open
imashkanov wants to merge 5 commits into
developfrom
feature/EMPRPP-migrate-tms-to-develop
Open

Remaining TMS tasks#2685
imashkanov wants to merge 5 commits into
developfrom
feature/EMPRPP-migrate-tms-to-develop

Conversation

@imashkanov

@imashkanov imashkanov commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Documentation

    • Updated API documentation wording for several batch/import/export/attribute/duplicate endpoints.
  • Improvements

    • More reliable test-case execution lifecycle: refined status transitions, retry handling for nested steps, and safer deletion ordering.
    • Support for persisting individual step-execution updates.
  • Tests

    • Expanded unit tests covering status transitions, retry flows, comment/patch scenarios, and deletion sequencing.
  • Chores

    • Adjusted migration script mapping used for upgrades.

Review Change Stack

@imashkanov imashkanov requested a review from pbortnik as a code owner May 20, 2026 18:33
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

OpenAPI @Operation tags removed and descriptions adjusted; migrations URL/mapping updated; TMS execution service reorders deletion, adds retry/reset builders and step update API, refactors patch status transitions, and expands unit tests to cover new flows.

Changes

OpenAPI Annotation Cleanup

Layer / File(s) Summary
Tag removal and description updates across batch and utility endpoints
src/main/java/com/epam/reportportal/base/core/tms/controller/TestCaseController.java, src/main/java/com/epam/reportportal/base/core/tms/controller/TmsTestPlanController.java
Removes explicit tags attributes from @Operation annotations and updates operation descriptions for six TestCaseController endpoints (delete, batch patch, CSV import, export, attribute patch, duplicate) and two TmsTestPlanController batch endpoints (add/remove). No signature or runtime logic changes.

Migration configuration

Layer / File(s) Summary
migrationsUrl suffix and mapping
project-properties.gradle
Changes non-release project.ext.migrationsUrl suffix to feature/EMPRPP-migrate-tms-to-develop and adds a testScriptsSrc mapping for 1003_increase_activity_name_length.up.sqlV216__increase_activity_name_length.up.sql.

TMS test-case execution behavior and tests

Layer / File(s) Summary
TestItemService API cleanup
src/main/java/com/epam/reportportal/base/core/item/TestItemService.java
Removes two transactional public methods (createToRunTestItemForTestCase, deleteTestItem) and trims imports to remaining logic.
Nested step retry builder
src/main/java/com/epam/reportportal/base/core/tms/mapper/NestedStepItemBuilder.java
Adds buildRetryNestedStepItem(...) and a small description-check predicate change used for retry step reconstruction.
Test-case retry builder
src/main/java/com/epam/reportportal/base/core/tms/mapper/TestCaseItemBuilder.java
Adds buildRetryTestCaseItem(...) to create retry TEST items by copying attributes/parameters/results and linking retry relations.
TmsStepExecutionService helper
src/main/java/com/epam/reportportal/base/core/tms/service/TmsStepExecutionService.java
Adds transactional updateTmsStepExecution(TmsStepExecution) to persist single step execution records.
Delete ordering and injected dependencies
src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java
Adds FinishTestItemHandler and builder dependencies and reorders deleteTestCaseExecutionFromLaunch to remove step executions, then TmsTestCaseExecution, then the TEST item and conditional SUITE cleanup.
Retry reset helper and patch status transitions
src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java
Adds resetStepExecutionsForRetry(...) to rebuild nested retry step items and refactors patch(...) into StatusEnum-driven transitions (active→active save, terminal→active retry reconstruction, active→terminal finish, terminal→terminal delegate).
Unit tests and wiring
src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java
Expands imports and mocks, initializes TestItemResults with StatusEnum.TO_RUN, wires additional collaborators, and adds tests covering active/terminal transitions, retry reconstruction, step reset, and failure/exception paths.

Sequence Diagram(s)

sequenceDiagram
  participant TmsService as TmsTestCaseExecutionServiceImpl
  participant StepExecRepo as TmsStepExecutionRepository
  participant StepService as TmsStepExecutionService
  participant ItemRepo as TestItemRepository
  participant FinishHandler as FinishTestItemHandler
  participant UpdateHandler as UpdateTestItemHandler

  TmsService->>StepExecRepo: fetch/delete step executions (delete flow)
  TmsService->>TmsService: delete TmsTestCaseExecution
  TmsService->>ItemRepo: delete TEST item (cascade)
  TmsService->>TmsService: evaluate requested StatusEnum
  alt requested IN_PROGRESS or TO_RUN and current active
    TmsService->>ItemRepo: set itemResults.status and save
  else requested IN_PROGRESS/TO_RUN and current terminal
    TmsService->>TmsService: mark hasRetries, buildRetryTestCaseItem
    TmsService->>StepService: resetStepExecutionsForRetry (rebuild nested STEP items)
    StepService->>StepExecRepo: update stepExecution records
    TmsService->>ItemRepo: save retry TestItem
  else active -> terminal
    TmsService->>FinishHandler: finishTestItem(FinishTestItemRQ)
  else terminal -> terminal
    TmsService->>UpdateHandler: updateTestItem(...)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • pbortnik

Poem

🐰 I hopped through controllers to tidy the tags,
I nudged migrations and mapped SQL flags,
I rebuilt retry steps with a soft little thump,
Reordered deletes and made tests jump,
A carrot, a patch, and a satisfied nap—huzzah!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "Remaining TMS tasks" is vague and does not convey meaningful information about the specific changes; it lacks clarity about what TMS tasks are being addressed. Replace with a more specific title that describes the main changes, such as "Add retry logic and refactor TMS test case execution status transitions" or "Implement TMS retry handling and update Swagger metadata."
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/EMPRPP-migrate-tms-to-develop

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
Contributor

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 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/base/core/tms/controller/TestCaseController.java`:
- Line 263: The long description string(s) in TestCaseController's
OpenAPI/Swagger annotation(s) exceed the 120-char limit; locate the
annotation(s) on TestCaseController that set description = "..." (the
multi-test-case update and the other two long descriptions) and split each long
literal into multiple shorter string literals concatenated with + (or into
multiple quoted segments joined by + across lines) so no source line exceeds 120
characters while preserving the exact text content and punctuation.
🪄 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: 91cadf00-d06d-4f90-8edc-bf4c38167ba4

📥 Commits

Reviewing files that changed from the base of the PR and between a7079c0 and 8835f56.

📒 Files selected for processing (2)
  • src/main/java/com/epam/reportportal/base/core/tms/controller/TestCaseController.java
  • src/main/java/com/epam/reportportal/base/core/tms/controller/TmsTestPlanController.java

@imashkanov imashkanov force-pushed the feature/EMPRPP-migrate-tms-to-develop branch 2 times, most recently from eaddbcf to 10e70f0 Compare May 23, 2026 20:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java (1)

130-153: 💤 Low value

Fix indentation to match project conventions.

The test method body is indented with 4 extra spaces (6 total instead of expected 4). Checkstyle flagged this as incorrect indentation level.

♻️ Fix indentation
-    `@Test`
-    void patch_WhenStatusIsInProgress_ShouldBypassUpdateTestItemHandler() {
-      // Given
-      Long executionId = 100L;
-      Long launchId = 10L;
-      TmsTestCaseExecutionRQ request = TmsTestCaseExecutionRQ.builder().status("IN_PROGRESS").build();
-      MembershipDetails membershipDetails = new MembershipDetails();
-      ReportPortalUser user = mock(ReportPortalUser.class);
-  
-      when(tmsTestCaseExecutionRepository.findByTestCaseExecutionIdAndLaunchId(executionId, launchId))
-          .thenReturn(Optional.of(execution1));
-      when(testItemRepository.save(any(TestItem.class))).thenReturn(testItem1);
-      when(tmsTestCaseExecutionRepository.save(execution1)).thenReturn(execution1);
-      when(tmsTestCaseExecutionMapper.convert(execution1)).thenReturn(new TmsTestCaseExecutionRS());
-  
-      // When
-      var result = sut.patch(membershipDetails, user, executionId, launchId, request);
-  
-      // Then
-      assertNotNull(result);
-      assertEquals(StatusEnum.IN_PROGRESS, testItem1.getItemResults().getStatus());
-      verify(testItemRepository).save(testItem1);
-      verifyNoInteractions(updateTestItemHandler);
-    }
+  `@Test`
+  void patch_WhenStatusIsInProgress_ShouldBypassUpdateTestItemHandler() {
+    // Given
+    Long executionId = 100L;
+    Long launchId = 10L;
+    TmsTestCaseExecutionRQ request = TmsTestCaseExecutionRQ.builder().status("IN_PROGRESS").build();
+    MembershipDetails membershipDetails = new MembershipDetails();
+    ReportPortalUser user = mock(ReportPortalUser.class);
+
+    when(tmsTestCaseExecutionRepository.findByTestCaseExecutionIdAndLaunchId(executionId, launchId))
+        .thenReturn(Optional.of(execution1));
+    when(testItemRepository.save(any(TestItem.class))).thenReturn(testItem1);
+    when(tmsTestCaseExecutionRepository.save(execution1)).thenReturn(execution1);
+    when(tmsTestCaseExecutionMapper.convert(execution1)).thenReturn(new TmsTestCaseExecutionRS());
+
+    // When
+    var result = sut.patch(membershipDetails, user, executionId, launchId, request);
+
+    // Then
+    assertNotNull(result);
+    assertEquals(StatusEnum.IN_PROGRESS, testItem1.getItemResults().getStatus());
+    verify(testItemRepository).save(testItem1);
+    verifyNoInteractions(updateTestItemHandler);
+  }
🤖 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/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`
around lines 130 - 153, The test method
patch_WhenStatusIsInProgress_ShouldBypassUpdateTestItemHandler in
TmsTestCaseExecutionServiceImplTest has its method body indented 6 spaces
instead of the project's 4-space standard; reformat the method body (all lines
inside the method) to use 4-space indentation so checkstyle passes, preserving
the existing code and assertions (including references to sut.patch, when(...)
stubbings, and verify/verifyNoInteractions calls).
🤖 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 `@project-properties.gradle`:
- Line 19: The migrationsUrl assignment currently hardcodes a feature branch for
non-release builds; update the logic that sets migrationsUrl (which uses
migrationsScriptsUrl and releaseMode) to use 'develop' by default for
non-release, or read an overridable project property (e.g.,
migrationsBranch/migrationsRef) when present; change the non-release branch
choice from 'feature/EMPRPP-migrate-tms-to-develop' to the property value if
supplied else 'develop' so non-release builds don't depend on a specific feature
branch.

In
`@src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`:
- Around line 155-177: The test
patch_WhenStatusIsFailed_ShouldCallUpdateTestItemHandler will NPE because
execution1 has no launchId and
tmsManualLaunchService.getTestPlanIdByLaunchId(...) is not stubbed; fix by
either setting a launchId on the execution1 test fixture used by this test or by
stubbing
tmsManualLaunchService.getTestPlanIdByLaunchId(execution1.getLaunchId()) to
return Optional.empty() or an Optional.of(testPlanId) as appropriate so
addTestCaseToTestPlan() does not call .ifPresentOrElse() on null; locate these
symbols in the test class (execution1, patch(...), addTestCaseToTestPlan,
tmsManualLaunchService.getTestPlanIdByLaunchId) and add the missing fixture
field or Mockito.when(...) stub.

---

Nitpick comments:
In
`@src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`:
- Around line 130-153: The test method
patch_WhenStatusIsInProgress_ShouldBypassUpdateTestItemHandler in
TmsTestCaseExecutionServiceImplTest has its method body indented 6 spaces
instead of the project's 4-space standard; reformat the method body (all lines
inside the method) to use 4-space indentation so checkstyle passes, preserving
the existing code and assertions (including references to sut.patch, when(...)
stubbings, and verify/verifyNoInteractions calls).
🪄 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: 65071ffa-fae3-476c-8294-fa3e6a125312

📥 Commits

Reviewing files that changed from the base of the PR and between 8835f56 and eaddbcf.

📒 Files selected for processing (5)
  • project-properties.gradle
  • src/main/java/com/epam/reportportal/base/core/tms/controller/TestCaseController.java
  • src/main/java/com/epam/reportportal/base/core/tms/controller/TmsTestPlanController.java
  • src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java
  • src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java

Comment thread project-properties.gradle
releaseMode = project.hasProperty("releaseMode") ? project.releaseMode.toBoolean() : false
scriptsUrl = commonScriptsUrl + (releaseMode ? '5.14.0' : 'develop')
migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.14.0' : 'develop')
migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.14.0' : 'feature/EMPRPP-migrate-tms-to-develop')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid hardcoding a feature branch in shared non-release migrations URL.

Using feature/EMPRPP-migrate-tms-to-develop for all non-release builds can break builds once that branch is renamed/deleted and can desync migrations from scriptsUrl (which still tracks develop for non-release). Prefer develop (or a configurable property override) as the default non-release source.

Suggested fix
-    migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.14.0' : 'feature/EMPRPP-migrate-tms-to-develop')
+    def migrationsBranch = project.findProperty("migrationsBranch") ?: "develop"
+    migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.14.0' : migrationsBranch)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.14.0' : 'feature/EMPRPP-migrate-tms-to-develop')
def migrationsBranch = project.findProperty("migrationsBranch") ?: "develop"
migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.14.0' : migrationsBranch)
🤖 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 `@project-properties.gradle` at line 19, The migrationsUrl assignment currently
hardcodes a feature branch for non-release builds; update the logic that sets
migrationsUrl (which uses migrationsScriptsUrl and releaseMode) to use 'develop'
by default for non-release, or read an overridable project property (e.g.,
migrationsBranch/migrationsRef) when present; change the non-release branch
choice from 'feature/EMPRPP-migrate-tms-to-develop' to the property value if
supplied else 'develop' so non-release builds don't depend on a specific feature
branch.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java (1)

543-564: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate request.getStatus() before branching.

Line 547 now calls StatusEnum.valueOf(...) on API input, so an unexpected status turns this patch path into an IllegalArgumentException/500 instead of a controlled domain error. Parse once with StatusEnum.fromValue(...) and reuse that enum for both the branch and addTestCaseToTestPlan().

🛠️ Suggested change
-              StatusEnum targetStatus = StatusEnum.valueOf(request.getStatus().toUpperCase());
+              StatusEnum targetStatus = StatusEnum.fromValue(request.getStatus())
+                  .orElseThrow(() -> new ReportPortalException(
+                      "Unsupported status: " + request.getStatus()
+                  ));
               if (targetStatus == StatusEnum.IN_PROGRESS || targetStatus == StatusEnum.TO_RUN) {
                 testItem.getItemResults().setStatus(targetStatus);
                 testItem = testItemRepository.save(testItem);
                 execution.setTestItem(testItem);
               } else {
                 execution.setTestItem(
                     updateTestItemHandler.updateTestItem(
                         membershipDetails,
                         testItem,
                         UpdateTestItemRQ.builder().status(request.getStatus()).build(),
                         user
                     )
                 );
               }
-              addTestCaseToTestPlan(execution, request.getStatus());
+              addTestCaseToTestPlan(execution, targetStatus);
-  private void addTestCaseToTestPlan(TmsTestCaseExecution execution, String status) {
+  private void addTestCaseToTestPlan(TmsTestCaseExecution execution, StatusEnum status) {
     if (status == null) {
       return;
     }
-    var statusEnum = StatusEnum.valueOf(status.toUpperCase());
-
-    // Check if the status is PASSED or FAILED
-    if (statusEnum == StatusEnum.PASSED || statusEnum == StatusEnum.FAILED) {
+    if (status == StatusEnum.PASSED || status == StatusEnum.FAILED) {
       tmsManualLaunchService
           .getTestPlanIdByLaunchId(execution.getLaunchId())
           .ifPresentOrElse(
               testPlanId -> {
                 var testCaseId = execution.getTestCaseId();
🤖 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/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java`
around lines 543 - 564, The code calls
StatusEnum.valueOf(request.getStatus().toUpperCase()) which can throw
IllegalArgumentException on bad input; instead parse and validate the status
once using a safe converter (e.g., StatusEnum.fromValue(...) or a
null/optional-returning factory) and store it in a local variable (e.g.,
targetStatus) before branching; use that validated targetStatus for the
IN_PROGRESS/TO_RUN checks, for updateTestItemHandler.updateTestItem(...) (pass
the original string or targetStatus as appropriate), and when calling
addTestCaseToTestPlan(execution, ...) to avoid reparsing and to ensure
controlled error handling for invalid statuses.
🧹 Nitpick comments (1)
src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java (1)

382-405: ⚡ Quick win

Add a regression test for the new delete sequence.

This change relies on deleting step executions, then the TmsTestCaseExecution, and only then the TEST item. Please pin that with an InOrder test so this ordering does not drift back in a later refactor.

🤖 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/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java`
around lines 382 - 405, Add a regression unit test for
TmsTestCaseExecutionServiceImpl that verifies the deletion order using
Mockito.inOrder: mock tmsStepExecutionService, tmsTestCaseExecutionRepository,
testItemRepository (and testFolderItemService when suiteItemId != null), call
the service method that performs the delete sequence, and assert inOrder.verify
calls occur in this exact order:
tmsStepExecutionService.deleteStepExecutionsByTestCaseExecution(executionId) ->
tmsTestCaseExecutionRepository.deleteById(executionId) ->
testItemRepository.deleteById(testItemId) (and when suiteItemId != null
additionally verify
testFolderItemService.deleteTestFolderTestItemByTestItemId(suiteItemId) before
testItemRepository.deleteById(suiteItemId)); include at least two scenarios
(with and without suiteItemId) to lock the behavior.
🤖 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.

Outside diff comments:
In
`@src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java`:
- Around line 543-564: The code calls
StatusEnum.valueOf(request.getStatus().toUpperCase()) which can throw
IllegalArgumentException on bad input; instead parse and validate the status
once using a safe converter (e.g., StatusEnum.fromValue(...) or a
null/optional-returning factory) and store it in a local variable (e.g.,
targetStatus) before branching; use that validated targetStatus for the
IN_PROGRESS/TO_RUN checks, for updateTestItemHandler.updateTestItem(...) (pass
the original string or targetStatus as appropriate), and when calling
addTestCaseToTestPlan(execution, ...) to avoid reparsing and to ensure
controlled error handling for invalid statuses.

---

Nitpick comments:
In
`@src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java`:
- Around line 382-405: Add a regression unit test for
TmsTestCaseExecutionServiceImpl that verifies the deletion order using
Mockito.inOrder: mock tmsStepExecutionService, tmsTestCaseExecutionRepository,
testItemRepository (and testFolderItemService when suiteItemId != null), call
the service method that performs the delete sequence, and assert inOrder.verify
calls occur in this exact order:
tmsStepExecutionService.deleteStepExecutionsByTestCaseExecution(executionId) ->
tmsTestCaseExecutionRepository.deleteById(executionId) ->
testItemRepository.deleteById(testItemId) (and when suiteItemId != null
additionally verify
testFolderItemService.deleteTestFolderTestItemByTestItemId(suiteItemId) before
testItemRepository.deleteById(suiteItemId)); include at least two scenarios
(with and without suiteItemId) to lock the behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 898b3017-3896-4637-a3d6-98b944f4dc34

📥 Commits

Reviewing files that changed from the base of the PR and between eaddbcf and 10e70f0.

📒 Files selected for processing (3)
  • project-properties.gradle
  • src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java
  • src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java

@imashkanov imashkanov force-pushed the feature/EMPRPP-migrate-tms-to-develop branch from 10e70f0 to 9fdc72c Compare May 24, 2026 21:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java`:
- Around line 574-575: Replace usages of StatusEnum.valueOf(...) with
StatusEnum.fromValue(...) in TmsTestCaseExecutionServiceImpl to guard against
invalid status strings; specifically update the targetStatus assignments where
code currently does var targetStatus =
StatusEnum.valueOf(request.getStatus().toUpperCase()); (and the analogous
occurrence later in the same class) so they call StatusEnum.fromValue(...) and
preserve the existing error handling that maps invalid values to
ErrorType.INCORRECT_REQUEST. Locate these changes in the
TmsTestCaseExecutionServiceImpl class around the targetStatus/currentStatus
logic and ensure no other call sites in this class still use valueOf for
request-derived status strings.

In
`@src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`:
- Around line 376-389: The test uses eq(testItem1) and stubs
updateTestItemHandler.updateTestItem to return a TestItem, but the handler
actually expects a test item ID (Long) and returns an operation/result object;
update the stub and verification to use the test item ID (e.g.,
eq(testItem1.getItemId() or testItemId variable) instead of eq(testItem1) and
make the when(...).thenReturn(...) return the correct operation/result type
expected by updateTestItemHandler.updateTestItem; adjust the verify(...) call
similarly and keep sut.patch invocation unchanged.
🪄 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: c52bd2fd-d629-4fe4-b375-6c8b9b570e76

📥 Commits

Reviewing files that changed from the base of the PR and between 10e70f0 and 9fdc72c.

📒 Files selected for processing (7)
  • project-properties.gradle
  • src/main/java/com/epam/reportportal/base/core/item/TestItemService.java
  • src/main/java/com/epam/reportportal/base/core/tms/mapper/NestedStepItemBuilder.java
  • src/main/java/com/epam/reportportal/base/core/tms/mapper/TestCaseItemBuilder.java
  • src/main/java/com/epam/reportportal/base/core/tms/service/TmsStepExecutionService.java
  • src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java
  • src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java
💤 Files with no reviewable changes (1)
  • src/main/java/com/epam/reportportal/base/core/item/TestItemService.java

@imashkanov imashkanov force-pushed the feature/EMPRPP-migrate-tms-to-develop branch from 9fdc72c to 609a2b0 Compare May 24, 2026 21:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java (1)

224-226: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Past issue: updateTestItemHandler contract mismatch still present.

The test stubs and verifies updateTestItemHandler.updateTestItem(...) with eq(testItem1) as the second argument, but the handler contract expects the test item ID (Long) rather than the TestItem object itself. This was previously flagged and remains unresolved.

🐛 Recommended fix from past review
     when(updateTestItemHandler.updateTestItem(
-        eq(membershipDetails), eq(testItem1), any(UpdateTestItemRQ.class), eq(user)))
-        .thenReturn(testItem1);
+        eq(membershipDetails), eq(testItem1.getItemId()), any(UpdateTestItemRQ.class), eq(user)))
+        .thenReturn(null);  // or appropriate operation result type

     // ...
     
     verify(updateTestItemHandler).updateTestItem(
-        eq(membershipDetails), eq(testItem1), any(UpdateTestItemRQ.class), eq(user));
+        eq(membershipDetails), eq(testItem1.getItemId()), any(UpdateTestItemRQ.class), eq(user));

Also applies to: 236-237

🤖 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/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`
around lines 224 - 226, The test stubs and verifies
updateTestItemHandler.updateTestItem(...) using eq(testItem1) but the handler
API expects the test item ID (Long); change the second argument in both the
when(...) and corresponding verify(...) calls to use the test item's id (e.g.,
eq(testItem1.getItemId()) or the Long id variable) so the call signature matches
updateTestItemHandler.updateTestItem(membershipDetails, Long, UpdateTestItemRQ,
user). Ensure you update both occurrences mentioned (around the when at the
shown diff and the verify at lines ~236-237) and keep the other matchers
(eq(membershipDetails), any(UpdateTestItemRQ.class), eq(user)) unchanged.
🧹 Nitpick comments (2)
src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java (2)

12-14: 💤 Low value

Checkstyle: Reorder ArgumentMatchers imports.

The ArgumentMatchers imports should appear before Mockito.* imports per lexicographical order.

📦 Suggested import order
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoInteractions;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
🤖 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/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`
around lines 12 - 14, Reorder the static imports so ArgumentMatchers come before
Mockito imports: move the static imports for any, anyString, eq
(ArgumentMatchers) to appear before any static imports from Mockito (e.g.,
Mockito.*) in TmsTestCaseExecutionServiceImplTest; ensure the import block
follows lexicographic order by adjusting the import sequence accordingly.

154-154: 💤 Low value

Checkstyle: Test method names violate camelCase pattern.

Several test methods use snake_case naming (with underscores), which violates the checkstyle pattern ^[a-z][a-z0-9][a-zA-Z0-9]*$. While this style is descriptive and commonly used in tests, the project's checkstyle enforces strict Java camelCase conventions.

Also applies to: 181-181, 212-212, 245-245, 433-433, 630-630

🤖 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/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`
at line 154, The test method name
patch_WhenActiveStatusChangesToAnotherActive_ShouldSaveDirectlyAndBypassHandlers
violates the project's camelCase Checkstyle rule; rename this method (and the
other flagged test methods referenced in the comment) to conform to the pattern
(e.g.,
patchWhenActiveStatusChangesToAnotherActiveShouldSaveDirectlyAndBypassHandlers)
and update any local references or usages if present (test frameworks usually
only rely on the `@Test` annotation so no other changes are typically needed); run
the test suite and Checkstyle to confirm the renames resolve the violations.
🤖 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/base/core/tms/mapper/NestedStepItemBuilder.java`:
- Around line 85-98: The retry nested step created by buildRetryNestedStepItem
is missing propagation of the testCaseHash causing inconsistent metadata; update
buildRetryNestedStepItem to set the new TestItem's testCaseHash (e.g., call
newStep.setTestCaseHash(...)) using the existing testCaseHash from the parent
retry item (parentRetryItem.getTestCaseHash()) so retry nested steps carry the
same testCaseHash as their parent.

---

Duplicate comments:
In
`@src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`:
- Around line 224-226: The test stubs and verifies
updateTestItemHandler.updateTestItem(...) using eq(testItem1) but the handler
API expects the test item ID (Long); change the second argument in both the
when(...) and corresponding verify(...) calls to use the test item's id (e.g.,
eq(testItem1.getItemId()) or the Long id variable) so the call signature matches
updateTestItemHandler.updateTestItem(membershipDetails, Long, UpdateTestItemRQ,
user). Ensure you update both occurrences mentioned (around the when at the
shown diff and the verify at lines ~236-237) and keep the other matchers
(eq(membershipDetails), any(UpdateTestItemRQ.class), eq(user)) unchanged.

---

Nitpick comments:
In
`@src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java`:
- Around line 12-14: Reorder the static imports so ArgumentMatchers come before
Mockito imports: move the static imports for any, anyString, eq
(ArgumentMatchers) to appear before any static imports from Mockito (e.g.,
Mockito.*) in TmsTestCaseExecutionServiceImplTest; ensure the import block
follows lexicographic order by adjusting the import sequence accordingly.
- Line 154: The test method name
patch_WhenActiveStatusChangesToAnotherActive_ShouldSaveDirectlyAndBypassHandlers
violates the project's camelCase Checkstyle rule; rename this method (and the
other flagged test methods referenced in the comment) to conform to the pattern
(e.g.,
patchWhenActiveStatusChangesToAnotherActiveShouldSaveDirectlyAndBypassHandlers)
and update any local references or usages if present (test frameworks usually
only rely on the `@Test` annotation so no other changes are typically needed); run
the test suite and Checkstyle to confirm the renames resolve the violations.
🪄 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: 1fe9cb3d-68a9-4ec2-aad6-a6753bf10158

📥 Commits

Reviewing files that changed from the base of the PR and between 9fdc72c and 609a2b0.

📒 Files selected for processing (7)
  • project-properties.gradle
  • src/main/java/com/epam/reportportal/base/core/item/TestItemService.java
  • src/main/java/com/epam/reportportal/base/core/tms/mapper/NestedStepItemBuilder.java
  • src/main/java/com/epam/reportportal/base/core/tms/mapper/TestCaseItemBuilder.java
  • src/main/java/com/epam/reportportal/base/core/tms/service/TmsStepExecutionService.java
  • src/main/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImpl.java
  • src/test/java/com/epam/reportportal/base/core/tms/service/TmsTestCaseExecutionServiceImplTest.java
💤 Files with no reviewable changes (1)
  • src/main/java/com/epam/reportportal/base/core/item/TestItemService.java
✅ Files skipped from review due to trivial changes (1)
  • project-properties.gradle

@imashkanov imashkanov force-pushed the feature/EMPRPP-migrate-tms-to-develop branch from 609a2b0 to ae376f1 Compare May 24, 2026 22:09
@imashkanov imashkanov force-pushed the feature/EMPRPP-migrate-tms-to-develop branch 3 times, most recently from 90e6907 to 5ca7050 Compare June 13, 2026 12:38
@imashkanov imashkanov force-pushed the feature/EMPRPP-migrate-tms-to-develop branch from 5ca7050 to f79e908 Compare June 13, 2026 12:38
@imashkanov imashkanov force-pushed the feature/EMPRPP-migrate-tms-to-develop branch from f79e908 to df91a6f Compare June 13, 2026 12:49
@sonarqubecloud

Copy link
Copy Markdown

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