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 @@