You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2026/10/09 07:14:32 UTC

(streampipes) branch fix-system-notifications-spec created (now 425624ff36)

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

tenthe pushed a change to branch fix-system-notifications-spec
in repository https://gitbox.apache.org/repos/asf/streampipes.git


      at 425624ff36 fix: clear system notification on reset

This branch includes the following new commits:

     new 425624ff36 fix: clear system notification on reset

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(streampipes) 01/01: fix: clear system notification on reset

Posted by ze...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tenthe pushed a commit to branch fix-system-notifications-spec
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 425624ff3612215b475fde5f4eaf2664ac401f86
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Fri Oct 9 09:14:08 2026 +0200

    fix: clear system notification on reset
---
 .../apache/streampipes/rest/ResetManagement.java   | 18 ++++-
 .../streampipes/rest/ResetManagementTest.java      | 82 ++++++++++++++++++++++
 .../systemNotification/systemNotification.spec.ts  |  6 --
 3 files changed, 99 insertions(+), 7 deletions(-)

diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/ResetManagement.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/ResetManagement.java
index e60ad33d53..7fb240fca2 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/ResetManagement.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/ResetManagement.java
@@ -31,6 +31,7 @@ import org.apache.streampipes.manager.pipeline.PipelineCacheManager;
 import org.apache.streampipes.manager.pipeline.PipelineCanvasMetadataCacheManager;
 import org.apache.streampipes.manager.pipeline.PipelineManager;
 import org.apache.streampipes.manager.pipeline.update.ChartSchemaUpdateCoordinator;
+import org.apache.streampipes.model.configuration.SystemNotificationConfig;
 import org.apache.streampipes.model.connect.adapter.AdapterDescription;
 import org.apache.streampipes.model.dataset.DatasetMetadata;
 import org.apache.streampipes.model.file.FileMetadata;
@@ -83,7 +84,7 @@ public class ResetManagement {
 
   /**
    * Remove all configurations for this user. This includes:
-   * [pipeline assembly cache, pipelines, adapters, files, assets]
+   * [pipeline assembly cache, pipelines, adapters, files, assets, system notification]
    *
    * @param username of the user to delte the resources
    */
@@ -112,6 +113,8 @@ public class ResetManagement {
 
     clearGenericStorage();
 
+    disableSystemNotification();
+
     logger.info("Resetting the system was completed");
   }
 
@@ -235,4 +238,17 @@ public class ResetManagement {
     });
 
   }
+
+  /**
+   * Switches the system notification off again, as on a fresh installation. The rest of the
+   * general configuration stays untouched.
+   */
+  void disableSystemNotification() {
+    var configStorage = resourceManager.getCoreConfigurationStorage();
+    var config = configStorage.get();
+    if (config != null && config.getGeneralConfig() != null) {
+      config.getGeneralConfig().setSystemNotification(SystemNotificationConfig.disabled());
+      configStorage.updateElement(config);
+    }
+  }
 }
diff --git a/streampipes-rest/src/test/java/org/apache/streampipes/rest/ResetManagementTest.java b/streampipes-rest/src/test/java/org/apache/streampipes/rest/ResetManagementTest.java
new file mode 100644
index 0000000000..9fd9e49424
--- /dev/null
+++ b/streampipes-rest/src/test/java/org/apache/streampipes/rest/ResetManagementTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.rest;
+
+import org.apache.streampipes.model.configuration.GeneralConfig;
+import org.apache.streampipes.model.configuration.SpCoreConfiguration;
+import org.apache.streampipes.model.configuration.SystemNotificationConfig;
+import org.apache.streampipes.model.configuration.SystemNotificationType;
+import org.apache.streampipes.resource.management.SpResourceManager;
+import org.apache.streampipes.storage.api.system.ISpCoreConfigurationStorage;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Tests for the system notification step of the {@link ResetManagement} class.
+ */
+class ResetManagementTest {
+
+  private final ISpCoreConfigurationStorage configStorage = mock(ISpCoreConfigurationStorage.class);
+
+  ResetManagement newResetManagement(SpCoreConfiguration storedConfig) {
+    var resourceManager = mock(SpResourceManager.class);
+    when(resourceManager.getCoreConfigurationStorage()).thenReturn(configStorage);
+    when(configStorage.get()).thenReturn(storedConfig);
+    return new ResetManagement(null, null, null, null, null, resourceManager, null, null);
+  }
+
+  /**
+   * Checks that an enabled notification is switched off while the rest of the general
+   * configuration is kept.
+   */
+  @Test
+  void testDisableSystemNotification_enabledNotification_storesDisabledAndKeepsRest() {
+    var generalConfig = new GeneralConfig();
+    var storedConfig = new SpCoreConfiguration();
+    generalConfig.setHostname("streampipes.example.org");
+    generalConfig.setSystemNotification(new SystemNotificationConfig(
+        true, "Maintenance tonight", SystemNotificationType.CRITICAL, null));
+    storedConfig.setGeneralConfig(generalConfig);
+
+    newResetManagement(storedConfig).disableSystemNotification();
+
+    verify(configStorage).updateElement(storedConfig);
+    assertEquals(SystemNotificationConfig.disabled(), generalConfig.getSystemNotification());
+    assertEquals("streampipes.example.org", generalConfig.getHostname());
+  }
+
+  @Test
+  void testDisableSystemNotification_nothingStored_storesNothing() {
+    newResetManagement(null).disableSystemNotification();
+    verify(configStorage, never()).updateElement(any());
+  }
+
+  @Test
+  void testDisableSystemNotification_noGeneralConfig_storesNothing() {
+    newResetManagement(new SpCoreConfiguration()).disableSystemNotification();
+    verify(configStorage, never()).updateElement(any());
+  }
+}
diff --git a/ui/cypress/tests/configuration/systemNotification/systemNotification.spec.ts b/ui/cypress/tests/configuration/systemNotification/systemNotification.spec.ts
index bef1848c1d..b5cd5f9a99 100644
--- a/ui/cypress/tests/configuration/systemNotification/systemNotification.spec.ts
+++ b/ui/cypress/tests/configuration/systemNotification/systemNotification.spec.ts
@@ -27,12 +27,6 @@ describe('Show a system notification to all users', () => {
         ConfigurationUtils.enableSystemNotification(message);
     });
 
-    afterEach('Switch the notification off again', () => {
-        // The reset does not touch the general configuration
-        cy.login();
-        ConfigurationUtils.disableSystemNotification();
-    });
-
     it('Shows the notification in the toolbar and on the login page', () => {
         ConfigurationBtns.systemNotification().should('contain.text', message);
         cy.logout();