Skip to content

Commit

Permalink
Fix tests on recent Bukkit
Browse files Browse the repository at this point in the history
This is a mess, lucky it works at all.
  • Loading branch information
Jikoo committed Oct 9, 2023
1 parent 4eb818f commit c421eed
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.when;

import com.github.jikoo.planarwrappers.config.impl.BooleanSetting;
Expand Down Expand Up @@ -65,7 +64,6 @@ class SettingTest {
@BeforeAll
void beforeAll() {
Server server = ServerMocks.newServer();
when(server.getRegistry(notNull())).thenReturn(null);
when(server.getTag(Tag.REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class))
.thenReturn(new Tag<>() {
private final Set<Material> materials = Set.of(Material.CRIMSON_WALL_SIGN, Material.WARPED_WALL_SIGN);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.github.jikoo.planarwrappers.mock;

import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.lang.reflect.Field;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Registry;
import org.bukkit.Server;
import org.jetbrains.annotations.NotNull;
import org.mockito.ArgumentMatchers;

public final class ServerMocks {

Expand All @@ -18,6 +21,8 @@ public final class ServerMocks {
when(mock.getLogger()).thenReturn(noOp);
when(mock.isPrimaryThread()).thenReturn(true);

doAnswer(invocation -> mock(Registry.class)).when(mock).getRegistry(ArgumentMatchers.notNull());

return mock;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.when;

import com.github.jikoo.planarwrappers.mock.ServerMocks;
Expand All @@ -30,7 +29,6 @@ class StringConvertersTest {
@BeforeAll
void beforeAll() {
Server server = ServerMocks.newServer();
when(server.getRegistry(notNull())).thenReturn(null);
when(server.getTag(Tag.REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class))
.thenReturn(new Tag<>() {
private final Set<Material> materials = Set.of(Material.CRIMSON_WALL_SIGN, Material.WARPED_WALL_SIGN);
Expand Down

0 comments on commit c421eed

Please sign in to comment.