Debug stuff for the broken test

This commit is contained in:
Rsl1122 2017-09-03 15:46:58 +03:00
parent 0aefa72eda
commit 78bcb3fda6
6 changed files with 54 additions and 19 deletions

View File

@ -86,4 +86,16 @@ public class UserInfo {
public int hashCode() {
return Objects.hash(uuid, name, registered, lastSeen, banned, opped);
}
@Override
public String toString() {
return "UserInfo{" +
"uuid=" + uuid +
", name='" + name + '\'' +
", registered=" + registered +
", lastSeen=" + lastSeen +
", banned=" + banned +
", opped=" + opped +
'}';
}
}

View File

@ -85,7 +85,7 @@ public abstract class SQLDB extends Database {
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
} finally {
cancel();
super.cancel();
}
}
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * secondsDelay);

View File

@ -114,6 +114,7 @@ public abstract class Table {
* @throws SQLException
*/
protected PreparedStatement prepareStatement(String sql) throws SQLException {
System.out.println(sql);
return getConnection().prepareStatement(sql);
}
@ -210,4 +211,8 @@ public abstract class Table {
public int hashCode() {
return Objects.hashCode(tableName, db, usingMySQL);
}
public SQLDB getDb() {
return db;
}
}

View File

@ -226,8 +226,9 @@ public class UserInfoTable extends UserIDTable {
userInfos.add(new UserInfo(uuid, "", registered, op, banned));
serverMap.put(uuid, userInfos);
serverMap.put(serverUUID, userInfos);
}
System.out.println(serverMap);
return serverMap;
} finally {
endTransaction(statement);

View File

@ -4,6 +4,7 @@
*/
package main.java.com.djrapitops.plan.database.tables.move;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
@ -67,92 +68,105 @@ public class BatchOperationTable extends Table {
if (toDB.equals(this)) {
return;
}
toDB.db.removeAllData();
Log.debug("Start Batch Copy Everything");
toDB.getDb().removeAllData();
copyServers(toDB);
System.out.println(toDB.getDb().getServerTable().getServerNames().toString());
copyUsers(toDB);
System.out.println(toDB.getDb().getSavedUUIDs().toString());
copyWorlds(toDB);
copyUserInfo(toDB);
copyActions(toDB);
copyCommandUse(toDB);
copyIPsAndGeolocs(toDB);
copyNicknames(toDB);
copyTPS(toDB);
copyWebUsers(toDB);
copyCommandUse(toDB);
copyActions(toDB);
copyIPsAndGeolocs(toDB);
copyNicknames(toDB);
copySessions(toDB);
copyUserInfo(toDB);
}
public void copyActions(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getActionsTable().insertActions(db.getActionsTable().getAllActions());
Log.debug("Batch Copy Actions");
toDB.getDb().getActionsTable().insertActions(db.getActionsTable().getAllActions());
}
public void copyCommandUse(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getCommandUseTable().insertCommandUsage(db.getCommandUseTable().getAllCommandUsages());
Log.debug("Batch Copy Commands");
toDB.getDb().getCommandUseTable().insertCommandUsage(db.getCommandUseTable().getAllCommandUsages());
}
public void copyIPsAndGeolocs(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getIpsTable().insertIPsAndGeolocations(db.getIpsTable().getAllIPsAndGeolocations());
Log.debug("Batch Copy IPs & Geolocations");
toDB.getDb().getIpsTable().insertIPsAndGeolocations(db.getIpsTable().getAllIPsAndGeolocations());
}
public void copyNicknames(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getNicknamesTable().insertNicknames(db.getNicknamesTable().getAllNicknames());
Log.debug("Batch Copy Nicknames");
toDB.getDb().getNicknamesTable().insertNicknames(db.getNicknamesTable().getAllNicknames());
}
public void copyWebUsers(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getSecurityTable().addUsers(db.getSecurityTable().getUsers());
Log.debug("Batch Copy WebUsers");
toDB.getDb().getSecurityTable().addUsers(db.getSecurityTable().getUsers());
}
public void copyServers(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
Log.debug("Batch Copy Servers");
ServerTable serverTable = db.getServerTable();
List<ServerInfo> servers = serverTable.getBukkitServers();
serverTable.getBungeeInfo().ifPresent(servers::add);
toDB.db.getServerTable().insertAllServers(servers);
toDB.getDb().getServerTable().insertAllServers(servers);
}
public void copyTPS(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getTpsTable().insertAllTPS(db.getTpsTable().getAllTPS());
Log.debug("Batch Copy TPS");
toDB.getDb().getTpsTable().insertAllTPS(db.getTpsTable().getAllTPS());
}
public void copyUserInfo(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getUserInfoTable().insertUserInfo(db.getUserInfoTable().getAllUserInfo());
Log.debug("Batch Copy UserInfo");
toDB.getDb().getUserInfoTable().insertUserInfo(db.getUserInfoTable().getAllUserInfo());
}
public void copyWorlds(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getWorldTable().saveWorlds(db.getWorldTable().getWorlds());
Log.debug("Batch Copy Worlds");
toDB.getDb().getWorldTable().saveWorlds(db.getWorldTable().getWorlds());
}
public void copyUsers(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
Log.debug("Batch Copy Users");
UsersTable fromTable = db.getUsersTable();
UsersTable toTable = toDB.db.getUsersTable();
UsersTable toTable = toDB.getDb().getUsersTable();
toTable.insertUsers(fromTable.getUsers());
toTable.updateKicked(fromTable.getAllTimesKicked());
}
@ -161,6 +175,7 @@ public class BatchOperationTable extends Table {
if (toDB.equals(this)) {
return;
}
toDB.db.getSessionsTable().insertSessions(db.getSessionsTable().getAllSessions(true), true);
Log.debug("Batch Copy Sessions");
toDB.getDb().getSessionsTable().insertSessions(db.getSessionsTable().getAllSessions(true), true);
}
}

View File

@ -596,6 +596,7 @@ public class DatabaseTest {
}
private void saveAllData(Database database) throws SQLException {
System.out.println("Saving all possible data to the Database..");
UserInfoTable userInfoTable = database.getUserInfoTable();
UsersTable usersTable = database.getUsersTable();
SessionsTable sessionsTable = database.getSessionsTable();
@ -647,6 +648,7 @@ public class DatabaseTest {
}
securityTable.addNewUser(new WebUser("Test", "RandomGarbageBlah", 0));
System.out.println("Done!\n");
}
@Test