fix(b5): WIPO 查询词先剥 Brand: 标签前缀
BrandCheckClient.postCheck 此前只 trim(),带前缀的品牌词原样打到 16890, 现网 19,247 次 undefined field Brand 即由此而来。改走 BrandLabel.strip, 带前缀不再成为查询键;补一条无代理短路用例钉住。
This commit is contained in:
+3
-1
@@ -153,7 +153,9 @@ public class BrandCheckClient {
|
||||
}
|
||||
|
||||
private BrandCheckResponse postCheck(String brand, String strategy, Long userId, String proxyUrl) {
|
||||
String normalizedBrand = normalize(brand);
|
||||
// B5 #8:WIPO 查询词同样要剥 `Brand:` 前缀。此前这里只 trim(),
|
||||
// 带前缀的词原样打到上游,现网 19,247 次 `undefined field Brand` 就是这么来的。
|
||||
String normalizedBrand = com.nanri.aiimage.common.text.BrandLabel.strip(normalize(brand));
|
||||
if (normalizedBrand.isBlank()) {
|
||||
return BrandCheckResponse.empty();
|
||||
}
|
||||
|
||||
+14
@@ -376,6 +376,20 @@ class BrandCheckClientTest {
|
||||
}
|
||||
|
||||
/** 有真实 HTTP 断言的用例必须桩出非空代理,否则客户端零请求短路、阶梯与指标全测不到。 */
|
||||
@Test
|
||||
void brandLabelPrefixIsStrippedBeforeQueryingUpstream() {
|
||||
UserApiSecretService noProxy = mock(UserApiSecretService.class);
|
||||
when(noProxy.findPlainValue(anyLong(), anyString())).thenReturn("");
|
||||
BrandCheckClient client = new BrandCheckClient(
|
||||
new BrandCheckProperties(), null, noProxy, new UnreachableCooldown());
|
||||
|
||||
BrandCheckClient.BrandCheckResponse response = client.check("Brand: NIKE", "Terms", 7L);
|
||||
|
||||
assertThat(response.getQueryFaildData())
|
||||
.as("查询词必须先剥标签前缀,否则上游判 undefined field Brand")
|
||||
.containsExactly("NIKE");
|
||||
}
|
||||
|
||||
private UserApiSecretService stubbedUserSecrets() {
|
||||
UserApiSecretService secrets = mock(UserApiSecretService.class);
|
||||
when(secrets.findPlainValue(anyLong(), anyString())).thenReturn("http://user:pass@127.0.0.1:9");
|
||||
|
||||
Reference in New Issue
Block a user