Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing for registry lists #6871

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Towny/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@
<version>21.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.20</artifactId>
<version>3.17.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.Registry;
import org.bukkit.Tag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.VisibleForTesting;
import java.util.Collection;
import java.util.HashSet;
import java.util.Locale;
Expand Down Expand Up @@ -45,6 +46,11 @@ public boolean contains(@NotNull String element) {
final T matched = BukkitTools.matchRegistry(this.registry, element);
return matched != null && this.contains(matched);
}

@VisibleForTesting
public Collection<T> tagged() {
return this.tagged;
}

@SuppressWarnings("unused")
public static class Builder<T extends Keyed, F extends AbstractRegistryList<T>> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.palmergames.bukkit.towny.test;

import be.seeseemelk.mockbukkit.MockBukkit;
import com.palmergames.bukkit.util.ItemLists;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class RegistryListTests {

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

@Test
void testListAdd() {
ItemLists itemList = ItemLists.newBuilder().add("stone").build();
assertEquals(1, itemList.tagged().size());
}
}