Fixed compile issues

This commit is contained in:
Rsl1122 2017-08-28 13:33:39 +03:00
parent 92626b2220
commit 48858b511a
11 changed files with 55 additions and 53 deletions

View File

@ -5,7 +5,7 @@
package main.java.com.djrapitops.plan.api.exceptions; package main.java.com.djrapitops.plan.api.exceptions;
/** /**
* //TODO Class Javadoc Comment * Thrown when something goes wrong in the database, generic exception.
* *
* @author Rsl1122 * @author Rsl1122
*/ */

View File

@ -5,7 +5,7 @@
package main.java.com.djrapitops.plan.api.exceptions; package main.java.com.djrapitops.plan.api.exceptions;
/** /**
* //TODO Class Javadoc Comment * Thrown when something goes wrong with Database#init.
* *
* @author Rsl1122 * @author Rsl1122
*/ */

View File

@ -5,7 +5,7 @@
package main.java.com.djrapitops.plan.api.exceptions; package main.java.com.djrapitops.plan.api.exceptions;
/** /**
* //TODO Class Javadoc Comment * Thrown when something goes wrong with creating tables with Table#createTable.
* *
* @author Rsl1122 * @author Rsl1122
*/ */

View File

@ -5,7 +5,7 @@
package main.java.com.djrapitops.plan.api.exceptions; package main.java.com.djrapitops.plan.api.exceptions;
/** /**
* //TODO Class Javadoc Comment * Thrown when something goes wrong with Plan initialization.
* *
* @author Rsl1122 * @author Rsl1122
*/ */

View File

@ -8,6 +8,7 @@ import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
@ -60,7 +61,7 @@ public class ManageBackupCommand extends SubCommand {
} }
runBackupTask(sender, args, database); runBackupTask(sender, args, database);
} catch (NullPointerException e) { } catch (DatabaseInitException | NullPointerException e) {
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
} }
return true; return true;

View File

@ -5,14 +5,12 @@ import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Check;
import main.java.com.djrapitops.plan.utilities.ManageUtils;
/** /**
* This manage subcommand is used to clear a database of all data. * This manage subcommand is used to clear a database of all data.
@ -62,15 +60,16 @@ public class ManageClearCommand extends SubCommand {
return true; return true;
} }
final Database database = ManageUtils.getDB(plugin, dbName); // TODO CLEAR COMMAND
// final Database database = ManageUtils.getDB(plugin, dbName);
//
// // If DB is null return
// if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
// Log.error(dbName + " was null!");
// return true;
// }
// If DB is null return // runClearTask(sender, database);
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!");
return true;
}
runClearTask(sender, database);
return true; return true;
} }

View File

@ -61,17 +61,18 @@ public class ManageHotswapCommand extends SubCommand {
return true; return true;
} }
final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!");
return true;
}
assert database != null;
try { try {
final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!");
return true;
}
assert database != null;
database.getVersion(); //Test db connection database.getVersion(); //Test db connection
} catch (Exception e) { } catch (Exception e) {
Log.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);

View File

@ -72,21 +72,22 @@ public class ManageMoveCommand extends SubCommand {
return true; return true;
} }
final Database fromDatabase = ManageUtils.getDB(plugin, fromDB); // TODO Move command.
// final Database fromDatabase = ManageUtils.getDB(plugin, fromDB);
if (!Check.isTrue(Verify.notNull(fromDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { // if (!Check.isTrue(Verify.notNull(fromDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(fromDB + " was null!"); // Log.error(fromDB + " was null!");
return true; // return true;
} // }
final Database toDatabase = ManageUtils.getDB(plugin, toDB); // final Database toDatabase = ManageUtils.getDB(plugin, toDB);
if (!Check.isTrue(Verify.notNull(toDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { // if (!Check.isTrue(Verify.notNull(toDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(toDB + " was null!"); // Log.error(toDB + " was null!");
return true; // return true;
} // }
runMoveTask(fromDatabase, toDatabase, sender); // runMoveTask(fromDatabase, toDatabase, sender);
return true; return true;
} }

View File

@ -61,14 +61,15 @@ public class ManageRestoreCommand extends SubCommand {
return true; return true;
} }
final Database database = ManageUtils.getDB(plugin, db); // TODO Restore command
// final Database database = ManageUtils.getDB(plugin, db);
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { //
Log.error(db + " was null!"); // if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
return true; // Log.error(db + " was null!");
} // return true;
// }
runRestoreTask(args, sender, database); //
// runRestoreTask(args, sender, database);
return true; return true;
} }

View File

@ -6,7 +6,6 @@ import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB; import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
import main.java.com.djrapitops.plan.utilities.file.FileUtil; import main.java.com.djrapitops.plan.utilities.file.FileUtil;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.junit.After; import org.junit.After;
@ -66,7 +65,7 @@ public class DatabaseCommitTest {
} }
@Test @Test
public void testNoExceptionWhenCommitEmpty() throws SQLException { public void testNoExceptionWhenCommitEmpty() throws Exception {
db.init(); db.init();
db.commit(db.getConnection()); db.commit(db.getConnection());
@ -76,13 +75,13 @@ public class DatabaseCommitTest {
@Ignore("//TODO") @Ignore("//TODO")
@Test @Test
public void testCommitToDBFile() throws SQLException { public void testCommitToDBFile() throws Exception {
db.init(); db.init();
} }
@Ignore("//TODO") @Ignore("//TODO")
@Test @Test
public void testCommitToDBFile2() throws SQLException { public void testCommitToDBFile2() throws Exception {
db.init(); db.init();
List<TPS> tps = RandomData.randomTPS(); List<TPS> tps = RandomData.randomTPS();
// db.getTpsTable().saveTPSData(tps); // db.getTpsTable().saveTPSData(tps);
@ -94,7 +93,7 @@ public class DatabaseCommitTest {
// TODO Commit tests for new Login save features. // TODO Commit tests for new Login save features.
@Test @Test
public void testCommitToDBFile5() throws SQLException, PassEncryptUtil.CannotPerformOperationException { public void testCommitToDBFile5() throws Exception {
db.init(); db.init();
WebUser webUser = new WebUser("Test", "SHA1:rioegnorgiengoieng:oiegnoeigneo:352", 0); WebUser webUser = new WebUser("Test", "SHA1:rioegnorgiengoieng:oiegnoeigneo:352", 0);
db.getSecurityTable().addNewUser(webUser); db.getSecurityTable().addNewUser(webUser);

View File

@ -6,6 +6,7 @@
package test.java.main.java.com.djrapitops.plan.database; package test.java.main.java.com.djrapitops.plan.database;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.data.*; import main.java.com.djrapitops.plan.data.*;
import main.java.com.djrapitops.plan.data.time.GMTimes; import main.java.com.djrapitops.plan.data.time.GMTimes;
import main.java.com.djrapitops.plan.data.time.WorldTimes; import main.java.com.djrapitops.plan.data.time.WorldTimes;
@ -84,8 +85,8 @@ public class DatabaseTest {
} }
@Test @Test
public void testInit() { public void testInit() throws DatabaseInitException {
assertTrue("Database failed to init.", db.init()); db.init();
} }
@Test @Test
@ -176,8 +177,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testTPSSaving() throws SQLException { public void testTPSSaving() throws Exception {
db.init();
TPSTable tpsTable = db.getTpsTable(); TPSTable tpsTable = db.getTpsTable();
Random r = new Random(); Random r = new Random();