|
15 | 15 | import org.apache.http.client.methods.HttpGet; |
16 | 16 | import org.apache.http.client.methods.HttpPatch; |
17 | 17 | import org.apache.http.client.methods.HttpPost; |
| 18 | +import org.apache.http.client.methods.HttpPut; |
18 | 19 | import org.junit.jupiter.api.Test; |
19 | 20 |
|
20 | 21 | import java.util.*; |
@@ -66,6 +67,8 @@ public class AIApiTest extends TestClient { |
66 | 67 | private static final String AI_PROMPT_COMPLETION_DOWNLOAD = "%s/users/%d/ai/prompts/%d/completions/%s/download"; |
67 | 68 | private static final String PROXY_CHAT = "%s/users/%d/ai/providers/%d/chat/completions"; |
68 | 69 | private static final String LIST_SUPPORTED_AI_PROVIDER_MODELS = "%s/users/%d/ai/providers/supported-models"; |
| 70 | + private static final String AI_GATEWAY = "%s/users/%d/ai/providers/%d/gateway/chat/completions"; |
| 71 | + private static final String gatewayPath = "chat/completions"; |
69 | 72 |
|
70 | 73 | @Override |
71 | 74 | public List<RequestMock> getMocks() { |
@@ -106,7 +109,12 @@ public List<RequestMock> getMocks() { |
106 | 109 | RequestMock.build(String.format(AI_PROMPT, this.url, userId, aiPromptId), HttpDelete.METHOD_NAME), |
107 | 110 | RequestMock.build(String.format(AI_PROMPT, this.url, userId, aiPromptId), HttpPatch.METHOD_NAME, "api/ai/editPromptRequest.json", "api/ai/promptResponse.json"), |
108 | 111 | RequestMock.build(String.format(PROXY_CHAT, this.url, userId, aiPromptId), HttpPost.METHOD_NAME, "api/ai/proxyChatCompletionRequest.json", "api/ai/proxyChatCompletionResponse.json"), |
109 | | - RequestMock.build(String.format(LIST_SUPPORTED_AI_PROVIDER_MODELS, this.url, userId), HttpGet.METHOD_NAME, "api/ai/listSupportedAiProviderModels.json") |
| 112 | + RequestMock.build(String.format(LIST_SUPPORTED_AI_PROVIDER_MODELS, this.url, userId), HttpGet.METHOD_NAME, "api/ai/listSupportedAiProviderModels.json"), |
| 113 | + RequestMock.build(String.format(AI_GATEWAY, this.url, userId, 1), HttpGet.METHOD_NAME, "api/ai/aiGatewayResponse.json"), |
| 114 | + RequestMock.build(String.format(AI_GATEWAY, this.url, userId, 1), HttpPost.METHOD_NAME, "api/ai/aiGatewayRequest.json", "api/ai/aiGatewayResponse.json"), |
| 115 | + RequestMock.build(String.format(AI_GATEWAY, this.url, userId, 1), HttpPut.METHOD_NAME, "api/ai/aiGatewayRequest.json", "api/ai/aiGatewayResponse.json"), |
| 116 | + RequestMock.build(String.format(AI_GATEWAY, this.url, userId, 1), HttpDelete.METHOD_NAME), |
| 117 | + RequestMock.build(String.format(AI_GATEWAY, this.url, userId, 1), HttpPatch.METHOD_NAME, "api/ai/aiGatewayRequest.json", "api/ai/aiGatewayResponse.json") |
110 | 118 | ); |
111 | 119 | } |
112 | 120 |
|
@@ -531,4 +539,39 @@ public void listSupportedAiProviderModelsTest() { |
531 | 539 | assertTrue(response.getData().get(0).getData().getModalities().getOutput().getImage()); |
532 | 540 | assertEquals(0.1, response.getData().get(0).getData().getPrice().getInput()); |
533 | 541 | } |
| 542 | + |
| 543 | + @Test |
| 544 | + public void aiGatewayGetTest() { |
| 545 | + ResponseObject<Map<String, Object>> response = this.getAiApi().aiGatewayGet(userId, 1L, gatewayPath); |
| 546 | + assertNotNull(response.getData()); |
| 547 | + } |
| 548 | + |
| 549 | + @Test |
| 550 | + public void aiGatewayPostTest() { |
| 551 | + Map<String, Object> req = new HashMap<>(); |
| 552 | + req.put("model", "string"); |
| 553 | + ResponseObject<Map<String, Object>> response = this.getAiApi().aiGatewayPost(userId, 1L, gatewayPath, req); |
| 554 | + assertNotNull(response.getData()); |
| 555 | + } |
| 556 | + |
| 557 | + @Test |
| 558 | + public void aiGatewayPutTest() { |
| 559 | + Map<String, Object> req = new HashMap<>(); |
| 560 | + req.put("model", "string"); |
| 561 | + ResponseObject<Map<String, Object>> response = this.getAiApi().aiGatewayPut(userId, 1L, gatewayPath, req); |
| 562 | + assertNotNull(response.getData()); |
| 563 | + } |
| 564 | + |
| 565 | + @Test |
| 566 | + public void aiGatewayDeleteTest() { |
| 567 | + this.getAiApi().aiGatewayDelete(userId, 1L, gatewayPath); |
| 568 | + } |
| 569 | + |
| 570 | + @Test |
| 571 | + public void aiGatewayPatchTest() { |
| 572 | + Map<String, Object> req = new HashMap<>(); |
| 573 | + req.put("model", "string"); |
| 574 | + ResponseObject<Map<String, Object>> response = this.getAiApi().aiGatewayPatch(userId, 1L, gatewayPath, req); |
| 575 | + assertNotNull(response.getData()); |
| 576 | + } |
534 | 577 | } |
0 commit comments