This is an automated email from the ASF dual-hosted git repository.
veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git
The following commit(s) were added to refs/heads/master by this push:
new cbf108b1b Factor out ParentNode base class from InjectorNode and
AbstractFanOutNode
cbf108b1b is described below
commit cbf108b1b2f0e8da8ee5f854774fedb0191d57fd
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Mon Mar 2 22:43:00 2026 +0000
Factor out ParentNode base class from InjectorNode and AbstractFanOutNode
Extract common child-management code (children list, addChild, and the
stream-flattening logic) into a new ParentNode abstract class that both
InjectorNode and AbstractFanOutNode now extend.
---
.../axiom/testutils/suite/AbstractFanOutNode.java | 16 +-------
.../apache/axiom/testutils/suite/InjectorNode.java | 14 ++-----
.../apache/axiom/testutils/suite/ParentNode.java | 46 ++++++++++++++++++++++
3 files changed, 51 insertions(+), 25 deletions(-)
diff --git
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
index ef4933058..825f3d010 100644
---
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
+++
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/AbstractFanOutNode.java
@@ -18,7 +18,6 @@
*/
package org.apache.axiom.testutils.suite;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -49,20 +48,15 @@ import com.google.inject.Injector;
*
* @param <T> the value type
*/
-public abstract class AbstractFanOutNode<T> extends MatrixTestNode {
+public abstract class AbstractFanOutNode<T> extends ParentNode {
private final Class<T> type;
private final List<T> values;
- private final List<MatrixTestNode> children = new ArrayList<>();
protected AbstractFanOutNode(Class<T> type, List<T> values) {
this.type = type;
this.values = values;
}
- public void addChild(MatrixTestNode child) {
- children.add(child);
- }
-
/**
* Extracts test parameters from the given value. The returned map entries
are used for the
* display name and for LDAP filter matching.
@@ -95,13 +89,7 @@ public abstract class AbstractFanOutNode<T> extends
MatrixTestNode {
.collect(Collectors.joining(", "));
return DynamicContainer.dynamicContainer(
displayName,
- children.stream()
- .flatMap(
- child ->
-
child.toDynamicNodes(
-
childInjector,
- params,
-
excludes)));
+ childDynamicNodes(childInjector, params,
excludes));
});
}
}
diff --git
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
index eb1d82c6a..0f2255b8f 100644
---
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
+++
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/InjectorNode.java
@@ -18,8 +18,6 @@
*/
package org.apache.axiom.testutils.suite;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import java.util.function.BiPredicate;
import java.util.stream.Stream;
@@ -38,9 +36,8 @@ import com.google.inject.Module;
* consumer (implementation under test), whereas the tree structure and
bindings are defined by the
* test suite author.
*/
-public class InjectorNode extends MatrixTestNode {
+public class InjectorNode extends ParentNode {
private final ImmutableList<Module> modules;
- private final List<MatrixTestNode> children = new ArrayList<>();
/**
* Creates a new node with the given list of modules.
@@ -60,17 +57,12 @@ public class InjectorNode extends MatrixTestNode {
this(ImmutableList.of(module));
}
- public void addChild(MatrixTestNode child) {
- children.add(child);
- }
-
@Override
Stream<DynamicNode> toDynamicNodes(
Injector parentInjector,
Map<String, String> inheritedParameters,
BiPredicate<Class<?>, Map<String, String>> excludes) {
- Injector injector = parentInjector.createChildInjector(modules);
- return children.stream()
- .flatMap(child -> child.toDynamicNodes(injector,
inheritedParameters, excludes));
+ return childDynamicNodes(
+ parentInjector.createChildInjector(modules),
inheritedParameters, excludes);
}
}
diff --git
a/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParentNode.java
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParentNode.java
new file mode 100644
index 000000000..4c20ea42d
--- /dev/null
+++
b/testing/matrix-testsuite/src/main/java/org/apache/axiom/testutils/suite/ParentNode.java
@@ -0,0 +1,46 @@
+/*
+ * 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.axiom.testutils.suite;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiPredicate;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.DynamicNode;
+
+import com.google.inject.Injector;
+
+/** A {@link MatrixTestNode} that maintains an ordered list of child nodes. */
+public abstract class ParentNode extends MatrixTestNode {
+ private final List<MatrixTestNode> children = new ArrayList<>();
+
+ public final void addChild(MatrixTestNode child) {
+ children.add(child);
+ }
+
+ protected final Stream<DynamicNode> childDynamicNodes(
+ Injector injector,
+ Map<String, String> parameters,
+ BiPredicate<Class<?>, Map<String, String>> excludes) {
+ return children.stream()
+ .flatMap(child -> child.toDynamicNodes(injector, parameters,
excludes));
+ }
+}