mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
fixes (some test cases don't pass)
This commit is contained in:
parent
e7f9030757
commit
2211a8fb24
@ -600,7 +600,10 @@ public class PlotMain extends JavaPlugin {
|
||||
|
||||
// Use mysql?
|
||||
if (Settings.DB.USE_MYSQL) {
|
||||
|
||||
if (DBFunc.dbManager == null) {
|
||||
DBFunc.dbManager = new SQLManager();
|
||||
}
|
||||
try {
|
||||
mySQL = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
||||
connection = mySQL.openConnection();
|
||||
@ -620,6 +623,12 @@ public class PlotMain extends JavaPlugin {
|
||||
if (!res.next()) {
|
||||
DBFunc.createTables("mysql", false);
|
||||
}
|
||||
else {
|
||||
res = meta.getTables(null, null, Settings.DB.PREFIX + "plot_comments", null);
|
||||
if (!res.next()) {
|
||||
DBFunc.createTables("mysql", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,9 @@ public class Claim extends SubCommand {
|
||||
final DefaultPlotWorld pW = (DefaultPlotWorld) world;
|
||||
if (pW.CLAIMED_WALL_BLOCK != pW.WALL_BLOCK) {
|
||||
PlotMain.getPlotManager(plot.getWorld()).setWall(plot.getWorld(), world, plot.getId(), pW.CLAIMED_WALL_BLOCK);
|
||||
if (PlotHelper.canSetFast) {
|
||||
SetBlockFast.update(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,256 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.intellectualcrafters.plot.Flag;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotComment;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlotManager;
|
||||
import com.intellectualcrafters.plot.PlotWorld;
|
||||
import com.intellectualcrafters.plot.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.Settings;
|
||||
import com.intellectualcrafters.plot.commands.Schematic;
|
||||
import com.intellectualcrafters.plot.database.AbstractDB;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.DefaultPlotManager;
|
||||
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
||||
import com.sk89q.worldguard.bukkit.BukkitBlacklist;
|
||||
|
||||
public class Test1 {
|
||||
|
||||
Integer count;
|
||||
|
||||
// I have no idea what I should actually test :p
|
||||
|
||||
@Test
|
||||
public void testSquare() {
|
||||
Assert.assertEquals(PlotHelper.square(5), 25);
|
||||
|
||||
public boolean nextTest() {
|
||||
PlotMain.counter++;
|
||||
switch (PlotMain.counter) {
|
||||
case 1:
|
||||
return test1_Square();
|
||||
case 2:
|
||||
return test2_InitMain(); // fails
|
||||
case 3:
|
||||
return test3_InitPlotId();
|
||||
case 4:
|
||||
return test4_InitPlot();
|
||||
case 5:
|
||||
return test5_InitDBFunc();
|
||||
case 6:
|
||||
return test6_Plots(); // fails
|
||||
case 7:
|
||||
return test7_OnEnable(); // fails
|
||||
case 8:
|
||||
return test8_AddPlotWorld(); // fails
|
||||
case 9:
|
||||
return test9_CanSetFast(); // fails
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlots() {
|
||||
Assert.assertNotNull(PlotMain.getAllPlotsRaw());
|
||||
@Test public void t1() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t2() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t3() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t4() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t5() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t6() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t7() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t8() {Assert.assertTrue(nextTest());}
|
||||
@Test public void t9() {Assert.assertTrue(nextTest());}
|
||||
|
||||
public boolean test1_Square() {
|
||||
return PlotHelper.square(5) == 25;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPlotWorld() {
|
||||
public boolean test2_InitMain() {
|
||||
boolean passed = false;
|
||||
try {
|
||||
PlotMain plugin = PlotMain.getMain();
|
||||
passed = plugin != null;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
public boolean test3_InitPlotId() {
|
||||
boolean passed = false;
|
||||
try {
|
||||
Object id = new PlotId(0,0);
|
||||
passed = id != null;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
public boolean test4_InitPlot() {
|
||||
boolean passed = false;
|
||||
try {
|
||||
Object plot = new Plot(new PlotId(0,0), DBFunc.everyone, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), null, PlotHomePosition.DEFAULT, null, "testworld", new boolean[] {false, false, false, false} );
|
||||
passed = plot != null;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
public boolean test5_InitDBFunc() {
|
||||
|
||||
Settings.DB.USE_MONGO = true;
|
||||
Settings.DB.USE_MYSQL = false;
|
||||
Settings.DB.USE_SQLITE = false;
|
||||
|
||||
boolean passed = false;
|
||||
try {
|
||||
DBFunc.dbManager = new AbstractDB() {
|
||||
|
||||
@Override
|
||||
public void setTrusted(String world, Plot plot, OfflinePlayer player) {
|
||||
}
|
||||
@Override
|
||||
public void setPosition(String world, Plot plot, String position) {
|
||||
}
|
||||
@Override
|
||||
public void setOwner(Plot plot, UUID uuid) {
|
||||
}
|
||||
@Override
|
||||
public void setMerged(String world, Plot plot, boolean[] merged) {
|
||||
}
|
||||
@Override
|
||||
public void setHelper(String world, Plot plot, OfflinePlayer player) {
|
||||
}
|
||||
@Override
|
||||
public void setFlags(String world, Plot plot, Flag[] flags) {
|
||||
}
|
||||
@Override
|
||||
public void setDenied(String world, Plot plot, OfflinePlayer player) {
|
||||
}
|
||||
@Override
|
||||
public void setComment(String world, Plot plot, PlotComment comment) {
|
||||
}
|
||||
@Override
|
||||
public void setAlias(String world, Plot plot, String alias) {
|
||||
}
|
||||
@Override
|
||||
public void removeTrusted(String world, Plot plot, OfflinePlayer player) {
|
||||
}
|
||||
@Override
|
||||
public void removeHelper(String world, Plot plot, OfflinePlayer player) {
|
||||
}
|
||||
@Override
|
||||
public void removeDenied(String world, Plot plot, OfflinePlayer player) {
|
||||
}
|
||||
@Override
|
||||
public void removeComment(String world, Plot plot, PlotComment comment) {
|
||||
}
|
||||
@Override
|
||||
public void purge(String world) {
|
||||
}
|
||||
@Override
|
||||
public void purge(String world, PlotId id) {
|
||||
}
|
||||
@Override
|
||||
public HashMap<String, Object> getSettings(int id) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public double getRatings(Plot plot) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public LinkedHashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
LinkedHashMap<String, HashMap<PlotId, Plot>> plots = new LinkedHashMap<String, HashMap<PlotId, Plot>>();
|
||||
|
||||
plots.put("testworld", new HashMap<PlotId, Plot>());
|
||||
|
||||
PlotId id = new PlotId(0,0);
|
||||
|
||||
plots.get("testworld").put(id,
|
||||
new Plot(id,
|
||||
DBFunc.everyone,
|
||||
Biome.FOREST,
|
||||
new ArrayList<UUID>(),
|
||||
new ArrayList<UUID>(),
|
||||
new ArrayList<UUID>(),
|
||||
null,
|
||||
PlotHomePosition.DEFAULT,
|
||||
null,
|
||||
"testworld",
|
||||
new boolean[] {false, false, false, false}));
|
||||
|
||||
return plots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(String world, PlotId id2) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public ArrayList<PlotComment> getComments(String world, Plot plot, int tier) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void delete(String world, Plot plot) {
|
||||
}
|
||||
@Override
|
||||
public void createTables(String database, boolean add_constraint) throws Exception {
|
||||
}
|
||||
@Override
|
||||
public void createPlots(ArrayList<Plot> plots) {
|
||||
}
|
||||
@Override
|
||||
public void createPlotSettings(int id, Plot plot) {
|
||||
}
|
||||
@Override
|
||||
public void createPlot(Plot plot) {
|
||||
}
|
||||
@Override
|
||||
public void createAllSettingsAndHelpers(ArrayList<Plot> plots) {
|
||||
}
|
||||
};
|
||||
passed = true;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
public boolean test6_Plots() {
|
||||
return PlotMain.getAllPlotsRaw() != null;
|
||||
}
|
||||
|
||||
public boolean test7_OnEnable() {
|
||||
boolean passed = false;
|
||||
try {
|
||||
PlotMain.getMain().onEnable();
|
||||
passed = true;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
public boolean test8_AddPlotWorld() {
|
||||
boolean passed = false;
|
||||
try {
|
||||
final PlotWorld plotworld = new DefaultPlotWorld("poop");
|
||||
@ -34,14 +261,21 @@ public class Test1 {
|
||||
catch (final Throwable e) {
|
||||
|
||||
}
|
||||
finally {
|
||||
Assert.assertTrue(passed);
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCanSetFast() {
|
||||
Assert.assertTrue(PlotHelper.canSetFast);
|
||||
|
||||
public boolean test9_CanSetFast() {
|
||||
boolean passed = false;
|
||||
try {
|
||||
new SetBlockFast();
|
||||
passed = true;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user