From c42b0c0798b24936fd41381c2b1c4336e38d1904 Mon Sep 17 00:00:00 2001 From: Steveplays28 Date: Thu, 14 Mar 2024 22:47:55 +0100 Subject: [PATCH] fix: Mock server player `connection` --- .../test/common/server/MixinServerPlayerTest.java | 14 ++++++++++++++ .../mixin/test/common/server/package-info.java | 7 +++++++ .../test/server/level/TestServerPlayer.java | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/MixinServerPlayerTest.java create mode 100644 src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/package-info.java diff --git a/src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/MixinServerPlayerTest.java b/src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/MixinServerPlayerTest.java new file mode 100644 index 00000000..29db72fb --- /dev/null +++ b/src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/MixinServerPlayerTest.java @@ -0,0 +1,14 @@ +package io.github.opencubicchunks.cubicchunks.mixin.test.common.server; + +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import org.mockito.Mockito; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(ServerPlayer.class) +public class MixinServerPlayerTest { + @Shadow + @SuppressWarnings("unused") + public ServerGamePacketListenerImpl connection = Mockito.mock(); +} diff --git a/src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/package-info.java b/src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/package-info.java new file mode 100644 index 00000000..51b30a2f --- /dev/null +++ b/src/test/java/io/github/opencubicchunks/cubicchunks/mixin/test/common/server/package-info.java @@ -0,0 +1,7 @@ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package io.github.opencubicchunks.cubicchunks.mixin.test.common.server; + +import javax.annotation.ParametersAreNonnullByDefault; + +import io.github.opencubicchunks.cc_core.annotation.MethodsReturnNonnullByDefault; diff --git a/src/test/java/io/github/opencubicchunks/cubicchunks/test/server/level/TestServerPlayer.java b/src/test/java/io/github/opencubicchunks/cubicchunks/test/server/level/TestServerPlayer.java index c6b9e20d..b2e81322 100644 --- a/src/test/java/io/github/opencubicchunks/cubicchunks/test/server/level/TestServerPlayer.java +++ b/src/test/java/io/github/opencubicchunks/cubicchunks/test/server/level/TestServerPlayer.java @@ -28,7 +28,7 @@ private ServerPlayer setupServerPlayer(ServerLevel serverLevel) { return new ServerPlayer(mock(RETURNS_DEEP_STUBS), serverLevel, mock(RETURNS_DEEP_STUBS), mock(RETURNS_DEEP_STUBS)); } - // TODO: Stub. This test needs a network connection to work. + // TODO: Stub. Test fails. @Disabled @Test public void testTeleportToVanilla() throws Exception { try (CloseableReference serverLevelReference = setupServerLevel()) { ServerPlayer player = setupServerPlayer(serverLevelReference.value());