Skip to content

Commit db7a8cb

Browse files
committed
apply spotless
Signed-off-by: Jiaping Zeng <[email protected]>
1 parent b97aaaf commit db7a8cb

File tree

13 files changed

+363
-338
lines changed

13 files changed

+363
-338
lines changed

common/src/test/java/org/opensearch/ml/common/agui/AGUIInputConverterTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import org.opensearch.ml.common.dataset.remote.RemoteInferenceInputDataSet;
1515
import org.opensearch.ml.common.input.execute.agent.AgentMLInput;
1616

17-
import com.google.gson.JsonObject;
18-
1917
public class AGUIInputConverterTest {
2018

2119
@Test
@@ -246,8 +244,6 @@ public void testConvertFromAGUIInput_WithTemplates() {
246244
);
247245
}
248246

249-
250-
251247
@Test
252248
public void testConvertFromAGUIInput_WithContext() {
253249
String aguiInput = "{\n"

common/src/test/java/org/opensearch/ml/common/agui/RunFinishedEventTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
import org.junit.Test;
1515
import org.opensearch.common.io.stream.BytesStreamOutput;
1616
import org.opensearch.core.common.io.stream.StreamInput;
17+
1718
public class RunFinishedEventTests {
1819

1920
@Test
2021
public void testConstructor() {
2122
String threadId = "thread_123";
2223
String runId = "run_456";
23-
24+
2425
RunFinishedEvent event = new RunFinishedEvent(threadId, runId, null);
25-
26+
2627
assertNotNull("Event should not be null", event);
2728
assertEquals("Type should be RUN_FINISHED", "RUN_FINISHED", event.getType());
2829
assertEquals("Thread ID should match", threadId, event.getThreadId());
@@ -33,13 +34,13 @@ public void testConstructor() {
3334
@Test
3435
public void testSerialization() throws IOException {
3536
RunFinishedEvent original = new RunFinishedEvent("thread_test", "run_test", null);
36-
37+
3738
BytesStreamOutput output = new BytesStreamOutput();
3839
original.writeTo(output);
39-
40+
4041
StreamInput input = output.bytes().streamInput();
4142
RunFinishedEvent deserialized = new RunFinishedEvent(input);
42-
43+
4344
assertEquals("Type should match", original.getType(), deserialized.getType());
4445
assertEquals("Thread ID should match", original.getThreadId(), deserialized.getThreadId());
4546
assertEquals("Run ID should match", original.getRunId(), deserialized.getRunId());
@@ -49,9 +50,9 @@ public void testSerialization() throws IOException {
4950
@Test
5051
public void testToXContent() throws IOException {
5152
RunFinishedEvent event = new RunFinishedEvent("thread_xcontent", "run_xcontent", null);
52-
53+
5354
String json = event.toJsonString();
54-
55+
5556
assertNotNull("JSON should not be null", json);
5657
assertTrue("JSON should contain type", json.contains("\"type\":\"RUN_FINISHED\""));
5758
assertTrue("JSON should contain threadId", json.contains("\"threadId\":\"thread_xcontent\""));
@@ -62,9 +63,9 @@ public void testToXContent() throws IOException {
6263
@Test
6364
public void testToJsonString() {
6465
RunFinishedEvent event = new RunFinishedEvent("thread_json", "run_json", null);
65-
66+
6667
String json = event.toJsonString();
67-
68+
6869
assertNotNull("JSON string should not be null", json);
6970
assertTrue("JSON should be valid", json.startsWith("{") && json.endsWith("}"));
7071
}
@@ -74,9 +75,8 @@ public void testTimestampGeneration() {
7475
long before = System.currentTimeMillis();
7576
RunFinishedEvent event = new RunFinishedEvent("thread_time", "run_time", null);
7677
long after = System.currentTimeMillis();
77-
78+
7879
assertNotNull("Timestamp should be set", event.getTimestamp());
79-
assertTrue("Timestamp should be in valid range",
80-
event.getTimestamp() >= before && event.getTimestamp() <= after);
80+
assertTrue("Timestamp should be in valid range", event.getTimestamp() >= before && event.getTimestamp() <= after);
8181
}
8282
}

common/src/test/java/org/opensearch/ml/common/agui/RunStartedEventTests.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
import org.junit.Test;
1515
import org.opensearch.common.io.stream.BytesStreamOutput;
1616
import org.opensearch.core.common.io.stream.StreamInput;
17+
1718
public class RunStartedEventTests {
1819

1920
@Test
2021
public void testConstructor() {
2122
String threadId = "thread_123";
2223
String runId = "run_456";
23-
24+
2425
RunStartedEvent event = new RunStartedEvent(threadId, runId);
25-
26+
2627
assertNotNull("Event should not be null", event);
2728
assertEquals("Type should be RUN_STARTED", "RUN_STARTED", event.getType());
2829
assertEquals("Thread ID should match", threadId, event.getThreadId());
@@ -34,13 +35,13 @@ public void testConstructor() {
3435
@Test
3536
public void testSerialization() throws IOException {
3637
RunStartedEvent original = new RunStartedEvent("thread_test", "run_test");
37-
38+
3839
BytesStreamOutput output = new BytesStreamOutput();
3940
original.writeTo(output);
40-
41+
4142
StreamInput input = output.bytes().streamInput();
4243
RunStartedEvent deserialized = new RunStartedEvent(input);
43-
44+
4445
assertEquals("Type should match", original.getType(), deserialized.getType());
4546
assertEquals("Thread ID should match", original.getThreadId(), deserialized.getThreadId());
4647
assertEquals("Run ID should match", original.getRunId(), deserialized.getRunId());
@@ -50,9 +51,9 @@ public void testSerialization() throws IOException {
5051
@Test
5152
public void testToXContent() throws IOException {
5253
RunStartedEvent event = new RunStartedEvent("thread_xcontent", "run_xcontent");
53-
54+
5455
String json = event.toJsonString();
55-
56+
5657
assertNotNull("JSON should not be null", json);
5758
assertTrue("JSON should contain type", json.contains("\"type\":\"RUN_STARTED\""));
5859
assertTrue("JSON should contain threadId", json.contains("\"threadId\":\"thread_xcontent\""));
@@ -63,25 +64,24 @@ public void testToXContent() throws IOException {
6364
@Test
6465
public void testToJsonString() {
6566
RunStartedEvent event = new RunStartedEvent("thread_json", "run_json");
66-
67+
6768
String json = event.toJsonString();
68-
69+
6970
assertNotNull("JSON string should not be null", json);
7071
assertTrue("JSON should be valid", json.startsWith("{") && json.endsWith("}"));
71-
assertTrue("JSON should contain all fields",
72-
json.contains("type") && json.contains("threadId") && json.contains("runId"));
72+
assertTrue("JSON should contain all fields", json.contains("type") && json.contains("threadId") && json.contains("runId"));
7373
}
7474

7575
@Test
7676
public void testTimestampGeneration() throws InterruptedException {
7777
long before = System.currentTimeMillis();
7878
Thread.sleep(10); // Small delay to ensure different timestamps
79-
79+
8080
RunStartedEvent event = new RunStartedEvent("thread_time", "run_time");
81-
81+
8282
Thread.sleep(10);
8383
long after = System.currentTimeMillis();
84-
84+
8585
assertNotNull("Timestamp should be set", event.getTimestamp());
8686
assertTrue("Timestamp should be after 'before'", event.getTimestamp() >= before);
8787
assertTrue("Timestamp should be before 'after'", event.getTimestamp() <= after);

common/src/test/java/org/opensearch/ml/common/agui/TextMessageContentEventTests.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
import org.junit.Test;
1515
import org.opensearch.common.io.stream.BytesStreamOutput;
1616
import org.opensearch.core.common.io.stream.StreamInput;
17+
1718
public class TextMessageContentEventTests {
1819

1920
@Test
2021
public void testConstructor() {
2122
String messageId = "msg_123";
2223
String delta = "Hello, ";
23-
24+
2425
TextMessageContentEvent event = new TextMessageContentEvent(messageId, delta);
25-
26+
2627
assertNotNull("Event should not be null", event);
2728
assertEquals("Type should be TEXT_MESSAGE_CONTENT", "TEXT_MESSAGE_CONTENT", event.getType());
2829
assertEquals("Message ID should match", messageId, event.getMessageId());
@@ -33,13 +34,13 @@ public void testConstructor() {
3334
@Test
3435
public void testSerialization() throws IOException {
3536
TextMessageContentEvent original = new TextMessageContentEvent("msg_test", "world!");
36-
37+
3738
BytesStreamOutput output = new BytesStreamOutput();
3839
original.writeTo(output);
39-
40+
4041
StreamInput input = output.bytes().streamInput();
4142
TextMessageContentEvent deserialized = new TextMessageContentEvent(input);
42-
43+
4344
assertEquals("Type should match", original.getType(), deserialized.getType());
4445
assertEquals("Message ID should match", original.getMessageId(), deserialized.getMessageId());
4546
assertEquals("Delta should match", original.getDelta(), deserialized.getDelta());
@@ -49,9 +50,9 @@ public void testSerialization() throws IOException {
4950
@Test
5051
public void testToXContent() throws IOException {
5152
TextMessageContentEvent event = new TextMessageContentEvent("msg_xcontent", "test content");
52-
53+
5354
String json = event.toJsonString();
54-
55+
5556
assertNotNull("JSON should not be null", json);
5657
assertTrue("JSON should contain type", json.contains("\"type\":\"TEXT_MESSAGE_CONTENT\""));
5758
assertTrue("JSON should contain messageId", json.contains("\"messageId\":\"msg_xcontent\""));
@@ -62,9 +63,9 @@ public void testToXContent() throws IOException {
6263
@Test
6364
public void testToJsonString() {
6465
TextMessageContentEvent event = new TextMessageContentEvent("msg_json", "content");
65-
66+
6667
String json = event.toJsonString();
67-
68+
6869
assertNotNull("JSON string should not be null", json);
6970
assertTrue("JSON should be valid", json.startsWith("{") && json.endsWith("}"));
7071
}
@@ -74,18 +75,17 @@ public void testTimestampGeneration() {
7475
long before = System.currentTimeMillis();
7576
TextMessageContentEvent event = new TextMessageContentEvent("msg_time", "delta");
7677
long after = System.currentTimeMillis();
77-
78+
7879
assertNotNull("Timestamp should be set", event.getTimestamp());
79-
assertTrue("Timestamp should be in valid range",
80-
event.getTimestamp() >= before && event.getTimestamp() <= after);
80+
assertTrue("Timestamp should be in valid range", event.getTimestamp() >= before && event.getTimestamp() <= after);
8181
}
8282

8383
@Test
8484
public void testEmptyDelta() {
8585
TextMessageContentEvent event = new TextMessageContentEvent("msg_empty", "");
86-
86+
8787
assertEquals("Empty delta should be preserved", "", event.getDelta());
88-
88+
8989
String json = event.toJsonString();
9090
assertTrue("JSON should contain empty delta", json.contains("\"delta\":\"\""));
9191
}
@@ -94,7 +94,7 @@ public void testEmptyDelta() {
9494
public void testSpecialCharactersInDelta() {
9595
String specialChars = "Hello \"world\" with\nnewlines\tand\ttabs";
9696
TextMessageContentEvent event = new TextMessageContentEvent("msg_special", specialChars);
97-
97+
9898
assertEquals("Special characters should be preserved", specialChars, event.getDelta());
9999
}
100100
}

common/src/test/java/org/opensearch/ml/common/agui/TextMessageStartEventTests.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
import org.junit.Test;
1515
import org.opensearch.common.io.stream.BytesStreamOutput;
1616
import org.opensearch.core.common.io.stream.StreamInput;
17+
1718
public class TextMessageStartEventTests {
1819

1920
@Test
2021
public void testConstructor() {
2122
String messageId = "msg_123";
2223
String role = "assistant";
23-
24+
2425
TextMessageStartEvent event = new TextMessageStartEvent(messageId, role);
25-
26+
2627
assertNotNull("Event should not be null", event);
2728
assertEquals("Type should be TEXT_MESSAGE_START", "TEXT_MESSAGE_START", event.getType());
2829
assertEquals("Message ID should match", messageId, event.getMessageId());
@@ -33,13 +34,13 @@ public void testConstructor() {
3334
@Test
3435
public void testSerialization() throws IOException {
3536
TextMessageStartEvent original = new TextMessageStartEvent("msg_test", "assistant");
36-
37+
3738
BytesStreamOutput output = new BytesStreamOutput();
3839
original.writeTo(output);
39-
40+
4041
StreamInput input = output.bytes().streamInput();
4142
TextMessageStartEvent deserialized = new TextMessageStartEvent(input);
42-
43+
4344
assertEquals("Type should match", original.getType(), deserialized.getType());
4445
assertEquals("Message ID should match", original.getMessageId(), deserialized.getMessageId());
4546
assertEquals("Role should match", original.getRole(), deserialized.getRole());
@@ -49,9 +50,9 @@ public void testSerialization() throws IOException {
4950
@Test
5051
public void testToXContent() throws IOException {
5152
TextMessageStartEvent event = new TextMessageStartEvent("msg_xcontent", "assistant");
52-
53+
5354
String json = event.toJsonString();
54-
55+
5556
assertNotNull("JSON should not be null", json);
5657
assertTrue("JSON should contain type", json.contains("\"type\":\"TEXT_MESSAGE_START\""));
5758
assertTrue("JSON should contain messageId", json.contains("\"messageId\":\"msg_xcontent\""));
@@ -62,23 +63,21 @@ public void testToXContent() throws IOException {
6263
@Test
6364
public void testToJsonString() {
6465
TextMessageStartEvent event = new TextMessageStartEvent("msg_json", "user");
65-
66+
6667
String json = event.toJsonString();
67-
68+
6869
assertNotNull("JSON string should not be null", json);
6970
assertTrue("JSON should be valid", json.startsWith("{") && json.endsWith("}"));
70-
assertTrue("JSON should contain messageId and role",
71-
json.contains("messageId") && json.contains("role"));
71+
assertTrue("JSON should contain messageId and role", json.contains("messageId") && json.contains("role"));
7272
}
7373

7474
@Test
7575
public void testTimestampGeneration() {
7676
long before = System.currentTimeMillis();
7777
TextMessageStartEvent event = new TextMessageStartEvent("msg_time", "assistant");
7878
long after = System.currentTimeMillis();
79-
79+
8080
assertNotNull("Timestamp should be set", event.getTimestamp());
81-
assertTrue("Timestamp should be in valid range",
82-
event.getTimestamp() >= before && event.getTimestamp() <= after);
81+
assertTrue("Timestamp should be in valid range", event.getTimestamp() >= before && event.getTimestamp() <= after);
8382
}
8483
}

0 commit comments

Comments
 (0)