mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-13 03:41:03 +01:00
Fixed tests
This commit is contained in:
parent
cb41ad61be
commit
5dba6ac27c
@ -14,11 +14,11 @@ import java.util.HashMap;
|
||||
*/
|
||||
public class PlaceholderReplacer extends HashMap<String, Serializable> implements Formatter<String> {
|
||||
|
||||
public void addPlaceholderFrom(DataContainer container, PlaceholderKey key) {
|
||||
public <T> void addPlaceholderFrom(DataContainer container, PlaceholderKey<T> key) {
|
||||
if (!container.supports(key)) {
|
||||
return;
|
||||
}
|
||||
put(key.getPlaceholder(), container.get(key).get().toString());
|
||||
put(key.getPlaceholder(), container.getSupplier(key).get().toString());
|
||||
}
|
||||
|
||||
public void addAllPlaceholdersFrom(DataContainer container, PlaceholderKey... keys) {
|
||||
|
@ -4,16 +4,26 @@
|
||||
*/
|
||||
package com.djrapitops.plan.data.additional.importer;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.data.time.GMTimes;
|
||||
import com.djrapitops.plan.system.database.databases.SQLiteTest;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
import com.djrapitops.plan.system.processing.importing.ServerImportData;
|
||||
import com.djrapitops.plan.system.processing.importing.UserImportData;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
import utilities.TestErrorManager;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -29,9 +39,27 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class ImportBuilderTest {
|
||||
|
||||
@ClassRule
|
||||
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
private int randomInt = RandomData.randomInt(0, 10);
|
||||
private String randomString = RandomData.randomString(randomInt);
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
System.out.println("--- Test Class Setup ---");
|
||||
SystemMockUtil.setUp(temporaryFolder.getRoot())
|
||||
.enableConfigSystem()
|
||||
.enableDatabaseSystem()
|
||||
.enableServerInfoSystem();
|
||||
StaticHolder.saveInstance(SQLDB.class, Plan.class);
|
||||
StaticHolder.saveInstance(SQLiteTest.class, Plan.class);
|
||||
|
||||
Log.setErrorManager(new TestErrorManager());
|
||||
|
||||
System.out.println("--- Class Setup Complete ---\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyServerBuilder() {
|
||||
ServerImportData data = ServerImportData.builder().build();
|
||||
|
@ -43,6 +43,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
|
||||
@ -1073,6 +1074,9 @@ public class SQLiteTest {
|
||||
|
||||
List<String> unsupported = new ArrayList<>();
|
||||
for (Field field : PlayerKeys.class.getDeclaredFields()) {
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
Key key = (Key) field.get(null);
|
||||
if (!playerContainer.supports(key)) {
|
||||
unsupported.add(field.getName());
|
||||
@ -1090,6 +1094,9 @@ public class SQLiteTest {
|
||||
|
||||
List<String> unsupported = new ArrayList<>();
|
||||
for (Field field : ServerKeys.class.getDeclaredFields()) {
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
Key key = (Key) field.get(null);
|
||||
if (!serverContainer.supports(key)) {
|
||||
unsupported.add(field.getName());
|
||||
@ -1106,6 +1113,9 @@ public class SQLiteTest {
|
||||
|
||||
List<String> unsupported = new ArrayList<>();
|
||||
for (Field field : AnalysisKeys.class.getDeclaredFields()) {
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
Key key = (Key) field.get(null);
|
||||
if (!analysisContainer.supports(key)) {
|
||||
unsupported.add(field.getName());
|
||||
|
@ -65,7 +65,7 @@ public class BukkitMockUtil extends MockUtil {
|
||||
}
|
||||
|
||||
public BukkitMockUtil withLogging() {
|
||||
doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString());
|
||||
Mockito.doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString());
|
||||
TestLogger testLogger = new TestLogger();
|
||||
doReturn(testLogger).when(planMock).getLogger();
|
||||
return this;
|
||||
|
Loading…
Reference in New Issue
Block a user