Fixed failing tests (thanks @rlf)

* This is the test fixing portion of PR#1746
* This fixes using a HashMap and relying on the order of the values.

(cherry picked from commit 8fdc0ad3da)
This commit is contained in:
rlf 2016-11-19 15:51:11 -05:00 committed by Jeremy Wood
parent ff1448fb5f
commit 43309dc841

View File

@ -24,12 +24,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.LinkedHashMap;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
public class MockWorldFactory { public class MockWorldFactory {
private static final Map<String, World> createdWorlds = new HashMap<String, World>(); private static final Map<String, World> createdWorlds = new LinkedHashMap<String, World>();
private static final Map<UUID, World> worldUIDS = new HashMap<UUID, World>(); private static final Map<UUID, World> worldUIDS = new HashMap<UUID, World>();
private static final Map<World, Boolean> pvpStates = new WeakHashMap<World, Boolean>(); private static final Map<World, Boolean> pvpStates = new WeakHashMap<World, Boolean>();
@ -212,13 +213,7 @@ public class MockWorldFactory {
} }
public static List<World> getWorlds() { public static List<World> getWorlds() {
// we have to invert the order! return new ArrayList<World>(createdWorlds.values());
ArrayList<World> myList = new ArrayList<World>(createdWorlds.values());
List<World> retList = new ArrayList<World>();
for (int i = (myList.size() - 1); i >= 0; i--) {
retList.add(myList.get(i));
}
return retList;
} }
public static void clearWorlds() { public static void clearWorlds() {