1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
package org.bukkit;
|
||||
|
||||
import static org.bukkit.support.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@org.junit.jupiter.api.Disabled // Paper
|
||||
public class BukkitMirrorTest {
|
||||
|
||||
public static Stream<Arguments> data() {
|
||||
return Stream.of(Server.class.getDeclaredMethods())
|
||||
.map(method -> {
|
||||
try {
|
||||
return Arguments.of(
|
||||
method,
|
||||
method.toGenericString().substring("public abstract ".length()).replace("(", "{").replace(")", "}"),
|
||||
Bukkit.class.getDeclaredMethod(method.getName(), method.getParameterTypes())
|
||||
);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void isStatic(Method server, String name, Method bukkit) throws Throwable {
|
||||
assertThat(Modifier.isStatic(bukkit.getModifiers()), is(true));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void isDeprecated(Method server, String name, Method bukkit) throws Throwable {
|
||||
assertThat(bukkit.isAnnotationPresent(Deprecated.class), is(server.isAnnotationPresent(Deprecated.class)));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void returnType(Method server, String name, Method bukkit) throws Throwable {
|
||||
assertThat(bukkit.getReturnType(), is((Object) server.getReturnType()));
|
||||
// assertThat(bukkit.getGenericReturnType(), is(server.getGenericReturnType())); // too strict on <T> type generics
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void parameterTypes(Method server, String name, Method bukkit) throws Throwable {
|
||||
// assertThat(bukkit.getGenericParameterTypes(), is(server.getGenericParameterTypes())); // too strict on <T> type generics
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void declaredException(Method server, String name, Method bukkit) throws Throwable {
|
||||
assertThat(bukkit.getGenericExceptionTypes(), is(server.getGenericExceptionTypes()));
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,6 @@ public class NamespacedKeyTest {
|
||||
assertNull(NamespacedKey.fromString("foo:bar:bazz"));
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Disabled // Paper - Fixup NamespacedKey handling
|
||||
@Test
|
||||
public void testFromStringEmptyInput() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NamespacedKey.fromString(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromStringNullInput() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NamespacedKey.fromString(null));
|
||||
@@ -75,12 +69,4 @@ public class NamespacedKeyTest {
|
||||
new NamespacedKey("loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas",
|
||||
"loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas").toString();
|
||||
}
|
||||
|
||||
@org.junit.jupiter.api.Disabled // Paper - Fixup NamespacedKey handling
|
||||
@Test
|
||||
public void testAboveLength() {
|
||||
assertThrows(IllegalArgumentException.class, () -> new NamespacedKey("loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas",
|
||||
"loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas/"
|
||||
+ "loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas").toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,46 +546,6 @@ public abstract class ConfigurationSectionTest {
|
||||
assertFalse(section.isVector("doesntExist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server")
|
||||
public void testGetItemStack_String() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
String key = "exists";
|
||||
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);
|
||||
|
||||
section.set(key, value);
|
||||
|
||||
assertEquals(value, section.getItemStack(key));
|
||||
assertNull(section.getString("doesntExist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server")
|
||||
public void testGetItemStack_String_ItemStack() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
String key = "exists";
|
||||
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);
|
||||
ItemStack def = new ItemStack(Material.STONE, 1);
|
||||
|
||||
section.set(key, value);
|
||||
|
||||
assertEquals(value, section.getItemStack(key, def));
|
||||
assertEquals(def, section.getItemStack("doesntExist", def));
|
||||
}
|
||||
|
||||
@Test
|
||||
@org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server")
|
||||
public void testIsItemStack() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
String key = "exists";
|
||||
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);
|
||||
|
||||
section.set(key, value);
|
||||
|
||||
assertTrue(section.isItemStack(key));
|
||||
assertFalse(section.isItemStack("doesntExist"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfigurationSection() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.bukkit.entity.memory;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MemoryKeyTest {
|
||||
|
||||
@Test
|
||||
public void shouldContainAllMemories() {
|
||||
List<MemoryKey> memories = Arrays.asList(MemoryKey.HOME, MemoryKey.JOB_SITE, MemoryKey.MEETING_POINT);
|
||||
assertTrue(MemoryKey.values().containsAll(memories));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetMemoryKeyHomeByNamespacedKey() {
|
||||
assertEquals(MemoryKey.HOME, MemoryKey.getByKey(NamespacedKey.minecraft("home")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetMemoryKeyJobSiteByNamespacedKey() {
|
||||
assertEquals(MemoryKey.JOB_SITE, MemoryKey.getByKey(NamespacedKey.minecraft("job_site")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetMemoryKeyMeetingPointByNamespacedKey() {
|
||||
assertEquals(MemoryKey.MEETING_POINT, MemoryKey.getByKey(NamespacedKey.minecraft("meeting_point")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnNullWhenNamespacedKeyisNotPresentAsMemoryKey() {
|
||||
assertNull(MemoryKey.getByKey(NamespacedKey.minecraft("not_present")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnNullWhenNamespacedKeyisNull() {
|
||||
assertNull(MemoryKey.getByKey(null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user