mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-15 12:41:36 +01:00
Improved PassEncryptTest runtime from 12s to 4s
Added debug varargs method
This commit is contained in:
parent
99da328544
commit
156aef8ce4
@ -58,16 +58,32 @@ public class Log {
|
||||
Plan.getInstance().getPluginLogger().debug(message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used for logging larger debug complexes.
|
||||
*
|
||||
* @param task complex this debug message is a part of.
|
||||
* @param message message
|
||||
* @param message Single message to add to the debug log.
|
||||
* @return full debug complex so far.
|
||||
*/
|
||||
public static DebugInfo debug(String task, String message) {
|
||||
return getDebug(task).addLine(message, MiscUtils.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for logging larger debug complexes.
|
||||
*
|
||||
* @param task complex this debug message is a part of.
|
||||
* @param messages All messages to add to the debug log.
|
||||
* @return full debug complex so far.
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static DebugInfo debug(String task, String... messages) {
|
||||
DebugInfo debug = getDebug(task);
|
||||
debug.addLine(message, MiscUtils.getTime());
|
||||
long time = MiscUtils.getTime();
|
||||
for (String message : messages) {
|
||||
debug.addLine(message, time);
|
||||
}
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
@ -410,16 +410,18 @@ public abstract class SQLDB extends Database {
|
||||
Map<Integer, Map<String, Long>> gmTimes = gmTimesTable.getGMTimes(ids);
|
||||
Map<Integer, Map<String, Long>> worldTimes = worldTimesTable.getWorldTimes(ids);
|
||||
|
||||
Log.debug("Database", "Data found for:");
|
||||
Log.debug("Database", " UUIDs: " + uuids.size());
|
||||
Log.debug("Database", " IDs: " + userIds.size());
|
||||
Log.debug("Database", " UserData: " + data.size());
|
||||
Log.debug("Database", " Nicknames: " + nicknames.size());
|
||||
Log.debug("Database", " IPs: " + ipList.size());
|
||||
Log.debug("Database", " Kills: " + playerKills.size());
|
||||
Log.debug("Database", " Sessions: " + sessionData.size());
|
||||
Log.debug("Database", " GM Times: " + gmTimes.size());
|
||||
Log.debug("Database", " World Times: " + worldTimes.size());
|
||||
Log.debug("Database",
|
||||
"Data found for:",
|
||||
" UUIDs: " + uuids.size(),
|
||||
" IDs: " + userIds.size(),
|
||||
" UserData: " + data.size(),
|
||||
" Nicknames: " + nicknames.size(),
|
||||
" IPs: " + ipList.size(),
|
||||
" Kills: " + playerKills.size(),
|
||||
" Sessions: " + sessionData.size(),
|
||||
" GM Times: " + gmTimes.size(),
|
||||
" World Times: " + worldTimes.size()
|
||||
);
|
||||
|
||||
for (UserData uData : data) {
|
||||
UUID uuid = uData.getUuid();
|
||||
|
@ -5,11 +5,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import test.java.utils.RandomData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -19,16 +16,14 @@ import static org.junit.Assert.assertTrue;
|
||||
*/
|
||||
public class PassEncryptTest {
|
||||
|
||||
private final List<String> PASSWORDS = new ArrayList<>();
|
||||
private final Map<String, String> PASSWORD_MAP = new HashMap<>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
IntStream.range(0, 50).forEach(i -> PASSWORDS.add(RandomData.randomString(RandomData.randomInt(1, 100))));
|
||||
|
||||
for (String password : PASSWORDS) {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
String password = RandomData.randomString(RandomData.randomInt(1, 50));
|
||||
PASSWORD_MAP.put(password, PassEncryptUtil.createHash(password));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -38,7 +33,7 @@ public class PassEncryptTest {
|
||||
String hash = entry.getValue();
|
||||
|
||||
assertTrue(PassEncryptUtil.verifyPassword(password, hash));
|
||||
assertFalse(PassEncryptUtil.verifyPassword(RandomData.randomString(RandomData.randomInt(1, 100)), hash));
|
||||
assertFalse(PassEncryptUtil.verifyPassword("WrongPassword", hash));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user