All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arextest.schedule.plan.builder.impl.OperationSourceReplayPlanBuilder Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
package com.arextest.schedule.plan.builder.impl;

import com.arextest.schedule.model.AppServiceOperationDescriptor;
import com.arextest.schedule.model.ReplayActionItem;
import com.arextest.schedule.model.plan.BuildReplayPlanRequest;
import com.arextest.schedule.model.plan.BuildReplayPlanType;
import com.arextest.schedule.model.plan.OperationCaseInfo;
import com.arextest.schedule.plan.PlanContext;
import com.arextest.schedule.plan.builder.BuildPlanValidateResult;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;

/**
 * @author jmo
 * @since 2021/9/18
 */
@Component
final class OperationSourceReplayPlanBuilder extends AbstractReplayPlanBuilder {
  @Override
  public boolean isSupported(BuildReplayPlanRequest request) {
    return request.getReplayPlanType() == BuildReplayPlanType.BY_OPERATION_OF_APP_ID.getValue();
  }

  @Override
  public BuildPlanValidateResult validate(BuildReplayPlanRequest request, PlanContext planContext) {
    if (CollectionUtils.isEmpty(request.getOperationCaseInfoList())) {
      return BuildPlanValidateResult.create(BuildPlanValidateResult.REQUESTED_EMPTY_OPERATION,
          "REQUESTED_EMPTY_OPERATION");
    }
    super.filterAppServiceDescriptors(request, planContext);
    return super.validate(request, planContext);
  }

  @Override
  List getReplayActionList(BuildReplayPlanRequest request,
      PlanContext planContext) {
    List replayActionItemList = new ArrayList<>();
    AppServiceOperationDescriptor operationDescriptor;
    for (OperationCaseInfo operationCaseInfo : request.getOperationCaseInfoList()) {
      operationDescriptor = planContext.findAppServiceOperationDescriptor(
          operationCaseInfo.getOperationId());
      if (operationDescriptor == null) {
        continue;
      }
      ReplayActionItem replayActionItem = planContext.toReplayAction(operationDescriptor);
      replayActionItemList.add(replayActionItem);
    }
    return replayActionItemList;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy