Run Spotless on src/test

This commit is contained in:
KingRainbow44 2023-03-31 22:34:19 -04:00
parent 6d9a81ba1c
commit e636fda14f
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -1,67 +1,60 @@
package io.grasscutter; package io.grasscutter;
import com.mchange.util.AssertException; import com.mchange.util.AssertException;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.config.Configuration; import emu.grasscutter.config.Configuration;
import lombok.Getter; import java.io.IOException;
import okhttp3.OkHttpClient; import lombok.Getter;
import okhttp3.Request; import okhttp3.OkHttpClient;
import org.junit.jupiter.api.Assertions; import okhttp3.Request;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
/** Testing entrypoint for {@link Grasscutter}. */
/** public final class GrasscutterTest {
* Testing entrypoint for {@link Grasscutter}. @Getter private static final OkHttpClient httpClient = new OkHttpClient();
*/
public final class GrasscutterTest { @Getter private static int httpPort = -1;
@Getter private static final OkHttpClient httpClient @Getter private static int gamePort = -1;
= new OkHttpClient();
/**
@Getter private static int httpPort = -1; * Creates an HTTP URL.
@Getter private static int gamePort = -1; *
* @param route The route to use.
/** * @return The URL.
* Creates an HTTP URL. */
* public static String http(String route) {
* @param route The route to use. return "http://127.0.0.1:" + GrasscutterTest.httpPort + "/" + route;
* @return The URL. }
*/
public static String http(String route) { @BeforeAll
return "http://127.0.0.1:" + GrasscutterTest.httpPort + "/" + route; public static void main() {
} try {
// Start Grasscutter.
@BeforeAll Grasscutter.main(new String[] {"-test"});
public static void main() { } catch (Exception ignored) {
try { throw new AssertException("Grasscutter failed to start.");
// Start Grasscutter. }
Grasscutter.main(new String[]{"-test"});
} catch (Exception ignored) { // Set the ports.
throw new AssertException("Grasscutter failed to start."); GrasscutterTest.httpPort = Configuration.SERVER.http.bindPort;
} GrasscutterTest.gamePort = Configuration.SERVER.game.bindPort;
}
// Set the ports.
GrasscutterTest.httpPort = Configuration.SERVER.http.bindPort; @Test
GrasscutterTest.gamePort = Configuration.SERVER.game.bindPort; @DisplayName("HTTP server check")
} public void checkHttpServer() {
// Create a request.
@Test var request = new Request.Builder().url(GrasscutterTest.http("")).build();
@DisplayName("HTTP server check")
public void checkHttpServer() { // Perform the request.
// Create a request. try (var response = GrasscutterTest.httpClient.newCall(request).execute()) {
var request = new Request.Builder() // Check the response.
.url(GrasscutterTest.http("")) Assertions.assertTrue(response.isSuccessful());
.build(); } catch (IOException exception) {
throw new AssertionError(exception);
// Perform the request. }
try (var response = GrasscutterTest.httpClient }
.newCall(request).execute()) { }
// Check the response.
Assertions.assertTrue(response.isSuccessful());
} catch (IOException exception) {
throw new AssertionError(exception);
}
}
}