Skip to content

Commit

Permalink
EPMRPP-93177 || Retry is reported as a separate step (#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
APiankouski committed Aug 22, 2024
1 parent c14ee95 commit 018911d
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.BooleanUtils.isTrue;

import com.epam.reportportal.rules.exception.ErrorType;
import com.epam.ta.reportportal.commons.Preconditions;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.core.item.StartTestItemHandler;
Expand Down Expand Up @@ -162,15 +163,7 @@ public ItemCreatedRS startChildItem(ReportPortalUser user,
.addLaunchId(launch.getId()).get();

if (isRetry) {
ofNullable(rq.getRetryOf()).flatMap(testItemRepository::findIdByUuidForUpdate)
.ifPresentOrElse(retryParentId -> {
saveChildItem(launch, item, parentItem);
retryHandler.handleRetries(launch, item, retryParentId);
}, () -> retrySearcher.findPreviousRetry(launch, item, parentItem)
.ifPresentOrElse(previousRetryId -> {
saveChildItem(launch, item, parentItem);
retryHandler.handleRetries(launch, item, previousRetryId);
}, () -> saveChildItem(launch, item, parentItem)));
processRetry(rq, launch, item, parentItem);
} else {
saveChildItem(launch, item, parentItem);
}
Expand All @@ -184,6 +177,16 @@ public ItemCreatedRS startChildItem(ReportPortalUser user,
return new ItemCreatedRS(item.getUuid(), item.getUniqueId());
}

private void processRetry(StartTestItemRQ rq, Launch launch, TestItem item, TestItem parentItem) {
Long retryParentId = Optional.ofNullable(rq.getRetryOf())
.flatMap(testItemRepository::findIdByUuidForUpdate)
.orElseGet(() -> retrySearcher.findPreviousRetry(launch, item, parentItem)
.orElseThrow(() -> new ReportPortalException(TEST_ITEM_NOT_FOUND, item.getUniqueId())));

saveChildItem(launch, item, parentItem);
retryHandler.handleRetries(launch, item, retryParentId);
}

private TestItem saveChildItem(Launch launch, TestItem childItem, TestItem parentItem) {
childItem.setParentId(parentItem.getItemId());
testItemRepository.save(childItem);
Expand Down

0 comments on commit 018911d

Please sign in to comment.