package com.microservices.pms.product.domain.vo;

import com.microservices.pms.enums.TestCaseStatus;
import com.microservices.pms.project.domain.PmsProjectTestsheetCases;
import com.microservices.system.api.domain.SimpleSysUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 产品需求对象 pms_product_requirement
 *
 * @author otto
 * @date 2023-10-10
 */
@Data
@ApiModel("需求规格关联测试用例数据对象")
public class ProductReqSpecsAssociatedTestcaseDataVo {
    private Long id;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "用例维护人")
    private SimpleSysUser assigneeUser;

    @ApiModelProperty(value = "执行次数")
    private Long executeCount;

    @ApiModelProperty(value = "未执行次数")
    private Long unExecuteCount;

    @ApiModelProperty(value = "通过次数")
    private Long executePassCount;

    @ApiModelProperty(value = "跳过次数")
    private Long executeSkipCount;

    @ApiModelProperty(value = "阻塞次数")
    private Long executeBlockCount;

    @ApiModelProperty(value = "失败次数")
    private Long executeFailCount;

    public void setCountData(List<PmsProjectTestsheetCases> testsheetCasesList) {
        this.setUnExecuteCount(testsheetCasesList.stream().filter(x -> TestCaseStatus.INIT.ordinal() == x.getTestStatus().intValue()).count());
        this.setExecutePassCount(testsheetCasesList.stream().filter(x -> TestCaseStatus.PASS.ordinal() == x.getTestStatus().intValue()).count());
        this.setExecuteFailCount(testsheetCasesList.stream().filter(x -> TestCaseStatus.FAIL.ordinal() == x.getTestStatus().intValue()).count());
        this.setExecuteBlockCount(testsheetCasesList.stream().filter(x -> TestCaseStatus.BLOCKING.ordinal() == x.getTestStatus().intValue()).count());
        this.setExecuteSkipCount(testsheetCasesList.stream().filter(x -> TestCaseStatus.SKIP.ordinal() == x.getTestStatus().intValue()).count());
        this.setExecuteCount((long) testsheetCasesList.size());
    }
}
