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 d46183013b fix(#2577): pipeline element templates do not work (#2582)
d46183013b is described below
commit d46183013b03b8aa4fb40fb8537b668d7cdf6961
Author: Philipp Zehnder <[email protected]>
AuthorDate: Tue Mar 19 15:59:16 2024 +0100
fix(#2577): pipeline element templates do not work (#2582)
* test(#2577): Add cypress test for connect configuration templates
* fix(#2577): Add logic to remove pipeline templates in ResetManagement
* fix(#2577): Fix endpoint to get PipelineElementTemplate
* fix(#2577): Add test case for templates in a pipeline
* fix(#2577): Remove mapping properties from template selection
* fix(#2577): Fix checkstyle
---
.../ps/PipelineElementTemplateResource.java | 6 +-
.../apache/streampipes/rest/ResetManagement.java | 14 ++++
.../support/utils/PipelineElementTemplateUtils.ts | 40 +++++++++++
ui/cypress/support/utils/PipelineUtils.ts | 38 +++++++---
.../connectConfigurationTemplate.spec.ts | 69 ++++++++++++++++++
.../pipelineElementConfigurationTemplate.ts | 82 ++++++++++++++++++++++
.../adapter-settings.component.html | 3 +
.../adapter-template-dialog.component.html | 1 +
...pipeline-element-template-config.component.html | 3 +
.../pipeline-element-template.pipe.ts | 6 +-
.../pipeline-assembly.component.html | 1 +
.../dialog/customize/customize.component.html | 4 ++
12 files changed, 253 insertions(+), 14 deletions(-)
diff --git
a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/PipelineElementTemplateResource.java
b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/PipelineElementTemplateResource.java
index db7d63fab9..09451a95f0 100644
---
a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/PipelineElementTemplateResource.java
+++
b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/PipelineElementTemplateResource.java
@@ -201,7 +201,8 @@ public class PipelineElementTemplateResource extends
AbstractRestResource {
@Parameter(description = "Overwrite the name and description of the
pipeline element with"
+ "the labels given in the pipeline element template")
- @RequestParam("overwriteNames") String overwriteNameAndDescription,
+ @RequestParam(value = "overwriteNames", defaultValue = "false", required
= false)
+ String overwriteNameAndDescription,
@RequestBody(description = "The data processor invocation that should be
configured with the template contents",
content = @Content(schema = @Schema(implementation =
DataProcessorInvocation.class)))
@@ -231,7 +232,8 @@ public class PipelineElementTemplateResource extends
AbstractRestResource {
@Parameter(description = "Overwrite the name and description of the
pipeline element"
+ "with the labels given in the pipeline element template")
- @RequestParam("overwriteNames") String overwriteNameAndDescription,
+ @RequestParam(value = "overwriteNames", defaultValue = "false", required
= false)
+ String overwriteNameAndDescription,
@RequestBody(description = "The adapter that should be configured with
the template contents",
content = @Content(schema = @Schema(implementation =
AdapterDescription.class)))
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 77fb60bb42..8319d0a4ee 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
@@ -85,6 +85,8 @@ public class ResetManagement {
removeAllAssets(username);
+ removeAllPipelineTemplates();
+
logger.info("Resetting the system was completed");
}
@@ -192,4 +194,16 @@ public class ResetManagement {
throw new SpRuntimeException("Could not delete assets of user
%s".formatted(username));
}
}
+
+ private static void removeAllPipelineTemplates() {
+ var pipelineElementTemplateStorage = StorageDispatcher
+ .INSTANCE
+ .getNoSqlStore()
+ .getPipelineElementTemplateStorage();
+
+ pipelineElementTemplateStorage
+ .getAll()
+ .forEach(pipelineElementTemplateStorage::deleteElement);
+
+ }
}
diff --git a/ui/cypress/support/utils/PipelineElementTemplateUtils.ts
b/ui/cypress/support/utils/PipelineElementTemplateUtils.ts
new file mode 100644
index 0000000000..2f4855efdd
--- /dev/null
+++ b/ui/cypress/support/utils/PipelineElementTemplateUtils.ts
@@ -0,0 +1,40 @@
+/*
+ * 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 PipelineElementTemplateUtils {
+ public static addTemplate(templateName: string) {
+ cy.dataCy('use-template').should('not.exist');
+ cy.dataCy('create-template').click();
+ cy.dataCy('template-name').type(templateName);
+ cy.dataCy('template-description').type(templateName);
+ cy.dataCy('save-template').click();
+ }
+
+ public static selectTemplate(templateName: string) {
+ cy.dataCy('use-template').should('exist');
+ cy.dataCy('use-template').click({ force: true });
+ cy.get('mat-option').contains(templateName).click({ force: true });
+ }
+
+ public static deleteTemplate() {
+ cy.dataCy('create-template').click();
+ cy.dataCy('delete-pipeline-element-template').should('have.length', 1);
+ cy.dataCy('delete-pipeline-element-template').click();
+ cy.dataCy('delete-pipeline-element-template').should('have.length', 0);
+ }
+}
diff --git a/ui/cypress/support/utils/PipelineUtils.ts
b/ui/cypress/support/utils/PipelineUtils.ts
index c05ecb1d7a..cb132e9347 100644
--- a/ui/cypress/support/utils/PipelineUtils.ts
+++ b/ui/cypress/support/utils/PipelineUtils.ts
@@ -19,6 +19,7 @@
import { PipelineInput } from '../model/PipelineInput';
import { StaticPropertyUtils } from './StaticPropertyUtils';
import { OutputStrategyUtils } from './OutputStrategyUtils';
+import { PipelineElementInput } from '../model/PipelineElementInput';
export class PipelineUtils {
public static addPipeline(pipelineInput: PipelineInput) {
@@ -50,22 +51,37 @@ export class PipelineUtils {
cy.dataCy(pipelineInput.dataSource, { timeout: 10000 }).click();
}
- private static configurePipeline(pipelineInput: PipelineInput) {
- // Open possible elements menu
- cy.dataCy('sp-possible-elements-' + pipelineInput.dataSource, {
+ public static openPossibleElementsMenu(dataSourceName: string) {
+ cy.dataCy('sp-possible-elements-' + dataSourceName, {
timeout: 10000,
}).click();
+ }
+
+ public static selectCompatibleElement(elementName: string) {
+ cy.dataCy('sp-compatible-elements-' + elementName).click();
+ }
+
+ public static configureProcessingElement(
+ processingElement: PipelineElementInput,
+ ) {
+ this.selectCompatibleElement(processingElement.name);
+ StaticPropertyUtils.input(processingElement.config);
+ OutputStrategyUtils.input(processingElement.output);
+ }
+
+ private static savePipelineElementConfiguration() {
+ cy.dataCy('sp-element-configuration-save').click();
+ }
+
+ private static configurePipeline(pipelineInput: PipelineInput) {
+ this.openPossibleElementsMenu(pipelineInput.dataSource);
// Select processor
if (pipelineInput.processingElement) {
- cy.dataCy(
- 'sp-compatible-elements-' +
- pipelineInput.processingElement.name,
- ).click();
- StaticPropertyUtils.input(pipelineInput.processingElement.config);
- OutputStrategyUtils.input(pipelineInput.processingElement.output);
- // Save configuration
- cy.dataCy('sp-element-configuration-save').click();
+ this.configureProcessingElement(pipelineInput.processingElement);
+
+ this.savePipelineElementConfiguration();
+
// Select sink
cy.dataCy(
'sp-possible-elements-' + pipelineInput.processingElement.name,
diff --git
a/ui/cypress/tests/pipelineElementConfigurationTemplate/connectConfigurationTemplate.spec.ts
b/ui/cypress/tests/pipelineElementConfigurationTemplate/connectConfigurationTemplate.spec.ts
new file mode 100644
index 0000000000..76eb8d8e56
--- /dev/null
+++
b/ui/cypress/tests/pipelineElementConfigurationTemplate/connectConfigurationTemplate.spec.ts
@@ -0,0 +1,69 @@
+/*
+ * 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 { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
+import { StaticPropertyUtils } from '../../support/utils/StaticPropertyUtils';
+import { AdapterBuilder } from '../../support/builder/AdapterBuilder';
+import { PipelineElementTemplateUtils } from
'../../support/utils/PipelineElementTemplateUtils';
+
+describe('Test Edit Adapter', () => {
+ beforeEach('Setup Test', () => {
+ // To set up test add a stream adapter that can be configured
+ cy.initStreamPipesTest();
+ ConnectUtils.goToConnect();
+ ConnectUtils.goToNewAdapterPage();
+ });
+
+ it('Create and use configuration templates for adapters', () => {
+ const WAIT_TIME_MS = 'wait-time-ms';
+ const SIMULATOR_OPTION_PRESSURE = 'simulator-option-pressure';
+ const TEMPLATE_NAME = 'Test Template';
+
+ // configure adapter template
+ const adapterTemplateInput = AdapterBuilder.create(
+ 'Machine_Data_Simulator',
+ )
+ .addInput('input', WAIT_TIME_MS, '3000')
+ .addInput('radio', 'selected', SIMULATOR_OPTION_PRESSURE)
+ .build();
+ ConnectUtils.selectAdapter(adapterTemplateInput.adapterType);
+ StaticPropertyUtils.input(adapterTemplateInput.adapterConfiguration);
+
+ // store adapter template
+ PipelineElementTemplateUtils.addTemplate(TEMPLATE_NAME);
+
+ cy.dataCy('connect-new-adapter-cancel').click();
+
+ // Reload template configuration
+ ConnectUtils.goToNewAdapterPage();
+ ConnectUtils.selectAdapter(adapterTemplateInput.adapterType);
+
+ // Select template
+ PipelineElementTemplateUtils.selectTemplate(TEMPLATE_NAME);
+
+ // validate that the template values are selected
+ cy.dataCy(WAIT_TIME_MS).should('have.value', '3000');
+ cy.dataCy('selected-' + SIMULATOR_OPTION_PRESSURE).should(
+ 'have.class',
+ 'mat-mdc-radio-checked',
+ );
+
+ // Delete the template
+ PipelineElementTemplateUtils.deleteTemplate();
+ });
+});
diff --git
a/ui/cypress/tests/pipelineElementConfigurationTemplate/pipelineElementConfigurationTemplate.ts
b/ui/cypress/tests/pipelineElementConfigurationTemplate/pipelineElementConfigurationTemplate.ts
new file mode 100644
index 0000000000..2b9fff9442
--- /dev/null
+++
b/ui/cypress/tests/pipelineElementConfigurationTemplate/pipelineElementConfigurationTemplate.ts
@@ -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.
+ *
+ */
+
+import { PipelineUtils } from '../../support/utils/PipelineUtils';
+import { PipelineBuilder } from '../../support/builder/PipelineBuilder';
+import { PipelineElementBuilder } from
'../../support/builder/PipelineElementBuilder';
+import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
+import { PipelineElementTemplateUtils } from
'../../support/utils/PipelineElementTemplateUtils';
+
+describe('Test Edit Adapter', () => {
+ const TEMPLATE_NAME = 'Test Template';
+ const adapterName = 'simulator';
+
+ beforeEach('Setup Test', () => {
+ cy.initStreamPipesTest();
+ ConnectUtils.addMachineDataSimulator(adapterName);
+ });
+
+ it('Create and use configuration templates for processing elements', () =>
{
+ PipelineUtils.goToPipelineEditor();
+
+ const pipelineInput = PipelineBuilder.create('Pipeline Test')
+ .addSource(adapterName)
+ .addProcessingElement(
+ PipelineElementBuilder.create('numerical_filter')
+ .addInput('drop-down', 'number-mapping', 'temperature')
+ .addInput('radio', 'operation', '\\=\\=')
+ .addInput('input', 'value', '20')
+ .build(),
+ )
+ .build();
+
+ // Create pipeline element template
+ PipelineUtils.selectDataStream(pipelineInput);
+ PipelineUtils.openPossibleElementsMenu(adapterName);
+ PipelineUtils.configureProcessingElement(
+ pipelineInput.processingElement,
+ );
+
+ // Add new template
+ PipelineElementTemplateUtils.addTemplate(TEMPLATE_NAME);
+
+ cy.dataCy('cancel-customize').click();
+
+ PipelineUtils.goToPipelineEditor();
+ PipelineUtils.selectDataStream(pipelineInput);
+ PipelineUtils.openPossibleElementsMenu(adapterName);
+ PipelineUtils.selectCompatibleElement(
+ pipelineInput.processingElement.name,
+ );
+
+ // Select template
+ PipelineElementTemplateUtils.selectTemplate(TEMPLATE_NAME);
+
+ // validate that selection is correct
+ cy.dataCy('value').should('have.value', '20');
+ cy.dataCy('operation-\\=\\=').should(
+ 'have.class',
+ 'mat-mdc-radio-checked',
+ );
+ // Mapping properties can not be stored in templates, therefore the
default value is required
+ cy.dataCy('number-mapping').contains('density');
+
+ // delete template
+ PipelineElementTemplateUtils.deleteTemplate();
+ });
+});
diff --git
a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
index 0be1a6d607..4b3be6f469 100644
---
a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
+++
b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
@@ -41,6 +41,7 @@
<mat-select
(selectionChange)="loadTemplate($event)"
[(value)]="selectedTemplate"
+ data-cy="use-template"
>
<mat-option>--</mat-option>
<mat-option
@@ -69,6 +70,7 @@
mat-raised-button
style="margin-right: 10px"
(click)="removeSelection()"
+ data-cy="connect-new-adapter-cancel"
>
Cancel
</button>
@@ -76,6 +78,7 @@
mat-button
mat-raised-button
class="mat-basic"
+ data-cy="create-template"
(click)="openTemplateDialog()"
>
Store config as template
diff --git
a/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
b/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
index ecaf92147e..1c00d85ade 100644
---
a/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
+++
b/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
@@ -36,6 +36,7 @@
color="accent"
(click)="saveTemplate()"
style="margin-right: 10px"
+ data-cy="save-template"
>
Create template
</button>
diff --git
a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
index 5ad61fb329..65c18d5129 100644
---
a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
+++
b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
@@ -27,6 +27,7 @@
name="templateName"
class="sp"
required
+ data-cy="template-name"
/>
</mat-form-field>
<mat-form-field fxFlex color="accent">
@@ -37,6 +38,7 @@
name="templateDescription"
class="sp"
required
+ data-cy="template-description"
/>
</mat-form-field>
<mat-divider class="divider"></mat-divider>
@@ -85,6 +87,7 @@
mat-icon-button
color="accent"
(click)="deleteTemplate(template._id)"
+ data-cy="delete-pipeline-element-template"
>
<mat-icon>delete</mat-icon>
</button>
diff --git
a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template.pipe.ts
b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template.pipe.ts
index 1469613ae2..90d949b38b 100644
---
a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template.pipe.ts
+++
b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template.pipe.ts
@@ -18,6 +18,8 @@
import { Injectable, Pipe, PipeTransform } from '@angular/core';
import {
+ MappingPropertyNary,
+ MappingPropertyUnary,
RuntimeResolvableAnyStaticProperty,
RuntimeResolvableOneOfStaticProperty,
RuntimeResolvableTreeInputStaticProperty,
@@ -34,7 +36,9 @@ export class PipelineElementTemplatePipe implements
PipeTransform {
!(
p instanceof RuntimeResolvableOneOfStaticProperty &&
!(p instanceof RuntimeResolvableTreeInputStaticProperty)
- ),
+ ) &&
+ !(p instanceof MappingPropertyUnary) &&
+ !(p instanceof MappingPropertyNary),
);
}
}
diff --git
a/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly.component.html
b/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly.component.html
index 05da14a5d4..592cc32b32 100644
---
a/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly.component.html
+++
b/ui/src/app/editor/components/pipeline-assembly/pipeline-assembly.component.html
@@ -125,6 +125,7 @@
[matTooltipPosition]="'above'"
[disabled]="editorService.pipelineAssemblyEmpty"
(click)="showClearAssemblyConfirmDialog($event)"
+ data-cy="clear-assembly-area"
>
<i class="material-icons">clear</i>
</button>
diff --git a/ui/src/app/editor/dialog/customize/customize.component.html
b/ui/src/app/editor/dialog/customize/customize.component.html
index 89d9c051be..70080ddde1 100644
--- a/ui/src/app/editor/dialog/customize/customize.component.html
+++ b/ui/src/app/editor/dialog/customize/customize.component.html
@@ -38,6 +38,7 @@
<mat-select
(selectionChange)="loadTemplate($event)"
[(value)]="selectedTemplate"
+ data-cy="use-template"
>
<mat-option>--</mat-option>
<mat-option
@@ -160,6 +161,7 @@
mat-raised-button
class="mat-basic"
(click)="close()"
+ data-cy="cancel-customize"
>
Cancel
</button>
@@ -169,6 +171,7 @@
mat-raised-button
color="accent"
[disabled]="!formValid"
+ data-cy="create-template"
(click)="triggerTemplateMode()"
>
<i class="material-icons">add_circle_outline</i
@@ -183,6 +186,7 @@
(click)="saveTemplate()"
style="margin-right: 10px"
[disabled]="!formValid"
+ data-cy="save-template"
>
<i class="material-icons">save</i
><span> Save template</span>