aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypointTest.java79
-rw-r--r--src/test/java/de/hysky/skyblocker/skyblock/filters/ComboFilterTest.java11
-rw-r--r--src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java38
-rw-r--r--src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java70
4 files changed, 195 insertions, 3 deletions
diff --git a/src/test/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypointTest.java b/src/test/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypointTest.java
new file mode 100644
index 00000000..0870e744
--- /dev/null
+++ b/src/test/java/de/hysky/skyblocker/skyblock/dungeon/secrets/SecretWaypointTest.java
@@ -0,0 +1,79 @@
+package de.hysky.skyblocker.skyblock.dungeon.secrets;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.mojang.serialization.JsonOps;
+import net.minecraft.util.math.BlockPos;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+public class SecretWaypointTest {
+ private final Gson gson = new Gson();
+
+ @Test
+ void testCodecSerialize() {
+ SecretWaypoint waypoint = new SecretWaypoint(0, SecretWaypoint.Category.DEFAULT, "name", BlockPos.ORIGIN);
+ JsonElement json = SecretWaypoint.CODEC.encodeStart(JsonOps.INSTANCE, waypoint).result().orElseThrow();
+ String expectedJson = "{\"secretIndex\":0,\"category\":\"default\",\"name\":{\"text\":\"name\"},\"pos\":[0,0,0]}";
+
+ Assertions.assertEquals(expectedJson, json.toString());
+ }
+
+ @Test
+ void testCodecDeserialize() {
+ String json = "{\"secretIndex\":0,\"category\":\"default\",\"name\":{\"text\":\"name\"},\"pos\":[0,0,0]}";
+ SecretWaypoint waypoint = SecretWaypoint.CODEC.parse(JsonOps.INSTANCE, gson.fromJson(json, JsonElement.class)).result().orElseThrow();
+ SecretWaypoint expectedWaypoint = new SecretWaypoint(0, SecretWaypoint.Category.DEFAULT, "name", BlockPos.ORIGIN);
+
+ equal(expectedWaypoint, waypoint);
+ }
+
+ @Test
+ void testListCodecSerialize() {
+ List<SecretWaypoint> waypoints = List.of(new SecretWaypoint(0, SecretWaypoint.Category.DEFAULT, "name", BlockPos.ORIGIN), new SecretWaypoint(1, SecretWaypoint.Category.CHEST, "name", new BlockPos(-1, 0, 1)));
+ JsonElement json = SecretWaypoint.LIST_CODEC.encodeStart(JsonOps.INSTANCE, waypoints).result().orElseThrow();
+ String expectedJson = "[{\"secretIndex\":0,\"category\":\"default\",\"name\":{\"text\":\"name\"},\"pos\":[0,0,0]},{\"secretIndex\":1,\"category\":\"chest\",\"name\":{\"text\":\"name\"},\"pos\":[-1,0,1]}]";
+
+ Assertions.assertEquals(expectedJson, json.toString());
+ }
+
+ @Test
+ void testListCodecDeserialize() {
+ String json = "[{\"secretIndex\":0,\"category\":\"default\",\"name\":{\"text\":\"name\"},\"pos\":[0,0,0]},{\"secretIndex\":1,\"category\":\"chest\",\"name\":{\"text\":\"name\"},\"pos\":[-1,0,1]}]";
+ List<SecretWaypoint> waypoints = SecretWaypoint.LIST_CODEC.parse(JsonOps.INSTANCE, gson.fromJson(json, JsonElement.class)).result().orElseThrow();
+ List<SecretWaypoint> expectedWaypoints = List.of(new SecretWaypoint(0, SecretWaypoint.Category.DEFAULT, "name", BlockPos.ORIGIN), new SecretWaypoint(1, SecretWaypoint.Category.CHEST, "name", new BlockPos(-1, 0, 1)));
+
+ Assertions.assertEquals(expectedWaypoints.size(), waypoints.size());
+ for (int i = 0; i < expectedWaypoints.size(); i++) {
+ SecretWaypoint expectedWaypoint = expectedWaypoints.get(i);
+ SecretWaypoint waypoint = waypoints.get(i);
+ equal(expectedWaypoint, waypoint);
+ }
+ }
+
+ @Test
+ void testGetCategory() {
+ JsonObject waypointJson = new JsonObject();
+ waypointJson.addProperty("category", "chest");
+ SecretWaypoint.Category category = SecretWaypoint.Category.get(waypointJson);
+ Assertions.assertEquals(SecretWaypoint.Category.CHEST, category);
+ }
+
+ @Test
+ void testGetCategoryDefault() {
+ JsonObject waypointJson = new JsonObject();
+ waypointJson.addProperty("category", "");
+ SecretWaypoint.Category category = SecretWaypoint.Category.get(waypointJson);
+ Assertions.assertEquals(SecretWaypoint.Category.DEFAULT, category);
+ }
+
+ private static void equal(SecretWaypoint expectedWaypoint, SecretWaypoint waypoint) {
+ Assertions.assertEquals(expectedWaypoint.secretIndex, waypoint.secretIndex);
+ Assertions.assertEquals(expectedWaypoint.category, waypoint.category);
+ Assertions.assertEquals(expectedWaypoint.name, waypoint.name);
+ Assertions.assertEquals(expectedWaypoint.pos, waypoint.pos);
+ }
+}
diff --git a/src/test/java/de/hysky/skyblocker/skyblock/filters/ComboFilterTest.java b/src/test/java/de/hysky/skyblocker/skyblock/filters/ComboFilterTest.java
index 85b01b4b..93d33070 100644
--- a/src/test/java/de/hysky/skyblocker/skyblock/filters/ComboFilterTest.java
+++ b/src/test/java/de/hysky/skyblocker/skyblock/filters/ComboFilterTest.java
@@ -9,7 +9,7 @@ public class ComboFilterTest extends ChatFilterTest<ComboFilter> {
@Test
void testComboMF() {
- assertMatches("+5 Kill Combo +3% ✯ Magic Find");
+ assertMatches("+5 Kill Combo +3✯ Magic Find");
}
@Test
@@ -18,8 +18,13 @@ public class ComboFilterTest extends ChatFilterTest<ComboFilter> {
}
@Test
- void testComboEXP() {
- assertMatches("+20 Kill Combo +15% Combat Exp");
+ void testComboWisdom() {
+ assertMatches("+20 Kill Combo +15☯ Combat Wisdom");
+ }
+
+ @Test
+ void testComboNoBonus() {
+ assertMatches("+50 Kill Combo");
}
@Test
diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java
new file mode 100644
index 00000000..9dc5b2b9
--- /dev/null
+++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/ProfileAwareWaypointTest.java
@@ -0,0 +1,38 @@
+package de.hysky.skyblocker.utils.waypoint;
+
+import net.minecraft.util.math.BlockPos;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class ProfileAwareWaypointTest {
+ @Test
+ void testShouldRender() {
+ ProfileAwareWaypoint waypoint = new ProfileAwareWaypoint(BlockPos.ORIGIN, null, null, null);
+ waypoint.setFound("profile");
+ Assertions.assertTrue(waypoint.shouldRender());
+ waypoint.setFound("");
+ Assertions.assertFalse(waypoint.shouldRender());
+ waypoint.setMissing();
+ Assertions.assertTrue(waypoint.shouldRender());
+ }
+
+ @Test
+ void testGetColorComponents() {
+ ProfileAwareWaypoint waypoint = new ProfileAwareWaypoint(BlockPos.ORIGIN, null, new float[]{0f, 0.5f, 1f}, new float[]{1f, 0.5f, 0f});
+ waypoint.setFound("profile");
+ float[] colorComponents = waypoint.getColorComponents();
+ Assertions.assertEquals(0f, colorComponents[0]);
+ Assertions.assertEquals(0.5f, colorComponents[1]);
+ Assertions.assertEquals(1f, colorComponents[2]);
+ waypoint.setFound("");
+ colorComponents = waypoint.getColorComponents();
+ Assertions.assertEquals(1f, colorComponents[0]);
+ Assertions.assertEquals(0.5f, colorComponents[1]);
+ Assertions.assertEquals(0f, colorComponents[2]);
+ waypoint.setMissing();
+ colorComponents = waypoint.getColorComponents();
+ Assertions.assertEquals(0f, colorComponents[0]);
+ Assertions.assertEquals(0.5f, colorComponents[1]);
+ Assertions.assertEquals(1f, colorComponents[2]);
+ }
+}
diff --git a/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java
new file mode 100644
index 00000000..d8839951
--- /dev/null
+++ b/src/test/java/de/hysky/skyblocker/utils/waypoint/WaypointTest.java
@@ -0,0 +1,70 @@
+package de.hysky.skyblocker.utils.waypoint;
+
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Box;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class WaypointTest {
+ private Waypoint.Type type;
+ private final float[] colorComponents = new float[]{0f, 0.5f, 1f};
+
+ @Test
+ void testDefaultConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents);
+ Assertions.assertEquals(BlockPos.ORIGIN, waypoint.pos);
+ Assertions.assertEquals(new Box(BlockPos.ORIGIN), waypoint.box);
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ Assertions.assertEquals(0f, waypoint.colorComponents[0]);
+ Assertions.assertEquals(0.5f, waypoint.colorComponents[1]);
+ Assertions.assertEquals(1f, waypoint.colorComponents[2]);
+ Assertions.assertEquals(Waypoint.DEFAULT_HIGHLIGHT_ALPHA, waypoint.alpha);
+ Assertions.assertEquals(Waypoint.DEFAULT_LINE_WIDTH, waypoint.lineWidth);
+ Assertions.assertTrue(waypoint.throughWalls);
+ Assertions.assertTrue(waypoint.shouldRender());
+ }
+
+ @Test
+ void testTypeConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, Waypoint.Type.WAYPOINT, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA);
+ Assertions.assertEquals(Waypoint.Type.WAYPOINT, waypoint.typeSupplier.get());
+ }
+
+ @Test
+ void testLineWidthConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, 10f);
+ Assertions.assertEquals(10f, waypoint.lineWidth);
+ }
+
+ @Test
+ void testThroughWallsConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, false);
+ Assertions.assertFalse(waypoint.throughWalls);
+ }
+
+ @Test
+ void testShouldRenderConstructor() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents, Waypoint.DEFAULT_HIGHLIGHT_ALPHA, Waypoint.DEFAULT_LINE_WIDTH, true, false);
+ Assertions.assertFalse(waypoint.shouldRender());
+ }
+
+ @Test
+ void testFound() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents);
+ Assertions.assertTrue(waypoint.shouldRender());
+ waypoint.setFound();
+ Assertions.assertFalse(waypoint.shouldRender());
+ waypoint.setMissing();
+ Assertions.assertTrue(waypoint.shouldRender());
+ }
+
+ @Test
+ void testType() {
+ Waypoint waypoint = new Waypoint(BlockPos.ORIGIN, () -> type, colorComponents);
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ type = Waypoint.Type.WAYPOINT;
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ type = Waypoint.Type.OUTLINED_HIGHLIGHT;
+ Assertions.assertEquals(type, waypoint.typeSupplier.get());
+ }
+}