eff = reg.getEffects();
if (eff.size() != 1) continue;
PotionEffectType type = CraftPotionEffectType.minecraftToBukkit(eff.get(0).getEffect());
- assertNotNull(String.valueOf(reg), type);
+ assertNotNull(type, String.valueOf(reg));
PotionType enumType = PotionType.getByEffect(type);
- assertNotNull(type.getName(), enumType);
+ assertNotNull(enumType, type.getName());
effects.put(enumType, enumType.name());
}
@@ -39,11 +39,11 @@ public class PotionTest extends AbstractTestingBase {
PotionEffectType bukkit = CraftPotionEffectType.minecraftToBukkit(nms);
- assertNotNull("No Bukkit type for " + key, bukkit);
- assertFalse("No name for " + key, bukkit.getName().contains("UNKNOWN"));
+ assertNotNull(bukkit, "No Bukkit type for " + key);
+ assertFalse(bukkit.getName().contains("UNKNOWN"), "No name for " + key);
PotionEffectType byName = PotionEffectType.getByName(bukkit.getName());
- assertEquals("Same type not returned by name " + key, bukkit, byName);
+ assertEquals(bukkit, byName, "Same type not returned by name " + key);
}
}
}
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
index ecfac636c..777d41856 100644
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
@@ -1,5 +1,6 @@
package org.bukkit.support;
+import static org.junit.jupiter.api.Assertions.*;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.List;
@@ -24,7 +25,6 @@ import net.minecraft.world.level.biome.BiomeBase;
import org.bukkit.Material;
import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
-import org.junit.Assert;
/**
* If you are getting: java.lang.ExceptionInInitializerError
@@ -73,6 +73,6 @@ public abstract class AbstractTestingBase {
}
}
INVALIDATED_MATERIALS = builder.build();
- Assert.assertEquals("Expected 610 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 610, INVALIDATED_MATERIALS.size());
+ assertEquals(610, INVALIDATED_MATERIALS.size(), "Expected 610 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")");
}
}
diff --git a/src/test/java/org/bukkit/support/MatcherAssert.java b/src/test/java/org/bukkit/support/MatcherAssert.java
new file mode 100644
index 000000000..b100262e8
--- /dev/null
+++ b/src/test/java/org/bukkit/support/MatcherAssert.java
@@ -0,0 +1,36 @@
+package org.bukkit.support;
+
+import org.hamcrest.Matcher;
+
+/**
+ * Custom assertThat methods, where the reason is put at the end of the method call.
+ * To better match with JUnit 5 argument order and also help with readability for longer reasons.
+ *
+ *
+ * assertThat(String.format("""
+ * The block data created for the material %s is not an instance of the data class from that material.
+ * """, material), blockData, is(instanceOf(expectedClass)));
+ *
+ * vs.
+ *
+ * assertThat(blockData, is(instanceOf(expectedClass)), String.format("""
+ * The block data created for the material %s is not an instance of the data class from that material.
+ * """, material));
+ *
+ */
+public final class MatcherAssert {
+
+ private MatcherAssert() {}
+
+ public static void assertThat(T actual, Matcher super T> matcher) {
+ org.hamcrest.MatcherAssert.assertThat(actual, matcher);
+ }
+
+ public static void assertThat(T actual, Matcher super T> matcher, String reason) {
+ org.hamcrest.MatcherAssert.assertThat(reason, actual, matcher);
+ }
+
+ public static void assertThat(boolean assertion, String reason) {
+ org.hamcrest.MatcherAssert.assertThat(reason, assertion);
+ }
+}