fix
This commit is contained in:
@@ -1271,6 +1271,82 @@ class DemandFlowApiTest {
|
||||
.isInstanceOf(com.linkerbot.cadworld.common.exception.BizException.class);
|
||||
}
|
||||
|
||||
@Test void capturedRealModelHeadReplacementAppliesWithoutInventingNewRequirements() throws Exception {
|
||||
defaultHumanoidModel(); humanoidComponents("sided");
|
||||
doAnswer(invocation -> {
|
||||
ObjectNode raw = humanoidRaw(invocation.getArgument(0));
|
||||
intent(raw, "form", "整机", "具有类人人形形态");
|
||||
raw.withArray("unmodeled").addObject().put("text", "未明确指定人形机器人的具体自由度、运动性能、载荷、尺寸、材料、外观细节、应用场景及执行任务等参数")
|
||||
.put("reason", "用户未提供具体参数").putArray("evidenceIds").add("e1"); return raw;
|
||||
}).when(model).analyze(anyList());
|
||||
Session session = create(); JsonNode first = submit(session, "m1", "给我一个人形机器人", List.of());
|
||||
duplicate("CW-HEAD_0", "CW-HEAD_0-NEW", "另一种头部");
|
||||
try (java.io.InputStream stream = getClass().getResourceAsStream("/fixtures/head-replacement-model-output.json")) {
|
||||
JsonNode captured = json.readTree(stream);
|
||||
doAnswer(invocation -> captured.deepCopy()).when(model).analyze(anyList());
|
||||
}
|
||||
JsonNode replaced = submit(session, "m2", "换个头", List.of());
|
||||
assertThat(replaced.path("match").path("change").path("status").asText()).isEqualTo("applied");
|
||||
assertThat(replaced.path("result").path("analysis").path("operation").path("targets").get(0).path("side").asText()).isEqualTo("all");
|
||||
Map<String, String> expected = codesByRole(first.path("match")); expected.put("HEAD_0:1", "CW-HEAD_0-NEW");
|
||||
assertThat(codesByRole(replaced.path("match"))).isEqualTo(expected);
|
||||
assertThat(replaced.path("result").path("analysis").path("unmodeled")).isEqualTo(first.path("result").path("analysis").path("unmodeled"));
|
||||
}
|
||||
|
||||
@Test void capturedRealModelConsecutiveReplacementDoesNotRepeatThePreviousHeadChange() throws Exception {
|
||||
defaultHumanoidModel(); humanoidComponents("sided");
|
||||
Session session = create(); JsonNode first = submit(session, "r1", "给我一个人形机器人", List.of());
|
||||
duplicate("CW-HEAD_0", "CW-HEAD_0-NEW", "另一种头部");
|
||||
replacementModel("HEAD", "all");
|
||||
JsonNode head = submit(session, "r2", "换个头", List.of());
|
||||
assertThat(head.path("match").path("change").path("status").asText()).isEqualTo("applied");
|
||||
duplicate("CW-ARM_L", "CW-ARM_L-NEW", "另一种左臂");
|
||||
try (java.io.InputStream stream = getClass().getResourceAsStream("/fixtures/consecutive-replacement-model-output.json")) {
|
||||
JsonNode captured = json.readTree(stream);
|
||||
doAnswer(invocation -> captured.deepCopy()).when(model).analyze(anyList());
|
||||
}
|
||||
JsonNode arm = submit(session, "r3", "单独换个左臂", List.of());
|
||||
assertThat(arm.path("match").path("change").path("status").asText()).isEqualTo("applied");
|
||||
assertThat(arm.path("match").path("change").path("targetInstanceIds")).hasSize(1);
|
||||
assertThat(arm.path("match").path("change").path("baseAnalysisId").asText()).isEqualTo(head.path("analysisId").asText());
|
||||
Map<String, String> expected = codesByRole(first.path("match"));
|
||||
expected.put("HEAD_0:1", "CW-HEAD_0-NEW"); expected.put("ARM_L:1", "CW-ARM_L-NEW");
|
||||
assertThat(codesByRole(arm.path("match"))).isEqualTo(expected);
|
||||
assertThat(arm.path("result").path("analysis").path("operation").path("targets")).hasSize(1);
|
||||
assertThat(generatedMatch(session, arm.path("analysisId").asText(), 3)).isEqualTo(arm.path("match"));
|
||||
}
|
||||
|
||||
@Test void headReplacementIgnoresRestatedHistoryAndInventedMissingParameters() throws Exception {
|
||||
defaultHumanoidModel(); humanoidComponents("sided");
|
||||
doAnswer(invocation -> {
|
||||
ObjectNode raw = humanoidRaw(invocation.getArgument(0));
|
||||
intent(raw, "form", "整机", "具有类人人形形态");
|
||||
raw.withArray("unmodeled").addObject().put("text", "用户未指定自由度、运动性能、载荷、尺寸、材料等参数")
|
||||
.put("reason", "未给出具体参数").putArray("evidenceIds").add("e1"); return raw;
|
||||
}).when(model).analyze(anyList());
|
||||
Session session = create(); JsonNode first = submit(session, "m1", "给我一个人形机器人", List.of());
|
||||
duplicate("CW-HEAD_0", "CW-HEAD_0-NEW", "另一种头部");
|
||||
doAnswer(invocation -> {
|
||||
List<DemandMessage> history = invocation.getArgument(0);
|
||||
ObjectNode raw = replacementRaw(history, "HEAD", "all");
|
||||
raw.withArray("observations").addObject().put("id", "old-shape").put("messageId", history.getFirst().id())
|
||||
.put("imageId", "").put("kind", "user_text").put("content", history.getFirst().text()).put("clarity", "clear").putArray("region");
|
||||
intent(raw, "form", "整机", "保持双足类人外形");
|
||||
((ObjectNode) raw.path("intentItems").get(0)).putArray("evidenceIds").add("old-shape");
|
||||
raw.withArray("unmodeled").addObject().put("text", "未明确人形机器人的具体尺寸与质量")
|
||||
.put("reason", "历史需求缺少参数").putArray("evidenceIds").add("old-shape");
|
||||
intent(raw, "other", "头部", "替换当前头部组件");
|
||||
raw.withArray("unmodeled").addObject().put("text", "未指定新头部的外形、材料和自由度")
|
||||
.put("reason", "当前替换未给出具体参数").putArray("evidenceIds").add("e1"); return raw;
|
||||
}).when(model).analyze(anyList());
|
||||
JsonNode replaced = submit(session, "m2", "换个头", List.of());
|
||||
assertThat(replaced.path("match").path("change").path("status").asText()).isEqualTo("applied");
|
||||
Map<String, String> expected = codesByRole(first.path("match")); expected.put("HEAD_0:1", "CW-HEAD_0-NEW");
|
||||
assertThat(codesByRole(replaced.path("match"))).isEqualTo(expected);
|
||||
assertThat(replaced.path("result").path("analysis").path("intentItems").toString()).contains("具有类人人形形态").doesNotContain("保持双足类人外形", "替换当前头部组件");
|
||||
assertThat(replaced.path("result").path("analysis").path("unmodeled")).isEqualTo(first.path("result").path("analysis").path("unmodeled"));
|
||||
}
|
||||
|
||||
@ParameterizedTest @ValueSource(booleans = {true, false})
|
||||
void replacementCannotCommitAfterNewMessageOrCancellationAndCancelledRevisionCanRetry(boolean supersede) throws Exception {
|
||||
defaultHumanoidModel(); humanoidComponents("sided");
|
||||
|
||||
Reference in New Issue
Block a user