mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-15 20:51:21 +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);
|
Plan.getInstance().getPluginLogger().debug(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for logging larger debug complexes.
|
* Used for logging larger debug complexes.
|
||||||
*
|
*
|
||||||
* @param task complex this debug message is a part of.
|
* @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.
|
* @return full debug complex so far.
|
||||||
*/
|
*/
|
||||||
public static DebugInfo debug(String task, String message) {
|
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);
|
DebugInfo debug = getDebug(task);
|
||||||
debug.addLine(message, MiscUtils.getTime());
|
long time = MiscUtils.getTime();
|
||||||
|
for (String message : messages) {
|
||||||
|
debug.addLine(message, time);
|
||||||
|
}
|
||||||
return debug;
|
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>> gmTimes = gmTimesTable.getGMTimes(ids);
|
||||||
Map<Integer, Map<String, Long>> worldTimes = worldTimesTable.getWorldTimes(ids);
|
Map<Integer, Map<String, Long>> worldTimes = worldTimesTable.getWorldTimes(ids);
|
||||||
|
|
||||||
Log.debug("Database", "Data found for:");
|
Log.debug("Database",
|
||||||
Log.debug("Database", " UUIDs: " + uuids.size());
|
"Data found for:",
|
||||||
Log.debug("Database", " IDs: " + userIds.size());
|
" UUIDs: " + uuids.size(),
|
||||||
Log.debug("Database", " UserData: " + data.size());
|
" IDs: " + userIds.size(),
|
||||||
Log.debug("Database", " Nicknames: " + nicknames.size());
|
" UserData: " + data.size(),
|
||||||
Log.debug("Database", " IPs: " + ipList.size());
|
" Nicknames: " + nicknames.size(),
|
||||||
Log.debug("Database", " Kills: " + playerKills.size());
|
" IPs: " + ipList.size(),
|
||||||
Log.debug("Database", " Sessions: " + sessionData.size());
|
" Kills: " + playerKills.size(),
|
||||||
Log.debug("Database", " GM Times: " + gmTimes.size());
|
" Sessions: " + sessionData.size(),
|
||||||
Log.debug("Database", " World Times: " + worldTimes.size());
|
" GM Times: " + gmTimes.size(),
|
||||||
|
" World Times: " + worldTimes.size()
|
||||||
|
);
|
||||||
|
|
||||||
for (UserData uData : data) {
|
for (UserData uData : data) {
|
||||||
UUID uuid = uData.getUuid();
|
UUID uuid = uData.getUuid();
|
||||||
|
@ -5,11 +5,8 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import test.java.utils.RandomData;
|
import test.java.utils.RandomData;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@ -19,16 +16,14 @@ import static org.junit.Assert.assertTrue;
|
|||||||
*/
|
*/
|
||||||
public class PassEncryptTest {
|
public class PassEncryptTest {
|
||||||
|
|
||||||
private final List<String> PASSWORDS = new ArrayList<>();
|
|
||||||
private final Map<String, String> PASSWORD_MAP = new HashMap<>();
|
private final Map<String, String> PASSWORD_MAP = new HashMap<>();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
IntStream.range(0, 50).forEach(i -> PASSWORDS.add(RandomData.randomString(RandomData.randomInt(1, 100))));
|
for (int i = 0; i < 20; i++) {
|
||||||
|
String password = RandomData.randomString(RandomData.randomInt(1, 50));
|
||||||
for (String password : PASSWORDS) {
|
|
||||||
PASSWORD_MAP.put(password, PassEncryptUtil.createHash(password));
|
PASSWORD_MAP.put(password, PassEncryptUtil.createHash(password));
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -38,7 +33,7 @@ public class PassEncryptTest {
|
|||||||
String hash = entry.getValue();
|
String hash = entry.getValue();
|
||||||
|
|
||||||
assertTrue(PassEncryptUtil.verifyPassword(password, hash));
|
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