Removed old PlayerActivityGraphCreatorTest

Fix some code smells
This commit is contained in:
Rsl1122 2017-08-17 10:24:39 +03:00
parent b1692f07c5
commit e9b06f4581
6 changed files with 15 additions and 50 deletions

View File

@ -341,6 +341,10 @@ public class Locale {
private static class LocaleHolder { private static class LocaleHolder {
private LocaleHolder() {
throw new IllegalStateException("Static variable holder class");
}
private static Locale locale; private static Locale locale;
public static Locale getLocale() { public static Locale getLocale() {

View File

@ -283,8 +283,8 @@ public class WebServer {
String content = "<h1>403 Forbidden - Access Denied</h1>" String content = "<h1>403 Forbidden - Access Denied</h1>"
+ "<p>Unauthorized User.<br>" + "<p>Unauthorized User.<br>"
+ "Make sure your user has the correct access level.<br>" + "Make sure your user has the correct access level.<br>"
+ "This page requires permission level of " + String.valueOf(required) + ",<br>" + "This page requires permission level of " + required + ",<br>"
+ "This user has permission level of " + String.valueOf(permLevel) + "</p>"; + "This user has permission level of " + permLevel + "</p>";
response403.setContent(content); response403.setContent(content);
return response403; return response403;
}); });

View File

@ -39,7 +39,7 @@ public class ManageUtils {
return false; return false;
} }
backupDB.init(); backupDB.init();
return clearAndCopy(backupDB, copyFromDB, uuids); return clearAndCopy(backupDB, copyFromDB);
} }
/** /**
@ -64,10 +64,9 @@ public class ManageUtils {
* @param clearAndCopyToDB Database that will be cleared data will be copied * @param clearAndCopyToDB Database that will be cleared data will be copied
* to. * to.
* @param copyFromDB Database where data will be copied from * @param copyFromDB Database where data will be copied from
* @param fromDBsavedUUIDs UUID collection of saved uuids in the copyFromDB
* @return success? * @return success?
*/ */
public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB, Collection<UUID> fromDBsavedUUIDs) { public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) {
try { try {
clearAndCopyToDB.removeAllData(); clearAndCopyToDB.removeAllData();
List<UserData> allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs()); List<UserData> allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs());

View File

@ -20,6 +20,10 @@ import java.util.stream.Stream;
public class FileUtil { public class FileUtil {
private FileUtil() {
throw new IllegalStateException("Utility class");
}
public static String getStringFromResource(String fileName) throws FileNotFoundException { public static String getStringFromResource(String fileName) throws FileNotFoundException {
InputStream resourceStream = null; InputStream resourceStream = null;
Scanner scanner = null; Scanner scanner = null;

View File

@ -194,6 +194,8 @@ public class Metrics {
* Starts the Scheduler which submits our data every 30 minutes. * Starts the Scheduler which submits our data every 30 minutes.
*/ */
private void startSubmitting() { private void startSubmitting() {
final Metrics metrics = this;
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
timer.scheduleAtFixedRate(new TimerTask() { timer.scheduleAtFixedRate(new TimerTask() {
@Override @Override
@ -204,7 +206,7 @@ public class Metrics {
} }
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler // Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;) // Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
Bukkit.getScheduler().runTask(plugin, () -> submitData()); Bukkit.getScheduler().runTask(plugin, metrics::submitData);
} }
}, TimeAmount.MINUTE.ms() * 5, TimeAmount.MINUTE.ms() * 30); }, TimeAmount.MINUTE.ms() * 5, TimeAmount.MINUTE.ms() * 30);
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start

View File

@ -1,44 +0,0 @@
package test.java.main.java.com.djrapitops.plan.ui.graphs;
import main.java.com.djrapitops.plan.data.SessionData;
import org.junit.Before;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
/**
* @author Rsl1122
*/
public class PlayerActivityGraphCreatorTest {
/**
*
*/
public PlayerActivityGraphCreatorTest() {
}
/**
* @return
*/
public static List<SessionData> createRandomSessionDataList() {
List<SessionData> list = new ArrayList<>();
Random r = new Random();
long now = new Date().toInstant().getEpochSecond();
while (list.size() < 500) {
int randomStart = r.nextInt(2592000);
long start = now - (long) (randomStart + 10);
long end = start + (long) r.nextInt(randomStart);
list.add(new SessionData((start * (long) 1000), (end * (long) 1000)));
}
return list;
}
/**
*
*/
@Before
public void setUp() throws Exception {
}
}