Skip to content

Commit 79194ad

Browse files
committed
delete comments
1 parent a75a2ed commit 79194ad

1 file changed

Lines changed: 9 additions & 27 deletions

File tree

src/test/java/ServerAPITest.java

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import io.swagger.v3.core.util.Json;
2-
import org.json.JSONArray; // Add this import
3-
import org.json.JSONObject; // Add this import
2+
import org.json.JSONArray;
3+
import org.json.JSONObject;
44
import org.junit.jupiter.api.DisplayName;
55
import org.junit.jupiter.api.Test;
66

77
import java.io.IOException;
88
import java.net.HttpURLConnection;
99

10-
import static org.junit.jupiter.api.Assertions.assertEquals; // Add this import
11-
import static org.junit.jupiter.api.Assertions.assertTrue; // Add this import
12-
import static org.junit.jupiter.api.Assertions.assertNotNull; // Add this import
10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
import static org.junit.jupiter.api.Assertions.assertTrue;
12+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1313

1414
public class ServerAPITest extends ApiTestHelper {
1515
@Test
@@ -159,13 +159,12 @@ public void testServerLogEndpoint() throws IOException {
159159

160160
@Test
161161
void testExecMultipleCommands() throws Exception {
162-
// Prepare JSON payload
163162
JSONObject payload = new JSONObject();
164163
JSONArray commands = new JSONArray();
165164
commands.put("say Hello from testExecMultipleCommands1");
166165
commands.put("time set day");
167-
commands.put("nonexistentcommandtest"); // A command expected to fail
168-
commands.put(""); // An empty command
166+
commands.put("nonexistentcommandtest");
167+
commands.put("");
169168
payload.put("commands", commands);
170169

171170
// Perform POST request
@@ -184,36 +183,19 @@ void testExecMultipleCommands() throws Exception {
184183
JSONObject result1 = resultsArray.getJSONObject(0);
185184
assertEquals("say Hello from testExecMultipleCommands1", result1.getString("command"));
186185
assertTrue(result1.getBoolean("success"));
187-
// Output for 'say' command can vary, so we check if it's not empty or if it contains a known part.
188-
// For testing purposes, we'll assume it contains the message.
189-
// Depending on server setup, 'say' might not produce direct string output here in the same way console commands do.
190-
// If Bukkit.dispatchCommand for 'say' doesn't populate outputCapture in this test environment, this might need adjustment.
191-
// For now, let's assume it might be empty or specific.
192-
//assertTrue(result1.getString("output").contains("Hello from testExecMultipleCommands1") || result1.getString("output").isEmpty());
193-
194186

195187
// Command 2: time set day
196188
JSONObject result2 = resultsArray.getJSONObject(1);
197189
assertEquals("time set day", result2.getString("command"));
198190
assertTrue(result2.getBoolean("success"));
199-
// Similar to 'say', 'time set day' output might be minimal or environment-dependent.
200-
//assertTrue(result2.getString("output").contains("Set the time to") || result2.getString("output").isEmpty());
201-
202-
191+
203192
// Command 3: nonexistentcommandtest
204193
JSONObject result3 = resultsArray.getJSONObject(2);
205194
assertEquals("nonexistentcommandtest", result3.getString("command"));
206-
// This depends on how the server handles unknown commands.
207-
// Bukkit.dispatchCommand usually returns false for unknown commands.
208-
// assertTrue(!result3.getBoolean("success")); // This might be true or false depending on server behavior for unknown commands.
209-
// The output usually contains "Unknown command".
210-
// assertTrue(result3.getString("output").toLowerCase().contains("unknown command"));
211-
212195

213196
// Command 4: Empty command
214197
JSONObject result4 = resultsArray.getJSONObject(3);
215-
//assertEquals(JSONObject.NULL, result4.get("command")); // This was in the plan, but JSONObject.NULL might not be directly comparable like this.
216-
// Let's check for the output message instead.
198+
217199
assertTrue(result4.isNull("command") || "".equals(result4.optString("command"))); // Check if command is null or empty string
218200
assertEquals(false, result4.getBoolean("success"));
219201
assertEquals("Empty command string provided.", result4.getString("output"));

0 commit comments

Comments
 (0)