This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 1c47a972a29 Refactor TestParameterLoader. (#30876)
1c47a972a29 is described below
commit 1c47a972a29c6d0faa98249424a8d2e411745a33
Author: Cong Hu <[email protected]>
AuthorDate: Sat Apr 13 17:59:18 2024 +0800
Refactor TestParameterLoader. (#30876)
---
.../test/loader/TestParameterLoader.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git
a/test/util/src/main/java/org/apache/shardingsphere/test/loader/TestParameterLoader.java
b/test/util/src/main/java/org/apache/shardingsphere/test/loader/TestParameterLoader.java
index 8061eafe5f5..ede5dd36d74 100644
---
a/test/util/src/main/java/org/apache/shardingsphere/test/loader/TestParameterLoader.java
+++
b/test/util/src/main/java/org/apache/shardingsphere/test/loader/TestParameterLoader.java
@@ -23,6 +23,7 @@ import com.google.common.io.Files;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.apache.shardingsphere.test.env.EnvironmentContext;
import
org.apache.shardingsphere.test.loader.strategy.TestParameterLoadStrategy;
import org.apache.shardingsphere.test.loader.summary.FileSummary;
@@ -65,11 +66,26 @@ public final class TestParameterLoader {
*/
@SneakyThrows
public Stream<ExternalSQLTestParameter> load(final URI sqlCaseURI, final
URI resultURI, final String databaseType, final String reportType) {
+ return load(sqlCaseURI, resultURI, databaseType, reportType, null);
+ }
+
+ /**
+ * Load test parameters.
+ *
+ * @param sqlCaseURI SQL case URI
+ * @param resultURI result URI
+ * @param databaseType database type
+ * @param reportType report type
+ * @param caseRegex case regex
+ * @return loaded test parameters
+ */
+ @SneakyThrows
+ public Stream<ExternalSQLTestParameter> load(final URI sqlCaseURI, final
URI resultURI, final String databaseType, final String reportType, final String
caseRegex) {
Collection<FileSummary> sqlCaseFileSummaries =
loadStrategy.loadSQLCaseFileSummaries(sqlCaseURI);
Collection<FileSummary> resultFileSummaries =
loadStrategy.loadSQLCaseFileSummaries(resultURI);
Map<String, FileSummary> resultFileSummaryMap =
resultFileSummaries.stream().collect(Collectors.toMap(fileSummary ->
Files.getNameWithoutExtension(fileSummary.getFileName()), Function.identity()));
- return sqlCaseFileSummaries.stream().flatMap(each -> {
+ return sqlCaseFileSummaries.stream().filter(each ->
StringUtils.isEmpty(caseRegex) ||
each.getFileName().matches(caseRegex)).flatMap(each -> {
List<String> sqlCaseFileContent =
loadContent(URI.create(each.getAccessURI()));
String fileName =
Files.getNameWithoutExtension(each.getFileName());
Optional<FileSummary> resultFileSummary =
Optional.ofNullable(resultFileSummaryMap.get(fileName));