[Test] Fixed PlayersTableTest

This commit is contained in:
Rsl1122 2018-10-13 13:45:01 +03:00
parent a2325a0e12
commit 77b8be26f3
3 changed files with 27 additions and 93 deletions

View File

@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
/**
* Test class for {@link LineGraph}.
@ -62,15 +62,15 @@ public class LineGraphTest {
break;
case ')':
Character pop = bracketStack.pop();
assertTrue("Bracket mismatch at char: " + i + " Expected (, got " + pop, '(' == pop);
assertEquals("Bracket mismatch at char: " + i + " Expected (, got " + pop, '(', (char) pop);
break;
case ']':
Character pop1 = bracketStack.pop();
assertTrue("Bracket mismatch at char: " + i + " Expected [, got " + pop1, '[' == pop1);
assertEquals("Bracket mismatch at char: " + i + " Expected [, got " + pop1, '[', (char) pop1);
break;
case '}':
Character pop2 = bracketStack.pop();
assertTrue("Bracket mismatch at char: " + i + " Expected {, got " + pop2, '{' == pop2);
assertEquals("Bracket mismatch at char: " + i + " Expected {, got " + pop2, '{', (char) pop2);
break;
default:
break;

View File

@ -1,12 +1,16 @@
package com.djrapitops.plan.utilities.html.tables;
import com.djrapitops.plan.api.ServerAPI;
import com.djrapitops.plan.data.plugin.HookHandler;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
import com.djrapitops.plugin.logging.console.TestPluginLogger;
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import utilities.mocks.SystemMockUtil;
import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.Collections;
@ -22,13 +26,14 @@ import static org.junit.Assert.assertTrue;
*/
public class PlayersTableTest {
@ClassRule
public static TemporaryFolder temporaryFolder = new TemporaryFolder();
@BeforeClass
public static void setUpClass() throws Exception {
SystemMockUtil.setUp(temporaryFolder.getRoot())
.enableConfigSystem();
public static void setUpClass() {
new ServerAPI(
Mockito.mock(UUIDUtility.class),
Mockito.mock(HookHandler.class),
Mockito.mock(DBSystem.class),
new ConsoleErrorLogger(new TestPluginLogger())
);
}
@Test
@ -36,7 +41,15 @@ public class PlayersTableTest {
PlayerContainer container = new PlayerContainer();
container.putRawData(PlayerKeys.SESSIONS, new ArrayList<>());
List<PlayerContainer> players = Collections.singletonList(container);
String html = new PlayersTable(players, 50, 60, 5, l -> "", l -> "", d -> "").parseHtml();
String html = new PlayersTable(
players,
50, // maxPlayers
60, // activeMinuteThreshold
5, // activeLoginThreshold
l -> "",
l -> "",
d -> ""
).parseHtml();
testHtmlValidity(html);
}

View File

@ -1,79 +0,0 @@
package utilities.module;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plugin.IPlugin;
import com.djrapitops.plugin.benchmarking.Timings;
import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.logging.console.TestPluginLogger;
import com.djrapitops.plugin.logging.debug.CombineDebugLogger;
import com.djrapitops.plugin.logging.debug.DebugLogger;
import com.djrapitops.plugin.logging.debug.MemoryDebugLogger;
import com.djrapitops.plugin.logging.error.CombineErrorHandler;
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.task.thread.ThreadRunnableFactory;
import dagger.Module;
import dagger.Provides;
import javax.inject.Named;
import javax.inject.Singleton;
/**
* Dagger Test module for defining Abstract Plugin Framework utilities.
*
* @author Rsl1122
*/
@Module
public class TestAPFModule {
@Provides
@Singleton
IPlugin provideIPlugin(PlanPlugin plugin) {
return plugin;
}
@Provides
@Named("currentVersion")
@Singleton
String provideCurrentVersion() {
return "0.0.1-TEST";
}
@Provides
@Singleton
ColorScheme provideColorScheme() {
return new ColorScheme("§2", "§7", "§f");
}
@Provides
@Singleton
DebugLogger provideDebugLogger() {
return new CombineDebugLogger(new MemoryDebugLogger());
}
@Provides
@Singleton
PluginLogger providePluginLogger() {
return new TestPluginLogger();
}
@Provides
@Singleton
ErrorHandler provideErrorHandler(PluginLogger logger) {
return new CombineErrorHandler(new ConsoleErrorLogger(logger));
}
@Provides
@Singleton
Timings provideTimings(DebugLogger debugLogger) {
return new Timings(debugLogger);
}
@Provides
@Singleton
RunnableFactory provideRunnableFactory() {
return new ThreadRunnableFactory();
}
}