This is an automated email from the ASF dual-hosted git repository.

sunnianjun 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 8f3c7f7f1ac Refactor E2ETestCasesLoader (#32191)
8f3c7f7f1ac is described below

commit 8f3c7f7f1ac38694e464dd150f959722d1668309
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jul 20 10:19:35 2024 +0800

    Refactor E2ETestCasesLoader (#32191)
    
    * Keep consistent for E2ETestCasesLoader on file module
    
    * Refactor E2ETestCasesLoader
---
 .../e2e/agent/file/cases/E2ETestCasesLoader.java     |  3 +--
 .../e2e/agent/jaeger/cases/E2ETestCasesLoader.java   | 20 +-------------------
 .../e2e/agent/zipkin/cases/E2ETestCasesLoader.java   | 20 +-------------------
 3 files changed, 3 insertions(+), 40 deletions(-)

diff --git 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCasesLoader.java
 
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCasesLoader.java
index dd5192166d0..0cef89352e9 100644
--- 
a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCasesLoader.java
+++ 
b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/cases/E2ETestCasesLoader.java
@@ -72,8 +72,7 @@ public final class E2ETestCasesLoader {
         }
         testCases = new LinkedList<>();
         URL url = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s",
 adapter)));
-        Collection<File> files = getFiles(url);
-        for (File each : files) {
+        for (File each : getFiles(url)) {
             testCases.addAll(unmarshal(each.getPath()).getTestCases());
         }
         return testCases;
diff --git 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCasesLoader.java
 
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCasesLoader.java
index 9ebbdc40595..5b6911731b2 100644
--- 
a/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCasesLoader.java
+++ 
b/test/e2e/agent/plugins/tracing/jaeger/src/test/java/org/apache/shardingsphere/test/e2e/agent/jaeger/cases/E2ETestCasesLoader.java
@@ -35,10 +35,8 @@ import java.nio.file.Paths;
 import java.nio.file.SimpleFileVisitor;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.LinkedList;
 import java.util.Objects;
-import java.util.stream.Collectors;
 
 /**
  * E2E test cases loader.
@@ -75,19 +73,11 @@ public final class E2ETestCasesLoader {
         testCases = new LinkedList<>();
         URL url = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s",
 adapter)));
         for (File each : getFiles(url)) {
-            testCases.addAll(loadTestCases(each));
+            testCases.addAll(unmarshal(each.getPath()).getTestCases());
         }
         return testCases;
     }
     
-    private Collection<SpanTestCase> loadTestCases(final File file) throws 
IOException, JAXBException {
-        Collection<SpanTestCase> result = new LinkedList<>();
-        for (SpanTestCase each : unmarshal(file.getPath()).getTestCases()) {
-            result.addAll(each.getTagCases().stream().map(optional -> 
createSpanTestCase(each.getServiceName(), each.getSpanName(), 
optional)).collect(Collectors.toList()));
-        }
-        return result;
-    }
-    
     private Collection<File> getFiles(final URL url) throws IOException, 
URISyntaxException {
         Collection<File> result = new LinkedList<>();
         Files.walkFileTree(Paths.get(url.toURI()), new 
SimpleFileVisitor<Path>() {
@@ -108,12 +98,4 @@ public final class E2ETestCasesLoader {
             return (E2ETestCases) 
JAXBContext.newInstance(E2ETestCases.class).createUnmarshaller().unmarshal(reader);
         }
     }
-    
-    private SpanTestCase createSpanTestCase(final String serviceName, final 
String spanName, final TagAssertion assertion) {
-        SpanTestCase result = new SpanTestCase();
-        result.setServiceName(serviceName);
-        result.setSpanName(spanName);
-        result.setTagCases(Collections.singletonList(assertion));
-        return result;
-    }
 }
diff --git 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCasesLoader.java
 
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCasesLoader.java
index ada9f9c8b31..22de34377d9 100644
--- 
a/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCasesLoader.java
+++ 
b/test/e2e/agent/plugins/tracing/zipkin/src/test/java/org/apache/shardingsphere/test/e2e/agent/zipkin/cases/E2ETestCasesLoader.java
@@ -35,10 +35,8 @@ import java.nio.file.Paths;
 import java.nio.file.SimpleFileVisitor;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.LinkedList;
 import java.util.Objects;
-import java.util.stream.Collectors;
 
 /**
  * E2E test cases loader.
@@ -75,19 +73,11 @@ public final class E2ETestCasesLoader {
         testCases = new LinkedList<>();
         URL url = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(String.format("cases/%s",
 adapter)));
         for (File each : getFiles(url)) {
-            testCases.addAll(loadTestCases(each));
+            testCases.addAll(unmarshal(each.getPath()).getTestCases());
         }
         return testCases;
     }
     
-    private Collection<SpanTestCase> loadTestCases(final File file) throws 
IOException, JAXBException {
-        Collection<SpanTestCase> result = new LinkedList<>();
-        for (SpanTestCase each : unmarshal(file.getPath()).getTestCases()) {
-            result.addAll(each.getTagCases().stream().map(optional -> 
createSpanTestCase(each.getServiceName(), each.getSpanName(), 
optional)).collect(Collectors.toList()));
-        }
-        return result;
-    }
-    
     private Collection<File> getFiles(final URL url) throws IOException, 
URISyntaxException {
         Collection<File> result = new LinkedList<>();
         Files.walkFileTree(Paths.get(url.toURI()), new 
SimpleFileVisitor<Path>() {
@@ -108,12 +98,4 @@ public final class E2ETestCasesLoader {
             return (E2ETestCases) 
JAXBContext.newInstance(E2ETestCases.class).createUnmarshaller().unmarshal(reader);
         }
     }
-    
-    private SpanTestCase createSpanTestCase(final String serviceName, final 
String spanName, final TagAssertion assertion) {
-        SpanTestCase result = new SpanTestCase();
-        result.setServiceName(serviceName);
-        result.setSpanName(spanName);
-        result.setTagCases(Collections.singletonList(assertion));
-        return result;
-    }
 }

Reply via email to