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

zehnder 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 eccff93592 Hotfix remove unused classes (#3389)
eccff93592 is described below

commit eccff93592b1373230be90046b08ff92d3d3d179
Author: Philipp Zehnder <[email protected]>
AuthorDate: Mon Jan 20 11:32:09 2025 +0100

    Hotfix remove unused classes (#3389)
    
    * fix(#3388): Refactor asset link test
    
    * fix(#3388): Extend asset link test to test deletion
    
    * refactor: Remove unused classes AssetsUtil and LocalesUtil
---
 .../extensions/management/util/AssetsUtil.java     | 36 -----------
 .../extensions/management/util/LocalesUtil.java    | 29 ---------
 ui/cypress/support/utils/asset/AssetBtns.ts        | 73 ++++++++++++++++++++++
 ui/cypress/support/utils/asset/AssetUtils.ts       | 67 ++++++++++++++++++++
 .../tests/assetManagement/createAsset.spec.ts      | 62 ------------------
 .../assetManagement/generalAssetTest.smoke.spec.ts | 49 +++++++++++++++
 .../edit-asset/asset-details.component.html        |  4 +-
 .../asset-overview/asset-overview.component.html   |  6 ++
 .../manage-asset-links-dialog.component.html       | 12 ++--
 9 files changed, 206 insertions(+), 132 deletions(-)

diff --git 
a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/util/AssetsUtil.java
 
b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/util/AssetsUtil.java
deleted file mode 100644
index 8414c1084e..0000000000
--- 
a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/util/AssetsUtil.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.util;
-
-import org.apache.streampipes.commons.constants.GlobalStreamPipesConstants;
-
-public class AssetsUtil {
-
-  public static String makeIconPath(String elementId) {
-    return makePath(elementId, GlobalStreamPipesConstants.STD_ICON_NAME);
-  }
-
-  public static String makeDocumentationPath(String elementId) {
-    return makePath(elementId, 
GlobalStreamPipesConstants.STD_DOCUMENTATION_NAME);
-  }
-
-  public static String makePath(String elementId, String assetAppendix) {
-    return elementId + "/" + assetAppendix;
-  }
-}
diff --git 
a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/util/LocalesUtil.java
 
b/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/util/LocalesUtil.java
deleted file mode 100644
index 1e5e222129..0000000000
--- 
a/streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/util/LocalesUtil.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.util;
-
-import org.apache.streampipes.model.base.NamedStreamPipesEntity;
-
-public class LocalesUtil {
-
-  public static String makePath(NamedStreamPipesEntity desc, String 
assetAppendix) {
-    return desc.getAppId()
-        + "/"
-        + assetAppendix;
-  }
-}
diff --git a/ui/cypress/support/utils/asset/AssetBtns.ts 
b/ui/cypress/support/utils/asset/AssetBtns.ts
new file mode 100644
index 0000000000..8d574e0e7e
--- /dev/null
+++ b/ui/cypress/support/utils/asset/AssetBtns.ts
@@ -0,0 +1,73 @@
+/*
+ *  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.
+ *
+ */
+
+export class AssetBtns {
+    public static createAssetBtn() {
+        return cy.dataCy('create-new-asset-button', { timeout: 10000 });
+    }
+
+    public static assetNameInput() {
+        return cy.dataCy('asset-name', { timeout: 10000 });
+    }
+
+    public static saveAssetBtn() {
+        return cy.dataCy('save-asset', { timeout: 10000 });
+    }
+
+    public static editAssetBtn(assetName: string) {
+        return cy.dataCy('edit-asset-' + assetName, { timeout: 10000 });
+    }
+
+    public static deleteAssetBtn(assetName: string) {
+        return cy.dataCy('delete-asset-' + assetName, { timeout: 10000 });
+    }
+
+    public static basicTab() {
+        return cy.dataCy('basic-tab', { timeout: 10000 });
+    }
+
+    public static assetLinksTab() {
+        return cy.dataCy('asset-links-tab', { timeout: 10000 });
+    }
+
+    public static manageLinksBtn() {
+        return cy.dataCy('assets-manage-links-button', { timeout: 10000 });
+    }
+
+    public static adapterCheckbox(adapterName: string) {
+        return cy.dataCy('select-adapters-checkbox-' + adapterName, {
+            timeout: 10000,
+        });
+    }
+
+    public static dataStreamCheckbox(adapterName: string) {
+        return cy.dataCy('select-data-stream-checkbox-' + adapterName, {
+            timeout: 10000,
+        });
+    }
+
+    public static updateAssetLinksBtn() {
+        return cy.dataCy('assets-update-links-button', { timeout: 10000 });
+    }
+
+    public static goBackToOverviewBtn() {
+        return cy.dataCy('save-data-explorer-go-back-to-overview', {
+            timeout: 10000,
+        });
+    }
+}
diff --git a/ui/cypress/support/utils/asset/AssetUtils.ts 
b/ui/cypress/support/utils/asset/AssetUtils.ts
index 1df1f6907e..deb9f21095 100644
--- a/ui/cypress/support/utils/asset/AssetUtils.ts
+++ b/ui/cypress/support/utils/asset/AssetUtils.ts
@@ -16,8 +16,75 @@
  *
  */
 
+import { AssetBtns } from './AssetBtns';
+import { ConnectUtils } from '../connect/ConnectUtils';
+
 export class AssetUtils {
     public static goToAssets() {
         cy.visit('#/assets/overview');
     }
+
+    public static goBackToOverview() {
+        AssetBtns.goBackToOverviewBtn().click();
+    }
+
+    public static addNewAsset(assetName: string) {
+        AssetBtns.createAssetBtn().click();
+        AssetBtns.assetNameInput().clear();
+        AssetBtns.assetNameInput().type(assetName);
+        AssetBtns.saveAssetBtn().click();
+    }
+
+    public static openManageAssetLinks() {
+        AssetBtns.manageLinksBtn().should('be.enabled');
+        AssetBtns.manageLinksBtn().click();
+    }
+
+    public static selectAdapterAssetLink(adapterName: string) {
+        AssetBtns.adapterCheckbox(adapterName).click();
+    }
+
+    public static selectDataStreamAssetLink(adapterName: string) {
+        AssetBtns.dataStreamCheckbox(adapterName).click();
+    }
+
+    public static checkAmountOfAssets(amount: number) {
+        cy.dataCy('assets-table').should('have.length', amount);
+    }
+
+    public static checkAmountOfLinkedResources(amount: number) {
+        cy.dataCy('linked-resources-list')
+            .children()
+            .should('have.length', amount);
+    }
+
+    public static editAsset(assetName: string) {
+        AssetBtns.editAssetBtn(assetName).click();
+    }
+
+    public static addAssetWithOneAdapter(assetName: string) {
+        const adapterName = 'Machine_Data_Simulator';
+        ConnectUtils.addMachineDataSimulator(adapterName);
+
+        // Create new asset from adapters
+        AssetUtils.goToAssets();
+
+        AssetUtils.addNewAsset(assetName);
+
+        AssetBtns.assetLinksTab().click();
+        AssetUtils.openManageAssetLinks();
+
+        AssetUtils.selectAdapterAssetLink(adapterName);
+        AssetUtils.selectDataStreamAssetLink(adapterName);
+        AssetBtns.updateAssetLinksBtn().click();
+
+        AssetUtils.checkAmountOfLinkedResources(2);
+        AssetBtns.saveAssetBtn().click();
+        AssetUtils.goBackToOverview();
+    }
+
+    public static deleteAsset(assetName: string) {
+        AssetBtns.deleteAssetBtn(assetName).click();
+        cy.dataCy('confirm-delete').click();
+    }
 }
diff --git a/ui/cypress/tests/assetManagement/createAsset.spec.ts 
b/ui/cypress/tests/assetManagement/createAsset.spec.ts
deleted file mode 100644
index 6aa726636d..0000000000
--- a/ui/cypress/tests/assetManagement/createAsset.spec.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.
- *
- */
-
-import { AdapterBuilder } from '../../support/builder/AdapterBuilder';
-import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
-import { AssetUtils } from '../../support/utils/asset/AssetUtils';
-import { DashboardUtils } from '../../support/utils/DashboardUtils';
-import { ConfigurationUtils } from 
'../../support/utils/configuration/ConfigurationUtils';
-
-describe('Creates a new adapter, add to assets and export assets', () => {
-    beforeEach('Setup Test', () => {
-        cy.initStreamPipesTest();
-        const adapterInput = AdapterBuilder.create('Machine_Data_Simulator')
-            .setName('Machine Data Simulator Test')
-            .addInput('input', 'wait-time-ms', '1000')
-            .setStartAdapter(true)
-            .build();
-
-        ConnectUtils.testAdapter(adapterInput);
-    });
-
-    it('Perform Test', () => {
-        // Create new asset from adapters
-        AssetUtils.goToAssets();
-        cy.dataCy('create-new-asset-button').click();
-        cy.dataCy('asset-name').clear();
-        cy.dataCy('asset-name').type('Test asset');
-        cy.dataCy('save-asset').click();
-        cy.get('.mdc-tab__text-label').contains('Asset 
Links').parent().click();
-        cy.dataCy('assets-manage-links-button', { timeout: 5000 }).should(
-            'be.enabled',
-        );
-        cy.dataCy('assets-manage-links-button').click();
-        cy.dataCy('manage-assets-select-adapters-checkbox').click();
-        cy.dataCy('manage-assets-select-data-sources-checkbox').click();
-        cy.dataCy('assets-update-links-button').click();
-
-        cy.dataCy('linked-resources-list').children().should('have.length', 2);
-        cy.dataCy('save-asset-button').click();
-        cy.dataCy('save-data-explorer-go-back-to-overview').click();
-
-        // Leave and navigate back to Assets
-        DashboardUtils.goToDashboard();
-        AssetUtils.goToAssets();
-        cy.dataCy('assets-table').should('have.length', 1);
-    });
-});
diff --git a/ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts 
b/ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts
new file mode 100644
index 0000000000..f19bb1d79a
--- /dev/null
+++ b/ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ *
+ */
+
+import { AssetUtils } from '../../support/utils/asset/AssetUtils';
+import { DashboardUtils } from '../../support/utils/DashboardUtils';
+import { AssetBtns } from '../../support/utils/asset/AssetBtns';
+
+describe('Creates a new adapter, add to assets', () => {
+    beforeEach('Setup Test', () => {
+        cy.initStreamPipesTest();
+    });
+
+    it('Perform Test', () => {
+        const assetName = 'TestAsset';
+
+        AssetUtils.addAssetWithOneAdapter(assetName);
+
+        // // Leave and navigate back to Assets
+        DashboardUtils.goToDashboard();
+        AssetUtils.goToAssets();
+        AssetUtils.checkAmountOfAssets(1);
+
+        // Check that everything was stored correctly
+        AssetUtils.editAsset(assetName);
+        AssetBtns.assetLinksTab().click();
+        AssetUtils.checkAmountOfLinkedResources(2);
+
+        // Check that deletion of asset works
+        AssetUtils.goToAssets();
+        AssetUtils.checkAmountOfAssets(1);
+        AssetUtils.deleteAsset(assetName);
+        AssetUtils.checkAmountOfAssets(0);
+    });
+});
diff --git 
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
 
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
index b6f2d28aa7..278f9bfbc6 100644
--- 
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
+++ 
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
@@ -40,7 +40,7 @@
                     <button
                         mat-button
                         mat-raised-button
-                        data-cy="save-asset-button"
+                        data-cy="save-asset"
                         color="accent"
                         (click)="saveAsset()"
                     >
@@ -56,12 +56,14 @@
                     <nav mat-tab-nav-bar color="accent">
                         <a
                             mat-tab-link
+                            data-cy="basic-tab"
                             [active]="activeTab === 'basic'"
                             (click)="activeTab = 'basic'"
                             >Basics</a
                         >
                         <a
                             mat-tab-link
+                            data-cy="asset-links-tab"
                             [active]="activeTab === 'asset-links'"
                             (click)="activeTab = 'asset-links'"
                             >Asset Links</a
diff --git 
a/ui/src/app/assets/components/asset-overview/asset-overview.component.html 
b/ui/src/app/assets/components/asset-overview/asset-overview.component.html
index 6c6b0fb2db..61d1d3ea04 100644
--- a/ui/src/app/assets/components/asset-overview/asset-overview.component.html
+++ b/ui/src/app/assets/components/asset-overview/asset-overview.component.html
@@ -107,6 +107,9 @@
                                     matTooltip="Edit asset"
                                     matTooltipPosition="above"
                                     data-cy="edit-asset-button"
+                                    [attr.data-cy]="
+                                        'edit-asset-' + asset.assetName
+                                    "
                                     (click)="goToDetailsView(asset, true)"
                                 >
                                     <i class="material-icons">edit</i>
@@ -119,6 +122,9 @@
                                     matTooltip="Delete asset"
                                     data-cy="delete"
                                     matTooltipPosition="above"
+                                    [attr.data-cy]="
+                                        'delete-asset-' + asset.assetName
+                                    "
                                     (click)="deleteAsset(asset)"
                                 >
                                     <i class="material-icons">delete</i>
diff --git 
a/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
 
b/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
index c7af829a91..5e68673fb1 100644
--- 
a/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
+++ 
b/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
@@ -64,7 +64,9 @@
                     <mat-checkbox
                         color="accent"
                         [checked]="linkSelected(element.elementId)"
-                        data-cy="manage-assets-select-adapters-checkbox"
+                        [attr.data-cy]="
+                            'select-adapters-checkbox-' + element.name
+                        "
                         (change)="
                             selectLink(
                                 $event.checked,
@@ -228,7 +230,9 @@
                     <mat-checkbox
                         color="accent"
                         [checked]="linkSelected(source.elementId)"
-                        data-cy="manage-assets-select-data-sources-checkbox"
+                        [attr.data-cy]="
+                            'select-data-stream-checkbox-' + source.name
+                        "
                         (change)="
                             selectLink(
                                 $event.checked,
@@ -394,8 +398,8 @@
                                 'pipeline'
                             )
                         "
-                        >{{ pipeline.name }}</mat-checkbox
-                    >
+                        >{{ pipeline.name }}
+                    </mat-checkbox>
                 </div>
             </div>
         </div>

Reply via email to