Skip to content
Merged
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
32 changes: 16 additions & 16 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion bazel/java.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ maven.install(
"io.netty:netty-transport",
"io.sentry:sentry-logback:8.34.1",
"jakarta.annotation:jakarta.annotation-api:3.0.0",
"junit:junit:4.13.2",
"org.junit.jupiter:junit-jupiter-api",
"org.junit.jupiter:junit-jupiter-engine",
"org.junit.jupiter:junit-jupiter-params",
"org.junit.platform:junit-platform-launcher",
"org.junit.platform:junit-platform-reporting",
"org.assertj:assertj-core:3.27.7",
"org.eclipse.jetty:jetty-server:%s" % JETTY_VERSION,
"org.eclipse.jetty.websocket:websocket-jetty-server:%s" % JETTY_VERSION,
Expand All @@ -66,9 +70,11 @@ maven.install(
"io.micronaut.jaxrs:micronaut-jaxrs-bom:4.10.0",
"io.micronaut.validation:micronaut-validation-bom:4.12.0",
"com.fasterxml.jackson:jackson-bom:2.21.0",
"org.junit:junit-bom:6.0.3",
],
generate_compat_repositories = True,
known_contributing_modules = [
"",
"moon-base",
"protobuf",
],
Expand Down
23 changes: 22 additions & 1 deletion bazel/rules/java.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,28 @@ load("@rules_java//java:defs.bzl", _java_binary = "java_binary", _java_library =
load("@rules_jvm_external//:defs.bzl", _artifact = "artifact")

artifact = _artifact
java_test_suite = _java_test_suite

_JUNIT_RUNTIME_DEPS = [
_artifact("org.junit.jupiter:junit-jupiter-engine"),
_artifact("org.junit.platform:junit-platform-launcher"),
_artifact("org.junit.platform:junit-platform-reporting"),
]

def java_test_suite(runner = "junit5", runtime_deps = [], **kwargs):
"""java_test_suite defaulting to JUnit 5 (Jupiter).

Automatically adds JUnit Jupiter engine and platform runtime deps.

Args:
runner: Test runner to use. Defaults to "junit5".
runtime_deps: Additional runtime dependencies.
**kwargs: Arguments passed to java_test_suite.
"""
_java_test_suite(
runner = runner,
runtime_deps = runtime_deps + _JUNIT_RUNTIME_DEPS,
**kwargs
)

_NULLAWAY_PLUGIN = "//bazel/rules:nullaway"

Expand Down
2 changes: 1 addition & 1 deletion domains/games/apis/mcpserver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ java_test_suite(
":tools",
"//domains/games/libs/chess_com_client",
"//domains/platform/libs/json",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ChessComGamesToolTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ChessComPlayerToolTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.muchq.platform.json.JsonUtils;
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ChessComStatsToolTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.time.Instant;
import java.time.ZoneId;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ServerTimeToolTest {
private static final Instant FIXED_INSTANT = Instant.parse("2024-01-15T10:30:45.123Z");
Expand Down
24 changes: 12 additions & 12 deletions domains/games/apis/one_d4/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ java_test_suite(
":engine",
":model",
":motifs",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Expand All @@ -284,7 +284,7 @@ java_test_suite(
deps = [
":model",
":motifs",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Expand All @@ -299,7 +299,7 @@ java_test_suite(
":engine",
":model",
":motifs",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Expand All @@ -310,7 +310,7 @@ java_test_suite(
srcs = ["src/test/java/com/muchq/games/one_d4/queue/InMemoryIndexQueueTest.java"],
deps = [
":queue",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Expand All @@ -336,7 +336,7 @@ java_test_suite(
"//domains/games/libs/chessql:compiler",
"//domains/games/libs/chessql:parser",
artifact("com.fasterxml.jackson.core:jackson-databind"),
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
artifact("org.jdbi:jdbi3-core"),
],
Expand All @@ -361,7 +361,7 @@ java_test_suite(
":queue",
"//domains/games/libs/chessql:compiler",
"//domains/games/libs/chessql:parser",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Expand All @@ -374,7 +374,7 @@ java_test_suite(
],
deps = [
":module",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Expand All @@ -395,7 +395,7 @@ java_test_suite(
":test_db",
"//domains/games/libs/chessql:compiler",
"//domains/games/libs/chessql:parser",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
artifact("org.jdbi:jdbi3-core"),
],
Expand Down Expand Up @@ -453,7 +453,7 @@ java_test_suite(
artifact("io.micronaut:micronaut-http-server-netty"),
artifact("io.micronaut:micronaut-inject"),
artifact("io.micronaut:micronaut-runtime"),
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Expand Down Expand Up @@ -481,7 +481,7 @@ java_test_suite(
"//domains/games/libs/chessql:compiler",
"//domains/games/libs/chessql:parser",
artifact("com.fasterxml.jackson.core:jackson-databind"),
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
artifact("org.jdbi:jdbi3-core"),
],
Expand All @@ -500,7 +500,7 @@ java_test_suite(
":test_db",
"//domains/games/libs/chessql:compiler",
"//domains/games/libs/chessql:parser",
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
artifact("org.jdbi:jdbi3-core"),
],
Expand All @@ -522,7 +522,7 @@ java_test_suite(
artifact("io.micronaut:micronaut-http-server-netty"),
artifact("io.micronaut:micronaut-inject"),
artifact("io.micronaut:micronaut-runtime"),
artifact("junit:junit"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class IndexerModuleTest {

@Rule public TemporaryFolder tmp = new TemporaryFolder();
@TempDir Path tmp;

@Test
public void readJdbcUrl_returnsEnvVar_whenSet() {
Expand All @@ -35,7 +34,7 @@ public void readJdbcUrl_ignoresBlankEnvVar() {

@Test
public void readJdbcUrl_ignoresNullEnvVar_andReadsFile() throws IOException {
Path configFile = tmp.newFile("db_config").toPath();
Path configFile = Files.createFile(tmp.resolve("db_config"));
Files.writeString(configFile, "jdbc:postgresql://file-host:5432/chess\n");

String result = IndexerModule.readJdbcUrl(null, configFile);
Expand All @@ -50,7 +49,7 @@ public void readJdbcUrl_returnsDefault_whenFileIsMissing() {

@Test
public void readJdbcUrl_returnsDefault_whenFileIsEmpty() throws IOException {
Path configFile = tmp.newFile("db_config_empty").toPath();
Path configFile = Files.createFile(tmp.resolve("db_config_empty"));
Files.writeString(configFile, " ");

String result = IndexerModule.readJdbcUrl(null, configFile);
Expand All @@ -59,7 +58,7 @@ public void readJdbcUrl_returnsDefault_whenFileIsEmpty() throws IOException {

@Test
public void readJdbcUrl_envVarTakesPrecedenceOverFile() throws IOException {
Path configFile = tmp.newFile("db_config_precedence").toPath();
Path configFile = Files.createFile(tmp.resolve("db_config_precedence"));
Files.writeString(configFile, "jdbc:postgresql://file-host/db");

String result = IndexerModule.readJdbcUrl("jdbc:postgresql://env-host/db", configFile);
Expand All @@ -69,7 +68,7 @@ public void readJdbcUrl_envVarTakesPrecedenceOverFile() throws IOException {
@Test
public void readJdbcUrl_throwsUncheckedIOException_onNonFileNotFoundIOError() {
// A directory path will cause an IOException (not NoSuchFileException) when read as a file
Path dirPath = tmp.getRoot().toPath();
Path dirPath = tmp;

assertThatThrownBy(() -> IndexerModule.readJdbcUrl(null, dirPath))
.isInstanceOf(UncheckedIOException.class)
Expand Down Expand Up @@ -104,6 +103,6 @@ public void parseThreads_respectsValidValue() {
}

private Path missingPath() {
return tmp.getRoot().toPath().resolve("nonexistent_db_config");
return tmp.resolve("nonexistent_db_config");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class AdminControllerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ContentTypeHandlingTest {

private EmbeddedServer server;
private HttpClient client;
private String baseUrl;

@Before
@BeforeEach
public void setUp() {
server =
ApplicationContext.run(
Expand All @@ -33,7 +33,7 @@ public void setUp() {
baseUrl = "http://localhost:" + server.getPort();
}

@After
@AfterEach
public void tearDown() {
server.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
import java.util.Optional;
import java.util.UUID;
import java.util.stream.IntStream;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class IndexControllerTest {

private IndexController controller;
private FakeIndexingRequestStore requestStore;
private FakeIndexQueue queue;

@Before
@BeforeEach
public void setUp() {
requestStore = new FakeIndexingRequestStore();
queue = new FakeIndexQueue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.muchq.games.one_d4.api.dto.IndexRequest;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class IndexRequestValidatorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class QueryControllerTest {

private QueryController controller;
private FakeGameFeatureStore store;

@Before
@BeforeEach
public void setUp() {
store = new FakeGameFeatureStore();
controller = new QueryController(store, new SqlCompiler(), new QueryRequestValidator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.muchq.games.one_d4.api.dto.QueryRequest;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class QueryRequestValidatorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Contract test: verifies that {@link DataFusionSqlCompiler} produces SQL that returns the same
Expand All @@ -34,7 +34,7 @@ public class DataFusionContractTest {
private final DataFusionSqlCompiler dfCompiler = new DataFusionSqlCompiler();
private UUID requestId;

@Before
@BeforeEach
public void setUp() {
TestDb testDb = TestDb.create("df_contract");

Expand Down
Loading
Loading