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

com.arextest.web.api.service.controller.config.ComparisonExclusionsController Maven / Gradle / Ivy

There is a newer version: 0.7.0.1
Show newest version
package com.arextest.web.api.service.controller.config;

import com.arextest.common.model.response.Response;
import com.arextest.common.utils.ResponseUtils;
import com.arextest.web.core.business.config.ConfigurableHandler;
import com.arextest.web.core.business.config.replay.ComparisonExclusionsConfigurableHandler;
import com.arextest.web.model.contract.contracts.config.replay.ComparisonExclusionsConfiguration;
import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType;
import java.util.List;
import javax.annotation.Resource;
import lombok.Getter;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/api/config/comparison/exclusions")
public class ComparisonExclusionsController extends
    AbstractConfigurableController {

  @Getter
  @Resource
  ComparisonExclusionsConfigurableHandler comparisonExclusionsConfigurableHandler;

  public ComparisonExclusionsController(
      @Autowired ConfigurableHandler configurableHandler) {
    super(configurableHandler);
  }

  @Deprecated
  @RequestMapping("/useResultAsList")
  @ResponseBody
  public final Response useResultList(@RequestParam String appId,
      @RequestParam(required = false) String operationId,
      @RequestParam(defaultValue = "false") Boolean filterExpired) {
    if (StringUtils.isEmpty(appId)) {
      return InvalidResponse.REQUESTED_APP_ID_IS_EMPTY;
    }
    List configs =
        getComparisonExclusionsConfigurableHandler().useResultAsList(appId, operationId);
    if (filterExpired && CollectionUtils.isNotEmpty(configs)) {
      configs.removeIf(
          config -> getComparisonExclusionsConfigurableHandler().removeDetailsExpired(config));
    }
    return ResponseUtils.successResponse(configs);
  }

  /**
   * query config which is compareConfig =1
   *
   * @param interfaceId
   * @return
   */
  @RequestMapping("/queryByInterfaceId")
  @ResponseBody
  public final Response queryByInterfaceId(@RequestParam String interfaceId,
      @RequestParam(defaultValue = "false") Boolean filterExpired) {
    if (StringUtils.isEmpty(interfaceId)) {
      return InvalidResponse.REQUESTED_INTERFACE_ID_IS_EMPTY;
    }
    List configs =
        getComparisonExclusionsConfigurableHandler().queryByInterfaceId(interfaceId);
    if (filterExpired && CollectionUtils.isNotEmpty(configs)) {
      configs.removeIf(
          config -> getComparisonExclusionsConfigurableHandler().removeDetailsExpired(config));
    }
    return ResponseUtils.successResponse(configs);
  }

  @PostMapping("/queryComparisonConfig")
  @ResponseBody
  public Response queryComparisonConfig(@RequestBody QueryComparisonRequestType request) {
    List configs = getComparisonExclusionsConfigurableHandler().queryComparisonConfig(
        request.getAppId(), request.getOperationId(), request.getOperationType(),
        request.getOperationName());
    if (Boolean.TRUE.equals(request.getFilterExpired()) && CollectionUtils.isNotEmpty(configs)) {
      configs.removeIf(
          config -> getComparisonExclusionsConfigurableHandler().removeDetailsExpired(config));
    }
    return ResponseUtils.successResponse(configs);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy