Skip to content

flow-engine#288 衍生:身份能力单元测试缺口补齐 #295

Done

Description

@xlorne

背景

PR #289 实测 453 个用例全绿(framework 430 / infra 6 / api 2 / starter 8 / example 7),数量真实。但改了逻辑却没有用例的位置有 8 类,其中若干是最容易回归的复合键与权限判定。

缺口清单(按风险排序)

  1. $bind.getOperatorByIdentity(userId, identity):提交 78591083 新增的脚本能力,零测试;
  2. FlowRevokeService / FlowUrgeService / FlowSubProcessResetService 的身份归属校验(三处逻辑都改了,无用例);
  3. AddAuditAction 同人异身份查重、ReduceAuditAction 减签的身份维度(复合键改动,最易回归);
  4. 转交 forwardOperatorIdentity / 委托 / 干预 interferedOperatorIdentity 落库(现有 P1 用例只断言了默认空串);
  5. FlowContent.loadCurrentNodeOperators 多身份(当前实现有缺陷,见衍生 issue,补用例正好暴露);
  6. Mock 查询链路身份隔离(见衍生 issue);
  7. BaseAuditNode 同人自动通过的身份过滤;
  8. FlowOperatorGateway.findByIds 批量取人的身份维度(见衍生 issue)。

期望

  • 每条缺口至少 1 个用例,遵循项目测试规范(目标 / 前置 / 步骤 / 断言明确,结果确定);
  • 优先覆盖「复合键 + 权限判定」类,即第 2、3、5、7 项;
  • 用例命名与现有风格一致(should_xxx_when_yyy)。

验收标准

  • 8 类缺口均有对应用例(或明确在 issue 中标注降级原因);
  • ./mvnw test 全绿,用例总数在 PR 中更新;
  • 不引入对时间、随机、外部网络的依赖。

关联

Activity

  1. added
    enhancement
    on Nov 23, 2026
  2. added a commit that references this issue on Nov 23, 2026
  3. xlorne commented on Nov 23, 2026

    @xlorne
    ContributorAuthor

    单元测试缺口补齐(本轮 +25 个用例,总计 478)

    新增用例明细

    测试类 数量 覆盖点
    FlowCurrentNodeOperatorsIdentityTest 4 真实多身份流程:分配二元组、存量 id 视图、每身份一条记录、详情页候选列表
    OperatorIdentityValidationTest 6 长度上限、非法字符、normalize 对存量数据保持宽松
    OperatorIdentityGuardTest 5 告警触发、按 (人,身份) 去重、默认身份不告警、网关已覆盖不告警
    GroovyScriptBindIdentityTest 3 $bind.getOperatorByIdentity(P3 零测试)、默认身份兼容、两身份隔离
    FlowOperatorBulkIdentityTest 3 批量身份缓存隔离、默认身份等价、存量网关退化
    FlowRecordQueryMockIdentityTest 3 Mock 查询身份过滤、历史 NULL 命中默认、存量签名不变
    FlowOperatorIdentityRecordTest +1 clearNotify 清理转交身份

    验证:./mvnw -o clean install 全量通过,7 模块 SUCCESS,478 用例 0 失败 0 跳过(framework 455 / infra 6 / api 2 / starter 8 / example 7)。

    仍未覆盖(保留本 issue 继续跟踪,未在本轮范围内):撤销 / 催办 / 子流程重置的身份归属校验、加签同人异身份查重与减签身份维度、转交 / 委托 / 干预身份落库、BaseAuditNode 同人自动通过的身份过滤、currentNodeOperators 跨多人员混合场景。这些路径在 P2/P3 已有代码改动但尚无针对性断言,建议下一轮补齐。


    交付信息

    项 值
    仓库 codingapi/flow-engine
    分支 feature/issue-288-operator-identity(已 fast-forward 合并并推送)
    提交 9af745fc3fa5cc36f4213b29156149eb31bc1e92
    PR #289
    验证 ./mvnw -o clean install:7 模块 SUCCESS,478 个用例 0 失败 0 跳过(原 453,新增 25)

    本 issue 暂保持 open:修复随 PR #289 一并交付,未合入默认分支不会自动关闭,待确认后再关闭。

  4. xlorne commented on Dec 2, 2026

    @xlorne
    ContributorAuthor

    代码已在 dev,这里同步一次逐项核对结果(保持开启,仍有 4 类缺口)。

    已覆盖(可勾掉)

    缺口 用例
    1. $bind.getOperatorByIdentity GroovyScriptBindIdentityTest
    5. FlowContent 多身份去重/排除 FlowCurrentNodeOperatorsIdentityTest
    6. Mock 查询身份隔离 FlowRecordQueryMockIdentityTest
    8. 网关批量取人身份维度 FlowOperatorBulkIdentityTest

    补充:FlowOperatorIdentityRecordTest 覆盖了创建人/审批人身份落库与 clearNotify 转交身份清零;OperatorIdentityGuardTest 覆盖降级告警;OperatorIdentityPermissionTest / OperatorIdentityUserOnlyPermissionTest 覆盖 STRICT / USER_ONLY 两种模式下的审批与删除拒绝。

    仍缺口

    • 2. 撤回 / 催办 / 子流程重置的身份校验:FlowRevokeServiceTest、FlowSubProcessEnhancementServiceTest 均无身份断言(grep 0 命中),三处逻辑已改但无用例;
    • 3. 加签同人异身份查重、减签身份维度:FlowAddAuditServiceTest、FlowIssue266ReduceAuditTest 无身份断言,复合键改动最易回归;
    • 4. 转交 / 委托 / 干预身份落库:只有 clearNotify 一处断言,forwardOperatorIdentity、interferedOperatorIdentity 正向写入无覆盖;
    • 7. BaseAuditNode 同人自动通过的跨身份过滤:FlowIssue224SameOperatorAuditTest、FlowIssue224SameOperatorAuditMultiModeTest、FlowIssue226AutoPassRecordTest 均无身份维度。

    优先级建议不变:2 / 3 / 7 属「复合键 + 权限判定」,应先补。

  5. xlorne commented on Dec 2, 2026

    @xlorne
    ContributorAuthor

    8 类缺口已全部收口(本轮 +15 例,总计 505)。

    缺口核对

    # 缺口 本轮覆盖
    1 $bind.getOperatorByIdentity 已覆盖(GroovyScriptBindIdentityTest)
    2 撤回 / 催办 / 子流程重置的身份归属 OperatorIdentityBoundaryTest 4 例 + FlowSubProcessResetServiceTest 2 例
    3 加签同人异身份查重、减签身份维度 OperatorIdentityBoundaryTest 4 例(加签 2 / 减签 2)
    4 转交 / 干预身份落库 OperatorIdentityBoundaryTest 3 例(转交目标、转交链、干预)
    5 FlowContent 多身份 已覆盖(FlowCurrentNodeOperatorsIdentityTest)
    6 Mock 查询身份隔离 已覆盖(FlowRecordQueryMockIdentityTest)
    7 BaseAuditNode 同人自动通过的身份过滤 OperatorIdentityBoundaryTest 2 例(USER_ONLY / STRICT)
    8 网关批量取人身份维度 已覆盖(FlowOperatorBulkIdentityTest)

    同时修正的两处实现不一致

    1. 待办合并键(FlowRecord#getTodoKey()):原先无条件按「身份」追加后缀,导致 USER_ONLY 下同一人换身份会生成两条重复待办。现改为由匹配模式决定:USER_ONLY 身份不进键(按人合并),STRICT 保持历史兼容追加格式。
    2. 加签查重(AddAuditAction#verifyNotInTodoQueue):原先用 userId + identity 复合键,USER_ONLY 下同人换身份仍可重复加签。现统一走 OperatorIdentityPolicy.matches,与审批/撤回/减签同口径。

    同人换身份不算干预这一条保持原实现(FlowRecord#update 已走策略),本轮补了正向断言。

    验证

    ./mvnw -o clean install:7 模块 SUCCESS,505 个用例 0 失败 0 跳过(framework 480 / starter-infra 6 / starter-api 2 / starter-query 0 / starter 10 / example 7),原 490,本轮新增 15。

    交付信息

    项 值
    仓库 codingapi/flow-engine
    分支 feature/issue-295-identity-tests
    提交 5573905c64c2fd332889e93818c29eba2bc8a994
    PR #299
    合并 未合并 dev,由人工决定
  6. added a commit that references this issue on Dec 2, 2026
  7. xlorne commented on Dec 2, 2026

    @xlorne
    ContributorAuthor

    已合并到 dev,本 issue 收口关闭。

    合并信息

    项 值
    仓库 codingapi/flow-engine
    PR #299(MERGED)
    分支 feature/issue-295-identity-tests → dev
    提交 5573905c
    合并提交 9736e92b
    合并时间 2026-12-02 17:27 (UTC+8)

    合并内容已核对进入 dev(5 文件 +712/−31):

    docs/Integration/operator-identity.md              |  24 +-
    .../flow/action/actions/AddAuditAction.java        |  33 +-
    .../java/com/codingapi/flow/record/FlowRecord.java |  21 +-
    .../service/FlowSubProcessResetServiceTest.java    |  69 +++
    .../flow/service/OperatorIdentityBoundaryTest.java | 596 +++++++++++++++++++++
    

    缺口收口情况

    8 类缺口全部有确定用例覆盖(本轮 +15 例):

    # 缺口 覆盖用例
    1 $bind.getOperatorByIdentity GroovyScriptBindIdentityTest(已有)
    2 撤回 / 催办 / 子流程重置的身份归属 OperatorIdentityBoundaryTest 4 例 + FlowSubProcessResetServiceTest 2 例
    3 加签同人异身份查重、减签身份维度 OperatorIdentityBoundaryTest 4 例
    4 转交 / 干预身份落库 OperatorIdentityBoundaryTest 3 例
    5 FlowContent 多身份 FlowCurrentNodeOperatorsIdentityTest(已有)
    6 Mock 查询身份隔离 FlowRecordQueryMockIdentityTest(已有)
    7 BaseAuditNode 同人自动通过的身份过滤 OperatorIdentityBoundaryTest 2 例(USER_ONLY / STRICT)
    8 网关批量取人身份维度 FlowOperatorBulkIdentityTest(已有)

    同时修正两处「按人 vs 按身份」不一致的实现:

    1. FlowRecord#getTodoKey():合并键改由 OperatorIdentityPolicy 决定——USER_ONLY 身份不进键(按人合并),STRICT 保持 #identity 历史兼容追加。修复了 USER_ONLY 下同一人换身份会生成两条重复待办的问题。
    2. AddAuditAction#verifyNotInTodoQueue:查重从 userId + identity 复合键改为 OperatorIdentityPolicy.matches,USER_ONLY 下同人换身份拒绝重复加签,与审批 / 撤回 / 减签同口径。

    「同人换身份不算干预」保持原实现(FlowRecord#update 已走策略),本轮补正向断言。

    验证

    ./mvnw -o clean install:7 模块 SUCCESS,505 用例 0 失败 0 跳过(framework 480 / starter-infra 6 / starter-api 2 / starter 10 / example 7),上一轮 490,本轮 +15。

    分支清理

    • worktree .worktrees/issue-295 已移除
    • 本地分支 feature/issue-295-identity-tests 已删除
    • 远程分支 origin/feature/issue-295-identity-tests 已删除
    • 两仓当前仅剩 dev / main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions