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;
/**
* //TODO Class Javadoc Comment
* Thrown when something goes wrong in the database, generic exception.
*
* @author Rsl1122
*/

View File

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

View File

@ -5,7 +5,7 @@
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
*/

View File

@ -5,7 +5,7 @@
package main.java.com.djrapitops.plan.api.exceptions;
/**
* //TODO Class Javadoc Comment
* Thrown when something goes wrong with Plan initialization.
*
* @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.Permissions;
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.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
@ -60,7 +61,7 @@ public class ManageBackupCommand extends SubCommand {
}
runBackupTask(sender, args, database);
} catch (NullPointerException e) {
} catch (DatabaseInitException | NullPointerException e) {
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
}
return true;

View File

@ -5,14 +5,12 @@ import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
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.
@ -62,15 +60,16 @@ public class ManageClearCommand extends SubCommand {
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
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);
// runClearTask(sender, database);
return true;
}

View File

@ -61,6 +61,7 @@ public class ManageHotswapCommand extends SubCommand {
return true;
}
try {
final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return
@ -71,7 +72,7 @@ public class ManageHotswapCommand extends SubCommand {
assert database != null;
try {
database.getVersion(); //Test db connection
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);

View File

@ -72,21 +72,22 @@ public class ManageMoveCommand extends SubCommand {
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)) {
Log.error(fromDB + " was null!");
return true;
}
// if (!Check.isTrue(Verify.notNull(fromDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
// Log.error(fromDB + " was null!");
// 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)) {
Log.error(toDB + " was null!");
return true;
}
// if (!Check.isTrue(Verify.notNull(toDatabase), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
// Log.error(toDB + " was null!");
// return true;
// }
runMoveTask(fromDatabase, toDatabase, sender);
// runMoveTask(fromDatabase, toDatabase, sender);
return true;
}

View File

@ -61,14 +61,15 @@ public class ManageRestoreCommand extends SubCommand {
return true;
}
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!");
return true;
}
runRestoreTask(args, sender, database);
// 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!");
// return true;
// }
//
// runRestoreTask(args, sender, database);
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.SQLiteDB;
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 org.bukkit.plugin.java.JavaPlugin;
import org.junit.After;
@ -66,7 +65,7 @@ public class DatabaseCommitTest {
}
@Test
public void testNoExceptionWhenCommitEmpty() throws SQLException {
public void testNoExceptionWhenCommitEmpty() throws Exception {
db.init();
db.commit(db.getConnection());
@ -76,13 +75,13 @@ public class DatabaseCommitTest {
@Ignore("//TODO")
@Test
public void testCommitToDBFile() throws SQLException {
public void testCommitToDBFile() throws Exception {
db.init();
}
@Ignore("//TODO")
@Test
public void testCommitToDBFile2() throws SQLException {
public void testCommitToDBFile2() throws Exception {
db.init();
List<TPS> tps = RandomData.randomTPS();
// db.getTpsTable().saveTPSData(tps);
@ -94,7 +93,7 @@ public class DatabaseCommitTest {
// TODO Commit tests for new Login save features.
@Test
public void testCommitToDBFile5() throws SQLException, PassEncryptUtil.CannotPerformOperationException {
public void testCommitToDBFile5() throws Exception {
db.init();
WebUser webUser = new WebUser("Test", "SHA1:rioegnorgiengoieng:oiegnoeigneo:352", 0);
db.getSecurityTable().addNewUser(webUser);

View File

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