Berkof commented on a change in pull request #475:
URL: https://github.com/apache/ignite-3/pull/475#discussion_r760076179



##########
File path: 
modules/configuration/src/test/java/org/apache/ignite/internal/configuration/tree/NamedListNodeTest.java
##########
@@ -347,4 +348,36 @@ public void errors() throws Exception {
         b.delete("X");
         b.delete("Y");
     }
+
+    /**
+     * Tests the {@link NamedListNode#update} method.
+     */
+    @Test
+    public void testUpdate() {
+        var list = new NamedListNode<SecondChange>("name", () -> 
cgen.instantiateNode(SecondConfigurationSchema.class), null);
+
+        list.create("foo", ch -> ch.changeStr("bar"));
+
+        assertThat(list.get("foo").str(), is(equalTo("bar")));
+
+        list.update("foo", ch -> ch.changeStr("baz"));
+
+        assertThat(list.get("foo").str(), is(equalTo("baz")));
+
+        list.delete("foo");
+
+        // updating a removed key should throw
+        assertThrows(IllegalArgumentException.class, () -> list.update("foo", 
ch -> {}));

Review comment:
       Add and run:
           assertThrows(IllegalArgumentException.class, () -> 
list.create("foo", ch -> ch.changeStr("bar2")));
   
           list.createAfter("foo", "foo2", ch -> ch.changeStr("a"));
   named list allows to add record after deleted one. Is it ok?

##########
File path: 
modules/configuration-api/src/main/java/org/apache/ignite/configuration/NamedListChange.java
##########
@@ -84,6 +84,20 @@
      */
     NamedListChange<VIEWT, CHANGET> createOrUpdate(String key, 
Consumer<CHANGET> valConsumer);
 
+    /**
+     * Updates a value in the named list configuration.
+     *
+     * @param key Key for the value to be updated.
+     * @param valConsumer Closure to modify the value associated with the key. 
Closure parameter must not be leaked
+     *      outside the scope of the closure.
+     * @return {@code this} for chaining.
+     *
+     * @throws NullPointerException If one of parameters is null.
+     * @throws IllegalArgumentException The given key does not exist or if 
{@link #delete(String)} has been invoked with the same key

Review comment:
       If the given key...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to