From 7e6148c2786b9e65cdee040769f1d582056a91a1 Mon Sep 17 00:00:00 2001 From: Dinh Nguyen Date: Wed, 20 Nov 2024 08:38:45 +0700 Subject: [PATCH] Update test case --- .../com/axonivy/connector/openai/mock/MockAI.java | 2 -- .../assist-insert-with-system-promt-response.json | 2 +- .../connector/openai/test/AiAssistanceTest.java | 14 +++++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openai-connector-test/src/com/axonivy/connector/openai/mock/MockAI.java b/openai-connector-test/src/com/axonivy/connector/openai/mock/MockAI.java index 4c309f9..bea7cbe 100644 --- a/openai-connector-test/src/com/axonivy/connector/openai/mock/MockAI.java +++ b/openai-connector-test/src/com/axonivy/connector/openai/mock/MockAI.java @@ -97,10 +97,8 @@ private String input(JsonNode request, Map examples) { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response chat(JsonNode request) { - Ivy.log().warn(request.toPrettyString()); var in = input(request, openAIExamples); var node = openAIExamples.get(in+"-response"); - Ivy.log().warn(request); return Response.ok() .entity(node) .build(); diff --git a/openai-connector-test/src/com/axonivy/connector/openai/mock/json/assist-insert-with-system-promt-response.json b/openai-connector-test/src/com/axonivy/connector/openai/mock/json/assist-insert-with-system-promt-response.json index 11d1211..49e5d74 100644 --- a/openai-connector-test/src/com/axonivy/connector/openai/mock/json/assist-insert-with-system-promt-response.json +++ b/openai-connector-test/src/com/axonivy/connector/openai/mock/json/assist-insert-with-system-promt-response.json @@ -8,7 +8,7 @@ "index": 0, "message": { "role": "assistant", - "content": "", + "content": "", "refusal": null }, "logprobs": null, diff --git a/openai-connector-test/src_test/com/axonivy/connector/openai/test/AiAssistanceTest.java b/openai-connector-test/src_test/com/axonivy/connector/openai/test/AiAssistanceTest.java index 07d5cbd..1391b1b 100644 --- a/openai-connector-test/src_test/com/axonivy/connector/openai/test/AiAssistanceTest.java +++ b/openai-connector-test/src_test/com/axonivy/connector/openai/test/AiAssistanceTest.java @@ -91,8 +91,17 @@ void mailGenerator() { @Test void askWithOutSystemPromt() { JsonNode result = assistWithQuestion("insert a combobox to pick a brand out of: Mercedes, BMW or Tesla", false); - assertThat(result.toPrettyString()) - .isNotEmpty(); + assertThat(result.toPrettyString()).isNotEmpty(); + assertThat(result.toPrettyString()).as("Provide combobox with generated message") + .contains("Sure, here is a combobox for you to pick a brand out of Mercedes, BMW, or Tesla"); + } + + @Test + void insertWithSystemPromt() { + JsonNode result = assistWithQuestion("insert a combobox to pick a brand out of: Mercedes, BMW or Tesla", true); + assertThat(result.toPrettyString()).isNotEmpty(); + assertThat(result.toPrettyString()).as("Provide combobox with system promt") + .contains("