From 56b302b8598ea9c8d7d3968b8882a74461c6a402 Mon Sep 17 00:00:00 2001 From: Theo Kanning Date: Wed, 15 Nov 2023 18:19:45 -0600 Subject: [PATCH] Update to version 0.18.0 (#406) --- gradle.properties | 2 +- .../openai/service/MessageTest.java | 6 +++++- .../theokanning/openai/service/ThreadTest.java | 18 ++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 671b33b6..e12dac0d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.theokanning.openai-gpt3-java -VERSION_NAME=0.17.0 +VERSION_NAME=0.18.0 POM_URL=https://github.com/theokanning/openai-java POM_SCM_URL=https://github.com/theokanning/openai-java diff --git a/service/src/test/java/com/theokanning/openai/service/MessageTest.java b/service/src/test/java/com/theokanning/openai/service/MessageTest.java index a1fe99cb..06a903c0 100644 --- a/service/src/test/java/com/theokanning/openai/service/MessageTest.java +++ b/service/src/test/java/com/theokanning/openai/service/MessageTest.java @@ -39,7 +39,11 @@ static void setup() { @AfterAll static void teardown() { - // todo delete thread + try { + service.deleteThread(threadId); + } catch (Exception e) { + // ignore + } } @Test diff --git a/service/src/test/java/com/theokanning/openai/service/ThreadTest.java b/service/src/test/java/com/theokanning/openai/service/ThreadTest.java index 2c203790..212653af 100644 --- a/service/src/test/java/com/theokanning/openai/service/ThreadTest.java +++ b/service/src/test/java/com/theokanning/openai/service/ThreadTest.java @@ -4,19 +4,25 @@ import com.theokanning.openai.messages.MessageRequest; import com.theokanning.openai.threads.Thread; import com.theokanning.openai.threads.ThreadRequest; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import java.util.*; import static org.junit.jupiter.api.Assertions.*; - +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class ThreadTest { String token = System.getenv("OPENAI_TOKEN"); OpenAiService service = new OpenAiService(token); + static String threadId; + @Test + @Order(1) void createThread() { MessageRequest messageRequest = MessageRequest.builder() .content("Hello") @@ -27,22 +33,21 @@ void createThread() { .build(); Thread thread = service.createThread(threadRequest); - System.out.println(thread.getId()); + threadId = thread.getId(); assertEquals("thread", thread.getObject()); } @Test + @Order(2) void retrieveThread() { - String threadId = "thread_K82pTg9kmhxpplGqalW6IHlc"; - Thread thread = service.retrieveThread(threadId); System.out.println(thread.getMetadata()); assertEquals("thread", thread.getObject()); } @Test + @Order(3) void modifyThread() { - String threadId = "thread_K82pTg9kmhxpplGqalW6IHlc"; Map metadata = new HashMap<>(); metadata.put("action", "modify"); ThreadRequest threadRequest = ThreadRequest.builder() @@ -50,11 +55,12 @@ void modifyThread() { .build(); Thread thread = service.modifyThread(threadId, threadRequest); assertEquals("thread", thread.getObject()); + assertEquals("modify", thread.getMetadata().get("action")); } @Test + @Order(4) void deleteThread() { - String threadId = "thread_K82pTg9kmhxpplGqalW6IHlc"; DeleteResult deleteResult = service.deleteThread(threadId); assertEquals("thread.deleted", deleteResult.getObject()); }