terrymanu commented on code in PR #25407:
URL: https://github.com/apache/shardingsphere/pull/25407#discussion_r1180951715
##########
test/util/pom.xml:
##########
@@ -51,7 +56,23 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockito.version}</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
Review Comment:
Please put all junit dep in same place
##########
test/util/src/main/java/org/apache/shardingsphere/test/loader/ExternalCaseSettings.java:
##########
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.it.sql.parser.external;
+package org.apache.shardingsphere.test.loader;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
- * External SQL parser integrate test settings.
+ * External SQL case test settings.
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
-public @interface ExternalSQLParserITSettings {
+public @interface ExternalCaseSettings {
Review Comment:
How about create a new annotaion? It maybe not consistency with sql parser
and IT
##########
test/util/pom.xml:
##########
@@ -51,7 +56,23 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockito.version}</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ <version>${json-path.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-csv</artifactId>
+ <version>${commons-csv.version}</version>
+ </dependency>
Review Comment:
test util is a common test, it should be high level abstract.
Please do not add more `csv` or `json` here
##########
test/util/src/main/java/org/apache/shardingsphere/test/loader/AbstractTestParameterLoader.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.shardingsphere.test.loader;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import
org.apache.shardingsphere.test.loader.strategy.TestParameterLoadStrategy;
+import org.apache.shardingsphere.test.loader.summary.FileSummary;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+/**
+ * Test parameter loader.
+ * @param <T> type of test parameter
Review Comment:
Please keep blank line between javadoc and @param
##########
test/util/src/main/java/org/apache/shardingsphere/test/loader/AbstractTestParameterLoader.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.shardingsphere.test.loader;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import
org.apache.shardingsphere.test.loader.strategy.TestParameterLoadStrategy;
+import org.apache.shardingsphere.test.loader.summary.FileSummary;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+/**
+ * Test parameter loader.
+ * @param <T> type of test parameter
+ */
+@RequiredArgsConstructor
+@Slf4j
+public abstract class AbstractTestParameterLoader<T> {
+
+ private final TestParameterLoadStrategy loadStrategy;
+
+ /**
+ * Load test parameters.
+ *
+ * @param sqlCaseURI SQL case URI
+ * @param resultURI result URI
+ * @param databaseType database type
+ * @param reportType report type
+ * @return loaded test parameters
+ */
+ public Collection<T> load(final URI sqlCaseURI, final URI resultURI, final
String databaseType, final String reportType) {
+ Collection<T> result = new LinkedList<>();
+ Map<String, FileSummary> sqlCaseFileSummaries =
loadStrategy.loadSQLCaseFileSummaries(sqlCaseURI).stream().collect(Collectors.toMap(FileSummary::getFileName,
v -> v, (k, v) -> v));
+ Map<String, FileSummary> resultFileSummaries =
loadStrategy.loadSQLCaseFileSummaries(resultURI).stream().collect(Collectors.toMap(FileSummary::getFileName,
v -> v, (k, v) -> v));
+ for (Entry<String, FileSummary> each :
sqlCaseFileSummaries.entrySet()) {
+ String fileName = each.getKey();
+ String sqlCaseFileContent =
loadContent(URI.create(each.getValue().getAccessURI()));
+ String resultFileContent =
resultFileSummaries.containsKey(fileName) ?
loadContent(URI.create(resultFileSummaries.get(fileName).getAccessURI())) : "";
+ result.addAll(createTestParameters(fileName, sqlCaseFileContent,
resultFileContent, databaseType, reportType));
+ }
+ return result;
+ }
+
+ /**
+ * Create test parameters.
+ * @param sqlCaseFileName sql case file name
Review Comment:
1. Please keep blank line between javadoc and @param
2. `sql` should be `SQL` in javadoc
##########
test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/external/loader/ExternalSQLParserTestParameterLoader.java:
##########
@@ -17,69 +17,35 @@
package org.apache.shardingsphere.test.it.sql.parser.external.loader;
-import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import
org.apache.shardingsphere.test.it.sql.parser.external.ExternalSQLParserTestParameter;
-import
org.apache.shardingsphere.test.it.sql.parser.external.loader.strategy.TestParameterLoadStrategy;
-import
org.apache.shardingsphere.test.it.sql.parser.external.loader.summary.FileSummary;
+import org.apache.shardingsphere.test.loader.AbstractTestParameterLoader;
+import
org.apache.shardingsphere.test.loader.strategy.TestParameterLoadStrategy;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URI;
import java.util.Collection;
import java.util.LinkedList;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
/**
* External SQL parser test parameter loader.
*/
-@RequiredArgsConstructor
@Slf4j
-public final class ExternalSQLParserTestParameterLoader {
+public final class ExternalSQLParserTestParameterLoader extends
AbstractTestParameterLoader<ExternalSQLParserTestParameter> {
- private final TestParameterLoadStrategy loadStrategy;
+ public ExternalSQLParserTestParameterLoader(final
TestParameterLoadStrategy loadStrategy) {
+ super(loadStrategy);
+ }
/**
- * Load SQL parser test parameters.
- *
- * @param sqlCaseURI SQL case URI
- * @param resultURI result URI
+ * create external sql parser test parameters.
Review Comment:
1. Please keep blank line between javadoc and @param
2. `sql` should be `SQL` in javadoc
--
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]