Repository: apache/streampipes
Pull request #1510 (2023-04-17 03:08:40)

Bump type-parser from 0.7.0 to 0.8.1
Bumps [type-parser](https://github.com/drapostolos/type-parser) from 0.7.0 to 0.8.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/drapostolos/type-parser/releases">type-parser's releases</a>.</em></p>
<blockquote>
<h2>v0.8.1</h2>
<ul>
<li>New features, enhancements:
<ul>
<li>Add support for <code>java.util.Optional&lt;E&gt;</code> <a href="https://redirect.github.com/drapostolos/type-parser/pull/40">#40</a>.</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/drapostolos/type-parser/commit/fe2b28ebe5f460f3e72a39bce288cf49611b919c"><code>fe2b28e</code></a> [Gradle Release Plugin] - pre tag commit:  'type-parser-0.8.1'.</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/0643f85da8ce05c1c23d3da284aa862615077dc2"><code>0643f85</code></a> Added: afterReleaseBuild.dependsOn publish (<a href="https://redirect.github.com/drapostolos/type-parser/issues/47">#47</a>)</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/ac6367c3e16a1628ba063b6f4d88c9b9150397c4"><code>ac6367c</code></a> [Gradle Release Plugin] - new version commit:  'type-parser-0.8.1-SNAPSHOT'.</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/1b8c9ddaa4ca8075952bf32d13a46525af462a9d"><code>1b8c9dd</code></a> [Gradle Release Plugin] - pre tag commit:  'type-parser-0.8.0'.</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/bfbe92f6bb242322c06d2bf1db7ce5784dc001bb"><code>bfbe92f</code></a> set release branch to master (<a href="https://redirect.github.com/drapostolos/type-parser/issues/46">#46</a>)</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/94e4417e66795035e87f53527701b3447a51ca2a"><code>94e4417</code></a> Update README.md</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/8386005a7158e39aa134edc87c090e5e067ffafd"><code>8386005</code></a> upload code coverage (<a href="https://redirect.github.com/drapostolos/type-parser/issues/45">#45</a>)</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/9a22c5c31d625986e96a4120e628e9b748d54d8c"><code>9a22c5c</code></a> Update README.md</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/5735eb5ba13ec3e6774cae2a3d005f01243ddbd9"><code>5735eb5</code></a> Update README.md</li>
<li><a href="https://github.com/drapostolos/type-parser/commit/12ae86d1f5eb76cf18c9883ccbcf7c30daf8714d"><code>12ae86d</code></a> Create README.md</li>
<li>Additional commits viewable in <a href="https://github.com/drapostolos/type-parser/compare/type-parser-0.7.0...type-parser-0.8.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=com.github.drapostolos:type-parser&package-manager=maven&previous-version=0.7.0&new-version=0.8.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/.github/workflows/python-docs.yml b/.github/workflows/python-docs.yml
index 19023a3098..6581ee030e 100644
--- a/.github/workflows/python-docs.yml
+++ b/.github/workflows/python-docs.yml
@@ -56,8 +56,7 @@ jobs:
       - name: Build Python docs
         working-directory: ./streampipes-client-python
         run: |
-          mike deploy dev latest -u --deploy-prefix ./streampipes-client-python/docs-tmp -b build-python-docs-${{ github.run_id }}
-          mike set-default latest --deploy-prefix ./streampipes-client-python/docs-tmp -b build-python-docs-${{ github.run_id }}
+          mike deploy dev -u --deploy-prefix ./streampipes-client-python/docs-tmp -b build-python-docs-${{ github.run_id }}
           git reset --hard  # undo local changes that delete generated doc files
 
       - name: Publish Python docs as artifact
diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml
new file mode 100644
index 0000000000..191d1599c1
--- /dev/null
+++ b/.github/workflows/stale-bot.yml
@@ -0,0 +1,39 @@
+# 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.
+
+name: 'Close and remind stale PRs'
+on:
+  schedule:
+    - cron: '0 1 * * *'
+  workflow_dispatch:
+
+permissions:
+  pull-requests: write
+
+jobs:
+  mark-stale-prs:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/stale@v8
+        with:
+          close-pr-message: "Hello there :wave:<br> <br> Unfortunately, we didn't hear back from you regarding your pull request, so we're closing it now. Don't worry, you can always reopen the PR at any time if you wish to continue working on it :raised_hands:.<br> <br> Please note that the branch associated with this pull request will not be deleted, so you can still access your changes and continue to work on them as needed :computer:.<br> <br> Thank you for your contributions to our project, and we hope to see you again soon!"
+          days-before-close: 7
+          days-before-stale: 21
+          exempt-pr-labels: 'blocked'
+          labels-to-remove-when-unstale: 'stale'
+          only-issue-labels: 'do-not-stale'
+          operations-per-run: 1000
+          stale-pr-label: 'stale'
+          stale-pr-message: "Hello there :wave:<br> <br> We noticed that it's been some time since activity occurred on your pull request :thinking:. In order to keep things moving forward, we're marking this PR as _stale_ and giving you 7 days to respond before it's automatically closed :alarm_clock:.<br> <br> Please take a moment to review your pull request and make any necessary updates or changes :man_technologist:. If you need more time or have any questions, please don't hesitate to let us know :speech_balloon:.<br> <br> Thank you for your contributions to our project, and we look forward to hearing back from you soon :pray:."
diff --git a/pom.xml b/pom.xml
index 356d900616..5c79c0ae35 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,7 +121,7 @@
 	<spring-boot.version>3.0.5</spring-boot.version>
 	<spring-security.version>6.0.2</spring-security.version>
 	<swagger.version>2.2.7</swagger.version>
-	<type-parser.version>0.7.0</type-parser.version>
+	<type-parser.version>0.8.1</type-parser.version>
 	<wildfly-common.version>1.6.0.Final</wildfly-common.version>
 	<hawtbuf.version>1.11</hawtbuf.version>
 	<netty-tc-native.version>2.0.52.Final</netty-tc-native.version>
diff --git a/streampipes-client-python/setup.py b/streampipes-client-python/setup.py
index ce7537a8b2..5602360afe 100644
--- a/streampipes-client-python/setup.py
+++ b/streampipes-client-python/setup.py
@@ -45,7 +45,7 @@ base_packages = [
 ]
 
 dev_packages = base_packages + [
-    "autoflake==2.0.0",
+    "autoflake==2.1.0",
     "black==23.3.0",
     "blacken-docs==1.13.0",
     "flake8==6.0.0",
@@ -67,7 +67,7 @@ docs_packages = [
     "mkdocs-material==9.1.3",
     "mkdocstrings[python]==0.21.1",
     "pytkdocs[numpy-style]>=0.16.1",
-    "mkdocs-gen-files==0.4.0",
+    "mkdocs-gen-files==0.5.0",
     "mkdocs-literate-nav==0.6.0",
     "numpydoc==1.5.0",
     "mkdocs-jupyter==0.24.0",
diff --git a/streampipes-client/pom.xml b/streampipes-client/pom.xml
index f24e663780..25c96b1a12 100644
--- a/streampipes-client/pom.xml
+++ b/streampipes-client/pom.xml
@@ -97,8 +97,13 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>
+                		checkstyle.config.base.path=${project.parent.basedir}/tools/maven
+                	</propertyExpansion>
+                </configuration>
             </plugin>
         </plugins>
     </build>
 
-</project>
+</project>
\ No newline at end of file
diff --git a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/preprocessing/transform/value/CorrectionValueTransformationRule.java b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/preprocessing/transform/value/CorrectionValueTransformationRule.java
index 4b1f6f838a..e720e4b27c 100644
--- a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/preprocessing/transform/value/CorrectionValueTransformationRule.java
+++ b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/preprocessing/transform/value/CorrectionValueTransformationRule.java
@@ -49,26 +49,22 @@ public class CorrectionValueTransformationRule implements ValueTransformationRul
     if (eventKey.size() == 1) {
       try {
         Object obj = event.get(eventKey.get(0));
-        double old = 0d;
+        double old;
         if (obj instanceof Number) {
           old = ((Number) obj).doubleValue();
+        } else {
+          throw new RuntimeException(
+              String.format("Selected property `%s` does not contain a numeric value: `%s", eventKey.get(0), obj)
+          );
         }
 
-        double corrected = 0d;
-        switch (operator) {
-          case "MULTIPLY":
-            corrected = old * correctionValue;
-            break;
-          case "ADD":
-            corrected = old + correctionValue;
-            break;
-          case "SUBSTRACT":
-            corrected = old - correctionValue;
-            break;
-          default:
-            corrected = old;
-            break;
-        }
+        double corrected = switch (operator) {
+          case "MULTIPLY" -> old * correctionValue;
+          case "ADD" -> old + correctionValue;
+          case "SUBTRACT" -> old - correctionValue;
+          case "DIVIDE" -> old / correctionValue;
+          default -> old;
+        };
 
         event.put(eventKey.get(0), corrected);
       } catch (ClassCastException e) {
diff --git a/streampipes-rest-extensions/pom.xml b/streampipes-rest-extensions/pom.xml
index d95d3e45de..192260917d 100644
--- a/streampipes-rest-extensions/pom.xml
+++ b/streampipes-rest-extensions/pom.xml
@@ -75,4 +75,4 @@
         </plugins>
     </build>
 
-</project>
+</project>
\ No newline at end of file
diff --git a/streampipes-rest-shared/pom.xml b/streampipes-rest-shared/pom.xml
index de74e640dc..e94975373e 100644
--- a/streampipes-rest-shared/pom.xml
+++ b/streampipes-rest-shared/pom.xml
@@ -17,7 +17,8 @@
   ~
   -->
 
-<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">
+<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>
diff --git a/streampipes-rest/pom.xml b/streampipes-rest/pom.xml
index 64eb418d7c..94bcca3803 100644
--- a/streampipes-rest/pom.xml
+++ b/streampipes-rest/pom.xml
@@ -159,7 +159,12 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>
+                        checkstyle.config.base.path=${project.parent.basedir}/tools/maven
+                    </propertyExpansion>
+                </configuration>
             </plugin>
         </plugins>
     </build>
-</project>
+</project>
\ No newline at end of file
diff --git a/tools/maven/checkstyle.xml b/tools/maven/checkstyle.xml
index 83861dbe07..a86ef413dc 100644
--- a/tools/maven/checkstyle.xml
+++ b/tools/maven/checkstyle.xml
@@ -28,7 +28,7 @@ page at http://checkstyle.sourceforge.net/config.html -->
     <property name="severity" value="error"/>
 
     <module name="Header">
-        <property name="headerFile" value="tools/maven/checkstyle-header.txt"/>
+        <property name="headerFile" value="${checkstyle.config.base.path}/checkstyle-header.txt" default="tools/maven/checkstyle-header.txt"/>
         <property name="fileExtensions" value="java"/>
     </module>
 
diff --git a/ui/README.md b/ui/README.md
index 91c19f6eb6..3f3ce4304e 100644
--- a/ui/README.md
+++ b/ui/README.md
@@ -43,4 +43,4 @@ To test your local version of the UI execute the following commands:
 Running `npm install` will cause a pre-commit hook to be created.
 This hook ensures that if you want to commit changes to this repository, these changes are compliant with our [formatting](https://prettier.io/) and [linting](https://eslint.org/) rules.
 
-If you see errors there, you can try to run `npm run format:fix` and `npm run lint:fix` to fix these issues automatically. Otherwise you have to run `npm run format` and `npm run lint` to get additional information about the problems.
+If you see errors there, you can try to run `npm run format:fix` and `npm run lint:fix` to fix these issues automatically. Otherwise, you have to run `npm run format` and `npm run lint` to get additional information about the problems.
diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/basic-view/basic-view.component.scss b/ui/projects/streampipes/shared-ui/src/lib/components/basic-view/basic-view.component.scss
index 66eb0f253d..6341039951 100644
--- a/ui/projects/streampipes/shared-ui/src/lib/components/basic-view/basic-view.component.scss
+++ b/ui/projects/streampipes/shared-ui/src/lib/components/basic-view/basic-view.component.scss
@@ -42,7 +42,7 @@
 .page-container {
     margin: 10px;
     border: 1px solid var(--color-bg-3);
-    min-height: calc(100% - 50px);
+    min-height: calc(100vh - 90px);
 }
 
 .page-container-padding-inner {
diff --git a/ui/src/app/connect/dialog/edit-event-property/components/edit-value-transformation/edit-correction-value/edit-correction-value.component.ts b/ui/src/app/connect/dialog/edit-event-property/components/edit-value-transformation/edit-correction-value/edit-correction-value.component.ts
index 90e17883ce..87b31c9fd1 100644
--- a/ui/src/app/connect/dialog/edit-event-property/components/edit-value-transformation/edit-correction-value/edit-correction-value.component.ts
+++ b/ui/src/app/connect/dialog/edit-event-property/components/edit-value-transformation/edit-correction-value/edit-correction-value.component.ts
@@ -30,7 +30,8 @@ export class EditCorrectionValueComponent {
     operators = [
         { value: 'MULTIPLY', viewValue: 'Multiply' },
         { value: 'ADD', viewValue: 'Add' },
-        { value: 'SUBSTRACT', viewValue: 'Substract' },
+        { value: 'SUBTRACT', viewValue: 'Subtract' },
+        { value: 'DIVIDE', viewValue: 'Divide' },
     ];
 
     constructor() {}
diff --git a/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts b/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts
index df8839db8d..b2c98542c5 100644
--- a/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts
+++ b/ui/src/app/connect/dialog/edit-event-property/edit-event-property.component.ts
@@ -159,7 +159,7 @@ export class EditEventPropertyComponent implements OnInit {
         this.property.label = this.cachedProperty.label;
         this.property.description = this.cachedProperty.description;
 
-        // remove undefined from domain properies array
+        // remove undefined from domain properties array
         this.property.domainProperties =
             this.cachedProperty.domainProperties.filter(n => n);
         this.property.runtimeName = this.cachedProperty.runtimeName;


Test patch:
diff --git a/streampipes-extensions-management/src/test/java/org/apache/streampipes/extensions/management/connect/adapter/transform/value/CorrectionValueTest.java b/streampipes-extensions-management/src/test/java/org/apache/streampipes/extensions/management/connect/adapter/transform/value/CorrectionValueTest.java
new file mode 100644
index 0000000000..5bc26c26d8
--- /dev/null
+++ b/streampipes-extensions-management/src/test/java/org/apache/streampipes/extensions/management/connect/adapter/transform/value/CorrectionValueTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.streampipes.extensions.management.connect.adapter.transform.value;
+
+import org.apache.streampipes.extensions.management.connect.adapter.preprocessing.transform.value.CorrectionValueTransformationRule;
+import org.apache.streampipes.model.schema.EventProperty;
+import org.apache.streampipes.model.schema.EventPropertyPrimitive;
+import org.apache.streampipes.model.schema.EventSchema;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+
+public class CorrectionValueTest {
+
+  private Map<String, Object> event;
+
+  private final String propertyNameBasicValue = "basicValue";
+  private final String propertyNameOtherValue = "otherValue";
+
+  @Before
+  public void setUp() {
+
+    EventSchema eventSchema = new EventSchema();
+    EventProperty eventProperty = new EventPropertyPrimitive();
+    eventProperty.setLabel(propertyNameBasicValue);
+    eventProperty.setRuntimeName(propertyNameBasicValue);
+    eventSchema.addEventProperty(eventProperty);
+
+    EventProperty eventPropertyOther = new EventPropertyPrimitive();
+    eventPropertyOther.setLabel(propertyNameBasicValue);
+    eventPropertyOther.setRuntimeName(propertyNameBasicValue);
+    eventSchema.addEventProperty(eventPropertyOther);
+
+    event = new HashMap<>();
+    event.put(propertyNameBasicValue, 100.0);
+    event.put(propertyNameOtherValue, "Hello");
+  }
+
+  @Test
+  public void testAdd() {
+
+    var correctionRule = new CorrectionValueTransformationRule(
+         List.of(propertyNameBasicValue),
+         10.0,
+         "ADD"
+     );
+
+    var resultEvent = correctionRule.transform(event);
+    assertNotNull(resultEvent);
+    assertEquals(110.0, resultEvent.get(propertyNameBasicValue));
+  }
+
+  @Test
+  public void testSubtract() {
+
+    var correctionRule = new CorrectionValueTransformationRule(
+        List.of(propertyNameBasicValue),
+        10.0,
+        "SUBTRACT"
+    );
+    var resultEvent = correctionRule.transform(event);
+    assertNotNull(resultEvent);
+    assertEquals(90.0, resultEvent.get(propertyNameBasicValue));
+  }
+
+  @Test
+  public void testMultiply() {
+
+    var correctionRule = new CorrectionValueTransformationRule(
+        List.of(propertyNameBasicValue),
+        1.5,
+        "MULTIPLY"
+    );
+    var resultEvent = correctionRule.transform(event);
+    assertNotNull(resultEvent);
+    assertEquals(150.0, resultEvent.get(propertyNameBasicValue));
+  }
+
+  @Test
+  public void testDivide() {
+
+    var correctionRule = new CorrectionValueTransformationRule(
+        List.of(propertyNameBasicValue),
+        5,
+        "DIVIDE"
+    );
+    var resultEvent = correctionRule.transform(event);
+    assertNotNull(resultEvent);
+    assertEquals(20.0, resultEvent.get(propertyNameBasicValue));
+  }
+
+  @Test
+  public void testDivideByZero() {
+
+    var correctionRule = new CorrectionValueTransformationRule(
+        List.of(propertyNameBasicValue),
+        0.0,
+        "DIVIDE"
+    );
+    var resultEvent = correctionRule.transform(event);
+    assertNotNull(resultEvent);
+    assertEquals(Double.POSITIVE_INFINITY, resultEvent.get(propertyNameBasicValue));
+  }
+
+  @Test
+  public void testNonNumericValue() {
+
+    var correctionRule = new CorrectionValueTransformationRule(
+        List.of(propertyNameOtherValue),
+        10.0,
+        "ADD"
+    );
+    assertThrows (
+        String.format("Selected property `%s` does not contain a numeric value: `%s", propertyNameOtherValue, "Hello"),
+        RuntimeException.class,
+        () -> correctionRule.transform(event).get(propertyNameOtherValue)
+    );
+
+
+  }
+
+  @Test
+  public void testUnsupportedOperation() {
+
+    var correctionRule = new CorrectionValueTransformationRule(
+        List.of(propertyNameBasicValue),
+        10.0,
+        "TEST"
+    );
+    var resultEvent = correctionRule.transform(event);
+    assertNotNull(resultEvent);
+    assertEquals(100.0, resultEvent.get(propertyNameBasicValue));
+  }
+}