Search in sources :

Example 21 with ConfigurationNode

use of org.spongepowered.configurate.ConfigurationNode in project SpongeCommon by SpongePowered.

the class DuplicateRemovalVisitorTest method testClearsEqualDoublesInChild.

@Test
void testClearsEqualDoublesInChild() {
    final ConfigurationNode parent = BasicConfigurationNode.root();
    final ConfigurationNode child = BasicConfigurationNode.root();
    parent.node("test").raw(42);
    child.node("test").raw(42d);
    DuplicateRemovalVisitor.visit(child, parent);
    assertTrue(child.empty());
    assertNull(child.node("test").raw());
}
Also used : CommentedConfigurationNode(org.spongepowered.configurate.CommentedConfigurationNode) BasicConfigurationNode(org.spongepowered.configurate.BasicConfigurationNode) ConfigurationNode(org.spongepowered.configurate.ConfigurationNode) Test(org.junit.jupiter.api.Test)

Example 22 with ConfigurationNode

use of org.spongepowered.configurate.ConfigurationNode in project SpongeCommon by SpongePowered.

the class DuplicateRemovalVisitorTest method testEmpty.

@Test
void testEmpty() {
    final ConfigurationNode parent = BasicConfigurationNode.root();
    final ConfigurationNode child = BasicConfigurationNode.root();
    DuplicateRemovalVisitor.visit(child, parent);
}
Also used : CommentedConfigurationNode(org.spongepowered.configurate.CommentedConfigurationNode) BasicConfigurationNode(org.spongepowered.configurate.BasicConfigurationNode) ConfigurationNode(org.spongepowered.configurate.ConfigurationNode) Test(org.junit.jupiter.api.Test)

Example 23 with ConfigurationNode

use of org.spongepowered.configurate.ConfigurationNode in project SpongeCommon by SpongePowered.

the class DuplicateRemovalVisitorTest method testClearsMapKeys.

@Test
void testClearsMapKeys() {
    final ConfigurationNode parent = BasicConfigurationNode.root(n -> {
        n.node("test1").raw("yeet");
        n.node("test2").raw("yoink");
    });
    final ConfigurationNode child = BasicConfigurationNode.root(n -> {
        n.node("test1").raw("yeet");
        n.node("test2").raw("yikes");
    });
    DuplicateRemovalVisitor.visit(child, parent);
    assertTrue(child.node("test1").virtual());
    assertEquals("yikes", child.node("test2").raw());
}
Also used : CommentedConfigurationNode(org.spongepowered.configurate.CommentedConfigurationNode) BasicConfigurationNode(org.spongepowered.configurate.BasicConfigurationNode) ConfigurationNode(org.spongepowered.configurate.ConfigurationNode) Test(org.junit.jupiter.api.Test)

Example 24 with ConfigurationNode

use of org.spongepowered.configurate.ConfigurationNode in project SpongeCommon by SpongePowered.

the class DuplicateRemovalVisitorTest method testClearsEqualDoubles.

@Test
void testClearsEqualDoubles() {
    final ConfigurationNode parent = BasicConfigurationNode.root();
    final ConfigurationNode child = BasicConfigurationNode.root();
    parent.raw(3d);
    child.raw(3d);
    DuplicateRemovalVisitor.visit(child, parent);
    assertEquals(3d, parent.raw());
    assertNull(child.raw());
    child.raw(3);
    DuplicateRemovalVisitor.visit(child, parent);
    assertNull(child.raw());
}
Also used : CommentedConfigurationNode(org.spongepowered.configurate.CommentedConfigurationNode) BasicConfigurationNode(org.spongepowered.configurate.BasicConfigurationNode) ConfigurationNode(org.spongepowered.configurate.ConfigurationNode) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationNode (org.spongepowered.configurate.ConfigurationNode)24 CommentedConfigurationNode (org.spongepowered.configurate.CommentedConfigurationNode)20 Test (org.junit.jupiter.api.Test)19 BasicConfigurationNode (org.spongepowered.configurate.BasicConfigurationNode)19 DataContainer (org.spongepowered.api.data.persistence.DataContainer)7 DataView (org.spongepowered.api.data.persistence.DataView)2 ConfigurateException (org.spongepowered.configurate.ConfigurateException)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 IOException (java.io.IOException)1 InvalidPathException (java.nio.file.InvalidPathException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ResourceKey (org.spongepowered.api.ResourceKey)1 RespawnLocation (org.spongepowered.api.util.RespawnLocation)1 NodePath (org.spongepowered.configurate.NodePath)1 HoconConfigurationLoader (org.spongepowered.configurate.hocon.HoconConfigurationLoader)1