svn commit: r1862219 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1862219 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java

mthl
Author: mthl
Date: Thu Jun 27 14:25:11 2019
New Revision: 1862219

URL: http://svn.apache.org/viewvc?rev=1862219&view=rev
Log:
Improved: Rewrite ‘ComponentConfig#getAllTestSuiteInfos’
(OFBIZ-11101)

It now has a stream based implementation.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java?rev=1862219&r1=1862218&r2=1862219&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java Thu Jun 27 14:25:11 2019
@@ -136,18 +136,17 @@ public final class ComponentConfig {
                 .collect(Collectors.toList());
     }
 
-    public static List<TestSuiteInfo> getAllTestSuiteInfos() {
-        return getAllTestSuiteInfos(null);
-    }
-
-    public static List<TestSuiteInfo> getAllTestSuiteInfos(String componentName) {
-        List<TestSuiteInfo> testSuiteInfos = new ArrayList<>();
-        for (ComponentConfig cc : getAllComponents()) {
-            if (componentName == null || componentName.equals(cc.getComponentName())) {
-                testSuiteInfos.addAll(cc.getTestSuiteInfos());
-            }
-        }
-        return testSuiteInfos;
+    /**
+     * Provides the list of all the test-suite information matching a component name.
+     *
+     * @param name  the name of the component to match where {@code null} means "any"
+     * @return a list of test-suite information
+     */
+    public static List<TestSuiteInfo> getAllTestSuiteInfos(String name) {
+        return getAllComponents().stream()
+                .filter(cc -> name == null || name.equals(cc.getComponentName()))
+                .flatMap(cc -> cc.getTestSuiteInfos().stream())
+                .collect(Collectors.toList());
     }
 
     public static List<WebappInfo> getAllWebappResourceInfos() {