Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Enhancements and Modernization of Test Classes #430

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.List;

/**
* An object containing the flags for each moderation category
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.theokanning.openai.threads;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.theokanning.openai.messages.MessageRequest;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/java/com/theokanning/openai/JsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.*;

public class JsonTest {
class JsonTest {

@ParameterizedTest
@ValueSource(classes = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.theokanning.openai.client;

import com.theokanning.openai.DeleteResult;
import com.theokanning.openai.ListSearchParameters;
import com.theokanning.openai.OpenAiResponse;
import com.theokanning.openai.assistants.*;
import com.theokanning.openai.audio.CreateSpeechRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.theokanning.openai.ListSearchParameters;
import com.theokanning.openai.OpenAiResponse;
import com.theokanning.openai.assistants.Assistant;
import com.theokanning.openai.assistants.AssistantFunction;
Expand All @@ -21,9 +20,7 @@
import com.theokanning.openai.runs.RequiredAction;
import com.theokanning.openai.runs.Run;
import com.theokanning.openai.runs.RunCreateRequest;
import com.theokanning.openai.runs.RunStep;
import com.theokanning.openai.runs.SubmitToolOutputRequestItem;
import com.theokanning.openai.runs.SubmitToolOutputs;
import com.theokanning.openai.runs.SubmitToolOutputsRequest;
import com.theokanning.openai.runs.ToolCall;
import com.theokanning.openai.threads.Thread;
Expand All @@ -35,9 +32,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class AssistantFunctionTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class AssistantTest {
class AssistantTest {

static OpenAiService service = new OpenAiService(System.getenv("OPENAI_TOKEN"));
static String assistantId;
Expand Down Expand Up @@ -44,16 +44,16 @@ void createAssistant() {

assistantId = assistant.getId();

assertEquals(assistant.getName(), "Math Tutor");
assertEquals(assistant.getTools().get(0).getType(), AssistantToolsEnum.CODE_INTERPRETER);
assertEquals("Math Tutor", assistant.getName());
assertEquals(AssistantToolsEnum.CODE_INTERPRETER, assistant.getTools().get(0).getType());
}

@Test
@Order(2)
void retrieveAssistant() {
Assistant assistant = service.retrieveAssistant(assistantId);

assertEquals(assistant.getName(), "Math Tutor");
assertEquals("Math Tutor", assistant.getName());
}

@Test
Expand Down Expand Up @@ -105,7 +105,7 @@ void listAssistantFiles() {

assertFalse(files.isEmpty());
assertEquals(files.get(0).getId(), fileId);
assertEquals(files.get(0).getObject(), "assistant.file");
assertEquals("assistant.file", files.get(0).getObject());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.jupiter.api.Assertions.*;


public class AudioTest {
class AudioTest {

static String englishAudioFilePath = "src/test/resources/hello-world.mp3";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static org.junit.jupiter.api.Assertions.*;


public class CompletionTest {
class CompletionTest {

String token = System.getenv("OPENAI_TOKEN");
OpenAiService service = new OpenAiService(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class EditTest {
class EditTest {

String token = System.getenv("OPENAI_TOKEN");
com.theokanning.openai.service.OpenAiService service = new OpenAiService(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;


public class EmbeddingTest {
class EmbeddingTest {

String token = System.getenv("OPENAI_TOKEN");
com.theokanning.openai.service.OpenAiService service = new OpenAiService(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class FileTest {
class FileTest {
static String filePath = "src/test/resources/fine-tuning-data.jsonl";

String token = System.getenv("OPENAI_TOKEN");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static org.junit.jupiter.api.Assertions.*;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class FineTuningTest {
class FineTuningTest {
static OpenAiService service;
static String fileId;
static String fineTuningJobId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;


public class ImageTest {
class ImageTest {

static String filePath = "src/test/resources/penguin.png";
static String fileWithAlphaPath = "src/test/resources/penguin_with_alpha.png";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.theokanning.openai.messages.MessageFile;
import com.theokanning.openai.messages.MessageRequest;
import com.theokanning.openai.messages.ModifyMessageRequest;
import com.theokanning.openai.threads.Thread;
import com.theokanning.openai.threads.ThreadRequest;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -21,7 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;


public class MessageTest {
class MessageTest {

static OpenAiService service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;


public class ModelTest {
class ModelTest {

String token = System.getenv("OPENAI_TOKEN");
com.theokanning.openai.service.OpenAiService service = new OpenAiService(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;


public class ModerationTest {
class ModerationTest {

String token = System.getenv("OPENAI_TOKEN");
com.theokanning.openai.service.OpenAiService service = new OpenAiService(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import static org.junit.jupiter.api.Assertions.*;

public class OpenAiServiceTest {
class OpenAiServiceTest {

@Test
void assertTokenNotNull() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class ResponseBodyCallbackTest {
class ResponseBodyCallbackTest {

@Test
void testHappyPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static org.junit.jupiter.api.Assertions.*;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ThreadTest {
class ThreadTest {

String token = System.getenv("OPENAI_TOKEN");
OpenAiService service = new OpenAiService(token);
Expand Down