ibessonov commented on a change in pull request #208:
URL: https://github.com/apache/ignite-3/pull/208#discussion_r672077085



##########
File path: 
modules/configuration-annotation-processor/src/test/java/org/apache/ignite/internal/configuration/tree/NamedListOrderTest.java
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.configuration.tree;
+
+import java.util.Map;
+import org.apache.ignite.configuration.NamedListChange;
+import org.apache.ignite.configuration.annotation.Config;
+import org.apache.ignite.configuration.annotation.ConfigurationRoot;
+import org.apache.ignite.configuration.annotation.NamedConfigValue;
+import org.apache.ignite.configuration.annotation.Value;
+import org.apache.ignite.internal.configuration.TestConfigurationChanger;
+import org.apache.ignite.internal.configuration.asm.ConfigurationAsmGenerator;
+import 
org.apache.ignite.internal.configuration.storage.TestConfigurationStorage;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/** Test for keys ordering in named list nodes. */
+public class NamedListOrderTest {
+    /** Root that has a single named list. */
+    @ConfigurationRoot(rootName = "a")
+    public static class AConfigurationSchema {
+        /** */
+        @NamedConfigValue
+        public BConfigurationSchema b;
+    }
+
+    /** Named list element node that in inself contains another named list. */
+    @Config
+    public static class BConfigurationSchema {
+        /** Every named list element node must have at least one configuration 
field that is not named list. */
+        @Value(hasDefault = true)
+        public String c = "foo";
+
+        @NamedConfigValue
+        public BConfigurationSchema b;
+    }
+
+    /** Runtime implementations generator. */
+    private static ConfigurationAsmGenerator cgen;
+
+    /** Test configuration storage. */
+    private TestConfigurationStorage storage;
+
+    /** Test configuration changer. */
+    private TestConfigurationChanger changer;
+
+    /** Instantiates {@link #cgen}. */
+    @BeforeAll
+    public static void beforeAll() {
+        cgen = new ConfigurationAsmGenerator();
+    }
+
+    /** Nullifies {@link #cgen} to prevent memory leak from having runtime 
ClassLoader accessible from GC root. */
+    @AfterAll
+    public static void afterAll() {
+        cgen = null;
+    }
+
+    /** */
+    @BeforeEach
+    public void before() {
+        storage = new TestConfigurationStorage();
+
+        changer = new TestConfigurationChanger(cgen);
+        changer.addRootKey(AConfiguration.KEY);
+        changer.register(storage);
+    }
+
+    /** */
+    @AfterEach
+    public void after() {
+        changer.stop();
+    }
+
+    /**
+     * Tests that there are no unnecessary {@code <idx>} values in the storage 
after all basic named list operations.
+     *
+     * @throws Exception If failed.
+     */
+    @Test
+    public void storageData() throws Exception {
+        // Manually instantiate configuration instance.
+        var a = (AConfiguration)cgen.instantiateCfg(AConfiguration.KEY, 
changer);
+
+        // Create values on several layers at the same time. They all shoud 
have <idx> = 0.

Review comment:
       Done

##########
File path: 
modules/configuration-annotation-processor/src/test/java/org/apache/ignite/internal/configuration/util/ConfigurationUtilTest.java
##########
@@ -128,7 +140,7 @@ public void findSuccessfully() {
         var parent = newParentInstance();

Review comment:
       Done

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/tree/NamedListNode.java
##########
@@ -18,22 +18,22 @@
 package org.apache.ignite.internal.configuration.tree;
 
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
 import java.util.Objects;
-import java.util.Set;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 import org.apache.ignite.configuration.NamedListChange;
-import org.apache.ignite.configuration.NamedListView;
 
 /** */

Review comment:
       Done

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/tree/NamedListNode.java
##########
@@ -18,22 +18,22 @@
 package org.apache.ignite.internal.configuration.tree;
 
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
 import java.util.Objects;
-import java.util.Set;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 import org.apache.ignite.configuration.NamedListChange;
-import org.apache.ignite.configuration.NamedListView;
 
 /** */
-public final class NamedListNode<N extends InnerNode> implements 
NamedListView<N>, NamedListChange<N>, TraversableTreeNode, 
ConstructableTreeNode {
+public final class NamedListNode<N extends InnerNode> implements 
NamedListChange<N>, TraversableTreeNode, ConstructableTreeNode {
+    /** Name of a synthetic configuration property that describes the order of 
elements in a named list. */
+    public static final String ORDER_IDX = "<idx>";
+
     /** */

Review comment:
       Done

##########
File path: 
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/tree/NamedListNode.java
##########
@@ -18,22 +18,22 @@
 package org.apache.ignite.internal.configuration.tree;
 
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
 import java.util.Objects;
-import java.util.Set;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 import org.apache.ignite.configuration.NamedListChange;
-import org.apache.ignite.configuration.NamedListView;
 
 /** */
-public final class NamedListNode<N extends InnerNode> implements 
NamedListView<N>, NamedListChange<N>, TraversableTreeNode, 
ConstructableTreeNode {
+public final class NamedListNode<N extends InnerNode> implements 
NamedListChange<N>, TraversableTreeNode, ConstructableTreeNode {
+    /** Name of a synthetic configuration property that describes the order of 
elements in a named list. */
+    public static final String ORDER_IDX = "<idx>";
+
     /** */
-    public final Supplier<N> valSupplier;
+    private final Supplier<N> valSupplier;
 
     /** */

Review comment:
       Done




-- 
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