1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-18 11:22:15 +01:00

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="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 -->
<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 -->
<module name="FinalClass"/>
<module name="InterfaceIsType"/>

View file

@ -218,9 +218,9 @@ public enum ChatColor {
char[] b = textToTranslate.toCharArray();
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+1] = Character.toLowerCase(b[i+1]);
b[i + 1] = Character.toLowerCase(b[i + 1]);
}
}
return new String(b);

View file

@ -263,5 +263,5 @@ public enum 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;
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("false", OFF)
.put("f", OFF)

View file

@ -29,7 +29,7 @@ public class HelpCommand extends BukkitCommand {
super("help");
this.description = "Shows the help menu";
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");
}

View file

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

View file

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

View file

@ -17,7 +17,7 @@ public abstract class BooleanPrompt extends ValidatingPrompt {
@Override
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());
}

View file

@ -3,4 +3,4 @@ package org.bukkit.entity;
/**
* 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 int level;
private boolean cancelled;
private final Map<Enchantment,Integer> enchants;
private final Map<Enchantment, Integer> enchants;
private final Player enchanter;
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
* 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) {
super(entity, target, reason);
}

View file

@ -71,6 +71,6 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable {
@Override
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
* CONTAINER.
*/
CHEST(27,"Chest"),
CHEST(27, "Chest"),
/**
* A dispenser inventory, with 9 slots of type CONTAINER.
*/
DISPENSER(9,"Dispenser"),
DISPENSER(9, "Dispenser"),
/**
* 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
* slot.
*/
FURNACE(3,"Furnace"),
FURNACE(3, "Furnace"),
/**
* 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.
* 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
* enchanting buttons.
*/
ENCHANTING(2,"Enchanting"),
ENCHANTING(2, "Enchanting"),
/**
* 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
* slots and 1 offhand slot. The ARMOR and offhand slots may not be visible
* to the player, though.
*/
PLAYER(41,"Player"),
PLAYER(41, "Player"),
/**
* The creative mode inventory, with only 9 QUICKBAR slots and nothing
* else. (The actual creative interface with the items is client-side and
* 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.
*/
MERCHANT(3,"Villager", false),
MERCHANT(3, "Villager", false),
/**
* 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
*/

View file

@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
* alternative for thread safe implementations.
*/
@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 {
private static final HandlerList handlers = new HandlerList();
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
*/
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;
}

View file

@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
* asynchronous.
*/
@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 {
private static final HandlerList handlers = new HandlerList();
private Result result;

View file

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

View file

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

View file

@ -49,7 +49,7 @@ import org.yaml.snakeyaml.error.YAMLException;
*/
public final class JavaPluginLoader implements PluginLoader {
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 List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
@ -288,8 +288,7 @@ public final class JavaPluginLoader implements PluginLoader {
plugin.getLogger().log(
Level.WARNING,
String.format(
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated." +
" \"%s\"; please notify the authors %s.",
"\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated. \"%s\"; please notify the authors %s.",
plugin.getDescription().getFullName(),
clazz.getName(),
method.toGenericString(),

View file

@ -58,7 +58,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskAsynchronously(Plugin, Runnable)
*/
@NotNull
public synchronized BukkitTask runTaskAsynchronously(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException {
public synchronized BukkitTask runTaskAsynchronously(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException {
checkNotYetScheduled();
return setupTask(Bukkit.getScheduler().runTaskAsynchronously(plugin, (Runnable) this));
}
@ -74,7 +74,7 @@ public abstract class BukkitRunnable implements Runnable {
* @see BukkitScheduler#runTaskLater(Plugin, Runnable, long)
*/
@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();
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)
*/
@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();
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)
*/
@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();
return setupTask(Bukkit.getScheduler().runTaskTimer(plugin, (Runnable) this, delay, period));
}
@ -135,7 +135,7 @@ public abstract class BukkitRunnable implements Runnable {
* long)
*/
@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();
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
*/
public abstract class NoiseGenerator {
protected final int[] perm= new int[512];
protected final int[] perm = new int[512];
protected double offsetX;
protected double offsetY;
protected double offsetZ;

View file

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

View file

@ -18,7 +18,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class BukkitMirrorTest {
@Parameters(name="{index}: {1}")
@Parameters(name = "{index}: {1}")
public static List<Object[]> data() {
return Lists.transform(Arrays.asList(Server.class.getDeclaredMethods()), new Function<Method, Object[]>() {
@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 */
new TestColor(0xFFFFFF, 0xFFFFFF, 0xFF, 0xFF, 0xFF),
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() {
Color.fromRGB(0x01000000);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidRGB2() {
Color.fromRGB(Integer.MIN_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidRGB3() {
Color.fromRGB(Integer.MAX_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidRGB4() {
Color.fromRGB(-1);
}
@ -129,22 +129,22 @@ public class ColorTest {
}
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidBGR1() {
Color.fromBGR(0x01000000);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidBGR2() {
Color.fromBGR(Integer.MIN_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidBGR3() {
Color.fromBGR(Integer.MAX_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidBGR4() {
Color.fromBGR(-1);
}
@ -160,62 +160,62 @@ public class ColorTest {
}
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR01() {
Color.fromRGB(-1, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR02() {
Color.fromRGB(Integer.MAX_VALUE, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR03() {
Color.fromRGB(Integer.MIN_VALUE, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR04() {
Color.fromRGB(0x100, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR05() {
Color.fromBGR(0x00, 0x00, -1);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR06() {
Color.fromBGR(0x00, 0x00, Integer.MAX_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR07() {
Color.fromBGR(0x00, 0x00, Integer.MIN_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR08() {
Color.fromBGR(0x00, 0x00, 0x100);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR09() {
Color.WHITE.setRed(-1);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR10() {
Color.WHITE.setRed(Integer.MAX_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR11() {
Color.WHITE.setRed(Integer.MIN_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidR12() {
Color.WHITE.setRed(0x100);
}
@ -231,62 +231,62 @@ public class ColorTest {
}
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB01() {
Color.fromRGB(0x00, 0x00, -1);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB02() {
Color.fromRGB(0x00, 0x00, Integer.MAX_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB03() {
Color.fromRGB(0x00, 0x00, Integer.MIN_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB04() {
Color.fromRGB(0x00, 0x00, 0x100);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB05() {
Color.fromBGR(-1, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB06() {
Color.fromBGR(Integer.MAX_VALUE, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB07() {
Color.fromBGR(Integer.MIN_VALUE, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB08() {
Color.fromBGR(0x100, 0x00, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB09() {
Color.WHITE.setBlue(-1);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB10() {
Color.WHITE.setBlue(Integer.MAX_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB11() {
Color.WHITE.setBlue(Integer.MIN_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidB12() {
Color.WHITE.setBlue(0x100);
}
@ -302,62 +302,62 @@ public class ColorTest {
}
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG01() {
Color.fromRGB(0x00, -1, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG02() {
Color.fromRGB(0x00, Integer.MAX_VALUE, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG03() {
Color.fromRGB(0x00, Integer.MIN_VALUE, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG04() {
Color.fromRGB(0x00, 0x100, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG05() {
Color.fromBGR(0x00, -1, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG06() {
Color.fromBGR(0x00, Integer.MAX_VALUE, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG07() {
Color.fromBGR(0x00, Integer.MIN_VALUE, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG08() {
Color.fromBGR(0x00, 0x100, 0x00);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG09() {
Color.WHITE.setGreen(-1);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG10() {
Color.WHITE.setGreen(Integer.MAX_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG11() {
Color.WHITE.setGreen(Integer.MIN_VALUE);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void testInvalidG12() {
Color.WHITE.setGreen(0x100);
}

View file

@ -16,7 +16,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class DyeColorTest {
@Parameters(name= "{index}: {0}")
@Parameters(name = "{index}: {0}")
public static List<Object[]> data() {
List<Object[]> list = new ArrayList<Object[]>();
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);
@Parameters(name= "{index}: {0}")
@Parameters(name = "{index}: {0}")
public static List<Object[]> data() {
Random RANDOM = new Random(1L); // Test is deterministic
int r = 0;
return ImmutableList.<Object[]>of(
new Object[] { "X",
new Object[]{"X",
1, 0, 0,
270, 0
},
new Object[] { "-X",
new Object[]{"-X",
-1, 0, 0,
90, 0
},
new Object[] { "Z",
new Object[]{"Z",
0, 0, 1,
0, 0
},
new Object[] { "-Z",
new Object[]{"-Z",
0, 0, -1,
180, 0
},
new Object[] { "Y",
new Object[]{"Y",
0, 1, 0,
0, -90 // Zero is here as a "default" value
},
new Object[] { "-Y",
new Object[]{"-Y",
0, -1, 0,
0, 90 // Zero is here as a "default" value
},
new Object[] { "X Z",
new Object[]{"X Z",
HALF_UNIT, 0, HALF_UNIT,
(270 + 360) / 2, 0
},
new Object[] { "X -Z",
new Object[]{"X -Z",
HALF_UNIT, 0, -HALF_UNIT,
(270 + 180) / 2, 0
},
new Object[] { "-X -Z",
new Object[]{"-X -Z",
-HALF_UNIT, 0, -HALF_UNIT,
(90 + 180) / 2, 0
},
new Object[] { "-X Z",
new Object[]{"-X Z",
-HALF_UNIT, 0, HALF_UNIT,
(90 + 0) / 2, 0
},
new Object[] { "X Y Z",
new Object[]{"X Y Z",
HALF_HALF_UNIT, HALF_UNIT, HALF_HALF_UNIT,
(270 + 360) / 2, -45
},
new Object[] { "-X -Y -Z",
new Object[]{"-X -Y -Z",
-HALF_HALF_UNIT, -HALF_UNIT, -HALF_HALF_UNIT,
(90 + 180) / 2, 45
},
@ -140,7 +140,7 @@ public class LocationTest {
location.setDirection(vector);
}
return new Object[] { "R" + index,
return new Object[]{"R" + index,
vector.getX(), vector.getY(), vector.getZ(),
location.getYaw(), location.getPitch()
};

View file

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

View file

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

View file

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

View file

@ -25,50 +25,45 @@ import org.junit.Test;
public class MaterialDataTest {
@Test
public void testDoor()
{
public void testDoor() {
@SuppressWarnings("deprecation")
Door door = new 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 direction",door.getFacing(),equalTo(BlockFace.WEST));
assertThat("Constructed with default open state",door.isOpen(),equalTo(false));
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 direction", door.getFacing(), equalTo(BlockFace.WEST));
assertThat("Constructed with default open state", door.isOpen(), equalTo(false));
Material[] types = new Material[] { Material.LEGACY_WOODEN_DOOR,
Material.LEGACY_IRON_DOOR_BLOCK, Material.LEGACY_SPRUCE_DOOR,
Material.LEGACY_BIRCH_DOOR, Material.LEGACY_JUNGLE_DOOR,
Material.LEGACY_ACACIA_DOOR, Material.LEGACY_DARK_OAK_DOOR };
BlockFace[] directions = new BlockFace[] { BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH };
boolean[] openStates = new boolean[] {false, true};
boolean[] hingeStates = new boolean[] {false, true};
for(Material type : types)
{
Material[] types = new Material[]{Material.LEGACY_WOODEN_DOOR,
Material.LEGACY_IRON_DOOR_BLOCK, Material.LEGACY_SPRUCE_DOOR,
Material.LEGACY_BIRCH_DOOR, Material.LEGACY_JUNGLE_DOOR,
Material.LEGACY_ACACIA_DOOR, Material.LEGACY_DARK_OAK_DOOR};
BlockFace[] directions = new BlockFace[]{BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH};
boolean[] openStates = new boolean[]{false, true};
boolean[] hingeStates = new boolean[]{false, true};
for (Material type : types) {
// Test bottom half
for(BlockFace facing : directions)
{
door = new Door(type,facing);
assertThat("Constructed with correct door type",door.getItemType(),equalTo(type));
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false));
assertThat("Constructed with correct direction",door.getFacing(),equalTo(facing));
assertThat("Constructed with default open state",door.isOpen(),equalTo(false));
for (BlockFace facing : directions) {
door = new Door(type, facing);
assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(false));
assertThat("Constructed with correct direction", door.getFacing(), equalTo(facing));
assertThat("Constructed with default open state", door.isOpen(), equalTo(false));
for(boolean openState : openStates)
{
door = new Door(type,facing,openState);
assertThat("Constructed with correct door type",door.getItemType(),equalTo(type));
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false));
assertThat("Constructed with correct direction",door.getFacing(),equalTo(facing));
assertThat("Constructed with correct open state",door.isOpen(),equalTo(openState));
for (boolean openState : openStates) {
door = new Door(type, facing, openState);
assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(false));
assertThat("Constructed with correct direction", door.getFacing(), equalTo(facing));
assertThat("Constructed with correct open state", door.isOpen(), equalTo(openState));
}
}
// Test top half
for(boolean hingeState : hingeStates)
{
door = new Door(type,hingeState);
assertThat("Constructed with correct door type",door.getItemType(),equalTo(type));
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(true));
assertThat("Constructed with correct direction",door.getHinge(),equalTo(hingeState));
for (boolean hingeState : hingeStates) {
door = new Door(type, hingeState);
assertThat("Constructed with correct door type", door.getItemType(), equalTo(type));
assertThat("Constructed with default top or bottom", door.isTopHalf(), equalTo(true));
assertThat("Constructed with correct direction", door.getHinge(), equalTo(hingeState));
}
}
}
@ -242,10 +237,10 @@ public class MaterialDataTest {
@Test
public void testMushroom() {
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.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST,
BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST };
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.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST,
BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST};
MushroomBlockTexture[] textures = MushroomBlockTexture.values();
for (Material type : mushroomTypes) {
Mushroom mushroom = new Mushroom(type);
@ -280,7 +275,7 @@ public class MaterialDataTest {
}
// 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) {
crops = new Crops(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
// 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));
crops = new Crops(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 default crop state", crops.getState(), equalTo(CropState.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();
assertThat("Nether Warts state translations match size", allWartStates.length, equalTo(allStates.length));
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 direction", diode.getFacing(), equalTo(BlockFace.NORTH));
BlockFace[] directions = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
int[] delays = new int[] {1, 2, 3, 4};
boolean[] states = new boolean[] {false, true};
BlockFace[] directions = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
int[] delays = new int[]{1, 2, 3, 4};
boolean[] states = new boolean[]{false, true};
for (BlockFace direction : directions) {
diode = new Diode(direction);
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 direction", comparator.getFacing(), equalTo(BlockFace.NORTH));
BlockFace[] directions = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
boolean[] modes = new boolean[] {false, true};
boolean[] states = new boolean[] {false, true};
BlockFace[] directions = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
boolean[] modes = new boolean[]{false, true};
boolean[] states = new boolean[]{false, true};
for (BlockFace direction : directions) {
comparator = new Comparator(direction);
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));
// 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 powered", comparator.isPowered(), equalTo(state));
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 direction", hopper.getFacing(), equalTo(BlockFace.DOWN));
BlockFace[] directions = new BlockFace[] {BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST};
boolean[] activeStates = new boolean[] {true, false};
BlockFace[] directions = new BlockFace[]{BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST, BlockFace.EAST};
boolean[] activeStates = new boolean[]{true, false};
for (BlockFace direction : directions) {
hopper = new Hopper(direction);
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 correct powered state", hopper.isPowered(), equalTo(false));
assertThat("Constructed with correct direction", hopper.getFacing(), equalTo(direction));
for(boolean isActive : activeStates) {
for (boolean isActive : activeStates) {
hopper = new Hopper(direction, isActive);
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
assertThat("Constructed with correct active state", hopper.isActive(), equalTo(isActive));

View file

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

View file

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

View file

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

View file

@ -10,27 +10,27 @@ import org.junit.Test;
public class StringUtilTest {
@Test(expected=NullPointerException.class)
@Test(expected = NullPointerException.class)
public void nullPrefixTest() {
StringUtil.startsWithIgnoreCase("String", null);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void nullStringTest() {
StringUtil.startsWithIgnoreCase(null, "String");
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void nullCollectionTest() {
StringUtil.copyPartialMatches("Token", ImmutableList.<String>of(), null);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void nullIterableTest() {
StringUtil.copyPartialMatches("Token", null, new ArrayList<String>());
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void nullTokenTest() {
StringUtil.copyPartialMatches(null, ImmutableList.<String>of(), new ArrayList<String>());
}
@ -38,20 +38,20 @@ public class StringUtilTest {
@Test
public void copyTokenTest() {
String token = "ab";
Iterable<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a");
List<String> expected = ImmutableList.of("ab12", "AB5195", "Ab76" );
List<String> original = ImmutableList.of("ab12", "aC561", "AB5195", "Ab76", "", "a");
List<String> expected = ImmutableList.of("ab12", "AB5195", "Ab76");
List<String> list = new ArrayList<String>();
assertThat(StringUtil.copyPartialMatches(token, original, list), is(expected));
assertThat(StringUtil.copyPartialMatches(token, original, list), is(sameInstance(list)));
assertThat(list.size(), is(expected.size() * 2));
}
@Test(expected=UnsupportedOperationException.class)
@Test(expected = UnsupportedOperationException.class)
public void copyUnsupportedTest() {
StringUtil.copyPartialMatches("token", ImmutableList.of("token1", "token2"), ImmutableList.of());
}
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void copyNullTest() {
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)
public class BukkitObjectStreamTest {
@Parameters(name= "{index}: {0}")
@Parameters(name = "{index}: {0}")
public static List<Object[]> data() {
return ImmutableList.<Object[]>of(
new Object[] {