From 0e6ff1fd6b626870bff4bc3c46f192d2af8eeec1 Mon Sep 17 00:00:00 2001 From: UnrealValentin Date: Thu, 29 Apr 2021 18:44:20 +0200 Subject: [PATCH] fixed 1 issue and the other one is up for wulkanat to fix --- .../config/ObjectInfoConfigHandler.java | 1 + .../registration/config/ObjectInfoData.kt | 2 +- src/test/java/org/hmcore/tests/JavaTests.java | 30 ++++++++++++------- .../modules/impl/JavaTestRegistryModule.java | 2 +- .../kotlin/org/hmcore/tests/KotlinTests.kt | 5 +++- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/hmcore/registration/config/ObjectInfoConfigHandler.java b/src/main/java/org/hmcore/registration/config/ObjectInfoConfigHandler.java index 80d6815..b673399 100644 --- a/src/main/java/org/hmcore/registration/config/ObjectInfoConfigHandler.java +++ b/src/main/java/org/hmcore/registration/config/ObjectInfoConfigHandler.java @@ -48,6 +48,7 @@ public class ObjectInfoConfigHandler { } else { System.out.println("[!] Either Object Info " + data.objectInfoChosen + " doesn't exist for " + data.objectInfoName + " or " + data.objectInfoName + " doesn't exist!\n" + "Please stop the Server, delete objetc-infos.json and let the server regenertate a new config [!]"); + return false; } } } diff --git a/src/main/kotlin/org/hmcore/registration/config/ObjectInfoData.kt b/src/main/kotlin/org/hmcore/registration/config/ObjectInfoData.kt index 0d89f2c..918a145 100644 --- a/src/main/kotlin/org/hmcore/registration/config/ObjectInfoData.kt +++ b/src/main/kotlin/org/hmcore/registration/config/ObjectInfoData.kt @@ -2,6 +2,6 @@ package org.hmcore.registration.config internal class ObjectInfoData @JvmOverloads constructor( @JvmField val objectInfoName: String, - @JvmField val availableOptions: String, + @JvmField val _availableOptions: String, @JvmField val objectInfoChosen: String = "default", ) \ No newline at end of file diff --git a/src/test/java/org/hmcore/tests/JavaTests.java b/src/test/java/org/hmcore/tests/JavaTests.java index 058545f..c71b279 100644 --- a/src/test/java/org/hmcore/tests/JavaTests.java +++ b/src/test/java/org/hmcore/tests/JavaTests.java @@ -1,6 +1,7 @@ package org.hmcore.tests; import org.hmcore.HMCore; +import org.hmcore.modules.Module; import org.hmcore.modules.RegistryModule; import org.hmcore.registration.config.ObjectInfoConfigHandler; import org.hmcore.tests.modules.impl.JavaCustomObjectInfo; @@ -8,6 +9,8 @@ import org.hmcore.tests.modules.impl.JavaTestRegistryModule; import org.junit.jupiter.api.Test; import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -55,30 +58,37 @@ public class JavaTests { testModule.addInfoToObject("test3", "opt5", new JavaCustomObjectInfo("dada", 32833)); testModule.addInfoToObject("test3", "opt6", new JavaCustomObjectInfo("e3312", 2130440)); + List> registryModules = new ArrayList<>(); + Module[] modules = HMCore.modules.values().toArray(new Module[0]); + for (Module module: + modules) { + if(module instanceof RegistryModule) registryModules.add((RegistryModule) module); + } + assertEquals("{\n" + " \"modules\": [\n" + " {\n" + " \"moduleName\": \"java_test\",\n" + " \"objects\": [\n" + " {\n" + - " \"objectName\": \"test2\",\n" + - " \"objectInfoChoosen\": \"default\",\n" + - " \"_availableOptions\": \"opt3, opt2\"\n" + + " \"objectInfoName\": \"test2\",\n" + + " \"_availableOptions\": \"opt3, opt2\",\n" + + " \"objectInfoChosen\": \"default\"\n" + " },\n" + " {\n" + - " \"objectName\": \"test3\",\n" + - " \"objectInfoChoosen\": \"default\",\n" + - " \"_availableOptions\": \"opt4, opt5, opt6\"\n" + + " \"objectInfoName\": \"test3\",\n" + + " \"_availableOptions\": \"opt4, opt5, opt6\",\n" + + " \"objectInfoChosen\": \"default\"\n" + " },\n" + " {\n" + - " \"objectName\": \"test1\",\n" + - " \"objectInfoChoosen\": \"default\",\n" + - " \"_availableOptions\": \"opt1\"\n" + + " \"objectInfoName\": \"test1\",\n" + + " \"_availableOptions\": \"opt1\",\n" + + " \"objectInfoChosen\": \"default\"\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + - "}", ObjectInfoConfigHandler.generateFreshJSON(HMCore.modules.values().toArray(new RegistryModule[0])), "JSON String generation working"); + "}", ObjectInfoConfigHandler.generateFreshJSON(registryModules.toArray(new RegistryModule[0])), "JSON String generation working"); } diff --git a/src/test/java/org/hmcore/tests/modules/impl/JavaTestRegistryModule.java b/src/test/java/org/hmcore/tests/modules/impl/JavaTestRegistryModule.java index 4f51d17..5f9e618 100644 --- a/src/test/java/org/hmcore/tests/modules/impl/JavaTestRegistryModule.java +++ b/src/test/java/org/hmcore/tests/modules/impl/JavaTestRegistryModule.java @@ -108,7 +108,7 @@ public class JavaTestRegistryModule extends RegistryModule