fix(外观专利): 整批失败文案带上游那句真因作样例(BK B95-02 判据收口)
上一条只做到「分类」:交付列写「服务侧解密链路故障」,但到底是 UTF-8 解不开、密钥不对 还是压缩坏了,只有上游那句 reason 知道——B95-02 的判据要求「能回读到是哪一步失败」。 - AppearancePatentBrandFailureText.describe:分类文案 + 一句样例(压单行、截 80 字、超出以 … 收尾),没给原因时退回纯分类文案,不凭空补。 - aggregate 改用 describe(分类口径与保守判定一字未动)。 - 用例:e2e 改成「保前缀 + 带 Malformed UTF-8 样例」;新增样例单行/截断/空原因三格(共 21 支)。
This commit is contained in:
+25
-1
@@ -32,6 +32,9 @@ final class AppearancePatentBrandFailureText {
|
||||
static final String SERVICE_UNREACHABLE =
|
||||
"商标查询失败:品牌检测服务不可达(连接未建立,非本行数据问题)";
|
||||
|
||||
/** 样例最多留几个字:够定位真因,又不把整段上游报错糊进交付列。 */
|
||||
static final int SAMPLE_KEEP = 80;
|
||||
|
||||
private AppearancePatentBrandFailureText() {
|
||||
}
|
||||
|
||||
@@ -56,7 +59,28 @@ final class AppearancePatentBrandFailureText {
|
||||
}
|
||||
reasons.add(normalize(check.reason()));
|
||||
}
|
||||
return anyChecked ? classify(reasons) : null;
|
||||
return anyChecked ? describe(classify(reasons), reasons) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类文案 + 一句失败样例。
|
||||
*
|
||||
* <p>BK B95-02 的判据是「解密失败那条要能回读到是哪一步失败」:分类只说到「解密链路」,
|
||||
* 具体是 UTF-8 解不开、密钥不对还是压缩坏了,只有上游那句 reason 才知道。样例截断到
|
||||
* {@link #SAMPLE_KEEP} 字并对齐单行——它是给人看的一句话,不是堆栈搬运。
|
||||
*/
|
||||
static String describe(String base, List<String> reasons) {
|
||||
String sample = "";
|
||||
if (reasons != null) {
|
||||
for (String reason : reasons) {
|
||||
String text = normalize(reason).replace('\n', ' ').replace('\r', ' ');
|
||||
if (!text.isEmpty()) {
|
||||
sample = text.length() > SAMPLE_KEEP ? text.substring(0, SAMPLE_KEEP) + "…" : text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sample.isEmpty() ? base : base + ";样例=" + sample;
|
||||
}
|
||||
|
||||
/** 批内 reason 全同形才分档;空 reason 或混形一律落回通用文案(不猜)。 */
|
||||
|
||||
+19
-1
@@ -155,13 +155,31 @@ class AppearancePatentLlmClientTest {
|
||||
|
||||
assertThat(merged).hasSize(2);
|
||||
assertThat(merged).allSatisfy(r -> {
|
||||
assertThat(r.getTitleRisk()).isEqualTo(AppearancePatentBrandFailureText.DECRYPT_BROKEN);
|
||||
// 分类文案在前、上游那句真因作为样例在后(B95-02 判据:要能回读到是哪一步失败)
|
||||
assertThat(r.getTitleRisk()).startsWith(AppearancePatentBrandFailureText.DECRYPT_BROKEN);
|
||||
assertThat(r.getTitleRisk()).contains("Malformed UTF-8");
|
||||
// 前缀不能变:状态列与 isBrandQueryFailed 都靠它判失败
|
||||
assertThat(r.getTitleRisk()).startsWith("商标查询失败");
|
||||
assertThat(r.getTitleRisk()).doesNotContain("上游整体不可用");
|
||||
});
|
||||
}
|
||||
|
||||
/** 样例只留一句、截断并压成单行;没给原因时退回纯分类文案(不凭空补样例)。 */
|
||||
@Test
|
||||
void 样例只留一句且截断成单行() {
|
||||
assertThat(AppearancePatentBrandFailureText.describe(
|
||||
AppearancePatentBrandFailureText.DECRYPT_BROKEN, List.of("")))
|
||||
.isEqualTo(AppearancePatentBrandFailureText.DECRYPT_BROKEN);
|
||||
assertThat(AppearancePatentBrandFailureText.describe(
|
||||
AppearancePatentBrandFailureText.DECRYPT_BROKEN, List.of("第一行\n第二行")))
|
||||
.isEqualTo(AppearancePatentBrandFailureText.DECRYPT_BROKEN + ";样例=第一行 第二行");
|
||||
String longReason = "解".repeat(AppearancePatentBrandFailureText.SAMPLE_KEEP + 10);
|
||||
assertThat(AppearancePatentBrandFailureText.describe(
|
||||
AppearancePatentBrandFailureText.DECRYPT_BROKEN, List.of(longReason)))
|
||||
.isEqualTo(AppearancePatentBrandFailureText.DECRYPT_BROKEN + ";样例="
|
||||
+ "解".repeat(AppearancePatentBrandFailureText.SAMPLE_KEEP) + "…");
|
||||
}
|
||||
|
||||
/** 整批全失败且原因是「连接没建立」时,文案要指向服务不可达,而不是解密或通用文案。 */
|
||||
@Test
|
||||
void 整批连接不上要写成服务不可达() {
|
||||
|
||||
Reference in New Issue
Block a user