mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-30 16:19:56 +08:00
Removed some unused code
This commit is contained in:
parent
8624d86793
commit
cbb2d328a1
@ -181,9 +181,9 @@ public class DataSvc implements DataService {
|
||||
}
|
||||
|
||||
private static class Mapper<A, B> {
|
||||
Class<A> typeA;
|
||||
Class<B> typeB;
|
||||
Function<A, B> func;
|
||||
final Class<A> typeA;
|
||||
final Class<B> typeB;
|
||||
final Function<A, B> func;
|
||||
|
||||
public Mapper(Class<A> typeA, Class<B> typeB, Function<A, B> func) {
|
||||
this.typeA = typeA;
|
||||
|
@ -103,8 +103,8 @@ public class Contributors {
|
||||
}
|
||||
|
||||
private static class Contributor implements Comparable<Contributor> {
|
||||
String name;
|
||||
For[] contributed;
|
||||
final String name;
|
||||
final For[] contributed;
|
||||
|
||||
Contributor(String name, For... contributed) {
|
||||
this.name = name;
|
||||
|
@ -38,6 +38,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -119,6 +120,7 @@ public class ShutdownDataPreservation extends TaskSystem.Task {
|
||||
}
|
||||
|
||||
List<FinishedSession> loadFinishedSessions() {
|
||||
if (!Files.exists(storeLocation)) return Collections.emptyList();
|
||||
try (Stream<String> lines = Files.lines(storeLocation)) {
|
||||
return lines.map(FinishedSession::deserializeCSV)
|
||||
.filter(Optional::isPresent)
|
||||
|
@ -52,7 +52,7 @@ public class CookieChangeTransaction extends Transaction {
|
||||
if (username == null) {
|
||||
execute(new ExecStatement(CookieTable.DELETE_ALL_STATEMENT) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
public void prepare(PreparedStatement statement) {
|
||||
// No parameters
|
||||
}
|
||||
});
|
||||
|
@ -16,19 +16,17 @@
|
||||
*/
|
||||
package com.djrapitops.plan.gathering;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.gathering.domain.FinishedSession;
|
||||
import net.playeranalytics.plugin.PlatformAbstractionLayer;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import utilities.RandomData;
|
||||
import utilities.dagger.DaggerPlanPluginComponent;
|
||||
import utilities.dagger.PlanPluginComponent;
|
||||
import utilities.mocks.PlanPluginMocker;
|
||||
import utilities.mocks.TestPlatformAbstractionLayer;
|
||||
import utilities.mocks.PluginMockComponent;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@ -38,18 +36,10 @@ class ShutdownDataPreservationTest {
|
||||
private ShutdownDataPreservation underTest;
|
||||
|
||||
@BeforeEach
|
||||
void setupPreservation(@TempDir Path temporaryFolder) {
|
||||
PlanPlugin planMock = PlanPluginMocker.setUp()
|
||||
.withDataFolder(temporaryFolder.resolve("ShutdownSaveTest").toFile())
|
||||
.withLogging()
|
||||
.getPlanMock();
|
||||
TestPlatformAbstractionLayer abstractionLayer = new TestPlatformAbstractionLayer(planMock);
|
||||
PlanPluginComponent pluginComponent = DaggerPlanPluginComponent.builder()
|
||||
.bindTemporaryDirectory(temporaryFolder)
|
||||
.plan(planMock)
|
||||
.abstractionLayer(abstractionLayer)
|
||||
.build();
|
||||
PlanSystem system = pluginComponent.system();
|
||||
void setupPreservation(@TempDir Path temporaryFolder) throws Exception {
|
||||
PluginMockComponent pluginMockComponent = new PluginMockComponent(temporaryFolder);
|
||||
PlanSystem system = pluginMockComponent.getPlanSystem();
|
||||
PlatformAbstractionLayer abstractionLayer = pluginMockComponent.getAbstractionLayer();
|
||||
|
||||
underTest = new ShutdownDataPreservation(
|
||||
system.getPlanFiles(),
|
||||
@ -69,4 +59,13 @@ class ShutdownDataPreservationTest {
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void dataIsSameAfterStorageWhenNoSessions() {
|
||||
List<FinishedSession> expected = Collections.emptyList();
|
||||
underTest.storeFinishedSessions(expected);
|
||||
|
||||
List<FinishedSession> result = underTest.loadFinishedSessions();
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.gathering;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.gathering.cache.SessionCache;
|
||||
import com.djrapitops.plan.gathering.domain.ActiveSession;
|
||||
@ -32,19 +31,14 @@ import com.djrapitops.plan.storage.database.transactions.StoreServerInformationT
|
||||
import com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction;
|
||||
import extension.PrintExtension;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import utilities.RandomData;
|
||||
import utilities.TestConstants;
|
||||
import utilities.TestPluginLogger;
|
||||
import utilities.dagger.DaggerPlanPluginComponent;
|
||||
import utilities.dagger.PlanPluginComponent;
|
||||
import utilities.mocks.PlanPluginMocker;
|
||||
import utilities.mocks.TestPlatformAbstractionLayer;
|
||||
import utilities.mocks.PluginMockComponent;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
@ -62,7 +56,6 @@ import static org.mockito.Mockito.when;
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
@ExtendWith(PrintExtension.class)
|
||||
class ShutdownSaveTest {
|
||||
|
||||
private boolean shutdownStatus;
|
||||
@ -72,16 +65,8 @@ class ShutdownSaveTest {
|
||||
|
||||
@BeforeEach
|
||||
void setupShutdownSaveObject(@TempDir Path temporaryFolder) throws Exception {
|
||||
PlanPlugin planMock = PlanPluginMocker.setUp()
|
||||
.withDataFolder(temporaryFolder.resolve("ShutdownSaveTest").toFile())
|
||||
.withLogging()
|
||||
.getPlanMock();
|
||||
PlanPluginComponent pluginComponent = DaggerPlanPluginComponent.builder()
|
||||
.bindTemporaryDirectory(temporaryFolder)
|
||||
.plan(planMock)
|
||||
.abstractionLayer(new TestPlatformAbstractionLayer(planMock))
|
||||
.build();
|
||||
PlanSystem system = pluginComponent.system();
|
||||
PluginMockComponent pluginMockComponent = new PluginMockComponent(temporaryFolder);
|
||||
PlanSystem system = pluginMockComponent.getPlanSystem();
|
||||
|
||||
database = system.getDatabaseSystem().getSqLiteFactory().usingFileCalled("test");
|
||||
database.init();
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package extension;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* JUnit 5 Extension that prints what test is being run before each test.
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
public class PrintExtension implements BeforeTestExecutionCallback, AfterTestExecutionCallback {
|
||||
|
||||
@Override
|
||||
public void beforeTestExecution(ExtensionContext context) {
|
||||
String testName = context.getTestClass().map(Class::getSimpleName).orElse("?");
|
||||
String testMethodName = context.getTestMethod().map(Method::getName).orElse("?");
|
||||
System.out.println(">> " + testName + " - " + testMethodName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTestExecution(ExtensionContext context) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ package utilities.mocks;
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.PlanSystem;
|
||||
import com.djrapitops.plan.utilities.logging.PluginErrorLogger;
|
||||
import net.playeranalytics.plugin.PlatformAbstractionLayer;
|
||||
import utilities.dagger.DaggerPlanPluginComponent;
|
||||
import utilities.dagger.PlanPluginComponent;
|
||||
|
||||
@ -35,6 +36,7 @@ public class PluginMockComponent {
|
||||
|
||||
private PlanPlugin planMock;
|
||||
private PlanPluginComponent component;
|
||||
private TestPlatformAbstractionLayer abstractionLayer;
|
||||
|
||||
public PluginMockComponent(Path tempDir) {
|
||||
this.tempDir = tempDir;
|
||||
@ -57,10 +59,11 @@ public class PluginMockComponent {
|
||||
private void initComponent() throws Exception {
|
||||
if (component == null) {
|
||||
PlanPlugin planMock = getPlanMock();
|
||||
abstractionLayer = new TestPlatformAbstractionLayer(planMock);
|
||||
component = DaggerPlanPluginComponent.builder()
|
||||
.bindTemporaryDirectory(tempDir)
|
||||
.plan(planMock)
|
||||
.abstractionLayer(new TestPlatformAbstractionLayer(planMock))
|
||||
.abstractionLayer(abstractionLayer)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -74,4 +77,9 @@ public class PluginMockComponent {
|
||||
initComponent();
|
||||
return component;
|
||||
}
|
||||
|
||||
public PlatformAbstractionLayer getAbstractionLayer() throws Exception {
|
||||
initComponent();
|
||||
return abstractionLayer;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user