Skip to content

Commit ba54e32

Browse files
committed
Improved: Rewrite ‘ComponentConfig#getAllTestSuiteInfos’
(OFBIZ-11101) It now has a stream based implementation. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862219 13f79535-47bb-0310-9956-ffa450edef68
1 parent 554cad0 commit ba54e32

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,17 @@ public static List<ServiceResourceInfo> getAllServiceResourceInfos(String type)
136136
.collect(Collectors.toList());
137137
}
138138

139-
public static List<TestSuiteInfo> getAllTestSuiteInfos() {
140-
return getAllTestSuiteInfos(null);
141-
}
142-
143-
public static List<TestSuiteInfo> getAllTestSuiteInfos(String componentName) {
144-
List<TestSuiteInfo> testSuiteInfos = new ArrayList<>();
145-
for (ComponentConfig cc : getAllComponents()) {
146-
if (componentName == null || componentName.equals(cc.getComponentName())) {
147-
testSuiteInfos.addAll(cc.getTestSuiteInfos());
148-
}
149-
}
150-
return testSuiteInfos;
139+
/**
140+
* Provides the list of all the test-suite information matching a component name.
141+
*
142+
* @param name the name of the component to match where {@code null} means "any"
143+
* @return a list of test-suite information
144+
*/
145+
public static List<TestSuiteInfo> getAllTestSuiteInfos(String name) {
146+
return getAllComponents().stream()
147+
.filter(cc -> name == null || name.equals(cc.getComponentName()))
148+
.flatMap(cc -> cc.getTestSuiteInfos().stream())
149+
.collect(Collectors.toList());
151150
}
152151

153152
public static List<WebappInfo> getAllWebappResourceInfos() {

0 commit comments

Comments
 (0)