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

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

The 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.ComparisonTransformConfigurableHandler;
import com.arextest.web.model.contract.contracts.config.replay.ComparisonTransformConfiguration;
import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
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/transform")
public class ComparisonTransformController extends
    AbstractConfigurableController {

  @Autowired
  private ComparisonTransformConfigurableHandler transformHandler;

  public ComparisonTransformController(
      ConfigurableHandler configurableHandler) {
    super(configurableHandler);
  }

  @Deprecated
  @GetMapping("/useResultAsList")
  @ResponseBody
  public 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 =
        transformHandler.useResultAsList(appId, operationId);
    transformHandler.removeDetailsExpired(configs, filterExpired);
    return ResponseUtils.successResponse(configs);
  }

  /**
   * query config which is compareConfig =1
   *
   * @param interfaceId
   * @return
   */
  @GetMapping("/queryByInterfaceId")
  @ResponseBody
  public Response queryByInterfaceId(@RequestParam String interfaceId,
      @RequestParam(defaultValue = "false") Boolean filterExpired) {
    if (StringUtils.isEmpty(interfaceId)) {
      return InvalidResponse.REQUESTED_INTERFACE_ID_IS_EMPTY;
    }
    List configs =
        transformHandler.queryByInterfaceId(interfaceId);
    transformHandler.removeDetailsExpired(configs, filterExpired);
    return ResponseUtils.successResponse(configs);
  }

  @PostMapping("/queryComparisonConfig")
  @ResponseBody
  public Response queryComparisonConfig(@RequestBody QueryComparisonRequestType request) {
    List configs = transformHandler.
        queryComparisonConfig(request.getAppId(), request.getOperationId(),
            request.getOperationType(), request.getOperationName());
    transformHandler.removeDetailsExpired(configs, request.getFilterExpired());
    return ResponseUtils.successResponse(configs);
  }

  @GetMapping("/getTransformMethod")
  @ResponseBody
  public Response getTransformMethod(@RequestParam String appId) {
    if (StringUtils.isEmpty(appId)) {
      return InvalidResponse.REQUESTED_APP_ID_IS_EMPTY;
    }
    return ResponseUtils.successResponse(transformHandler.getTransformMethodList());
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy