Skip to content

Commit

Permalink
Revert "Fix build"
Browse files Browse the repository at this point in the history
This reverts commit bec383d.
  • Loading branch information
HardNorth committed Oct 30, 2024
1 parent 3089b23 commit a62dd80
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/epam/reportportal/service/Launch.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
import com.epam.reportportal.listeners.ListenerParameters;
import com.epam.reportportal.service.step.DefaultStepReporter;
import com.epam.reportportal.service.step.StepReporter;
import com.epam.reportportal.utils.StaticStructuresUtils;
import com.epam.ta.reportportal.ws.reporting.*;
import com.epam.ta.reportportal.ws.reporting.FinishExecutionRQ;
import com.epam.ta.reportportal.ws.reporting.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.reporting.Issue;
import com.epam.ta.reportportal.ws.reporting.Issue.ExternalSystemIssue;
import com.epam.ta.reportportal.ws.reporting.OperationCompletionRS;
import com.epam.ta.reportportal.ws.reporting.StartTestItemRQ;
import io.reactivex.Maybe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
46 changes: 29 additions & 17 deletions src/main/java/com/epam/reportportal/service/LaunchImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ public class LaunchImpl extends Launch {
private static final int ITEM_FINISH_RETRY_TIMEOUT = 10;

private static final Predicate<Throwable> INTERNAL_CLIENT_EXCEPTION_PREDICATE = throwable -> throwable instanceof InternalReportPortalClientException;
private static final Predicate<Throwable> TEST_ITEM_FINISH_RETRY_PREDICATE = throwable -> (throwable instanceof ReportPortalException
&& ErrorType.FINISH_ITEM_NOT_ALLOWED.equals(((ReportPortalException) throwable).getError().getErrorType()))
|| INTERNAL_CLIENT_EXCEPTION_PREDICATE.test(throwable);
private static final Predicate<Throwable> TEST_ITEM_FINISH_RETRY_PREDICATE = throwable ->
(throwable instanceof ReportPortalException
&& ErrorType.FINISH_ITEM_NOT_ALLOWED.equals(((ReportPortalException) throwable).getError()
.getErrorType())) || INTERNAL_CLIENT_EXCEPTION_PREDICATE.test(throwable);

private static final RetryWithDelay DEFAULT_REQUEST_RETRY = new RetryWithDelay(INTERNAL_CLIENT_EXCEPTION_PREDICATE,
DEFAULT_RETRY_COUNT,
TimeUnit.SECONDS.toMillis(DEFAULT_RETRY_TIMEOUT)
);
private static final RetryWithDelay TEST_ITEM_FINISH_REQUEST_RETRY = new RetryWithDelay(TEST_ITEM_FINISH_RETRY_PREDICATE,
private static final RetryWithDelay TEST_ITEM_FINISH_REQUEST_RETRY = new RetryWithDelay(
TEST_ITEM_FINISH_RETRY_PREDICATE,
ITEM_FINISH_MAX_RETRIES,
TimeUnit.SECONDS.toMillis(ITEM_FINISH_RETRY_TIMEOUT)
);
Expand All @@ -100,8 +102,9 @@ public class LaunchImpl extends Launch {
private StatisticsService statisticsService;
private final StartLaunchRQ startRq;

protected LaunchImpl(@Nonnull final ReportPortalClient reportPortalClient, @Nonnull final ListenerParameters parameters,
@Nonnull final StartLaunchRQ rq, @Nonnull final ExecutorService executorService) {
protected LaunchImpl(@Nonnull final ReportPortalClient reportPortalClient,
@Nonnull final ListenerParameters parameters, @Nonnull final StartLaunchRQ rq,
@Nonnull final ExecutorService executorService) {
super(reportPortalClient, parameters);
requireNonNull(parameters, "Parameters shouldn't be NULL");
executor = requireNonNull(executorService);
Expand All @@ -128,8 +131,9 @@ protected LaunchImpl(@Nonnull final ReportPortalClient reportPortalClient, @Nonn
}).cache();
}

protected LaunchImpl(@Nonnull final ReportPortalClient reportPortalClient, @Nonnull final ListenerParameters parameters,
@Nonnull final Maybe<String> launchMaybe, @Nonnull final ExecutorService executorService) {
protected LaunchImpl(@Nonnull final ReportPortalClient reportPortalClient,
@Nonnull final ListenerParameters parameters, @Nonnull final Maybe<String> launchMaybe,
@Nonnull final ExecutorService executorService) {
super(reportPortalClient, parameters);
requireNonNull(parameters, "Parameters shouldn't be NULL");
executor = requireNonNull(executorService);
Expand All @@ -143,7 +147,10 @@ protected LaunchImpl(@Nonnull final ReportPortalClient reportPortalClient, @Nonn

private static StartLaunchRQ emptyStartLaunchForStatistics() {
StartLaunchRQ result = new StartLaunchRQ();
result.setAttributes(Collections.singleton(new ItemAttributesRQ(DefaultProperties.AGENT.getName(), CUSTOM_AGENT, true)));
result.setAttributes(Collections.singleton(new ItemAttributesRQ(DefaultProperties.AGENT.getName(),
CUSTOM_AGENT,
true
)));
return result;
}

Expand Down Expand Up @@ -203,7 +210,8 @@ private Set<ItemAttributesRQ> truncateAttributes(@Nullable final Set<ItemAttribu
ItemAttributesRQ updated = attribute;
int keyLength = ofNullable(updated.getKey()).map(String::length).orElse(0);
if (keyLength > limit && keyLength > replacement.length()) {
updated = new ItemAttributesRQ(updated.getKey().substring(0, limit - replacement.length()) + replacement,
updated = new ItemAttributesRQ(
updated.getKey().substring(0, limit - replacement.length()) + replacement,
updated.getValue(),
updated.isSystem()
);
Expand Down Expand Up @@ -237,11 +245,11 @@ private void truncateAttributes(@Nonnull final FinishExecutionRQ rq) {
protected Maybe<String> start(boolean statistics) {
launch.subscribe(logMaybeResults("Launch start"));
ListenerParameters params = getParameters();
if (params.isPrintLaunchUuid()) {
if(params.isPrintLaunchUuid()) {
launch.subscribe(printLaunch(params));
}
LaunchLoggingContext.init(this.launch, getClient(), getScheduler(), getParameters());
if (statistics) {
if(statistics) {
getStatisticsService().sendEvent(launch, startRq);
}
return launch;
Expand Down Expand Up @@ -310,7 +318,10 @@ public Maybe<String> startTestItem(final StartTestItemRQ request) {

Maybe<String> item = launch.flatMap((Function<String, Maybe<String>>) launchId -> {
rq.setLaunchUuid(launchId);
return getClient().startTestItem(rq).retry(DEFAULT_REQUEST_RETRY).doOnSuccess(logCreated("item")).map(TO_ID);
return getClient().startTestItem(rq)
.retry(DEFAULT_REQUEST_RETRY)
.doOnSuccess(logCreated("item"))
.map(TO_ID);
}).cache();

item.subscribeOn(getScheduler()).subscribe(logMaybeResults("Start test item"));
Expand All @@ -330,7 +341,8 @@ public Maybe<String> startTestItem(final StartTestItemRQ request) {
* @return Test Item ID promise
*/
@Nonnull
public Maybe<String> startTestItem(final Maybe<String> parentId, final Maybe<String> retryOf, final StartTestItemRQ rq) {
public Maybe<String> startTestItem(final Maybe<String> parentId, final Maybe<String> retryOf,
final StartTestItemRQ rq) {
return retryOf.flatMap((Function<String, Maybe<String>>) s -> startTestItem(parentId, rq)).cache();
}

Expand Down Expand Up @@ -374,15 +386,15 @@ public Maybe<String> startTestItem(final Maybe<String> parentId, final StartTest
}

protected void completeBtsIssues(@Nullable Issue issue) {
if (!ofNullable(issue).map(Issue::getExternalSystemIssues).filter(issues -> !issues.isEmpty()).isPresent()) {
if(!ofNullable(issue).map(Issue::getExternalSystemIssues).filter(issues -> !issues.isEmpty()).isPresent()) {
return;
}
ListenerParameters params = getParameters();
Optional<String> btsUrl = ofNullable(params.getBtsUrl()).filter(StringUtils::isNotBlank);
Optional<String> btsProjectId = ofNullable(params.getBtsProjectId()).filter(StringUtils::isNotBlank);
Optional<String> btsIssueUrl = ofNullable(params.getBtsIssueUrl()).filter(StringUtils::isNotBlank);
issue.getExternalSystemIssues().stream().filter(Objects::nonNull).forEach(externalIssue -> {
if (StringUtils.isBlank(externalIssue.getTicketId())) {
if(StringUtils.isBlank(externalIssue.getTicketId())) {
return;
}
if (btsUrl.isPresent() && StringUtils.isBlank(externalIssue.getBtsUrl())) {
Expand Down Expand Up @@ -507,7 +519,7 @@ public Maybe<String> getParent() {
}
}

protected static class ComputationConcurrentHashMap extends ConcurrentHashMap<Maybe<String>, LaunchImpl.TreeItem> {
protected static class ComputationConcurrentHashMap extends ConcurrentHashMap<Maybe<String>, LaunchImpl.TreeItem> {
public LaunchImpl.TreeItem getOrCompute(Maybe<String> key) {
return computeIfAbsent(key, k -> new LaunchImpl.TreeItem());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.epam.reportportal.utils;

import com.epam.ta.reportportal.ws.reporting.Issue;
import com.epam.ta.reportportal.ws.model.issue.Issue;

import java.util.Set;

Expand Down
7 changes: 6 additions & 1 deletion src/test/java/com/epam/reportportal/service/LaunchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
import com.epam.reportportal.utils.ObjectUtils;
import com.epam.reportportal.utils.StaticStructuresUtils;
import com.epam.reportportal.utils.properties.DefaultProperties;
import com.epam.ta.reportportal.ws.reporting.*;
import com.epam.ta.reportportal.ws.reporting.FinishExecutionRQ;
import com.epam.ta.reportportal.ws.reporting.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.reporting.ItemAttributesRQ;
import com.epam.ta.reportportal.ws.reporting.OperationCompletionRS;
import com.epam.ta.reportportal.ws.reporting.StartLaunchRQ;
import com.epam.ta.reportportal.ws.reporting.StartTestItemRQ;
import io.reactivex.Maybe;
import org.apache.commons.lang3.RandomStringUtils;
import org.aspectj.lang.reflect.MethodSignature;
Expand Down

0 comments on commit a62dd80

Please sign in to comment.