Skip to content

Commit 87d361a

Browse files
Msquittto陈潇文
andauthored
adapt to changes in Qianfan interface response (#190)
* [app-platform] add KnowledgeController test shouldOkWhenGetKnowledgeConfigId * [app-platform] add "@JsonIgnoreProperties" annotation to ingore unused key in qianfan interface response --------- Co-authored-by: 陈潇文 <[email protected]>
1 parent ac54576 commit 87d361a

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

app-knowledge/plugins/knowledge-manager/src/test/java/modelengine/jade/knowledge/KnowledgeControllerTest.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
package modelengine.jade.knowledge;
88

9+
import static modelengine.jade.knowledge.enums.FilterType.REFERENCE_TOP_K;
10+
import static modelengine.jade.knowledge.enums.FilterType.SIMILARITY_THRESHOLD;
11+
import static org.assertj.core.api.Assertions.assertThat;
12+
import static org.mockito.ArgumentMatchers.any;
13+
import static org.mockito.ArgumentMatchers.anyString;
14+
import static org.mockito.Mockito.when;
15+
16+
import modelengine.fel.tool.service.ToolGroupService;
917
import modelengine.fit.http.client.HttpClassicClientResponse;
1018
import modelengine.fit.jane.task.gateway.Authenticator;
1119
import modelengine.fitframework.annotation.Fit;
@@ -18,7 +26,6 @@
1826
import modelengine.fitframework.util.ObjectUtils;
1927
import modelengine.fitframework.util.TypeUtils;
2028
import modelengine.jade.authentication.AuthenticationService;
21-
import modelengine.fel.tool.service.ToolGroupService;
2229
import modelengine.jade.common.filter.support.LoginFilter;
2330
import modelengine.jade.common.vo.PageVo;
2431
import modelengine.jade.knowledge.config.KnowledgeConfig;
@@ -44,13 +51,6 @@
4451
import java.util.Collections;
4552
import java.util.List;
4653

47-
import static modelengine.jade.knowledge.enums.FilterType.REFERENCE_TOP_K;
48-
import static modelengine.jade.knowledge.enums.FilterType.SIMILARITY_THRESHOLD;
49-
import static org.assertj.core.api.Assertions.assertThat;
50-
import static org.mockito.ArgumentMatchers.any;
51-
import static org.mockito.ArgumentMatchers.anyString;
52-
import static org.mockito.Mockito.when;
53-
5454
/**
5555
* 表示 {@link KnowledgeController} 的测试用例。
5656
*
@@ -208,6 +208,19 @@ void shouldOkWhenGetProperty() {
208208
assertThat(property.getRerankConfig()).hasSize(1);
209209
}
210210

211+
@Test
212+
@DisplayName("查询知识库config配置成功")
213+
public void shouldOkWhenGetKnowledgeConfigId() {
214+
when(this.knowledgeCenterService.getKnowledgeConfigId(any(), anyString())).thenReturn("id1");
215+
MockRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/knowledge-manager/configId")
216+
.param("groupId", this.buildMockGroupId())
217+
.responseType(String.class);
218+
this.response = this.mockMvc.perform(requestBuilder);
219+
Assertions.assertThat(this.response.statusCode()).isEqualTo(200);
220+
Assertions.assertThat(this.response.objectEntity()).isPresent();
221+
assertThat(this.response.textEntity().get().content()).isEqualTo("id1");
222+
}
223+
211224
private KnowledgeProperty getExpectProperty() {
212225
KnowledgeProperty.IndexInfo indexType =
213226
new KnowledgeProperty.IndexInfo(IndexType.SEMANTIC, "语义检索", "使用向量进行文本相关查询");

app-knowledge/plugins/qianfan-knowledge/src/main/java/modelengine/jade/knowledge/entity/QianfanKnowledgeEntity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
package modelengine.jade.knowledge.entity;
88

9+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
10+
911
import lombok.AllArgsConstructor;
1012
import lombok.Builder;
1113
import lombok.Data;
@@ -21,6 +23,7 @@
2123
@Builder
2224
@NoArgsConstructor
2325
@AllArgsConstructor
26+
@JsonIgnoreProperties(ignoreUnknown = true)
2427
public class QianfanKnowledgeEntity {
2528
/**
2629
* 知识库id。
@@ -44,6 +47,7 @@ public class QianfanKnowledgeEntity {
4447
private QianfanKnowledgeConfigEntity config;
4548

4649
@Data
50+
@JsonIgnoreProperties(ignoreUnknown = true)
4751
public static class QianfanKnowledgeConfigEntity {
4852
/**
4953
* 知识库索引配置。
@@ -52,6 +56,7 @@ public static class QianfanKnowledgeConfigEntity {
5256
}
5357

5458
@Data
59+
@JsonIgnoreProperties(ignoreUnknown = true)
5560
public static class QianfanKnowledgeConfigIndexEntity {
5661
/**
5762
* 知识库索引存储配置 (public | bes | vdb)。

app-knowledge/plugins/qianfan-knowledge/src/main/java/modelengine/jade/knowledge/entity/QianfanKnowledgeListEntity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package modelengine.jade.knowledge.entity;
88

9+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
910
import com.fasterxml.jackson.annotation.JsonProperty;
1011

1112
import lombok.AllArgsConstructor;
@@ -25,6 +26,7 @@
2526
@Builder
2627
@NoArgsConstructor
2728
@AllArgsConstructor
29+
@JsonIgnoreProperties(ignoreUnknown = true)
2830
public class QianfanKnowledgeListEntity {
2931
/**
3032
* 知识库查询的起始id。

0 commit comments

Comments
 (0)