Skip to content

Commit ebdbd98

Browse files
committed
Remove exceptions from method signatures when not thrown
1 parent 3af3f27 commit ebdbd98

File tree

18 files changed

+44
-57
lines changed

18 files changed

+44
-57
lines changed

Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
*/
3838
class BukkitSystemTest {
3939

40-
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
40+
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
4141
private PlanSystem system;
4242

4343
@BeforeEach
44-
void prepareSystem(@TempDir Path temp) throws Exception {
44+
void prepareSystem(@TempDir Path temp) {
4545
system = new BukkitMockComponent(temp).getPlanSystem();
4646
system.getConfigSystem().getConfig()
4747
.set(WebserverSettings.PORT, TEST_PORT_NUMBER);

Plan/bukkit/src/test/java/utilities/mocks/BukkitMockComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public BukkitMockComponent(Path tempDir) {
4848
SQLDB.setDownloadDriver(false);
4949
}
5050

51-
public PlanPlugin getPlanMock() throws Exception {
51+
public PlanPlugin getPlanMock() {
5252
if (planMock == null) {
5353
planMock = PlanPluginMocker.setUp()
5454
.withDataFolder(tempDir.resolve("data").toFile())
@@ -57,7 +57,7 @@ public PlanPlugin getPlanMock() throws Exception {
5757
return planMock;
5858
}
5959

60-
public PlanSystem getPlanSystem() throws Exception {
60+
public PlanSystem getPlanSystem() {
6161
if (component == null) {
6262
PlanPlugin planMock = getPlanMock();
6363
component = DaggerPlanBukkitComponent.builder()

Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
*/
4444
class BungeeSystemTest {
4545

46-
private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
46+
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
4747

4848
private BungeeMockComponent component;
4949
private DBPreparer dbPreparer;

Plan/common/src/test/java/com/djrapitops/plan/commands/PlanCommandTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import java.util.Optional;
4747
import java.util.Set;
4848
import java.util.UUID;
49-
import java.util.concurrent.ExecutionException;
5049
import java.util.stream.Stream;
5150

5251
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -156,7 +155,7 @@ void serverCommandSendsLink() {
156155
}
157156

158157
@Test
159-
void networkCommandSendsLink(Database database) throws ExecutionException, InterruptedException {
158+
void networkCommandSendsLink(Database database) {
160159
try {
161160
Server server = new Server(ServerUUID.randomUUID(), "Serve", "", "");
162161
server.setProxy(true);

Plan/common/src/test/java/com/djrapitops/plan/gathering/ShutdownDataPreservationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ShutdownDataPreservationTest {
4040
private ShutdownDataPreservation underTest;
4141

4242
@BeforeEach
43-
void setupPreservation(@TempDir Path temporaryFolder) throws Exception {
43+
void setupPreservation(@TempDir Path temporaryFolder) {
4444
PluginMockComponent pluginMockComponent = new PluginMockComponent(temporaryFolder);
4545
PlanSystem system = pluginMockComponent.getPlanSystem();
4646
PlatformAbstractionLayer abstractionLayer = pluginMockComponent.getAbstractionLayer();

Plan/common/src/test/java/com/djrapitops/plan/placeholder/PlanPlaceholdersTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PlanPlaceholdersTest {
5353
private static UUID playerUUID;
5454

5555
@BeforeAll
56-
static void prepareSystem(@TempDir Path tempDir) throws Exception {
56+
static void prepareSystem(@TempDir Path tempDir) {
5757
PluginMockComponent mockComponent = new PluginMockComponent(tempDir);
5858
component = mockComponent.getComponent();
5959
mockComponent.getPlanSystem().enable();

Plan/common/src/test/java/com/djrapitops/plan/utilities/PassEncryptTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ class PassEncryptTest {
3434
private static final Map<String, String> PASSWORD_MAP = new HashMap<>();
3535

3636
@BeforeAll
37-
static void setUpPasswords() throws Exception {
37+
static void setUpPasswords() {
3838
for (int i = 0; i < RandomData.randomInt(1, 10); i++) {
3939
String password = RandomData.randomString(RandomData.randomInt(5, 16));
4040
PASSWORD_MAP.put(password, PassEncryptUtil.createHash(password));
4141
}
4242
}
4343

4444
@Test
45-
void testVerification() throws Exception {
45+
void testVerification() {
4646
for (Map.Entry<String, String> entry : PASSWORD_MAP.entrySet()) {
4747
String password = entry.getKey();
4848
String hash = entry.getValue();

Plan/common/src/test/java/com/djrapitops/plan/utilities/logging/ErrorLoggerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ErrorLoggerTest {
4545
private static PlanSystem SYSTEM;
4646

4747
@BeforeAll
48-
static void preparePlugin(@TempDir Path dir) throws Exception {
48+
static void preparePlugin(@TempDir Path dir) {
4949
PluginMockComponent component = new PluginMockComponent(dir);
5050
SYSTEM = component.getPlanSystem();
5151
SYSTEM.enable();

Plan/common/src/test/java/extension/FullSystemExtension.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import com.djrapitops.plan.storage.file.PlanFiles;
3737
import com.djrapitops.plan.storage.file.PublicHtmlFiles;
3838
import com.djrapitops.plan.utilities.java.Maps;
39-
import com.djrapitops.plan.utilities.java.ThrowingSupplier;
4039
import net.playeranalytics.plugin.server.PluginLogger;
4140
import org.junit.jupiter.api.extension.*;
4241
import utilities.RandomData;
@@ -58,12 +57,11 @@
5857
public class FullSystemExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback {
5958

6059
private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500);
60+
private final Map<Class, Supplier> parameterResolvers;
6161
public PluginMockComponent component;
6262
private Path tempDir;
6363
private PlanSystem planSystem;
6464

65-
private final Map<Class, Supplier> parameterResolvers;
66-
6765
public FullSystemExtension() {
6866
// You can't use method references here because planSystem is null when this method is initialized.
6967

@@ -74,9 +72,9 @@ public FullSystemExtension() {
7472
.put(Theme.class, () -> planSystem.getConfigSystem().getTheme())
7573
.put(ConfigSystem.class, () -> planSystem.getConfigSystem())
7674
.put(ServerUUID.class, () -> planSystem.getServerInfo().getServerUUID())
77-
.put(PlanPluginComponent.class, catching(PlanPluginComponent.class, () -> component.getComponent()))
78-
.put(PluginLogger.class, catching(PluginLogger.class, () -> component.getAbstractionLayer().getPluginLogger()))
79-
.put(PlanCommand.class, catching(PlanCommand.class, () -> component.getComponent().planCommand()))
75+
.put(PlanPluginComponent.class, () -> component.getComponent())
76+
.put(PluginLogger.class, () -> component.getAbstractionLayer().getPluginLogger())
77+
.put(PlanCommand.class, () -> component.getComponent().planCommand())
8078
.put(Database.class, () -> planSystem.getDatabaseSystem().getDatabase())
8179
.put(DeliveryUtilities.class, () -> planSystem.getDeliveryUtilities())
8280
.put(Formatters.class, () -> planSystem.getDeliveryUtilities().getFormatters())
@@ -91,18 +89,8 @@ public FullSystemExtension() {
9189
.build();
9290
}
9391

94-
private <T, E extends Exception> Supplier<T> catching(Class<T> type, ThrowingSupplier<T, E> throwingSupplier) {
95-
return () -> {
96-
try {
97-
return throwingSupplier.get();
98-
} catch (Exception e) {
99-
throw new ParameterResolutionException("Error getting " + type, e);
100-
}
101-
};
102-
}
103-
10492
@Override
105-
public void beforeAll(ExtensionContext context) throws Exception {
93+
public void beforeAll(ExtensionContext context) throws IOException {
10694
tempDir = Files.createTempDirectory("plan-fullsystem-test");
10795
component = new PluginMockComponent(tempDir);
10896
planSystem = component.getPlanSystem();
@@ -111,7 +99,7 @@ public void beforeAll(ExtensionContext context) throws Exception {
11199
}
112100

113101
@Override
114-
public void afterAll(ExtensionContext context) throws Exception {
102+
public void afterAll(ExtensionContext context) throws IOException {
115103
if (tempDir != null) deleteDirectory(tempDir);
116104
}
117105

Plan/common/src/test/java/utilities/LocaleResourceUpdateUtility.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import utilities.mocks.PluginMockComponent;
2424

2525
import java.io.File;
26+
import java.io.IOException;
2627
import java.nio.file.Files;
2728
import java.nio.file.Path;
2829
import java.nio.file.StandardCopyOption;
@@ -35,7 +36,7 @@
3536
*/
3637
public class LocaleResourceUpdateUtility {
3738

38-
public static void main(String[] args) throws Exception {
39+
public static void main(String[] args) throws IOException {
3940
PluginMockComponent mockComponent = new PluginMockComponent(Files.createTempDirectory("temp-plan-"));
4041
PlanPluginComponent component = mockComponent.getComponent();
4142

0 commit comments

Comments
 (0)