Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
md5sha256 committed Jan 1, 2025
1 parent 7fcb032 commit 1d51eef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public DrugPlantData fromBytes(byte[] bytes) {
final ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
final ConfigurationLoader<?> loader = loader(bos);
final ConfigurationNode node = loader.createNode();
final List<DrugPlantData> dataAsList;
try {
node.set(DrugPlantData.class, data);
loader.save(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockbukkit.mockbukkit.MockBukkit;
import org.mockbukkit.mockbukkit.ServerMock;
import org.mockbukkit.mockbukkit.world.WorldMock;

import java.util.Collection;
Expand All @@ -30,13 +31,16 @@

public class TestPDCResolver {

private static ServerMock mock;

@BeforeAll
public static void init() {
MockBukkit.mock();
mock = MockBukkit.mock();
}

@AfterAll
public static void teardown() {
mock = null;
MockBukkit.unmock();
}

Expand All @@ -51,7 +55,7 @@ public void testPDCResolver() {
"",
new DummyDrugForm(Bukkit.getItemFactory()));
drugRegistry.registerComponent(drug);
World world = new WorldMock();
World world = mock.addSimpleWorld("test");
Chunk chunk = world.getChunkAt(0, 0);
PlantDataResolver resolver = new PDCResolver(plugin, drugRegistry);
ChunkPosition chunkPosition = new ChunkPosition(chunk);
Expand All @@ -64,6 +68,7 @@ public void testPDCResolver() {
Collection<DrugPlantData> collection = Collections.singleton(data);
resolver.saveData(chunkPosition, collection);
Collection<DrugPlantData> loaded = resolver.loadData(chunkPosition).values();
Assertions.assertEquals(1, loaded.size());
DrugPlantData deserialized = loaded.iterator().next();
data.elapsed().stop();
deserialized.elapsed().stop();
Expand Down

0 comments on commit 1d51eef

Please sign in to comment.