You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by zi...@apache.org on 2022/11/30 14:25:48 UTC

[streampipes] branch dev updated: Enable check style for `streampipes-integration-test`

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

zike pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 5cf66dc64 Enable check style for `streampipes-integration-test`
     new d377291b7 Merge pull request #814 from RobertIndie/check-integration
5cf66dc64 is described below

commit 5cf66dc64491d9af458617ad3c3907cb87ac9036
Author: Zike Yang <zi...@apache.org>
AuthorDate: Tue Nov 29 19:38:28 2022 +0800

    Enable check style for `streampipes-integration-test`
---
 pom.xml                                            |  49 ++++----
 streampipes-integration-tests/pom.xml              | 123 ++++++++++++---------
 .../integration/adapters/AdapterTesterBase.java    |  45 ++++----
 .../integration/adapters/AdaptersTest.java         |  30 ++---
 .../integration/adapters/PulsarAdapterTester.java  |   9 +-
 .../integration/containers/PulsarContainer.java    |  14 ++-
 tools/maven/checkstyle-header.txt                  |   5 +-
 tools/maven/checkstyle.xml                         |   9 +-
 8 files changed, 161 insertions(+), 123 deletions(-)

diff --git a/pom.xml b/pom.xml
index eaf5c298a..ea7a94105 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1563,7 +1563,30 @@ IoT data streams.
 				<plugin>
 					<groupId>org.apache.maven.plugins</groupId>
 					<artifactId>maven-checkstyle-plugin</artifactId>
-					<version>${maven-checkstyle-plugin.version}</version>
+					<dependencies>
+						<dependency>
+							<groupId>com.puppycrawl.tools</groupId>
+							<artifactId>checkstyle</artifactId>
+							<version>9.2.1</version>
+						</dependency>
+					</dependencies>
+					<executions>
+						<execution>
+							<id>validate</id>
+							<phase>validate</phase>
+							<goals>
+								<goal>check</goal>
+							</goals>
+						</execution>
+					</executions>
+					<configuration>
+						<suppressionsLocation>tools/maven/suppressions.xml</suppressionsLocation>
+						<includeTestSourceDirectory>true</includeTestSourceDirectory>
+						<configLocation>tools/maven/checkstyle.xml</configLocation>
+						<encoding>UTF-8</encoding>
+						<logViolationsToConsole>false</logViolationsToConsole>
+						<failOnViolation>false</failOnViolation>
+					</configuration>
 				</plugin>
 				<plugin>
 					<groupId>org.apache.maven.plugins</groupId>
@@ -1783,29 +1806,7 @@ IoT data streams.
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-checkstyle-plugin</artifactId>
-				<dependencies>
-					<dependency>
-						<groupId>com.puppycrawl.tools</groupId>
-						<artifactId>checkstyle</artifactId>
-						<version>9.2.1</version>
-					</dependency>
-				</dependencies>
-				<executions>
-					<execution>
-						<id>validate</id>
-						<phase>validate</phase>
-						<goals>
-							<goal>check</goal>
-						</goals>
-					</execution>
-				</executions>
-				<configuration>
-					<suppressionsLocation>/tools/maven/suppressions.xml</suppressionsLocation>
-					<includeTestSourceDirectory>false</includeTestSourceDirectory>
-					<configLocation>/tools/maven/checkstyle.xml</configLocation>
-					<logViolationsToConsole>false</logViolationsToConsole>
-					<failOnViolation>false</failOnViolation>
-				</configuration>
+				<version>${maven-checkstyle-plugin.version}</version>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
diff --git a/streampipes-integration-tests/pom.xml b/streampipes-integration-tests/pom.xml
index 814bfe434..98e9fb32c 100644
--- a/streampipes-integration-tests/pom.xml
+++ b/streampipes-integration-tests/pom.xml
@@ -22,59 +22,82 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <parent>
-    <artifactId>streampipes-parent</artifactId>
-    <groupId>org.apache.streampipes</groupId>
-    <version>0.71.0-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>streampipes-parent</artifactId>
+        <groupId>org.apache.streampipes</groupId>
+        <version>0.71.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
 
-  <artifactId>integration</artifactId>
-  <name>StreamPipes Integration Tests</name>
+    <artifactId>integration</artifactId>
+    <name>StreamPipes Integration Tests</name>
 
-  <properties>
-    <owasp.check.skip>true</owasp.check.skip>
-    <maven.deploy.skip>false</maven.deploy.skip>
+    <properties>
+        <owasp.check.skip>true</owasp.check.skip>
+        <maven.deploy.skip>false</maven.deploy.skip>
 
-    <pulsar.version>2.10.1</pulsar.version>
-  </properties>
+        <pulsar.version>2.10.1</pulsar.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.streampipes</groupId>
+            <artifactId>streampipes-connect</artifactId>
+            <version>0.71.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.streampipes</groupId>
+            <artifactId>streampipes-container</artifactId>
+            <version>0.71.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.pulsar</groupId>
+            <artifactId>pulsar-client</artifactId>
+            <version>${pulsar.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.streampipes</groupId>
+            <artifactId>streampipes-connect-adapters-iiot</artifactId>
+            <version>0.71.0-SNAPSHOT</version>
+            <classifier>embed</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
+            <version>1.17.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>validate</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <logViolationsToConsole>true</logViolationsToConsole>
+                    <failOnViolation>true</failOnViolation>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.streampipes</groupId>
-      <artifactId>streampipes-connect</artifactId>
-      <version>0.71.0-SNAPSHOT</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.streampipes</groupId>
-      <artifactId>streampipes-container</artifactId>
-      <version>0.71.0-SNAPSHOT</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.pulsar</groupId>
-      <artifactId>pulsar-client</artifactId>
-      <version>${pulsar.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.streampipes</groupId>
-      <artifactId>streampipes-connect-adapters-iiot</artifactId>
-      <version>0.71.0-SNAPSHOT</version>
-      <classifier>embed</classifier>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.testcontainers</groupId>
-      <artifactId>testcontainers</artifactId>
-      <version>1.17.4</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
 
 </project>
diff --git a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdapterTesterBase.java b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdapterTesterBase.java
index fba59f1ea..495fba1c5 100644
--- a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdapterTesterBase.java
+++ b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdapterTesterBase.java
@@ -17,8 +17,6 @@
  */
 package org.apache.streampipes.integration.adapters;
 
-import java.util.List;
-import java.util.Map;
 import org.apache.streampipes.connect.adapter.Adapter;
 import org.apache.streampipes.connect.adapter.preprocessing.elements.DebugAdapterSink;
 import org.apache.streampipes.connect.api.exception.AdapterException;
@@ -27,33 +25,36 @@ import org.apache.streampipes.connect.iiot.protocol.stream.pulsar.PulsarProtocol
 import org.apache.streampipes.container.init.DeclarersSingleton;
 import org.apache.streampipes.model.connect.adapter.AdapterDescription;
 
+import java.util.List;
+import java.util.Map;
+
 public abstract class AdapterTesterBase implements AutoCloseable {
-    Adapter adapter;
-
-    public Adapter startAdapter(AdapterDescription adapterDescription) throws AdapterException {
-        DeclarersSingleton.getInstance().add(new PulsarProtocol());
-        Adapter adapter = (Adapter) AdapterUtils.setAdapter(adapterDescription);
-        adapter.startAdapter();
-        this.adapter = adapter;
-        return adapter;
-    }
+  Adapter adapter;
 
-    public abstract void startAdapterService() throws Exception;
+  public Adapter startAdapter(AdapterDescription adapterDescription) throws AdapterException {
+    DeclarersSingleton.getInstance().add(new PulsarProtocol());
+    Adapter adapter = (Adapter) AdapterUtils.setAdapter(adapterDescription);
+    adapter.startAdapter();
+    this.adapter = adapter;
+    return adapter;
+  }
 
-    public abstract AdapterDescription prepareAdapter() throws Exception;
+  public abstract void startAdapterService() throws Exception;
 
-    public abstract List<Map<String, Object>> generateData() throws Exception;
+  public abstract AdapterDescription prepareAdapter() throws Exception;
 
-    public abstract void validateData(List<Map<String, Object>> data) throws Exception;
+  public abstract List<Map<String, Object>> generateData() throws Exception;
 
-    public Map<String, Object> takeEvent() throws InterruptedException {
-        return ((DebugAdapterSink) adapter.getAdapterPipeline().getPipelineSink()).takeEvent();
-    }
+  public abstract void validateData(List<Map<String, Object>> data) throws Exception;
+
+  public Map<String, Object> takeEvent() throws InterruptedException {
+    return ((DebugAdapterSink) adapter.getAdapterPipeline().getPipelineSink()).takeEvent();
+  }
 
-    public void stopAdapter() throws AdapterException {
-        if (adapter != null) {
-            adapter.stopAdapter();
-        }
+  public void stopAdapter() throws AdapterException {
+    if (adapter != null) {
+      adapter.stopAdapter();
     }
+  }
 
 }
diff --git a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdaptersTest.java b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdaptersTest.java
index ed9fef073..9d1801294 100644
--- a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdaptersTest.java
+++ b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/AdaptersTest.java
@@ -17,24 +17,26 @@
  */
 package org.apache.streampipes.integration.adapters;
 
-import java.util.List;
-import java.util.Map;
 import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+
 import org.junit.Test;
 
+import java.util.List;
+import java.util.Map;
+
 public class AdaptersTest {
-    public void testAdapter(AdapterTesterBase adapterTester) throws Exception {
-        adapterTester.startAdapterService();
-        AdapterDescription adapterDescription = adapterTester.prepareAdapter();
-        adapterTester.startAdapter(adapterDescription);
-        List<Map<String, Object>> data = adapterTester.generateData();
-        adapterTester.validateData(data);
-    }
+  public void testAdapter(AdapterTesterBase adapterTester) throws Exception {
+    adapterTester.startAdapterService();
+    AdapterDescription adapterDescription = adapterTester.prepareAdapter();
+    adapterTester.startAdapter(adapterDescription);
+    List<Map<String, Object>> data = adapterTester.generateData();
+    adapterTester.validateData(data);
+  }
 
-    @Test
-    public void testPulsarAdapter() throws Exception {
-        try (PulsarAdapterTester pulsarAdapterTester = new PulsarAdapterTester()) {
-            testAdapter(pulsarAdapterTester);
-        }
+  @Test
+  public void testPulsarAdapter() throws Exception {
+    try (PulsarAdapterTester pulsarAdapterTester = new PulsarAdapterTester()) {
+      testAdapter(pulsarAdapterTester);
     }
+  }
 }
diff --git a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/PulsarAdapterTester.java b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/PulsarAdapterTester.java
index 27cdbb327..85c2fa667 100644
--- a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/PulsarAdapterTester.java
+++ b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/adapters/PulsarAdapterTester.java
@@ -17,9 +17,6 @@
  */
 package org.apache.streampipes.integration.adapters;
 
-import com.google.common.collect.Maps;
-import org.apache.pulsar.client.api.Producer;
-import org.apache.pulsar.client.api.PulsarClient;
 import org.apache.streampipes.connect.adapter.format.json.object.JsonObjectFormat;
 import org.apache.streampipes.connect.api.exception.AdapterException;
 import org.apache.streampipes.connect.iiot.protocol.stream.pulsar.PulsarProtocol;
@@ -30,6 +27,10 @@ import org.apache.streampipes.model.connect.rules.DebugSinkRuleDescription;
 import org.apache.streampipes.sdk.builder.adapter.GenericDataStreamAdapterBuilder;
 import org.apache.streampipes.sdk.builder.adapter.ProtocolDescriptionBuilder;
 import org.apache.streampipes.sdk.helpers.Labels;
+
+import com.google.common.collect.Maps;
+import org.apache.pulsar.client.api.Producer;
+import org.apache.pulsar.client.api.PulsarClient;
 import org.junit.Assert;
 import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
 
@@ -41,7 +42,7 @@ import java.util.Objects;
 
 public class PulsarAdapterTester extends AdapterTesterBase {
   PulsarContainer pulsarContainer;
-  private final static String TOPIC = "test-topic";
+  private static final String TOPIC = "test-topic";
 
   @Override
   public void startAdapterService() {
diff --git a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/containers/PulsarContainer.java b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/containers/PulsarContainer.java
index fb12f5663..5d48711ee 100644
--- a/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/containers/PulsarContainer.java
+++ b/streampipes-integration-tests/src/test/java/org/apache/streampipes/integration/containers/PulsarContainer.java
@@ -17,11 +17,13 @@
  */
 package org.apache.streampipes.integration.containers;
 
-import static java.time.temporal.ChronoUnit.SECONDS;
-import java.time.Duration;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
 
+import java.time.Duration;
+
+import static java.time.temporal.ChronoUnit.SECONDS;
+
 public class PulsarContainer extends GenericContainer<PulsarContainer> {
   private static final int BROKER_HTTP_PORT = 8080;
   private static final int BROKER_SERVICE_PORT = 6650;
@@ -32,10 +34,10 @@ public class PulsarContainer extends GenericContainer<PulsarContainer> {
 
   public void start() {
     this.waitStrategy = new HttpWaitStrategy()
-            .forPort(BROKER_HTTP_PORT)
-            .forStatusCode(200)
-            .forPath("/admin/v2/namespaces/public/default")
-            .withStartupTimeout(Duration.of(300, SECONDS));
+        .forPort(BROKER_HTTP_PORT)
+        .forStatusCode(200)
+        .forPath("/admin/v2/namespaces/public/default")
+        .withStartupTimeout(Duration.of(300, SECONDS));
     this.withExposedPorts(BROKER_SERVICE_PORT, BROKER_HTTP_PORT);
     this.withCreateContainerCmdModifier(createContainerCmd -> {
       createContainerCmd.withEntrypoint("bin/pulsar");
diff --git a/tools/maven/checkstyle-header.txt b/tools/maven/checkstyle-header.txt
index f974c9ac4..13cbc4aac 100644
--- a/tools/maven/checkstyle-header.txt
+++ b/tools/maven/checkstyle-header.txt
@@ -6,11 +6,12 @@
  * (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
+ *    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.
- */
\ No newline at end of file
+ *
+ */
diff --git a/tools/maven/checkstyle.xml b/tools/maven/checkstyle.xml
index 9b099b769..b81a4a9f9 100644
--- a/tools/maven/checkstyle.xml
+++ b/tools/maven/checkstyle.xml
@@ -441,6 +441,13 @@ page at http://checkstyle.sourceforge.net/config.html -->
             <property name="severity" value="error"/>
         </module>
 
-
+        <module name="Indentation">
+            <property name="basicOffset" value="2"/>
+            <property name="braceAdjustment" value="2"/>
+            <property name="caseIndent" value="2"/>
+            <property name="throwsIndent" value="4"/>
+            <property name="lineWrappingIndentation" value="4"/>
+            <property name="arrayInitIndent" value="2"/>
+        </module>
     </module>
 </module>