use of org.apache.ignite.internal.configuration.tree.NamedListNode.NAME in project ignite-3 by apache.
the class ConfigurationUtilTest method findUnsuccessfully.
/**
* Tests that {@link ConfigurationUtil#find(List, TraversableTreeNode, boolean)} throws {@link KeyNotFoundException} when provided with
* a wrong path.
*/
@Test
public void findUnsuccessfully() {
InnerNode parentNode = newNodeInstance(ParentConfigurationSchema.class);
ParentChange parentChange = (ParentChange) parentNode;
assertThrows(KeyNotFoundException.class, () -> ConfigurationUtil.find(List.of("elements", "name", "child"), parentNode, true));
parentChange.changeElements(elements -> elements.createOrUpdate("name", element -> {
}));
assertThrows(KeyNotFoundException.class, () -> ConfigurationUtil.find(List.of("elements", "name", "child", "str0"), parentNode, true));
((NamedElementChange) parentChange.elements().get("name")).changeChild(child -> child.changeStr("value"));
assertThrows(KeyNotFoundException.class, () -> ConfigurationUtil.find(List.of("elements", "name", "child", "str", "foo"), parentNode, true));
}
use of org.apache.ignite.internal.configuration.tree.NamedListNode.NAME in project ignite-3 by apache.
the class ConfigurationUtilTest method fillFromPrefixMapSuccessfullyWithRemove.
/**
* Tests that patching of configuration node with a prefix map works fine when prefix map is valid.
*/
@Test
public void fillFromPrefixMapSuccessfullyWithRemove() {
InnerNode parentNode = newNodeInstance(ParentConfigurationSchema.class);
ParentChange parentChange = (ParentChange) parentNode;
parentChange.changeElements(elements -> elements.createOrUpdate("name", element -> element.changeChild(child -> {
})));
UUID internalId = ((InnerNode) ((ParentView) parentNode).elements().get("name")).internalId();
ConfigurationUtil.fillFromPrefixMap(parentNode, Map.of("elements", singletonMap(internalId.toString(), null)));
assertNull(parentChange.elements().get("node"));
}
use of org.apache.ignite.internal.configuration.tree.NamedListNode.NAME in project ignite-3 by apache.
the class ConfigurationUtilTest method findNulls.
/**
* Tests that {@link ConfigurationUtil#find(List, TraversableTreeNode, boolean)} returns null when path points to nonexistent named list
* element.
*/
@Test
public void findNulls() {
InnerNode parentNode = newNodeInstance(ParentConfigurationSchema.class);
ParentChange parentChange = (ParentChange) parentNode;
assertNull(ConfigurationUtil.find(List.of("elements", "name"), parentNode, true));
parentChange.changeElements(elements -> elements.createOrUpdate("name", element -> {
}));
assertNull(ConfigurationUtil.find(List.of("elements", "name", "child", "str"), parentNode, true));
}
use of org.apache.ignite.internal.configuration.tree.NamedListNode.NAME in project ignite-3 by apache.
the class ConfigurationUtilTest method findSuccessfully.
/**
* Tests that {@link ConfigurationUtil#find(List, TraversableTreeNode, boolean)} finds proper node when provided with correct path.
*/
@Test
public void findSuccessfully() {
InnerNode parentNode = newNodeInstance(ParentConfigurationSchema.class);
ParentChange parentChange = (ParentChange) parentNode;
parentChange.changeElements(elements -> elements.createOrUpdate("name", element -> element.changeChild(child -> child.changeStr("value"))));
assertSame(parentNode, ConfigurationUtil.find(List.of(), parentNode, true));
assertSame(parentChange.elements(), ConfigurationUtil.find(List.of("elements"), parentNode, true));
assertSame(parentChange.elements().get("name"), ConfigurationUtil.find(List.of("elements", "name"), parentNode, true));
assertSame(parentChange.elements().get("name").child(), ConfigurationUtil.find(List.of("elements", "name", "child"), parentNode, true));
assertSame(parentChange.elements().get("name").child().str(), ConfigurationUtil.find(List.of("elements", "name", "child", "str"), parentNode, true));
}
Aggregations