Try to find server registration error, did not.

This commit is contained in:
Aurora Lahtela 2022-05-26 09:26:45 +03:00
parent 24e955e428
commit c1537681ab
3 changed files with 31 additions and 7 deletions

View File

@ -92,7 +92,7 @@ public class ServerFileLoader extends Config implements ServerLoader {
if (!prepared) prepare();
server.getId().ifPresent(id -> set("Server.ID", id));
set("Server.UUID", server.getUuid());
set("Server.UUID", server.getUuid().toString());
set("Server.Web_address", server.getWebAddress());
save();

View File

@ -303,7 +303,7 @@ public class ConfigNode {
* @return List of config keys
*/
public List<String> getConfigPaths() {
Stack<ConfigNode> dfs = new Stack<>();
ArrayDeque<ConfigNode> dfs = new ArrayDeque<>();
dfs.push(this);
List<String> configPaths = new ArrayList<>();
@ -345,7 +345,9 @@ public class ConfigNode {
}
// Override value conditionally
if (value == null || value.isEmpty() && from.value != null) {
boolean currentValueIsMissing = value == null || value.isEmpty();
boolean otherNodeHasValue = from.value != null && !from.value.isEmpty();
if (currentValueIsMissing && otherNodeHasValue) {
value = from.value;
}

View File

@ -17,12 +17,12 @@
package com.djrapitops.plan.settings.config;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.*;
@ -371,4 +371,26 @@ class ConfigNodeTest {
copied = testTree.getString("Test." + SECOND_LEVEL + "." + THIRD_LEVEL);
assertEquals("ORIGINAL", copied);
}
@TestFactory
Collection<DynamicTest> copyMissingCorrectnessTests() {
return Arrays.stream(new String[][]{
new String[]{"", "Value"},
new String[]{null, "Value"},
new String[]{"Value", ""},
new String[]{"Value", null}
}).map(valuePair -> {
String previousValue = valuePair[0];
String overridingValue = valuePair[1];
return DynamicTest.dynamicTest("ConfigNode#copyMissing sets 'Value' correctly '" + previousValue + "', '" + overridingValue + "'",
() -> {
ConfigNode underTest = new ConfigNode("Test", null, previousValue);
ConfigNode copyFrom = new ConfigNode("Test", null, overridingValue);
underTest.copyMissing(copyFrom);
assertEquals("Value", underTest.getString());
});
}).collect(Collectors.toList());
}
}