blob: 883f5081839c38063c86d725c4681d3b60323c83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
package org.bukkit;
import java.util.Map;
import java.util.TreeMap;
import net.minecraft.server.GameRules;
import org.junit.Assert;
import org.junit.Test;
public class GameRuleTest {
@Test
public void testBukkitRules() {
GameRule<?>[] rules = GameRule.values();
for (GameRule<?> rule : rules) {
GameRule<?> registeredRule = GameRule.getByName(rule.getName());
Assert.assertNotNull("Null GameRule", registeredRule);
Assert.assertEquals("Invalid GameRule equality", rule, registeredRule);
}
}
@Test
public void testMinecraftRules() {
TreeMap<String, GameRules.b> minecraftRules = GameRules.getGameRules();
for (Map.Entry<String, GameRules.b> entry : minecraftRules.entrySet()) {
GameRule<?> bukkitRule = GameRule.getByName(entry.getKey());
Assert.assertNotNull(bukkitRule);
Assert.assertEquals("Invalid GameRule Name", bukkitRule.getName(), entry.getKey());
}
}
@Test(expected = NullPointerException.class)
public void nullGameRuleName() {
GameRule.getByName(null);
}
@Test
public void emptyGameRuleName() {
Assert.assertNull(GameRule.getByName(""));
}
@Test
public void incorrectGameRuleName() {
Assert.assertNull(GameRule.getByName("doAnnounceAdvancements"));
Assert.assertNull(GameRule.getByName("sendCommandBlockFeedback"));
}
@Test
public void invalidCasing() {
Assert.assertNull(GameRule.getByName("CommandBlockOutput"));
Assert.assertNull(GameRule.getByName("spAwnRadius"));
Assert.assertNull(GameRule.getByName("rand0mTickSpeEd"));
}
}
|