Add additional checkstyle checks

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2020-01-24 17:37:30 +11:00
parent 78e6909f8c
commit 0c53c95293
35 changed files with 227 additions and 202 deletions

View File

@@ -50,9 +50,34 @@
<module name="RedundantImport"/> <module name="RedundantImport"/>
<module name="UnusedImports"/> <module name="UnusedImports"/>
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoLineWrap"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore">
<property name="allowLineBreaks" value="true"/>
</module>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="SingleSpaceSeparator"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="allowEmptyCatches" value="true"/>
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
</module>
<!-- See http://checkstyle.sourceforge.net/config_modifiers.html --> <!-- See http://checkstyle.sourceforge.net/config_modifiers.html -->
<module name="ModifierOrder"/> <module name="ModifierOrder"/>
<!-- See https://checkstyle.org/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<!-- See http://checkstyle.sourceforge.net/config_design.html --> <!-- See http://checkstyle.sourceforge.net/config_design.html -->
<module name="FinalClass"/> <module name="FinalClass"/>
<module name="InterfaceIsType"/> <module name="InterfaceIsType"/>

View File

@@ -218,9 +218,9 @@ public enum ChatColor {
char[] b = textToTranslate.toCharArray(); char[] b = textToTranslate.toCharArray();
for (int i = 0; i < b.length - 1; i++) { for (int i = 0; i < b.length - 1; i++) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) { if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
b[i] = ChatColor.COLOR_CHAR; b[i] = ChatColor.COLOR_CHAR;
b[i+1] = Character.toLowerCase(b[i+1]); b[i + 1] = Character.toLowerCase(b[i + 1]);
} }
} }
return new String(b); return new String(b);

View File

@@ -263,5 +263,5 @@ public enum Effect {
/** /**
* Represents the type of an effect. * Represents the type of an effect.
*/ */
public enum Type {SOUND, VISUAL} public enum Type { SOUND, VISUAL }
} }

View File

@@ -38,7 +38,7 @@ public @interface Warning {
*/ */
DEFAULT; DEFAULT;
private static final Map<String, WarningState> values = ImmutableMap.<String,WarningState>builder() private static final Map<String, WarningState> values = ImmutableMap.<String, WarningState>builder()
.put("off", OFF) .put("off", OFF)
.put("false", OFF) .put("false", OFF)
.put("f", OFF) .put("f", OFF)

View File

@@ -29,7 +29,7 @@ public class HelpCommand extends BukkitCommand {
super("help"); super("help");
this.description = "Shows the help menu"; this.description = "Shows the help menu";
this.usageMessage = "/help <pageNumber>\n/help <topic>\n/help <topic> <pageNumber>"; this.usageMessage = "/help <pageNumber>\n/help <topic>\n/help <topic> <pageNumber>";
this.setAliases(Arrays.asList(new String[] { "?" })); this.setAliases(Arrays.asList(new String[]{"?"}));
this.setPermission("bukkit.command.help"); this.setPermission("bukkit.command.help");
} }

View File

@@ -31,7 +31,7 @@ public class TimingsCommand extends BukkitCommand {
@Override @Override
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {
if (!testPermission(sender)) return true; if (!testPermission(sender)) return true;
if (args.length != 1) { if (args.length != 1) {
sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
return false; return false;
} }
@@ -73,8 +73,9 @@ public class TimingsCommand extends BukkitCommand {
if (separate) { if (separate) {
fileNames.println(pluginIdx + " " + plugin.getDescription().getFullName()); fileNames.println(pluginIdx + " " + plugin.getDescription().getFullName());
fileTimings.println("Plugin " + pluginIdx); fileTimings.println("Plugin " + pluginIdx);
} else {
fileTimings.println(plugin.getDescription().getFullName());
} }
else fileTimings.println(plugin.getDescription().getFullName());
for (RegisteredListener listener : HandlerList.getRegisteredListeners(plugin)) { for (RegisteredListener listener : HandlerList.getRegisteredListeners(plugin)) {
if (listener instanceof TimedRegisteredListener) { if (listener instanceof TimedRegisteredListener) {
TimedRegisteredListener trl = (TimedRegisteredListener) listener; TimedRegisteredListener trl = (TimedRegisteredListener) listener;

View File

@@ -826,10 +826,10 @@ public class MemorySection implements ConfigurationSection {
} }
protected boolean isPrimitiveWrapper(@Nullable Object input) { protected boolean isPrimitiveWrapper(@Nullable Object input) {
return input instanceof Integer || input instanceof Boolean || return input instanceof Integer || input instanceof Boolean
input instanceof Character || input instanceof Byte || || input instanceof Character || input instanceof Byte
input instanceof Short || input instanceof Double || || input instanceof Short || input instanceof Double
input instanceof Long || input instanceof Float; || input instanceof Long || input instanceof Float;
} }
@Nullable @Nullable

View File

@@ -17,7 +17,7 @@ public abstract class BooleanPrompt extends ValidatingPrompt {
@Override @Override
protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) { protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) {
String[] accepted = {/* Apache values: */"true", "false", "on", "off", "yes", "no",/* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"}; String[] accepted = {/* Apache values: */ "true", "false", "on", "off", "yes", "no", /* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"};
return ArrayUtils.contains(accepted, input.toLowerCase()); return ArrayUtils.contains(accepted, input.toLowerCase());
} }

View File

@@ -3,4 +3,4 @@ package org.bukkit.entity;
/** /**
* Represents a trader Llama. * Represents a trader Llama.
*/ */
public interface TraderLlama extends Llama { } public interface TraderLlama extends Llama { }

View File

@@ -23,7 +23,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
private final ItemStack item; private final ItemStack item;
private int level; private int level;
private boolean cancelled; private boolean cancelled;
private final Map<Enchantment,Integer> enchants; private final Map<Enchantment, Integer> enchants;
private final Player enchanter; private final Player enchanter;
private final int button; private final int button;

View File

@@ -9,7 +9,7 @@ import org.jetbrains.annotations.Nullable;
* Called when an Entity targets a {@link LivingEntity} and can only target * Called when an Entity targets a {@link LivingEntity} and can only target
* LivingEntity's. * LivingEntity's.
*/ */
public class EntityTargetLivingEntityEvent extends EntityTargetEvent{ public class EntityTargetLivingEntityEvent extends EntityTargetEvent {
public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @Nullable final TargetReason reason) { public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @Nullable final TargetReason reason) {
super(entity, target, reason); super(entity, target, reason);
} }

View File

@@ -71,6 +71,6 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable {
@Override @Override
public void setCancelled(boolean cancel) { public void setCancelled(boolean cancel) {
this.cancelled = cancel; this.cancelled = cancel;
} }
} }

View File

@@ -25,11 +25,11 @@ public enum InventoryType {
* A chest inventory, with 0, 9, 18, 27, 36, 45, or 54 slots of type * A chest inventory, with 0, 9, 18, 27, 36, 45, or 54 slots of type
* CONTAINER. * CONTAINER.
*/ */
CHEST(27,"Chest"), CHEST(27, "Chest"),
/** /**
* A dispenser inventory, with 9 slots of type CONTAINER. * A dispenser inventory, with 9 slots of type CONTAINER.
*/ */
DISPENSER(9,"Dispenser"), DISPENSER(9, "Dispenser"),
/** /**
* A dropper inventory, with 9 slots of type CONTAINER. * A dropper inventory, with 9 slots of type CONTAINER.
*/ */
@@ -38,45 +38,45 @@ public enum InventoryType {
* A furnace inventory, with a RESULT slot, a CRAFTING slot, and a FUEL * A furnace inventory, with a RESULT slot, a CRAFTING slot, and a FUEL
* slot. * slot.
*/ */
FURNACE(3,"Furnace"), FURNACE(3, "Furnace"),
/** /**
* A workbench inventory, with 9 CRAFTING slots and a RESULT slot. * A workbench inventory, with 9 CRAFTING slots and a RESULT slot.
*/ */
WORKBENCH(10,"Crafting"), WORKBENCH(10, "Crafting"),
/** /**
* A player's crafting inventory, with 4 CRAFTING slots and a RESULT slot. * A player's crafting inventory, with 4 CRAFTING slots and a RESULT slot.
* Also implies that the 4 ARMOR slots are accessible. * Also implies that the 4 ARMOR slots are accessible.
*/ */
CRAFTING(5,"Crafting", false), CRAFTING(5, "Crafting", false),
/** /**
* An enchantment table inventory, with two CRAFTING slots and three * An enchantment table inventory, with two CRAFTING slots and three
* enchanting buttons. * enchanting buttons.
*/ */
ENCHANTING(2,"Enchanting"), ENCHANTING(2, "Enchanting"),
/** /**
* A brewing stand inventory, with one FUEL slot and four CRAFTING slots. * A brewing stand inventory, with one FUEL slot and four CRAFTING slots.
*/ */
BREWING(5,"Brewing"), BREWING(5, "Brewing"),
/** /**
* A player's inventory, with 9 QUICKBAR slots, 27 CONTAINER slots, 4 ARMOR * A player's inventory, with 9 QUICKBAR slots, 27 CONTAINER slots, 4 ARMOR
* slots and 1 offhand slot. The ARMOR and offhand slots may not be visible * slots and 1 offhand slot. The ARMOR and offhand slots may not be visible
* to the player, though. * to the player, though.
*/ */
PLAYER(41,"Player"), PLAYER(41, "Player"),
/** /**
* The creative mode inventory, with only 9 QUICKBAR slots and nothing * The creative mode inventory, with only 9 QUICKBAR slots and nothing
* else. (The actual creative interface with the items is client-side and * else. (The actual creative interface with the items is client-side and
* cannot be altered by the server.) * cannot be altered by the server.)
*/ */
CREATIVE(9,"Creative", false), CREATIVE(9, "Creative", false),
/** /**
* The merchant inventory, with 2 CRAFTING slots, and 1 RESULT slot. * The merchant inventory, with 2 CRAFTING slots, and 1 RESULT slot.
*/ */
MERCHANT(3,"Villager", false), MERCHANT(3, "Villager", false),
/** /**
* The ender chest inventory, with 27 slots. * The ender chest inventory, with 27 slots.
*/ */
ENDER_CHEST(27,"Ender Chest"), ENDER_CHEST(27, "Ender Chest"),
/** /**
* An anvil inventory, with 2 CRAFTING slots and 1 RESULT slot * An anvil inventory, with 2 CRAFTING slots and 1 RESULT slot
*/ */

View File

@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
* alternative for thread safe implementations. * alternative for thread safe implementations.
*/ */
@Deprecated @Deprecated
@Warning(reason="Listening to this event forces chat to wait for the main thread, delaying chat messages.") @Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.")
public class PlayerChatEvent extends PlayerEvent implements Cancellable { public class PlayerChatEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private boolean cancel = false; private boolean cancel = false;

View File

@@ -70,7 +70,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
* @param hatchType The type of the mob being hatched by the egg * @param hatchType The type of the mob being hatched by the egg
*/ */
public void setHatchingType(@NotNull EntityType hatchType) { public void setHatchingType(@NotNull EntityType hatchType) {
if(!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!"); if (!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!");
this.hatchType = hatchType; this.hatchType = hatchType;
} }

View File

@@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
* asynchronous. * asynchronous.
*/ */
@Deprecated @Deprecated
@Warning(reason="This event causes a login thread to synchronize with the main thread") @Warning(reason = "This event causes a login thread to synchronize with the main thread")
public class PlayerPreLoginEvent extends Event { public class PlayerPreLoginEvent extends Event {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private Result result; private Result result;

View File

@@ -329,13 +329,13 @@ public abstract class InventoryView {
public final InventoryType.SlotType getSlotType(int slot) { public final InventoryType.SlotType getSlotType(int slot) {
InventoryType.SlotType type = InventoryType.SlotType.CONTAINER; InventoryType.SlotType type = InventoryType.SlotType.CONTAINER;
if (slot >= 0 && slot < this.getTopInventory().getSize()) { if (slot >= 0 && slot < this.getTopInventory().getSize()) {
switch(this.getType()) { switch (this.getType()) {
case BLAST_FURNACE: case BLAST_FURNACE:
case FURNACE: case FURNACE:
case SMOKER: case SMOKER:
if (slot == 2) { if (slot == 2) {
type = InventoryType.SlotType.RESULT; type = InventoryType.SlotType.RESULT;
} else if(slot == 1) { } else if (slot == 1) {
type = InventoryType.SlotType.FUEL; type = InventoryType.SlotType.FUEL;
} else { } else {
type = InventoryType.SlotType.CRAFTING; type = InventoryType.SlotType.CRAFTING;

View File

@@ -9,6 +9,7 @@ public class MinecraftFont extends MapFont {
private static final int spaceSize = 2; private static final int spaceSize = 2;
// CHECKSTYLE:OFF
private static final String fontChars = private static final String fontChars =
" !\"#$%&'()*+,-./0123456789:;<=>?" + " !\"#$%&'()*+,-./0123456789:;<=>?" +
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" +
@@ -278,6 +279,7 @@ public class MinecraftFont extends MapFont {
/* 254 */ {0,0,60,60,60,60,0,0}, /* 254 */ {0,0,60,60,60,60,0,0},
/* 255 */ {0,0,0,0,0,0,0,0}, /* 255 */ {0,0,0,0,0,0,0,0},
}; };
// CHECKSTYLE:ON
/** /**
* A static non-malleable MinecraftFont. * A static non-malleable MinecraftFont.

View File

@@ -49,7 +49,7 @@ import org.yaml.snakeyaml.error.YAMLException;
*/ */
public final class JavaPluginLoader implements PluginLoader { public final class JavaPluginLoader implements PluginLoader {
final Server server; final Server server;
private final Pattern[] fileFilters = new Pattern[] { Pattern.compile("\\.jar$"), }; private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>(); private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>(); private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
@@ -288,8 +288,7 @@ public final class JavaPluginLoader implements PluginLoader {
plugin.getLogger().log( plugin.getLogger().log(
Level.WARNING, Level.WARNING,
String.format( String.format(
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated." + "\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated. \"%s\"; please notify the authors %s.",
" \"%s\"; please notify the authors %s.",
plugin.getDescription().getFullName(), plugin.getDescription().getFullName(),
clazz.getName(), clazz.getName(),
method.toGenericString(), method.toGenericString(),

View File

@@ -58,7 +58,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskAsynchronously(Plugin, Runnable) * @see BukkitScheduler#runTaskAsynchronously(Plugin, Runnable)
*/ */
@NotNull @NotNull
public synchronized BukkitTask runTaskAsynchronously(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException { public synchronized BukkitTask runTaskAsynchronously(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled(); checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskAsynchronously(plugin, (Runnable) this)); return setupTask(Bukkit.getScheduler().runTaskAsynchronously(plugin, (Runnable) this));
} }
@@ -74,7 +74,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskLater(Plugin, Runnable, long) * @see BukkitScheduler#runTaskLater(Plugin, Runnable, long)
*/ */
@NotNull @NotNull
public synchronized BukkitTask runTaskLater(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { public synchronized BukkitTask runTaskLater(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled(); checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskLater(plugin, (Runnable) this, delay)); return setupTask(Bukkit.getScheduler().runTaskLater(plugin, (Runnable) this, delay));
} }
@@ -94,7 +94,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskLaterAsynchronously(Plugin, Runnable, long) * @see BukkitScheduler#runTaskLaterAsynchronously(Plugin, Runnable, long)
*/ */
@NotNull @NotNull
public synchronized BukkitTask runTaskLaterAsynchronously(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { public synchronized BukkitTask runTaskLaterAsynchronously(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled(); checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, (Runnable) this, delay)); return setupTask(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, (Runnable) this, delay));
} }
@@ -112,7 +112,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskTimer(Plugin, Runnable, long, long) * @see BukkitScheduler#runTaskTimer(Plugin, Runnable, long, long)
*/ */
@NotNull @NotNull
public synchronized BukkitTask runTaskTimer(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { public synchronized BukkitTask runTaskTimer(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled(); checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period)); return setupTask(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period));
} }
@@ -135,7 +135,7 @@ public abstract class BukkitRunnable implements Runnable {
* long) * long)
*/ */
@NotNull @NotNull
public synchronized BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { public synchronized BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled(); checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, (Runnable) this, delay, period)); return setupTask(Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, (Runnable) this, delay, period));
} }

View File

@@ -4,7 +4,7 @@ package org.bukkit.util.noise;
* Base class for all noise generators * Base class for all noise generators
*/ */
public abstract class NoiseGenerator { public abstract class NoiseGenerator {
protected final int[] perm= new int[512]; protected final int[] perm = new int[512];
protected double offsetX; protected double offsetX;
protected double offsetY; protected double offsetY;
protected double offsetZ; protected double offsetZ;

View File

@@ -1,3 +1,4 @@
// CHECKSTYLE:OFF
package org.bukkit.util.noise; package org.bukkit.util.noise;
import java.util.Random; import java.util.Random;

View File

@@ -18,7 +18,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class BukkitMirrorTest { public class BukkitMirrorTest {
@Parameters(name="{index}: {1}") @Parameters(name = "{index}: {1}")
public static List<Object[]> data() { public static List<Object[]> data() {
return Lists.transform(Arrays.asList(Server.class.getDeclaredMethods()), new Function<Method, Object[]>() { return Lists.transform(Arrays.asList(Server.class.getDeclaredMethods()), new Function<Method, Object[]>() {
@Override @Override

View File

@@ -26,7 +26,7 @@ public class ColorTest {
} }
} }
static TestColor[] examples = new TestColor[] { static TestColor[] examples = new TestColor[]{
/* 0xRRGGBB, 0xBBGGRR, 0xRR, 0xGG, 0xBB */ /* 0xRRGGBB, 0xBBGGRR, 0xRR, 0xGG, 0xBB */
new TestColor(0xFFFFFF, 0xFFFFFF, 0xFF, 0xFF, 0xFF), new TestColor(0xFFFFFF, 0xFFFFFF, 0xFF, 0xFF, 0xFF),
new TestColor(0xFFFFAA, 0xAAFFFF, 0xFF, 0xFF, 0xAA), new TestColor(0xFFFFAA, 0xAAFFFF, 0xFF, 0xFF, 0xAA),
@@ -98,22 +98,22 @@ public class ColorTest {
} }
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidRGB1() { public void testInvalidRGB1() {
Color.fromRGB(0x01000000); Color.fromRGB(0x01000000);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidRGB2() { public void testInvalidRGB2() {
Color.fromRGB(Integer.MIN_VALUE); Color.fromRGB(Integer.MIN_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidRGB3() { public void testInvalidRGB3() {
Color.fromRGB(Integer.MAX_VALUE); Color.fromRGB(Integer.MAX_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidRGB4() { public void testInvalidRGB4() {
Color.fromRGB(-1); Color.fromRGB(-1);
} }
@@ -129,22 +129,22 @@ public class ColorTest {
} }
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidBGR1() { public void testInvalidBGR1() {
Color.fromBGR(0x01000000); Color.fromBGR(0x01000000);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidBGR2() { public void testInvalidBGR2() {
Color.fromBGR(Integer.MIN_VALUE); Color.fromBGR(Integer.MIN_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidBGR3() { public void testInvalidBGR3() {
Color.fromBGR(Integer.MAX_VALUE); Color.fromBGR(Integer.MAX_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidBGR4() { public void testInvalidBGR4() {
Color.fromBGR(-1); Color.fromBGR(-1);
} }
@@ -160,62 +160,62 @@ public class ColorTest {
} }
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR01() { public void testInvalidR01() {
Color.fromRGB(-1, 0x00, 0x00); Color.fromRGB(-1, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR02() { public void testInvalidR02() {
Color.fromRGB(Integer.MAX_VALUE, 0x00, 0x00); Color.fromRGB(Integer.MAX_VALUE, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR03() { public void testInvalidR03() {
Color.fromRGB(Integer.MIN_VALUE, 0x00, 0x00); Color.fromRGB(Integer.MIN_VALUE, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR04() { public void testInvalidR04() {
Color.fromRGB(0x100, 0x00, 0x00); Color.fromRGB(0x100, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR05() { public void testInvalidR05() {
Color.fromBGR(0x00, 0x00, -1); Color.fromBGR(0x00, 0x00, -1);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR06() { public void testInvalidR06() {
Color.fromBGR(0x00, 0x00, Integer.MAX_VALUE); Color.fromBGR(0x00, 0x00, Integer.MAX_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR07() { public void testInvalidR07() {
Color.fromBGR(0x00, 0x00, Integer.MIN_VALUE); Color.fromBGR(0x00, 0x00, Integer.MIN_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR08() { public void testInvalidR08() {
Color.fromBGR(0x00, 0x00, 0x100); Color.fromBGR(0x00, 0x00, 0x100);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR09() { public void testInvalidR09() {
Color.WHITE.setRed(-1); Color.WHITE.setRed(-1);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR10() { public void testInvalidR10() {
Color.WHITE.setRed(Integer.MAX_VALUE); Color.WHITE.setRed(Integer.MAX_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR11() { public void testInvalidR11() {
Color.WHITE.setRed(Integer.MIN_VALUE); Color.WHITE.setRed(Integer.MIN_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidR12() { public void testInvalidR12() {
Color.WHITE.setRed(0x100); Color.WHITE.setRed(0x100);
} }
@@ -231,62 +231,62 @@ public class ColorTest {
} }
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB01() { public void testInvalidB01() {
Color.fromRGB(0x00, 0x00, -1); Color.fromRGB(0x00, 0x00, -1);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB02() { public void testInvalidB02() {
Color.fromRGB(0x00, 0x00, Integer.MAX_VALUE); Color.fromRGB(0x00, 0x00, Integer.MAX_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB03() { public void testInvalidB03() {
Color.fromRGB(0x00, 0x00, Integer.MIN_VALUE); Color.fromRGB(0x00, 0x00, Integer.MIN_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB04() { public void testInvalidB04() {
Color.fromRGB(0x00, 0x00, 0x100); Color.fromRGB(0x00, 0x00, 0x100);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB05() { public void testInvalidB05() {
Color.fromBGR(-1, 0x00, 0x00); Color.fromBGR(-1, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB06() { public void testInvalidB06() {
Color.fromBGR(Integer.MAX_VALUE, 0x00, 0x00); Color.fromBGR(Integer.MAX_VALUE, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB07() { public void testInvalidB07() {
Color.fromBGR(Integer.MIN_VALUE, 0x00, 0x00); Color.fromBGR(Integer.MIN_VALUE, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB08() { public void testInvalidB08() {
Color.fromBGR(0x100, 0x00, 0x00); Color.fromBGR(0x100, 0x00, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB09() { public void testInvalidB09() {
Color.WHITE.setBlue(-1); Color.WHITE.setBlue(-1);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB10() { public void testInvalidB10() {
Color.WHITE.setBlue(Integer.MAX_VALUE); Color.WHITE.setBlue(Integer.MAX_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB11() { public void testInvalidB11() {
Color.WHITE.setBlue(Integer.MIN_VALUE); Color.WHITE.setBlue(Integer.MIN_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidB12() { public void testInvalidB12() {
Color.WHITE.setBlue(0x100); Color.WHITE.setBlue(0x100);
} }
@@ -302,62 +302,62 @@ public class ColorTest {
} }
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG01() { public void testInvalidG01() {
Color.fromRGB(0x00, -1, 0x00); Color.fromRGB(0x00, -1, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG02() { public void testInvalidG02() {
Color.fromRGB(0x00, Integer.MAX_VALUE, 0x00); Color.fromRGB(0x00, Integer.MAX_VALUE, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG03() { public void testInvalidG03() {
Color.fromRGB(0x00, Integer.MIN_VALUE, 0x00); Color.fromRGB(0x00, Integer.MIN_VALUE, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG04() { public void testInvalidG04() {
Color.fromRGB(0x00, 0x100, 0x00); Color.fromRGB(0x00, 0x100, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG05() { public void testInvalidG05() {
Color.fromBGR(0x00, -1, 0x00); Color.fromBGR(0x00, -1, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG06() { public void testInvalidG06() {
Color.fromBGR(0x00, Integer.MAX_VALUE, 0x00); Color.fromBGR(0x00, Integer.MAX_VALUE, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG07() { public void testInvalidG07() {
Color.fromBGR(0x00, Integer.MIN_VALUE, 0x00); Color.fromBGR(0x00, Integer.MIN_VALUE, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG08() { public void testInvalidG08() {
Color.fromBGR(0x00, 0x100, 0x00); Color.fromBGR(0x00, 0x100, 0x00);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG09() { public void testInvalidG09() {
Color.WHITE.setGreen(-1); Color.WHITE.setGreen(-1);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG10() { public void testInvalidG10() {
Color.WHITE.setGreen(Integer.MAX_VALUE); Color.WHITE.setGreen(Integer.MAX_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG11() { public void testInvalidG11() {
Color.WHITE.setGreen(Integer.MIN_VALUE); Color.WHITE.setGreen(Integer.MIN_VALUE);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testInvalidG12() { public void testInvalidG12() {
Color.WHITE.setGreen(0x100); Color.WHITE.setGreen(0x100);
} }

View File

@@ -16,7 +16,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class DyeColorTest { public class DyeColorTest {
@Parameters(name= "{index}: {0}") @Parameters(name = "{index}: {0}")
public static List<Object[]> data() { public static List<Object[]> data() {
List<Object[]> list = new ArrayList<Object[]>(); List<Object[]> list = new ArrayList<Object[]>();
for (DyeColor dye : DyeColor.values()) { for (DyeColor dye : DyeColor.values()) {

View File

@@ -36,56 +36,56 @@ public class LocationTest {
*/ */
private static final double HALF_HALF_UNIT = Math.sqrt(1 / 4f); private static final double HALF_HALF_UNIT = Math.sqrt(1 / 4f);
@Parameters(name= "{index}: {0}") @Parameters(name = "{index}: {0}")
public static List<Object[]> data() { public static List<Object[]> data() {
Random RANDOM = new Random(1L); // Test is deterministic Random RANDOM = new Random(1L); // Test is deterministic
int r = 0; int r = 0;
return ImmutableList.<Object[]>of( return ImmutableList.<Object[]>of(
new Object[] { "X", new Object[]{"X",
1, 0, 0, 1, 0, 0,
270, 0 270, 0
}, },
new Object[] { "-X", new Object[]{"-X",
-1, 0, 0, -1, 0, 0,
90, 0 90, 0
}, },
new Object[] { "Z", new Object[]{"Z",
0, 0, 1, 0, 0, 1,
0, 0 0, 0
}, },
new Object[] { "-Z", new Object[]{"-Z",
0, 0, -1, 0, 0, -1,
180, 0 180, 0
}, },
new Object[] { "Y", new Object[]{"Y",
0, 1, 0, 0, 1, 0,
0, -90 // Zero is here as a "default" value 0, -90 // Zero is here as a "default" value
}, },
new Object[] { "-Y", new Object[]{"-Y",
0, -1, 0, 0, -1, 0,
0, 90 // Zero is here as a "default" value 0, 90 // Zero is here as a "default" value
}, },
new Object[] { "X Z", new Object[]{"X Z",
HALF_UNIT, 0, HALF_UNIT, HALF_UNIT, 0, HALF_UNIT,
(270 + 360) / 2, 0 (270 + 360) / 2, 0
}, },
new Object[] { "X -Z", new Object[]{"X -Z",
HALF_UNIT, 0, -HALF_UNIT, HALF_UNIT, 0, -HALF_UNIT,
(270 + 180) / 2, 0 (270 + 180) / 2, 0
}, },
new Object[] { "-X -Z", new Object[]{"-X -Z",
-HALF_UNIT, 0, -HALF_UNIT, -HALF_UNIT, 0, -HALF_UNIT,
(90 + 180) / 2, 0 (90 + 180) / 2, 0
}, },
new Object[] { "-X Z", new Object[]{"-X Z",
-HALF_UNIT, 0, HALF_UNIT, -HALF_UNIT, 0, HALF_UNIT,
(90 + 0) / 2, 0 (90 + 0) / 2, 0
}, },
new Object[] { "X Y Z", new Object[]{"X Y Z",
HALF_HALF_UNIT, HALF_UNIT, HALF_HALF_UNIT, HALF_HALF_UNIT, HALF_UNIT, HALF_HALF_UNIT,
(270 + 360) / 2, -45 (270 + 360) / 2, -45
}, },
new Object[] { "-X -Y -Z", new Object[]{"-X -Y -Z",
-HALF_HALF_UNIT, -HALF_UNIT, -HALF_HALF_UNIT, -HALF_HALF_UNIT, -HALF_UNIT, -HALF_HALF_UNIT,
(90 + 180) / 2, 45 (90 + 180) / 2, 45
}, },
@@ -140,7 +140,7 @@ public class LocationTest {
location.setDirection(vector); location.setDirection(vector);
} }
return new Object[] { "R" + index, return new Object[]{"R" + index,
vector.getX(), vector.getY(), vector.getZ(), vector.getX(), vector.getY(), vector.getZ(),
location.getYaw(), location.getPitch() location.getYaw(), location.getPitch()
}; };

View File

@@ -114,7 +114,7 @@ public class NoteTest {
assertEquals(note.getOctave(), 2); assertEquals(note.getOctave(), 2);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testSharpWrapping2() { public void testSharpWrapping2() {
new Note(2, Note.Tone.F, true).sharped(); new Note(2, Note.Tone.F, true).sharped();
} }
@@ -122,13 +122,13 @@ public class NoteTest {
@Test @Test
public void testHighest() { public void testHighest() {
Note note = new Note(2, Note.Tone.F, true); Note note = new Note(2, Note.Tone.F, true);
assertEquals(note.getId(), (byte)24); assertEquals(note.getId(), (byte) 24);
} }
@Test @Test
public void testLowest() { public void testLowest() {
Note note = new Note(0, Note.Tone.F, true); Note note = new Note(0, Note.Tone.F, true);
assertEquals(note.getId(), (byte)0); assertEquals(note.getId(), (byte) 0);
} }
@Test @Test

View File

@@ -25,9 +25,9 @@ public abstract class ConfigurationSectionTest {
section.set("key2", true); section.set("key2", true);
section.set("42", true); section.set("42", true);
assertArrayEquals(new String[] { "key", "subsection", "key2", "42" }, section.getKeys(false).toArray()); assertArrayEquals(new String[]{"key", "subsection", "key2", "42"}, section.getKeys(false).toArray());
assertArrayEquals(new String[] { "key", "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "42" }, section.getKeys(true).toArray()); assertArrayEquals(new String[]{"key", "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "42"}, section.getKeys(true).toArray());
assertArrayEquals(new String[] { "subkey", "subkey2", "subsubsection", "subsubsection.key" }, section.getConfigurationSection("subsection").getKeys(true).toArray()); assertArrayEquals(new String[]{"subkey", "subkey2", "subsubsection", "subsubsection.key"}, section.getConfigurationSection("subsection").getKeys(true).toArray());
} }
@Test @Test
@@ -41,9 +41,9 @@ public abstract class ConfigurationSectionTest {
section.addDefault("subsection.subsubsection.key", true); section.addDefault("subsection.subsubsection.key", true);
section.addDefault("key2", true); section.addDefault("key2", true);
assertArrayEquals(new String[] { "subsection", "key2", "key" }, section.getKeys(false).toArray()); assertArrayEquals(new String[]{"subsection", "key2", "key"}, section.getKeys(false).toArray());
assertArrayEquals(new String[] { "subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "key" }, section.getKeys(true).toArray()); assertArrayEquals(new String[]{"subsection", "subsection.subkey", "subsection.subkey2", "subsection.subsubsection", "subsection.subsubsection.key", "key2", "key"}, section.getKeys(true).toArray());
assertArrayEquals(new String[] { "subkey", "subkey2", "subsubsection", "subsubsection.key" }, section.getConfigurationSection("subsection").getKeys(true).toArray()); assertArrayEquals(new String[]{"subkey", "subkey2", "subsubsection", "subsubsection.key"}, section.getConfigurationSection("subsection").getKeys(true).toArray());
} }
@Test @Test
@@ -56,12 +56,12 @@ public abstract class ConfigurationSectionTest {
section.set("int", 42); section.set("int", 42);
Map<String, Object> shallowValues = section.getValues(false); Map<String, Object> shallowValues = section.getValues(false);
assertArrayEquals(new String[] { "bool", "subsection", "int" }, shallowValues.keySet().toArray()); assertArrayEquals(new String[]{"bool", "subsection", "int"}, shallowValues.keySet().toArray());
assertArrayEquals(new Object[] { true, section.getConfigurationSection("subsection"), 42 }, shallowValues.values().toArray()); assertArrayEquals(new Object[]{true, section.getConfigurationSection("subsection"), 42}, shallowValues.values().toArray());
Map<String, Object> deepValues = section.getValues(true); Map<String, Object> deepValues = section.getValues(true);
assertArrayEquals(new String[] { "bool", "subsection", "subsection.string", "subsection.long", "int" }, deepValues.keySet().toArray()); assertArrayEquals(new String[]{"bool", "subsection", "subsection.string", "subsection.long", "int"}, deepValues.keySet().toArray());
assertArrayEquals(new Object[] { true, section.getConfigurationSection("subsection"), "test", Long.MAX_VALUE, 42 }, deepValues.values().toArray()); assertArrayEquals(new Object[]{true, section.getConfigurationSection("subsection"), "test", Long.MAX_VALUE, 42}, deepValues.values().toArray());
} }
@Test @Test
@@ -78,12 +78,12 @@ public abstract class ConfigurationSectionTest {
section.addDefault("int", 42); section.addDefault("int", 42);
Map<String, Object> shallowValues = section.getValues(false); Map<String, Object> shallowValues = section.getValues(false);
assertArrayEquals(new String[] { "int", "bool", "subsection" }, shallowValues.keySet().toArray()); assertArrayEquals(new String[]{"int", "bool", "subsection"}, shallowValues.keySet().toArray());
assertArrayEquals(new Object[] { 42, true, section.getConfigurationSection("subsection") }, shallowValues.values().toArray()); assertArrayEquals(new Object[]{42, true, section.getConfigurationSection("subsection")}, shallowValues.values().toArray());
Map<String, Object> deepValues = section.getValues(true); Map<String, Object> deepValues = section.getValues(true);
assertArrayEquals(new String[] { "subsection.long", "int", "bool", "subsection", "subsection.string" }, deepValues.keySet().toArray()); assertArrayEquals(new String[]{"subsection.long", "int", "bool", "subsection", "subsection.string"}, deepValues.keySet().toArray());
assertArrayEquals(new Object[] { Long.MAX_VALUE, 42, true, section.getConfigurationSection("subsection"), "test" }, deepValues.values().toArray()); assertArrayEquals(new Object[]{Long.MAX_VALUE, 42, true, section.getConfigurationSection("subsection"), "test"}, deepValues.values().toArray());
} }
@Test @Test

View File

@@ -22,23 +22,23 @@ public class YamlConfigurationTest extends FileConfigurationTest {
@Override @Override
public String getTestValuesString() { public String getTestValuesString() {
return "integer: -2147483648\n" + return "integer: -2147483648\n"
"string: String Value\n" + + "string: String Value\n"
"long: 9223372036854775807\n" + + "long: 9223372036854775807\n"
"true-boolean: true\n" + + "true-boolean: true\n"
"false-boolean: false\n" + + "false-boolean: false\n"
"vector:\n" + + "vector:\n"
" ==: Vector\n" + + " ==: Vector\n"
" x: 12345.67\n" + + " x: 12345.67\n"
" y: 64.0\n" + + " y: 64.0\n"
" z: -12345.6789\n" + + " z: -12345.6789\n"
"list:\n" + + "list:\n"
"- 1\n" + + "- 1\n"
"- 2\n" + + "- 2\n"
"- 3\n" + + "- 3\n"
"- 4\n" + + "- 4\n"
"- 5\n" + + "- 5\n"
"'42': The Answer\n"; + "'42': The Answer\n";
} }
@Test @Test

View File

@@ -25,50 +25,45 @@ import org.junit.Test;
public class MaterialDataTest { public class MaterialDataTest {
@Test @Test
public void testDoor() public void testDoor() {
{
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
Door door = new Door(); Door door = new Door();
assertThat("Constructed with default door type",door.getItemType(),equalTo(Material.LEGACY_WOODEN_DOOR)); assertThat("Constructed with default door type", door.getItemType(), equalTo(Material.LEGACY_WOODEN_DOOR));
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false)); assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(false));
assertThat("Constructed with default direction",door.getFacing(),equalTo(BlockFace.WEST)); assertThat("Constructed with default direction", door.getFacing(), equalTo(BlockFace.WEST));
assertThat("Constructed with default open state",door.isOpen(),equalTo(false)); assertThat("Constructed with default open state", door.isOpen(), equalTo(false));
Material[] types = new Material[] { Material.LEGACY_WOODEN_DOOR, Material[] types = new Material[]{Material.LEGACY_WOODEN_DOOR,
Material.LEGACY_IRON_DOOR_BLOCK, Material.LEGACY_SPRUCE_DOOR, Material.LEGACY_IRON_DOOR_BLOCK, Material.LEGACY_SPRUCE_DOOR,
Material.LEGACY_BIRCH_DOOR, Material.LEGACY_JUNGLE_DOOR, Material.LEGACY_BIRCH_DOOR, Material.LEGACY_JUNGLE_DOOR,
Material.LEGACY_ACACIA_DOOR, Material.LEGACY_DARK_OAK_DOOR }; Material.LEGACY_ACACIA_DOOR, Material.LEGACY_DARK_OAK_DOOR};
BlockFace[] directions = new BlockFace[] { BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH }; BlockFace[] directions = new BlockFace[]{BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH};
boolean[] openStates = new boolean[] {false, true}; boolean[] openStates = new boolean[]{false, true};
boolean[] hingeStates = new boolean[] {false, true}; boolean[] hingeStates = new boolean[]{false, true};
for(Material type : types) for (Material type : types) {
{
// Test bottom half // Test bottom half
for(BlockFace facing : directions) for (BlockFace facing : directions) {
{ door = new Door(type, facing);
door = new Door(type,facing); assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with correct door type",door.getItemType(),equalTo(type)); assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(false));
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false)); assertThat("Constructed with correct direction", door.getFacing(), equalTo(facing));
assertThat("Constructed with correct direction",door.getFacing(),equalTo(facing)); assertThat("Constructed with default open state", door.isOpen(), equalTo(false));
assertThat("Constructed with default open state",door.isOpen(),equalTo(false));
for(boolean openState : openStates) for (boolean openState : openStates) {
{ door = new Door(type, facing, openState);
door = new Door(type,facing,openState); assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with correct door type",door.getItemType(),equalTo(type)); assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(false));
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false)); assertThat("Constructed with correct direction", door.getFacing(), equalTo(facing));
assertThat("Constructed with correct direction",door.getFacing(),equalTo(facing)); assertThat("Constructed with correct open state", door.isOpen(), equalTo(openState));
assertThat("Constructed with correct open state",door.isOpen(),equalTo(openState));
} }
} }
// Test top half // Test top half
for(boolean hingeState : hingeStates) for (boolean hingeState : hingeStates) {
{ door = new Door(type, hingeState);
door = new Door(type,hingeState); assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with correct door type",door.getItemType(),equalTo(type)); assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(true));
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(true)); assertThat("Constructed with correct direction", door.getHinge(), equalTo(hingeState));
assertThat("Constructed with correct direction",door.getHinge(),equalTo(hingeState));
} }
} }
} }
@@ -242,10 +237,10 @@ public class MaterialDataTest {
@Test @Test
public void testMushroom() { public void testMushroom() {
Material[] mushroomTypes = new Material[] { Material.LEGACY_HUGE_MUSHROOM_1, Material.LEGACY_HUGE_MUSHROOM_2 }; Material[] mushroomTypes = new Material[]{Material.LEGACY_HUGE_MUSHROOM_1, Material.LEGACY_HUGE_MUSHROOM_2};
BlockFace[] setFaces = new BlockFace[] { BlockFace.SELF, BlockFace.UP, BlockFace.NORTH, BlockFace[] setFaces = new BlockFace[]{BlockFace.SELF, BlockFace.UP, BlockFace.NORTH,
BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST,
BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST }; BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST};
MushroomBlockTexture[] textures = MushroomBlockTexture.values(); MushroomBlockTexture[] textures = MushroomBlockTexture.values();
for (Material type : mushroomTypes) { for (Material type : mushroomTypes) {
Mushroom mushroom = new Mushroom(type); Mushroom mushroom = new Mushroom(type);
@@ -280,7 +275,7 @@ public class MaterialDataTest {
} }
// The crops which fully implement all crop states // The crops which fully implement all crop states
Material[] allCrops = new Material[] {Material.LEGACY_CROPS, Material.LEGACY_CARROT, Material.LEGACY_POTATO}; Material[] allCrops = new Material[]{Material.LEGACY_CROPS, Material.LEGACY_CARROT, Material.LEGACY_POTATO};
for (Material crop : allCrops) { for (Material crop : allCrops) {
crops = new Crops(crop); crops = new Crops(crop);
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(crop)); assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(crop));
@@ -295,7 +290,7 @@ public class MaterialDataTest {
// Beetroot are crops too, but they only have four states // Beetroot are crops too, but they only have four states
// Setting different crop states for beetroot will return the following when retrieved back // Setting different crop states for beetroot will return the following when retrieved back
CropState[] beetrootStates = new CropState[] {CropState.SEEDED, CropState.SEEDED, CropState.SMALL, CropState.SMALL, CropState.TALL, CropState.TALL, CropState.RIPE, CropState.RIPE}; CropState[] beetrootStates = new CropState[]{CropState.SEEDED, CropState.SEEDED, CropState.SMALL, CropState.SMALL, CropState.TALL, CropState.TALL, CropState.RIPE, CropState.RIPE};
assertThat("Beetroot state translations match size", beetrootStates.length, equalTo(allStates.length)); assertThat("Beetroot state translations match size", beetrootStates.length, equalTo(allStates.length));
crops = new Crops(Material.LEGACY_BEETROOT_BLOCK); crops = new Crops(Material.LEGACY_BEETROOT_BLOCK);
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(Material.LEGACY_BEETROOT_BLOCK)); assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(Material.LEGACY_BEETROOT_BLOCK));
@@ -312,7 +307,7 @@ public class MaterialDataTest {
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(warts.getItemType())); assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(warts.getItemType()));
assertThat("Constructed with default crop state", crops.getState(), equalTo(CropState.SEEDED)); assertThat("Constructed with default crop state", crops.getState(), equalTo(CropState.SEEDED));
assertThat("Constructed with default wart state", warts.getState(), equalTo(NetherWartsState.SEEDED)); assertThat("Constructed with default wart state", warts.getState(), equalTo(NetherWartsState.SEEDED));
allStates = new CropState[] {CropState.SEEDED, CropState.SMALL, CropState.TALL, CropState.RIPE}; allStates = new CropState[]{CropState.SEEDED, CropState.SMALL, CropState.TALL, CropState.RIPE};
NetherWartsState[] allWartStates = NetherWartsState.values(); NetherWartsState[] allWartStates = NetherWartsState.values();
assertThat("Nether Warts state translations match size", allWartStates.length, equalTo(allStates.length)); assertThat("Nether Warts state translations match size", allWartStates.length, equalTo(allStates.length));
for (int s = 0; s < allStates.length; s++) { for (int s = 0; s < allStates.length; s++) {
@@ -332,9 +327,9 @@ public class MaterialDataTest {
assertThat("Constructed with default delay", diode.getDelay(), equalTo(1)); assertThat("Constructed with default delay", diode.getDelay(), equalTo(1));
assertThat("Constructed with default direction", diode.getFacing(), equalTo(BlockFace.NORTH)); assertThat("Constructed with default direction", diode.getFacing(), equalTo(BlockFace.NORTH));
BlockFace[] directions = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}; BlockFace[] directions = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
int[] delays = new int[] {1, 2, 3, 4}; int[] delays = new int[]{1, 2, 3, 4};
boolean[] states = new boolean[] {false, true}; boolean[] states = new boolean[]{false, true};
for (BlockFace direction : directions) { for (BlockFace direction : directions) {
diode = new Diode(direction); diode = new Diode(direction);
assertThat("Constructed with default diode state", diode.getItemType(), equalTo(Material.LEGACY_DIODE_BLOCK_OFF)); assertThat("Constructed with default diode state", diode.getItemType(), equalTo(Material.LEGACY_DIODE_BLOCK_OFF));
@@ -367,9 +362,9 @@ public class MaterialDataTest {
assertThat("Constructed with default mode", comparator.isSubtractionMode(), equalTo(false)); assertThat("Constructed with default mode", comparator.isSubtractionMode(), equalTo(false));
assertThat("Constructed with default direction", comparator.getFacing(), equalTo(BlockFace.NORTH)); assertThat("Constructed with default direction", comparator.getFacing(), equalTo(BlockFace.NORTH));
BlockFace[] directions = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}; BlockFace[] directions = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
boolean[] modes = new boolean[] {false, true}; boolean[] modes = new boolean[]{false, true};
boolean[] states = new boolean[] {false, true}; boolean[] states = new boolean[]{false, true};
for (BlockFace direction : directions) { for (BlockFace direction : directions) {
comparator = new Comparator(direction); comparator = new Comparator(direction);
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.LEGACY_REDSTONE_COMPARATOR_OFF)); assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.LEGACY_REDSTONE_COMPARATOR_OFF));
@@ -393,7 +388,7 @@ public class MaterialDataTest {
assertThat("Constructed with correct direction", comparator.getFacing(), equalTo(direction)); assertThat("Constructed with correct direction", comparator.getFacing(), equalTo(direction));
// Check if the game sets the fourth bit, that block data is still interpreted correctly // Check if the game sets the fourth bit, that block data is still interpreted correctly
comparator.setData((byte)((comparator.getData() & 0x7) | 0x8)); comparator.setData((byte) ((comparator.getData() & 0x7) | 0x8));
assertThat("Constructed with correct comparator state", comparator.getItemType(), equalTo(state ? Material.LEGACY_REDSTONE_COMPARATOR_ON : Material.LEGACY_REDSTONE_COMPARATOR_OFF)); assertThat("Constructed with correct comparator state", comparator.getItemType(), equalTo(state ? Material.LEGACY_REDSTONE_COMPARATOR_ON : Material.LEGACY_REDSTONE_COMPARATOR_OFF));
assertThat("Constructed with correct powered", comparator.isPowered(), equalTo(state)); assertThat("Constructed with correct powered", comparator.isPowered(), equalTo(state));
assertThat("Constructed with correct being powered", comparator.isBeingPowered(), equalTo(true)); assertThat("Constructed with correct being powered", comparator.isBeingPowered(), equalTo(true));
@@ -412,15 +407,15 @@ public class MaterialDataTest {
assertThat("Constructed with default powered state", hopper.isPowered(), equalTo(false)); assertThat("Constructed with default powered state", hopper.isPowered(), equalTo(false));
assertThat("Constructed with default direction", hopper.getFacing(), equalTo(BlockFace.DOWN)); assertThat("Constructed with default direction", hopper.getFacing(), equalTo(BlockFace.DOWN));
BlockFace[] directions = new BlockFace[] {BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST}; BlockFace[] directions = new BlockFace[]{BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST};
boolean[] activeStates = new boolean[] {true, false}; boolean[] activeStates = new boolean[]{true, false};
for (BlockFace direction : directions) { for (BlockFace direction : directions) {
hopper = new Hopper(direction); hopper = new Hopper(direction);
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER)); assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
assertThat("Constructed with default active state", hopper.isActive(), equalTo(true)); assertThat("Constructed with default active state", hopper.isActive(), equalTo(true));
assertThat("Constructed with correct powered state", hopper.isPowered(), equalTo(false)); assertThat("Constructed with correct powered state", hopper.isPowered(), equalTo(false));
assertThat("Constructed with correct direction", hopper.getFacing(), equalTo(direction)); assertThat("Constructed with correct direction", hopper.getFacing(), equalTo(direction));
for(boolean isActive : activeStates) { for (boolean isActive : activeStates) {
hopper = new Hopper(direction, isActive); hopper = new Hopper(direction, isActive);
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER)); assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
assertThat("Constructed with correct active state", hopper.isActive(), equalTo(isActive)); assertThat("Constructed with correct active state", hopper.isActive(), equalTo(isActive));

View File

@@ -22,7 +22,7 @@ public class LazyMetadataValueTest {
double value = 10.5; double value = 10.5;
subject = makeSimpleCallable(value); subject = makeSimpleCallable(value);
assertEquals(value, (Double)subject.value(), 0.01); assertEquals(value, (Double) subject.value(), 0.01);
} }
@Test @Test
@@ -41,7 +41,7 @@ public class LazyMetadataValueTest {
assertEquals(value, subject.value()); assertEquals(value, subject.value());
} }
@Test(expected=MetadataEvaluationException.class) @Test(expected = MetadataEvaluationException.class)
public void testEvalException() { public void testEvalException() {
subject = new LazyMetadataValue(plugin, LazyMetadataValue.CacheStrategy.CACHE_AFTER_FIRST_EVAL, new Callable<Object>() { subject = new LazyMetadataValue(plugin, LazyMetadataValue.CacheStrategy.CACHE_AFTER_FIRST_EVAL, new Callable<Object>() {
@Override @Override

View File

@@ -71,7 +71,9 @@ public class PluginManagerTest {
} catch (Throwable ex) { } catch (Throwable ex) {
store.value = ex; store.value = ex;
} }
}}); }
}
);
secondThread.start(); secondThread.start();
secondThread.join(); secondThread.join();
if (store.value != null) { if (store.value != null) {

View File

@@ -13,7 +13,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class StringUtilStartsWithTest { public class StringUtilStartsWithTest {
@Parameters(name= "{index}: {0} startsWith {1} == {2}") @Parameters(name = "{index}: {0} startsWith {1} == {2}")
public static List<Object[]> data() { public static List<Object[]> data() {
return ImmutableList.<Object[]>of( return ImmutableList.<Object[]>of(
new Object[] { new Object[] {

View File

@@ -10,27 +10,27 @@ import org.junit.Test;
public class StringUtilTest { public class StringUtilTest {
@Test(expected=NullPointerException.class) @Test(expected = NullPointerException.class)
public void nullPrefixTest() { public void nullPrefixTest() {
StringUtil.startsWithIgnoreCase("String", null); StringUtil.startsWithIgnoreCase("String", null);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void nullStringTest() { public void nullStringTest() {
StringUtil.startsWithIgnoreCase(null, "String"); StringUtil.startsWithIgnoreCase(null, "String");
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void nullCollectionTest() { public void nullCollectionTest() {
StringUtil.copyPartialMatches("Token", ImmutableList.<String>of(), null); StringUtil.copyPartialMatches("Token", ImmutableList.<String>of(), null);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void nullIterableTest() { public void nullIterableTest() {
StringUtil.copyPartialMatches("Token", null, new ArrayList<String>()); StringUtil.copyPartialMatches("Token", null, new ArrayList<String>());
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void nullTokenTest() { public void nullTokenTest() {
StringUtil.copyPartialMatches(null, ImmutableList.<String>of(), new ArrayList<String>()); StringUtil.copyPartialMatches(null, ImmutableList.<String>of(), new ArrayList<String>());
} }
@@ -38,20 +38,20 @@ public class StringUtilTest {
@Test @Test
public void copyTokenTest() { public void copyTokenTest() {
String token = "ab"; String token = "ab";
Iterable<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a"); List<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a");
List<String> expected = ImmutableList.of("ab12", "AB5195", "Ab76" ); List<String> expected = ImmutableList.of("ab12", "AB5195", "Ab76");
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
assertThat(StringUtil.copyPartialMatches(token, original, list), is(expected)); assertThat(StringUtil.copyPartialMatches(token, original, list), is(expected));
assertThat(StringUtil.copyPartialMatches(token, original, list), is(sameInstance(list))); assertThat(StringUtil.copyPartialMatches(token, original, list), is(sameInstance(list)));
assertThat(list.size(), is(expected.size() * 2)); assertThat(list.size(), is(expected.size() * 2));
} }
@Test(expected=UnsupportedOperationException.class) @Test(expected = UnsupportedOperationException.class)
public void copyUnsupportedTest() { public void copyUnsupportedTest() {
StringUtil.copyPartialMatches("token", ImmutableList.of("token1", "token2"), ImmutableList.of()); StringUtil.copyPartialMatches("token", ImmutableList.of("token1", "token2"), ImmutableList.of());
} }
@Test(expected=IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void copyNullTest() { public void copyNullTest() {
StringUtil.copyPartialMatches("token", Arrays.asList("token1", "token2", null), new ArrayList<String>()); StringUtil.copyPartialMatches("token", Arrays.asList("token1", "token2", null), new ArrayList<String>());
} }

View File

@@ -25,7 +25,7 @@ import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class BukkitObjectStreamTest { public class BukkitObjectStreamTest {
@Parameters(name= "{index}: {0}") @Parameters(name = "{index}: {0}")
public static List<Object[]> data() { public static List<Object[]> data() {
return ImmutableList.<Object[]>of( return ImmutableList.<Object[]>of(
new Object[] { new Object[] {