Repository: apache/streampipes
Pull request #2892 (2024-05-22 02:38:51)

chore(deps): remove jakarta.validation:jakarta.validation-api dependency
Bumps [jakarta.validation:jakarta.validation-api](https://github.com/jakartaee/validation) from 3.0.2 to 3.1.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/jakartaee/validation/releases">jakarta.validation:jakarta.validation-api's releases</a>.</em></p>
<blockquote>
<h2>3.1.0-M1</h2>
<p>The 3.1.0-M1 milestone release for EE 11</p>
<h2>What's Changed</h2>
<ul>
<li>Use the same lock for all methods accessing Validation.GetValidationProviderListAction#providersPerClassloader by <a href="https://github.com/yrodiere"><code>@​yrodiere</code></a> in <a href="https://redirect.github.com/jakartaee/validation/pull/182">jakartaee/validation#182</a></li>
<li>edburns-msft-183-rename-to-just-validation by <a href="https://github.com/edburns"><code>@​edburns</code></a> in <a href="https://redirect.github.com/jakartaee/validation/pull/185">jakartaee/validation#185</a></li>
<li>Adding CI pull request workflow by <a href="https://github.com/mswatosh"><code>@​mswatosh</code></a> in <a href="https://redirect.github.com/jakartaee/validation/pull/190">jakartaee/validation#190</a></li>
<li>Dependency and plugin version updates by <a href="https://github.com/starksm64"><code>@​starksm64</code></a> in <a href="https://redirect.github.com/jakartaee/validation/pull/191">jakartaee/validation#191</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/yrodiere"><code>@​yrodiere</code></a> made their first contribution in <a href="https://redirect.github.com/jakartaee/validation/pull/182">jakartaee/validation#182</a></li>
<li><a href="https://github.com/edburns"><code>@​edburns</code></a> made their first contribution in <a href="https://redirect.github.com/jakartaee/validation/pull/185">jakartaee/validation#185</a></li>
<li><a href="https://github.com/mswatosh"><code>@​mswatosh</code></a> made their first contribution in <a href="https://redirect.github.com/jakartaee/validation/pull/190">jakartaee/validation#190</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/jakartaee/validation/compare/3.0.2...3.1.0-M1">https://github.com/jakartaee/validation/compare/3.0.2...3.1.0-M1</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/jakartaee/validation/commit/cac4dff8adba0ff7bd09857012f9a3aa1448cb54"><code>cac4dff</code></a> Tag and branch for 3.1.0 release (<a href="https://redirect.github.com/jakartaee/validation/issues/211">#211</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/9520b423a657cb8350e23621c6ce6c95e4cca916"><code>9520b42</code></a> Prepare for the 3.1.0-M2 release (<a href="https://redirect.github.com/jakartaee/validation/issues/210">#210</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/30da76e0fa2e12bbd5dfd323c5a1e31a9a4f1a92"><code>30da76e</code></a> Update builds to cover JDK 17 and JDK 21 (<a href="https://redirect.github.com/jakartaee/validation/issues/201">#201</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/29ea0de173e6665a9a73427493e085910b392ac6"><code>29ea0de</code></a> Bump org.apache.maven.plugins:maven-deploy-plugin from 3.0.0-M1 to 3.1.1 (<a href="https://redirect.github.com/jakartaee/validation/issues/199">#199</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/8fd096997aa4c8a6c1c94d776ff855169a3f36ae"><code>8fd0969</code></a> Bump org.apache.maven.plugins:maven-compiler-plugin from 3.8.1 to 3.12.1 (<a href="https://redirect.github.com/jakartaee/validation/issues/198">#198</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/4ed088a7018a1abbe27f29e10b7cdbe11f7809f5"><code>4ed088a</code></a> Bump org.apache.felix:maven-bundle-plugin from 3.5.0 to 5.1.9 (<a href="https://redirect.github.com/jakartaee/validation/issues/197">#197</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/a8be989f95b92ccd59024cedef8d0f753a2aebcf"><code>a8be989</code></a> Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.2 to 3.2.5 (<a href="https://redirect.github.com/jakartaee/validation/issues/196">#196</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/c1ad252b634603bc2e821783def4b75b4b5b35d8"><code>c1ad252</code></a> Bump actions/setup-java from 3.13.0 to 4.0.0 (<a href="https://redirect.github.com/jakartaee/validation/issues/195">#195</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/56000aae14db687afbe86bbe72593d31cf056cb4"><code>56000aa</code></a> Adding Dependabot and NOTICE.md updates (<a href="https://redirect.github.com/jakartaee/validation/issues/192">#192</a>)</li>
<li><a href="https://github.com/jakartaee/validation/commit/c3a6baa831edbe2fa3b44407fed8dfa3d1d2a663"><code>c3a6baa</code></a> Prepare for the 3.1.0-M1 release</li>
<li>Additional commits viewable in <a href="https://github.com/jakartaee/validation/compare/3.0.2...3.1.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=jakarta.validation:jakarta.validation-api&package-manager=maven&previous-version=3.0.2&new-version=3.1.0)](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 show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@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/pom.xml b/pom.xml
index 6e1f33d663..9a713f93ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,6 @@
         <jakarta-activation-api.version>2.1.3</jakarta-activation-api.version>
         <jakarta-inject-api.version>2.0.1</jakarta-inject-api.version>
         <jakarta-servlet-api.version>6.0.0</jakarta-servlet-api.version>
-        <jakarta-validation.version>3.0.2</jakarta-validation.version>
         <jakarta-xml-bind-api.version>4.0.0</jakarta-xml-bind-api.version>
         <javax.xml.bind.version>2.4.0-b180725.0427</javax.xml.bind.version>
         <java-websocket.version>1.5.0</java-websocket.version>
@@ -328,11 +327,6 @@
                 <artifactId>jakarta.inject-api</artifactId>
                 <version>${jakarta-inject-api.version}</version>
             </dependency>
-            <dependency>
-                <groupId>jakarta.validation</groupId>
-                <artifactId>jakarta.validation-api</artifactId>
-                <version>${jakarta-validation.version}</version>
-            </dependency>
             <dependency>
                 <groupId>jakarta.servlet</groupId>
                 <artifactId>jakarta.servlet-api</artifactId>
diff --git a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/SupportsNestedTransformationRule.java b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/SupportsNestedTransformationRule.java
index d332a79e42..a0494cff34 100644
--- a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/SupportsNestedTransformationRule.java
+++ b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/SupportsNestedTransformationRule.java
@@ -42,7 +42,10 @@ public abstract class SupportsNestedTransformationRule implements Transformation
           applyNested((Map<String, Object>) event.get(eventKey.get(0)), newKeysTmpList);
 
       event.remove(key);
-      event.put(key, newSubEvent);
+
+      if (newSubEvent != null && !newSubEvent.isEmpty()) {
+        event.put(key, newSubEvent);
+      }
     }
     return event;
   }
diff --git a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRule.java b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRule.java
index ae2d1c70d9..7fe7805baa 100644
--- a/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRule.java
+++ b/streampipes-connect-shared/src/main/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRule.java
@@ -38,6 +38,8 @@ public class DeleteTransformationRule extends SupportsNestedTransformationRule {
 
   @Override
   protected void applyTransformation(Map<String, Object> event, List<String> eventKeys) {
+    if (event != null) {
       event.remove(eventKeys.get(0));
+    }
   }
 }


Test patch:
diff --git a/streampipes-connect-shared/src/test/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRuleTest.java b/streampipes-connect-shared/src/test/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRuleTest.java
index 7253b33bd5..e8d5e1feb8 100644
--- a/streampipes-connect-shared/src/test/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRuleTest.java
+++ b/streampipes-connect-shared/src/test/java/org/apache/streampipes/connect/shared/preprocessing/transform/schema/DeleteTransformationRuleTest.java
@@ -44,13 +44,39 @@ public class DeleteTransformationRuleTest {
   public void transformNested() {
     var child = new HashMap<String, Object>();
     child.put("child", "value");
+    child.put("secondChild", "value");
     var event = new HashMap<String, Object>();
     event.put("parent", child);
+    event.put("keepProperty", "test");
+
+    var deleteRule = new DeleteTransformationRule(List.of("parent", "child"));
+
+    var result = deleteRule.apply(event);
+
+    assertEquals(2, result.keySet().size());
+  }
+
+  @Test
+  // verifying that mathod applyTransformation method works when passed a null event.
+  public void applyTransformationWithNullParameter() {
+    new DeleteTransformationRule(List.of())
+        .applyTransformation(null, List.of());
+  }
+
+  @Test
+  public void deleteNestedChildWithParentProperty() {
+    var child = new HashMap<String, Object>();
+    child.put("child", "value");
+    var event = new HashMap<String, Object>();
+    event.put("parent", child);
+    event.put("keepProperty", "test");
 
     var deleteRule = new DeleteTransformationRule(Arrays.asList("parent", "child"));
 
     var result = deleteRule.apply(event);
 
     assertEquals(1, result.keySet().size());
+    assertEquals("test", result.get("keepProperty"));
   }
+
 }
diff --git a/ui/cypress/tests/adapter/rules/deleteTransformationRule.spec.ts b/ui/cypress/tests/adapter/rules/deleteTransformationRule.spec.ts
index debbc5473f..2ece7e9a38 100644
--- a/ui/cypress/tests/adapter/rules/deleteTransformationRule.spec.ts
+++ b/ui/cypress/tests/adapter/rules/deleteTransformationRule.spec.ts
@@ -19,6 +19,7 @@ import { ConnectUtils } from '../../../support/utils/connect/ConnectUtils';
 import { FileManagementUtils } from '../../../support/utils/FileManagementUtils';
 import { ConnectEventSchemaUtils } from '../../../support/utils/ConnectEventSchemaUtils';
 import { AdapterBuilder } from '../../../support/builder/AdapterBuilder';
+import { ConnectBtns } from '../../../support/utils/connect/ConnectBtns';
 
 describe('Connect delete rule transformation', () => {
     beforeEach('Setup Test', () => {
@@ -72,5 +73,15 @@ describe('Connect delete rule transformation', () => {
             'have.text',
             '{\u00A0\u00A0\u00A0\u00A0"parent":\u00A0{},\u00A0\u00A0\u00A0\u00A0"timestamp":\u00A01667904471000}',
         );
+
+        ConnectBtns.refreshSchema().click();
+
+        // Test to delete the parent property
+        ConnectEventSchemaUtils.deleteProperty('parent');
+        cy.dataCy('schema-preview-result-event').should(
+            'have.text',
+
+            '{\u00A0\u00A0\u00A0\u00A0"timestamp":\u00A01667904471000}',
+        );
     });
 });